blob: d2cccdb4a585b93101054fbe76c8a5e5e3377e63 [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 Bakkerb7584a52016-05-10 10:50:43 +010036RUN_TEST_NUMBER=''
37
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010038print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010044 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045}
46
47get_options() {
48 while [ $# -gt 0 ]; do
49 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050 -f|--filter)
51 shift; FILTER=$1
52 ;;
53 -e|--exclude)
54 shift; EXCLUDE=$1
55 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010056 -m|--memcheck)
57 MEMCHECK=1
58 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010059 -n|--number)
60 shift; RUN_TEST_NUMBER=$1
61 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010076# skip next test if the flag is not enabled in config.h
77requires_config_enabled() {
78 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020083# skip next test if OpenSSL doesn't support FALLBACK_SCSV
84requires_openssl_with_fallback_scsv() {
85 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
86 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
87 then
88 OPENSSL_HAS_FBSCSV="YES"
89 else
90 OPENSSL_HAS_FBSCSV="NO"
91 fi
92 fi
93 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
94 SKIP_NEXT="YES"
95 fi
96}
97
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020098# skip next test if GnuTLS isn't available
99requires_gnutls() {
100 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200101 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200102 GNUTLS_AVAILABLE="YES"
103 else
104 GNUTLS_AVAILABLE="NO"
105 fi
106 fi
107 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
108 SKIP_NEXT="YES"
109 fi
110}
111
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200112# skip next test if IPv6 isn't available on this host
113requires_ipv6() {
114 if [ -z "${HAS_IPV6:-}" ]; then
115 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
116 SRV_PID=$!
117 sleep 1
118 kill $SRV_PID >/dev/null 2>&1
119 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
120 HAS_IPV6="NO"
121 else
122 HAS_IPV6="YES"
123 fi
124 rm -r $SRV_OUT
125 fi
126
127 if [ "$HAS_IPV6" = "NO" ]; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200132# skip the next test if valgrind is in use
133not_with_valgrind() {
134 if [ "$MEMCHECK" -gt 0 ]; then
135 SKIP_NEXT="YES"
136 fi
137}
138
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200139# multiply the client timeout delay by the given factor for the next test
140needs_more_time() {
141 CLI_DELAY_FACTOR=$1
142}
143
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100144# print_name <name>
145print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100146 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200147 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100148 for i in `seq 1 $LEN`; do printf '.'; done
149 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100150
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200151 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100152}
153
154# fail <message>
155fail() {
156 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100157 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100158
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200159 mv $SRV_OUT o-srv-${TESTS}.log
160 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200161 if [ -n "$PXY_CMD" ]; then
162 mv $PXY_OUT o-pxy-${TESTS}.log
163 fi
164 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100165
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200166 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
167 echo " ! server output:"
168 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200169 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200170 echo " ! client output:"
171 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200172 if [ -n "$PXY_CMD" ]; then
173 echo " ! ========================================================"
174 echo " ! proxy output:"
175 cat o-pxy-${TESTS}.log
176 fi
177 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200178 fi
179
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200180 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100181}
182
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100183# is_polar <cmd_line>
184is_polar() {
185 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
186}
187
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200188# openssl s_server doesn't have -www with DTLS
189check_osrv_dtls() {
190 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
191 NEEDS_INPUT=1
192 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
193 else
194 NEEDS_INPUT=0
195 fi
196}
197
198# provide input to commands that need it
199provide_input() {
200 if [ $NEEDS_INPUT -eq 0 ]; then
201 return
202 fi
203
204 while true; do
205 echo "HTTP/1.0 200 OK"
206 sleep 1
207 done
208}
209
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100210# has_mem_err <log_file_name>
211has_mem_err() {
212 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
213 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
214 then
215 return 1 # false: does not have errors
216 else
217 return 0 # true: has errors
218 fi
219}
220
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200221# wait for server to start: two versions depending on lsof availability
222wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200223 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200224 START_TIME=$( date +%s )
225 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200226
227 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200228 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200229 while [ $DONE -eq 0 ]; do
230 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
231 then
232 DONE=1
233 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
234 echo "SERVERSTART TIMEOUT"
235 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
236 DONE=1
237 fi
238 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200239 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200240 while [ $DONE -eq 0 ]; do
241 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
242 then
243 DONE=1
244 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
245 echo "SERVERSTART TIMEOUT"
246 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
247 DONE=1
248 fi
249 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200250 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200251 else
252 sleep "$START_DELAY"
253 fi
254}
255
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200256# wait for client to terminate and set CLI_EXIT
257# must be called right after starting the client
258wait_client_done() {
259 CLI_PID=$!
260
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200261 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
262 CLI_DELAY_FACTOR=1
263
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200264 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200265 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266
267 wait $CLI_PID
268 CLI_EXIT=$?
269
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200270 kill $DOG_PID >/dev/null 2>&1
271 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200272
273 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
274}
275
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200276# check if the given command uses dtls and sets global variable DTLS
277detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200278 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200279 DTLS=1
280 else
281 DTLS=0
282 fi
283}
284
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200285# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100286# Options: -s pattern pattern that must be present in server output
287# -c pattern pattern that must be present in client output
288# -S pattern pattern that must be absent in server output
289# -C pattern pattern that must be absent in client output
290run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100291 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200292 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100293
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100294 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
295 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200296 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100297 return
298 fi
299
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100300 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100301
Paul Bakkerb7584a52016-05-10 10:50:43 +0100302 # Do we only run numbered tests?
303 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
304 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
305 else
306 SKIP_NEXT="YES"
307 fi
308
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200309 # should we skip?
310 if [ "X$SKIP_NEXT" = "XYES" ]; then
311 SKIP_NEXT="NO"
312 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200313 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200314 return
315 fi
316
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200317 # does this test use a proxy?
318 if [ "X$1" = "X-p" ]; then
319 PXY_CMD="$2"
320 shift 2
321 else
322 PXY_CMD=""
323 fi
324
325 # get commands and client output
326 SRV_CMD="$1"
327 CLI_CMD="$2"
328 CLI_EXPECT="$3"
329 shift 3
330
331 # fix client port
332 if [ -n "$PXY_CMD" ]; then
333 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
334 else
335 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
336 fi
337
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200338 # update DTLS variable
339 detect_dtls "$SRV_CMD"
340
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100341 # prepend valgrind to our commands if active
342 if [ "$MEMCHECK" -gt 0 ]; then
343 if is_polar "$SRV_CMD"; then
344 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
345 fi
346 if is_polar "$CLI_CMD"; then
347 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
348 fi
349 fi
350
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200351 TIMES_LEFT=2
352 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200353 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200354
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200355 # run the commands
356 if [ -n "$PXY_CMD" ]; then
357 echo "$PXY_CMD" > $PXY_OUT
358 $PXY_CMD >> $PXY_OUT 2>&1 &
359 PXY_PID=$!
360 # assume proxy starts faster than server
361 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200362
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200363 check_osrv_dtls
364 echo "$SRV_CMD" > $SRV_OUT
365 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
366 SRV_PID=$!
367 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200368
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200369 echo "$CLI_CMD" > $CLI_OUT
370 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
371 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100372
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200373 # terminate the server (and the proxy)
374 kill $SRV_PID
375 wait $SRV_PID
376 if [ -n "$PXY_CMD" ]; then
377 kill $PXY_PID >/dev/null 2>&1
378 wait $PXY_PID
379 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100380
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200381 # retry only on timeouts
382 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
383 printf "RETRY "
384 else
385 TIMES_LEFT=0
386 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200387 done
388
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100389 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200390 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100391 # expected client exit to incorrectly succeed in case of catastrophic
392 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100393 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200394 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100395 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100396 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100397 return
398 fi
399 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100400 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200401 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100402 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100403 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100404 return
405 fi
406 fi
407
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100408 # check server exit code
409 if [ $? != 0 ]; then
410 fail "server fail"
411 return
412 fi
413
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100414 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100415 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
416 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100417 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200418 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100419 return
420 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100421
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100422 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200423 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100424 while [ $# -gt 0 ]
425 do
426 case $1 in
427 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200428 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100429 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100430 return
431 fi
432 ;;
433
434 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200435 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100436 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100437 return
438 fi
439 ;;
440
441 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200442 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100443 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100444 return
445 fi
446 ;;
447
448 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200449 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100450 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100451 return
452 fi
453 ;;
454
455 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200456 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100457 exit 1
458 esac
459 shift 2
460 done
461
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100462 # check valgrind's results
463 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200464 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100465 fail "Server has memory errors"
466 return
467 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200468 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100469 fail "Client has memory errors"
470 return
471 fi
472 fi
473
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100474 # if we're here, everything is ok
475 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200476 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100477}
478
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100479cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200480 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200481 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
482 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
483 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
484 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100485 exit 1
486}
487
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100488#
489# MAIN
490#
491
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000492if cd $( dirname $0 ); then :; else
493 echo "cd $( dirname $0 ) failed" >&2
494 exit 1
495fi
496
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100497get_options "$@"
498
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100499# sanity checks, avoid an avalanche of errors
500if [ ! -x "$P_SRV" ]; then
501 echo "Command '$P_SRV' is not an executable file"
502 exit 1
503fi
504if [ ! -x "$P_CLI" ]; then
505 echo "Command '$P_CLI' is not an executable file"
506 exit 1
507fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200508if [ ! -x "$P_PXY" ]; then
509 echo "Command '$P_PXY' is not an executable file"
510 exit 1
511fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100512if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
513 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100514 exit 1
515fi
516
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200517# used by watchdog
518MAIN_PID="$$"
519
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200520# be more patient with valgrind
521if [ "$MEMCHECK" -gt 0 ]; then
522 START_DELAY=3
523 DOG_DELAY=30
524else
525 START_DELAY=1
526 DOG_DELAY=10
527fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200528CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200529
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530# Pick a "unique" server port in the range 10000-19999, and a proxy port
531PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000532PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200533SRV_PORT="1$PORT_BASE"
534PXY_PORT="2$PORT_BASE"
535unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200536
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200537# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000538# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200539P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
540P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
541P_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 +0200542O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200543O_CLI="$O_CLI -connect localhost:+SRV_PORT"
544G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000545G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200546
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200547# Also pick a unique name for intermediate files
548SRV_OUT="srv_out.$$"
549CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200550PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200551SESSION="session.$$"
552
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200553SKIP_NEXT="NO"
554
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100555trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100556
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200557# Basic test
558
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200559# Checks that:
560# - things work with all ciphersuites active (used with config-full in all.sh)
561# - the expected (highest security) parameters are selected
562# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200563run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200564 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200565 "$P_CLI" \
566 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200567 -s "Protocol is TLSv1.2" \
568 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
569 -s "client hello v3, signature_algorithm ext: 6" \
570 -s "ECDHE curve: secp521r1" \
571 -S "error" \
572 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200573
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000574run_test "Default, DTLS" \
575 "$P_SRV dtls=1" \
576 "$P_CLI dtls=1" \
577 0 \
578 -s "Protocol is DTLSv1.2" \
579 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
580
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100581# Tests for rc4 option
582
583run_test "RC4: server disabled, client enabled" \
584 "$P_SRV" \
585 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
586 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100587 -s "SSL - The server has no ciphersuites in common"
588
589run_test "RC4: server half, client enabled" \
590 "$P_SRV arc4=1" \
591 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
592 1 \
593 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100594
595run_test "RC4: server enabled, client disabled" \
596 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
597 "$P_CLI" \
598 1 \
599 -s "SSL - The server has no ciphersuites in common"
600
601run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100602 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100603 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
604 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100605 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100606 -S "SSL - The server has no ciphersuites in common"
607
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100608# Tests for Truncated HMAC extension
609
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100610run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200611 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100612 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100613 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100614 -s "dumping 'computed mac' (20 bytes)" \
615 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100616
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100617run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200618 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100619 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
620 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100621 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100622 -s "dumping 'computed mac' (20 bytes)" \
623 -S "dumping 'computed mac' (10 bytes)"
624
625run_test "Truncated HMAC: client enabled, server default" \
626 "$P_SRV debug_level=4" \
627 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
628 trunc_hmac=1" \
629 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100630 -s "dumping 'computed mac' (20 bytes)" \
631 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100632
633run_test "Truncated HMAC: client enabled, server disabled" \
634 "$P_SRV debug_level=4 trunc_hmac=0" \
635 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
636 trunc_hmac=1" \
637 0 \
638 -s "dumping 'computed mac' (20 bytes)" \
639 -S "dumping 'computed mac' (10 bytes)"
640
641run_test "Truncated HMAC: client enabled, server enabled" \
642 "$P_SRV debug_level=4 trunc_hmac=1" \
643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
644 trunc_hmac=1" \
645 0 \
646 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100647 -s "dumping 'computed mac' (10 bytes)"
648
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100649# Tests for Encrypt-then-MAC extension
650
651run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100652 "$P_SRV debug_level=3 \
653 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100654 "$P_CLI debug_level=3" \
655 0 \
656 -c "client hello, adding encrypt_then_mac extension" \
657 -s "found encrypt then mac extension" \
658 -s "server hello, adding encrypt then mac extension" \
659 -c "found encrypt_then_mac extension" \
660 -c "using encrypt then mac" \
661 -s "using encrypt then mac"
662
663run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100664 "$P_SRV debug_level=3 etm=0 \
665 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100666 "$P_CLI debug_level=3 etm=1" \
667 0 \
668 -c "client hello, adding encrypt_then_mac extension" \
669 -s "found encrypt then mac extension" \
670 -S "server hello, adding encrypt then mac extension" \
671 -C "found encrypt_then_mac extension" \
672 -C "using encrypt then mac" \
673 -S "using encrypt then mac"
674
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100675run_test "Encrypt then MAC: client enabled, aead cipher" \
676 "$P_SRV debug_level=3 etm=1 \
677 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
678 "$P_CLI debug_level=3 etm=1" \
679 0 \
680 -c "client hello, adding encrypt_then_mac extension" \
681 -s "found encrypt then mac extension" \
682 -S "server hello, adding encrypt then mac extension" \
683 -C "found encrypt_then_mac extension" \
684 -C "using encrypt then mac" \
685 -S "using encrypt then mac"
686
687run_test "Encrypt then MAC: client enabled, stream cipher" \
688 "$P_SRV debug_level=3 etm=1 \
689 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100690 "$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 +0100691 0 \
692 -c "client hello, adding encrypt_then_mac extension" \
693 -s "found encrypt then mac extension" \
694 -S "server hello, adding encrypt then mac extension" \
695 -C "found encrypt_then_mac extension" \
696 -C "using encrypt then mac" \
697 -S "using encrypt then mac"
698
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100699run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100700 "$P_SRV debug_level=3 etm=1 \
701 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100702 "$P_CLI debug_level=3 etm=0" \
703 0 \
704 -C "client hello, adding encrypt_then_mac extension" \
705 -S "found encrypt then mac extension" \
706 -S "server hello, adding encrypt then mac extension" \
707 -C "found encrypt_then_mac extension" \
708 -C "using encrypt then mac" \
709 -S "using encrypt then mac"
710
Janos Follathe2681a42016-03-07 15:57:05 +0000711requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100712run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100713 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100714 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100715 "$P_CLI debug_level=3 force_version=ssl3" \
716 0 \
717 -C "client hello, adding encrypt_then_mac extension" \
718 -S "found encrypt then mac extension" \
719 -S "server hello, adding encrypt then mac extension" \
720 -C "found encrypt_then_mac extension" \
721 -C "using encrypt then mac" \
722 -S "using encrypt then mac"
723
Janos Follathe2681a42016-03-07 15:57:05 +0000724requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100725run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100726 "$P_SRV debug_level=3 force_version=ssl3 \
727 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100728 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100729 0 \
730 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100731 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100732 -S "server hello, adding encrypt then mac extension" \
733 -C "found encrypt_then_mac extension" \
734 -C "using encrypt then mac" \
735 -S "using encrypt then mac"
736
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200737# Tests for Extended Master Secret extension
738
739run_test "Extended Master Secret: default" \
740 "$P_SRV debug_level=3" \
741 "$P_CLI debug_level=3" \
742 0 \
743 -c "client hello, adding extended_master_secret extension" \
744 -s "found extended master secret extension" \
745 -s "server hello, adding extended master secret extension" \
746 -c "found extended_master_secret extension" \
747 -c "using extended master secret" \
748 -s "using extended master secret"
749
750run_test "Extended Master Secret: client enabled, server disabled" \
751 "$P_SRV debug_level=3 extended_ms=0" \
752 "$P_CLI debug_level=3 extended_ms=1" \
753 0 \
754 -c "client hello, adding extended_master_secret extension" \
755 -s "found extended master secret extension" \
756 -S "server hello, adding extended master secret extension" \
757 -C "found extended_master_secret extension" \
758 -C "using extended master secret" \
759 -S "using extended master secret"
760
761run_test "Extended Master Secret: client disabled, server enabled" \
762 "$P_SRV debug_level=3 extended_ms=1" \
763 "$P_CLI debug_level=3 extended_ms=0" \
764 0 \
765 -C "client hello, adding extended_master_secret extension" \
766 -S "found extended master secret extension" \
767 -S "server hello, adding extended master secret extension" \
768 -C "found extended_master_secret extension" \
769 -C "using extended master secret" \
770 -S "using extended master secret"
771
Janos Follathe2681a42016-03-07 15:57:05 +0000772requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200773run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100774 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200775 "$P_CLI debug_level=3 force_version=ssl3" \
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
Janos Follathe2681a42016-03-07 15:57:05 +0000784requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200785run_test "Extended Master Secret: client enabled, server SSLv3" \
786 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100787 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200788 0 \
789 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100790 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200791 -S "server hello, adding extended master secret extension" \
792 -C "found extended_master_secret extension" \
793 -C "using extended master secret" \
794 -S "using extended master secret"
795
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200796# Tests for FALLBACK_SCSV
797
798run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200799 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200800 "$P_CLI debug_level=3 force_version=tls1_1" \
801 0 \
802 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200803 -S "received FALLBACK_SCSV" \
804 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200805 -C "is a fatal alert message (msg 86)"
806
807run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200808 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200809 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
810 0 \
811 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200812 -S "received FALLBACK_SCSV" \
813 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200814 -C "is a fatal alert message (msg 86)"
815
816run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200817 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200818 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200819 1 \
820 -c "adding FALLBACK_SCSV" \
821 -s "received FALLBACK_SCSV" \
822 -s "inapropriate fallback" \
823 -c "is a fatal alert message (msg 86)"
824
825run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200826 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200827 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200828 0 \
829 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200830 -s "received FALLBACK_SCSV" \
831 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200832 -C "is a fatal alert message (msg 86)"
833
834requires_openssl_with_fallback_scsv
835run_test "Fallback SCSV: default, openssl server" \
836 "$O_SRV" \
837 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
838 0 \
839 -C "adding FALLBACK_SCSV" \
840 -C "is a fatal alert message (msg 86)"
841
842requires_openssl_with_fallback_scsv
843run_test "Fallback SCSV: enabled, openssl server" \
844 "$O_SRV" \
845 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
846 1 \
847 -c "adding FALLBACK_SCSV" \
848 -c "is a fatal alert message (msg 86)"
849
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200850requires_openssl_with_fallback_scsv
851run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200852 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200853 "$O_CLI -tls1_1" \
854 0 \
855 -S "received FALLBACK_SCSV" \
856 -S "inapropriate fallback"
857
858requires_openssl_with_fallback_scsv
859run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200860 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200861 "$O_CLI -tls1_1 -fallback_scsv" \
862 1 \
863 -s "received FALLBACK_SCSV" \
864 -s "inapropriate fallback"
865
866requires_openssl_with_fallback_scsv
867run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200868 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200869 "$O_CLI -fallback_scsv" \
870 0 \
871 -s "received FALLBACK_SCSV" \
872 -S "inapropriate fallback"
873
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100874# Tests for CBC 1/n-1 record splitting
875
876run_test "CBC Record splitting: TLS 1.2, no splitting" \
877 "$P_SRV" \
878 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
879 request_size=123 force_version=tls1_2" \
880 0 \
881 -s "Read from client: 123 bytes read" \
882 -S "Read from client: 1 bytes read" \
883 -S "122 bytes read"
884
885run_test "CBC Record splitting: TLS 1.1, no splitting" \
886 "$P_SRV" \
887 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
888 request_size=123 force_version=tls1_1" \
889 0 \
890 -s "Read from client: 123 bytes read" \
891 -S "Read from client: 1 bytes read" \
892 -S "122 bytes read"
893
894run_test "CBC Record splitting: TLS 1.0, splitting" \
895 "$P_SRV" \
896 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
897 request_size=123 force_version=tls1" \
898 0 \
899 -S "Read from client: 123 bytes read" \
900 -s "Read from client: 1 bytes read" \
901 -s "122 bytes read"
902
Janos Follathe2681a42016-03-07 15:57:05 +0000903requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100904run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100905 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100906 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
907 request_size=123 force_version=ssl3" \
908 0 \
909 -S "Read from client: 123 bytes read" \
910 -s "Read from client: 1 bytes read" \
911 -s "122 bytes read"
912
913run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100914 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100915 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
916 request_size=123 force_version=tls1" \
917 0 \
918 -s "Read from client: 123 bytes read" \
919 -S "Read from client: 1 bytes read" \
920 -S "122 bytes read"
921
922run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
923 "$P_SRV" \
924 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
925 request_size=123 force_version=tls1 recsplit=0" \
926 0 \
927 -s "Read from client: 123 bytes read" \
928 -S "Read from client: 1 bytes read" \
929 -S "122 bytes read"
930
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100931run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
932 "$P_SRV nbio=2" \
933 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
934 request_size=123 force_version=tls1" \
935 0 \
936 -S "Read from client: 123 bytes read" \
937 -s "Read from client: 1 bytes read" \
938 -s "122 bytes read"
939
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100940# Tests for Session Tickets
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200943 "$P_SRV debug_level=3 tickets=1" \
944 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100945 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100946 -c "client hello, adding session ticket extension" \
947 -s "found session ticket extension" \
948 -s "server hello, adding session ticket extension" \
949 -c "found session_ticket extension" \
950 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100951 -S "session successfully restored from cache" \
952 -s "session successfully restored from ticket" \
953 -s "a session has been resumed" \
954 -c "a session has been resumed"
955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200956run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200957 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
958 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100959 0 \
960 -c "client hello, adding session ticket extension" \
961 -s "found session ticket extension" \
962 -s "server hello, adding session ticket extension" \
963 -c "found session_ticket extension" \
964 -c "parse new session ticket" \
965 -S "session successfully restored from cache" \
966 -s "session successfully restored from ticket" \
967 -s "a session has been resumed" \
968 -c "a session has been resumed"
969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200970run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200971 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
972 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100973 0 \
974 -c "client hello, adding session ticket extension" \
975 -s "found session ticket extension" \
976 -s "server hello, adding session ticket extension" \
977 -c "found session_ticket extension" \
978 -c "parse new session ticket" \
979 -S "session successfully restored from cache" \
980 -S "session successfully restored from ticket" \
981 -S "a session has been resumed" \
982 -C "a session has been resumed"
983
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200984run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100985 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200986 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100987 0 \
988 -c "client hello, adding session ticket extension" \
989 -c "found session_ticket extension" \
990 -c "parse new session ticket" \
991 -c "a session has been resumed"
992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200995 "( $O_CLI -sess_out $SESSION; \
996 $O_CLI -sess_in $SESSION; \
997 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100998 0 \
999 -s "found session ticket extension" \
1000 -s "server hello, adding session ticket extension" \
1001 -S "session successfully restored from cache" \
1002 -s "session successfully restored from ticket" \
1003 -s "a session has been resumed"
1004
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001005# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001007run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001008 "$P_SRV debug_level=3 tickets=0" \
1009 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001010 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001011 -c "client hello, adding session ticket extension" \
1012 -s "found session ticket extension" \
1013 -S "server hello, adding session ticket extension" \
1014 -C "found session_ticket extension" \
1015 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001016 -s "session successfully restored from cache" \
1017 -S "session successfully restored from ticket" \
1018 -s "a session has been resumed" \
1019 -c "a session has been resumed"
1020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001021run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001022 "$P_SRV debug_level=3 tickets=1" \
1023 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001024 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001025 -C "client hello, adding session ticket extension" \
1026 -S "found session ticket extension" \
1027 -S "server hello, adding session ticket extension" \
1028 -C "found session_ticket extension" \
1029 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001030 -s "session successfully restored from cache" \
1031 -S "session successfully restored from ticket" \
1032 -s "a session has been resumed" \
1033 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001034
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001035run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001036 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1037 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001038 0 \
1039 -S "session successfully restored from cache" \
1040 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001041 -S "a session has been resumed" \
1042 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001043
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001044run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1046 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001047 0 \
1048 -s "session successfully restored from cache" \
1049 -S "session successfully restored from ticket" \
1050 -s "a session has been resumed" \
1051 -c "a session has been resumed"
1052
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001053run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001054 "$P_SRV debug_level=3 tickets=0" \
1055 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001056 0 \
1057 -s "session successfully restored from cache" \
1058 -S "session successfully restored from ticket" \
1059 -s "a session has been resumed" \
1060 -c "a session has been resumed"
1061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001063 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1064 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001065 0 \
1066 -S "session successfully restored from cache" \
1067 -S "session successfully restored from ticket" \
1068 -S "a session has been resumed" \
1069 -C "a session has been resumed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1073 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001074 0 \
1075 -s "session successfully restored from cache" \
1076 -S "session successfully restored from ticket" \
1077 -s "a session has been resumed" \
1078 -c "a session has been resumed"
1079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001080run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001081 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001082 "( $O_CLI -sess_out $SESSION; \
1083 $O_CLI -sess_in $SESSION; \
1084 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001085 0 \
1086 -s "found session ticket extension" \
1087 -S "server hello, adding session ticket extension" \
1088 -s "session successfully restored from cache" \
1089 -S "session successfully restored from ticket" \
1090 -s "a session has been resumed"
1091
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001092run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001093 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001094 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001095 0 \
1096 -C "found session_ticket extension" \
1097 -C "parse new session ticket" \
1098 -c "a session has been resumed"
1099
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001100# Tests for Max Fragment Length extension
1101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001102run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001103 "$P_SRV debug_level=3" \
1104 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001105 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001106 -c "Maximum fragment length is 16384" \
1107 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001108 -C "client hello, adding max_fragment_length extension" \
1109 -S "found max fragment length extension" \
1110 -S "server hello, max_fragment_length extension" \
1111 -C "found max_fragment_length extension"
1112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001113run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001114 "$P_SRV debug_level=3" \
1115 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001116 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001117 -c "Maximum fragment length is 4096" \
1118 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001119 -c "client hello, adding max_fragment_length extension" \
1120 -s "found max fragment length extension" \
1121 -s "server hello, max_fragment_length extension" \
1122 -c "found max_fragment_length extension"
1123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001124run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001125 "$P_SRV debug_level=3 max_frag_len=4096" \
1126 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001127 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001128 -c "Maximum fragment length is 16384" \
1129 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001130 -C "client hello, adding max_fragment_length extension" \
1131 -S "found max fragment length extension" \
1132 -S "server hello, max_fragment_length extension" \
1133 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001134
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001135requires_gnutls
1136run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001137 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001138 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001139 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001140 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001141 -c "client hello, adding max_fragment_length extension" \
1142 -c "found max_fragment_length extension"
1143
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001144run_test "Max fragment length: client, message just fits" \
1145 "$P_SRV debug_level=3" \
1146 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1147 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001148 -c "Maximum fragment length is 2048" \
1149 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001150 -c "client hello, adding max_fragment_length extension" \
1151 -s "found max fragment length extension" \
1152 -s "server hello, max_fragment_length extension" \
1153 -c "found max_fragment_length extension" \
1154 -c "2048 bytes written in 1 fragments" \
1155 -s "2048 bytes read"
1156
1157run_test "Max fragment length: client, larger message" \
1158 "$P_SRV debug_level=3" \
1159 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1160 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001161 -c "Maximum fragment length is 2048" \
1162 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001163 -c "client hello, adding max_fragment_length extension" \
1164 -s "found max fragment length extension" \
1165 -s "server hello, max_fragment_length extension" \
1166 -c "found max_fragment_length extension" \
1167 -c "2345 bytes written in 2 fragments" \
1168 -s "2048 bytes read" \
1169 -s "297 bytes read"
1170
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001171run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001172 "$P_SRV debug_level=3 dtls=1" \
1173 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1174 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001175 -c "Maximum fragment length is 2048" \
1176 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001177 -c "client hello, adding max_fragment_length extension" \
1178 -s "found max fragment length extension" \
1179 -s "server hello, max_fragment_length extension" \
1180 -c "found max_fragment_length extension" \
1181 -c "fragment larger than.*maximum"
1182
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001183# Tests for renegotiation
1184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001185run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001186 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001187 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001188 0 \
1189 -C "client hello, adding renegotiation extension" \
1190 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1191 -S "found renegotiation extension" \
1192 -s "server hello, secure renegotiation extension" \
1193 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001194 -C "=> renegotiate" \
1195 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001196 -S "write hello request"
1197
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001198run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001199 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001200 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001201 0 \
1202 -c "client hello, adding renegotiation extension" \
1203 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1204 -s "found renegotiation extension" \
1205 -s "server hello, secure renegotiation extension" \
1206 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001207 -c "=> renegotiate" \
1208 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001209 -S "write hello request"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001212 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001214 0 \
1215 -c "client hello, adding renegotiation extension" \
1216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1217 -s "found renegotiation extension" \
1218 -s "server hello, secure renegotiation extension" \
1219 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001220 -c "=> renegotiate" \
1221 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001222 -s "write hello request"
1223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001225 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227 0 \
1228 -c "client hello, adding renegotiation extension" \
1229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1230 -s "found renegotiation extension" \
1231 -s "server hello, secure renegotiation extension" \
1232 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001233 -c "=> renegotiate" \
1234 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001235 -s "write hello request"
1236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001237run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001238 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001239 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001240 1 \
1241 -c "client hello, adding renegotiation extension" \
1242 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1243 -S "found renegotiation extension" \
1244 -s "server hello, secure renegotiation extension" \
1245 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001246 -c "=> renegotiate" \
1247 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001248 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001249 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001250 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001252run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001253 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001254 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001255 0 \
1256 -C "client hello, adding renegotiation extension" \
1257 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1258 -S "found renegotiation extension" \
1259 -s "server hello, secure renegotiation extension" \
1260 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001261 -C "=> renegotiate" \
1262 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001263 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001264 -S "SSL - An unexpected message was received from our peer" \
1265 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001267run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001268 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001269 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001270 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001271 0 \
1272 -C "client hello, adding renegotiation extension" \
1273 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1274 -S "found renegotiation extension" \
1275 -s "server hello, secure renegotiation extension" \
1276 -c "found renegotiation extension" \
1277 -C "=> renegotiate" \
1278 -S "=> renegotiate" \
1279 -s "write hello request" \
1280 -S "SSL - An unexpected message was received from our peer" \
1281 -S "failed"
1282
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001283# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001284run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001286 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001287 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001288 0 \
1289 -C "client hello, adding renegotiation extension" \
1290 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1291 -S "found renegotiation extension" \
1292 -s "server hello, secure renegotiation extension" \
1293 -c "found renegotiation extension" \
1294 -C "=> renegotiate" \
1295 -S "=> renegotiate" \
1296 -s "write hello request" \
1297 -S "SSL - An unexpected message was received from our peer" \
1298 -S "failed"
1299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001300run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001301 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001302 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001304 0 \
1305 -C "client hello, adding renegotiation extension" \
1306 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1307 -S "found renegotiation extension" \
1308 -s "server hello, secure renegotiation extension" \
1309 -c "found renegotiation extension" \
1310 -C "=> renegotiate" \
1311 -S "=> renegotiate" \
1312 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001313 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001315run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001316 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001317 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001318 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001319 0 \
1320 -c "client hello, adding renegotiation extension" \
1321 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1322 -s "found renegotiation extension" \
1323 -s "server hello, secure renegotiation extension" \
1324 -c "found renegotiation extension" \
1325 -c "=> renegotiate" \
1326 -s "=> renegotiate" \
1327 -s "write hello request" \
1328 -S "SSL - An unexpected message was received from our peer" \
1329 -S "failed"
1330
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001331run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001332 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001333 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1334 0 \
1335 -C "client hello, adding renegotiation extension" \
1336 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1337 -S "found renegotiation extension" \
1338 -s "server hello, secure renegotiation extension" \
1339 -c "found renegotiation extension" \
1340 -S "record counter limit reached: renegotiate" \
1341 -C "=> renegotiate" \
1342 -S "=> renegotiate" \
1343 -S "write hello request" \
1344 -S "SSL - An unexpected message was received from our peer" \
1345 -S "failed"
1346
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001347# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001348run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001349 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001350 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001351 0 \
1352 -c "client hello, adding renegotiation extension" \
1353 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1354 -s "found renegotiation extension" \
1355 -s "server hello, secure renegotiation extension" \
1356 -c "found renegotiation extension" \
1357 -s "record counter limit reached: renegotiate" \
1358 -c "=> renegotiate" \
1359 -s "=> renegotiate" \
1360 -s "write hello request" \
1361 -S "SSL - An unexpected message was received from our peer" \
1362 -S "failed"
1363
1364run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001365 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001366 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001367 0 \
1368 -c "client hello, adding renegotiation extension" \
1369 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1370 -s "found renegotiation extension" \
1371 -s "server hello, secure renegotiation extension" \
1372 -c "found renegotiation extension" \
1373 -s "record counter limit reached: renegotiate" \
1374 -c "=> renegotiate" \
1375 -s "=> renegotiate" \
1376 -s "write hello request" \
1377 -S "SSL - An unexpected message was received from our peer" \
1378 -S "failed"
1379
1380run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001381 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001382 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1383 0 \
1384 -C "client hello, adding renegotiation extension" \
1385 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1386 -S "found renegotiation extension" \
1387 -s "server hello, secure renegotiation extension" \
1388 -c "found renegotiation extension" \
1389 -S "record counter limit reached: renegotiate" \
1390 -C "=> renegotiate" \
1391 -S "=> renegotiate" \
1392 -S "write hello request" \
1393 -S "SSL - An unexpected message was received from our peer" \
1394 -S "failed"
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001399 0 \
1400 -c "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -s "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
1405 -c "=> renegotiate" \
1406 -s "=> renegotiate" \
1407 -S "write hello request"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001410 "$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 +02001411 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001412 0 \
1413 -c "client hello, adding renegotiation extension" \
1414 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1415 -s "found renegotiation extension" \
1416 -s "server hello, secure renegotiation extension" \
1417 -c "found renegotiation extension" \
1418 -c "=> renegotiate" \
1419 -s "=> renegotiate" \
1420 -s "write hello request"
1421
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001422run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001423 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001424 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001425 0 \
1426 -c "client hello, adding renegotiation extension" \
1427 -c "found renegotiation extension" \
1428 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001429 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001430 -C "error" \
1431 -c "HTTP/1.0 200 [Oo][Kk]"
1432
Paul Bakker539d9722015-02-08 16:18:35 +01001433requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001434run_test "Renegotiation: gnutls server strict, client-initiated" \
1435 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001437 0 \
1438 -c "client hello, adding renegotiation extension" \
1439 -c "found renegotiation extension" \
1440 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001441 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001442 -C "error" \
1443 -c "HTTP/1.0 200 [Oo][Kk]"
1444
Paul Bakker539d9722015-02-08 16:18:35 +01001445requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001446run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1447 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1448 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1449 1 \
1450 -c "client hello, adding renegotiation extension" \
1451 -C "found renegotiation extension" \
1452 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001453 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001454 -c "error" \
1455 -C "HTTP/1.0 200 [Oo][Kk]"
1456
Paul Bakker539d9722015-02-08 16:18:35 +01001457requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001458run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1459 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1460 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1461 allow_legacy=0" \
1462 1 \
1463 -c "client hello, adding renegotiation extension" \
1464 -C "found renegotiation extension" \
1465 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001466 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001467 -c "error" \
1468 -C "HTTP/1.0 200 [Oo][Kk]"
1469
Paul Bakker539d9722015-02-08 16:18:35 +01001470requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001471run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1472 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1473 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1474 allow_legacy=1" \
1475 0 \
1476 -c "client hello, adding renegotiation extension" \
1477 -C "found renegotiation extension" \
1478 -c "=> renegotiate" \
1479 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001480 -C "error" \
1481 -c "HTTP/1.0 200 [Oo][Kk]"
1482
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001483run_test "Renegotiation: DTLS, client-initiated" \
1484 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1485 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1486 0 \
1487 -c "client hello, adding renegotiation extension" \
1488 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1489 -s "found renegotiation extension" \
1490 -s "server hello, secure renegotiation extension" \
1491 -c "found renegotiation extension" \
1492 -c "=> renegotiate" \
1493 -s "=> renegotiate" \
1494 -S "write hello request"
1495
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001496run_test "Renegotiation: DTLS, server-initiated" \
1497 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001498 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1499 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001500 0 \
1501 -c "client hello, adding renegotiation extension" \
1502 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1503 -s "found renegotiation extension" \
1504 -s "server hello, secure renegotiation extension" \
1505 -c "found renegotiation extension" \
1506 -c "=> renegotiate" \
1507 -s "=> renegotiate" \
1508 -s "write hello request"
1509
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001510requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001511run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1512 "$G_SRV -u --mtu 4096" \
1513 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1514 0 \
1515 -c "client hello, adding renegotiation extension" \
1516 -c "found renegotiation extension" \
1517 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001518 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001519 -C "error" \
1520 -s "Extra-header:"
1521
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001522# Test for the "secure renegotation" extension only (no actual renegotiation)
1523
Paul Bakker539d9722015-02-08 16:18:35 +01001524requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001525run_test "Renego ext: gnutls server strict, client default" \
1526 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1527 "$P_CLI debug_level=3" \
1528 0 \
1529 -c "found renegotiation extension" \
1530 -C "error" \
1531 -c "HTTP/1.0 200 [Oo][Kk]"
1532
Paul Bakker539d9722015-02-08 16:18:35 +01001533requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001534run_test "Renego ext: gnutls server unsafe, client default" \
1535 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1536 "$P_CLI debug_level=3" \
1537 0 \
1538 -C "found renegotiation extension" \
1539 -C "error" \
1540 -c "HTTP/1.0 200 [Oo][Kk]"
1541
Paul Bakker539d9722015-02-08 16:18:35 +01001542requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001543run_test "Renego ext: gnutls server unsafe, client break legacy" \
1544 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1545 "$P_CLI debug_level=3 allow_legacy=-1" \
1546 1 \
1547 -C "found renegotiation extension" \
1548 -c "error" \
1549 -C "HTTP/1.0 200 [Oo][Kk]"
1550
Paul Bakker539d9722015-02-08 16:18:35 +01001551requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001552run_test "Renego ext: gnutls client strict, server default" \
1553 "$P_SRV debug_level=3" \
1554 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1555 0 \
1556 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1557 -s "server hello, secure renegotiation extension"
1558
Paul Bakker539d9722015-02-08 16:18:35 +01001559requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001560run_test "Renego ext: gnutls client unsafe, server default" \
1561 "$P_SRV debug_level=3" \
1562 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1563 0 \
1564 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1565 -S "server hello, secure renegotiation extension"
1566
Paul Bakker539d9722015-02-08 16:18:35 +01001567requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001568run_test "Renego ext: gnutls client unsafe, server break legacy" \
1569 "$P_SRV debug_level=3 allow_legacy=-1" \
1570 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1571 1 \
1572 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1573 -S "server hello, secure renegotiation extension"
1574
Janos Follath0b242342016-02-17 10:11:21 +00001575# Tests for silently dropping trailing extra bytes in .der certificates
1576
1577requires_gnutls
1578run_test "DER format: no trailing bytes" \
1579 "$P_SRV crt_file=data_files/server5-der0.crt \
1580 key_file=data_files/server5.key" \
1581 "$G_CLI " \
1582 0 \
1583 -c "Handshake was completed" \
1584
1585requires_gnutls
1586run_test "DER format: with a trailing zero byte" \
1587 "$P_SRV crt_file=data_files/server5-der1a.crt \
1588 key_file=data_files/server5.key" \
1589 "$G_CLI " \
1590 0 \
1591 -c "Handshake was completed" \
1592
1593requires_gnutls
1594run_test "DER format: with a trailing random byte" \
1595 "$P_SRV crt_file=data_files/server5-der1b.crt \
1596 key_file=data_files/server5.key" \
1597 "$G_CLI " \
1598 0 \
1599 -c "Handshake was completed" \
1600
1601requires_gnutls
1602run_test "DER format: with 2 trailing random bytes" \
1603 "$P_SRV crt_file=data_files/server5-der2.crt \
1604 key_file=data_files/server5.key" \
1605 "$G_CLI " \
1606 0 \
1607 -c "Handshake was completed" \
1608
1609requires_gnutls
1610run_test "DER format: with 4 trailing random bytes" \
1611 "$P_SRV crt_file=data_files/server5-der4.crt \
1612 key_file=data_files/server5.key" \
1613 "$G_CLI " \
1614 0 \
1615 -c "Handshake was completed" \
1616
1617requires_gnutls
1618run_test "DER format: with 8 trailing random bytes" \
1619 "$P_SRV crt_file=data_files/server5-der8.crt \
1620 key_file=data_files/server5.key" \
1621 "$G_CLI " \
1622 0 \
1623 -c "Handshake was completed" \
1624
1625requires_gnutls
1626run_test "DER format: with 9 trailing random bytes" \
1627 "$P_SRV crt_file=data_files/server5-der9.crt \
1628 key_file=data_files/server5.key" \
1629 "$G_CLI " \
1630 0 \
1631 -c "Handshake was completed" \
1632
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001633# Tests for auth_mode
1634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001635run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001636 "$P_SRV crt_file=data_files/server5-badsign.crt \
1637 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001638 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001639 1 \
1640 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001641 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001642 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001643 -c "X509 - Certificate verification failed"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001646 "$P_SRV crt_file=data_files/server5-badsign.crt \
1647 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001648 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001649 0 \
1650 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001651 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001652 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001653 -C "X509 - Certificate verification failed"
1654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001655run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001656 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001657 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001658 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001659 0 \
1660 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001661 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001662 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001663 -C "X509 - Certificate verification failed"
1664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001665run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001666 "$P_SRV debug_level=3 auth_mode=required" \
1667 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001668 key_file=data_files/server5.key" \
1669 1 \
1670 -S "skip write certificate request" \
1671 -C "skip parse certificate request" \
1672 -c "got a certificate request" \
1673 -C "skip write certificate" \
1674 -C "skip write certificate verify" \
1675 -S "skip parse certificate verify" \
1676 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001677 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001678 -s "! mbedtls_ssl_handshake returned" \
1679 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001680 -s "X509 - Certificate verification failed"
1681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001682run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001683 "$P_SRV debug_level=3 auth_mode=optional" \
1684 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001685 key_file=data_files/server5.key" \
1686 0 \
1687 -S "skip write certificate request" \
1688 -C "skip parse certificate request" \
1689 -c "got a certificate request" \
1690 -C "skip write certificate" \
1691 -C "skip write certificate verify" \
1692 -S "skip parse certificate verify" \
1693 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001694 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001695 -S "! mbedtls_ssl_handshake returned" \
1696 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001697 -S "X509 - Certificate verification failed"
1698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001699run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001700 "$P_SRV debug_level=3 auth_mode=none" \
1701 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001702 key_file=data_files/server5.key" \
1703 0 \
1704 -s "skip write certificate request" \
1705 -C "skip parse certificate request" \
1706 -c "got no certificate request" \
1707 -c "skip write certificate" \
1708 -c "skip write certificate verify" \
1709 -s "skip parse certificate verify" \
1710 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001711 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001712 -S "! mbedtls_ssl_handshake returned" \
1713 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001714 -S "X509 - Certificate verification failed"
1715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001716run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_SRV debug_level=3 auth_mode=optional" \
1718 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001719 0 \
1720 -S "skip write certificate request" \
1721 -C "skip parse certificate request" \
1722 -c "got a certificate request" \
1723 -C "skip write certificate$" \
1724 -C "got no certificate to send" \
1725 -S "SSLv3 client has no certificate" \
1726 -c "skip write certificate verify" \
1727 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001728 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001729 -S "! mbedtls_ssl_handshake returned" \
1730 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001731 -S "X509 - Certificate verification failed"
1732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001733run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001734 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001735 "$O_CLI" \
1736 0 \
1737 -S "skip write certificate request" \
1738 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001739 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001740 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001741 -S "X509 - Certificate verification failed"
1742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001743run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001744 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001746 0 \
1747 -C "skip parse certificate request" \
1748 -c "got a certificate request" \
1749 -C "skip write certificate$" \
1750 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001751 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001752
Janos Follathe2681a42016-03-07 15:57:05 +00001753requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001754run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001755 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001756 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001757 0 \
1758 -S "skip write certificate request" \
1759 -C "skip parse certificate request" \
1760 -c "got a certificate request" \
1761 -C "skip write certificate$" \
1762 -c "skip write certificate verify" \
1763 -c "got no certificate to send" \
1764 -s "SSLv3 client has no certificate" \
1765 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001766 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001767 -S "! mbedtls_ssl_handshake returned" \
1768 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001769 -S "X509 - Certificate verification failed"
1770
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001771# Tests for certificate selection based on SHA verson
1772
1773run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1774 "$P_SRV crt_file=data_files/server5.crt \
1775 key_file=data_files/server5.key \
1776 crt_file2=data_files/server5-sha1.crt \
1777 key_file2=data_files/server5.key" \
1778 "$P_CLI force_version=tls1_2" \
1779 0 \
1780 -c "signed using.*ECDSA with SHA256" \
1781 -C "signed using.*ECDSA with SHA1"
1782
1783run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1784 "$P_SRV crt_file=data_files/server5.crt \
1785 key_file=data_files/server5.key \
1786 crt_file2=data_files/server5-sha1.crt \
1787 key_file2=data_files/server5.key" \
1788 "$P_CLI force_version=tls1_1" \
1789 0 \
1790 -C "signed using.*ECDSA with SHA256" \
1791 -c "signed using.*ECDSA with SHA1"
1792
1793run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1794 "$P_SRV crt_file=data_files/server5.crt \
1795 key_file=data_files/server5.key \
1796 crt_file2=data_files/server5-sha1.crt \
1797 key_file2=data_files/server5.key" \
1798 "$P_CLI force_version=tls1" \
1799 0 \
1800 -C "signed using.*ECDSA with SHA256" \
1801 -c "signed using.*ECDSA with SHA1"
1802
1803run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1804 "$P_SRV crt_file=data_files/server5.crt \
1805 key_file=data_files/server5.key \
1806 crt_file2=data_files/server6.crt \
1807 key_file2=data_files/server6.key" \
1808 "$P_CLI force_version=tls1_1" \
1809 0 \
1810 -c "serial number.*09" \
1811 -c "signed using.*ECDSA with SHA256" \
1812 -C "signed using.*ECDSA with SHA1"
1813
1814run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1815 "$P_SRV crt_file=data_files/server6.crt \
1816 key_file=data_files/server6.key \
1817 crt_file2=data_files/server5.crt \
1818 key_file2=data_files/server5.key" \
1819 "$P_CLI force_version=tls1_1" \
1820 0 \
1821 -c "serial number.*0A" \
1822 -c "signed using.*ECDSA with SHA256" \
1823 -C "signed using.*ECDSA with SHA1"
1824
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001825# tests for SNI
1826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001827run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001828 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001829 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001830 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001831 0 \
1832 -S "parse ServerName extension" \
1833 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1834 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001836run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001837 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001838 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001839 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 +02001840 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001841 0 \
1842 -s "parse ServerName extension" \
1843 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1844 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001847 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001848 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001849 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 +02001850 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001851 0 \
1852 -s "parse ServerName extension" \
1853 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1854 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001856run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001857 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001858 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001859 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 +02001860 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001861 1 \
1862 -s "parse ServerName extension" \
1863 -s "ssl_sni_wrapper() returned" \
1864 -s "mbedtls_ssl_handshake returned" \
1865 -c "mbedtls_ssl_handshake returned" \
1866 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001867
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001868run_test "SNI: client auth no override: optional" \
1869 "$P_SRV debug_level=3 auth_mode=optional \
1870 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1871 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1872 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001873 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001874 -S "skip write certificate request" \
1875 -C "skip parse certificate request" \
1876 -c "got a certificate request" \
1877 -C "skip write certificate" \
1878 -C "skip write certificate verify" \
1879 -S "skip parse certificate verify"
1880
1881run_test "SNI: client auth override: none -> optional" \
1882 "$P_SRV debug_level=3 auth_mode=none \
1883 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1884 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1885 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001886 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001887 -S "skip write certificate request" \
1888 -C "skip parse certificate request" \
1889 -c "got a certificate request" \
1890 -C "skip write certificate" \
1891 -C "skip write certificate verify" \
1892 -S "skip parse certificate verify"
1893
1894run_test "SNI: client auth override: optional -> none" \
1895 "$P_SRV debug_level=3 auth_mode=optional \
1896 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1897 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1898 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001899 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001900 -s "skip write certificate request" \
1901 -C "skip parse certificate request" \
1902 -c "got no certificate request" \
1903 -c "skip write certificate" \
1904 -c "skip write certificate verify" \
1905 -s "skip parse certificate verify"
1906
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001907run_test "SNI: CA no override" \
1908 "$P_SRV debug_level=3 auth_mode=optional \
1909 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1910 ca_file=data_files/test-ca.crt \
1911 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1912 "$P_CLI debug_level=3 server_name=localhost \
1913 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1914 1 \
1915 -S "skip write certificate request" \
1916 -C "skip parse certificate request" \
1917 -c "got a certificate request" \
1918 -C "skip write certificate" \
1919 -C "skip write certificate verify" \
1920 -S "skip parse certificate verify" \
1921 -s "x509_verify_cert() returned" \
1922 -s "! The certificate is not correctly signed by the trusted CA" \
1923 -S "The certificate has been revoked (is on a CRL)"
1924
1925run_test "SNI: CA override" \
1926 "$P_SRV debug_level=3 auth_mode=optional \
1927 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1928 ca_file=data_files/test-ca.crt \
1929 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1930 "$P_CLI debug_level=3 server_name=localhost \
1931 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1932 0 \
1933 -S "skip write certificate request" \
1934 -C "skip parse certificate request" \
1935 -c "got a certificate request" \
1936 -C "skip write certificate" \
1937 -C "skip write certificate verify" \
1938 -S "skip parse certificate verify" \
1939 -S "x509_verify_cert() returned" \
1940 -S "! The certificate is not correctly signed by the trusted CA" \
1941 -S "The certificate has been revoked (is on a CRL)"
1942
1943run_test "SNI: CA override with CRL" \
1944 "$P_SRV debug_level=3 auth_mode=optional \
1945 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1946 ca_file=data_files/test-ca.crt \
1947 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1948 "$P_CLI debug_level=3 server_name=localhost \
1949 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1950 1 \
1951 -S "skip write certificate request" \
1952 -C "skip parse certificate request" \
1953 -c "got a certificate request" \
1954 -C "skip write certificate" \
1955 -C "skip write certificate verify" \
1956 -S "skip parse certificate verify" \
1957 -s "x509_verify_cert() returned" \
1958 -S "! The certificate is not correctly signed by the trusted CA" \
1959 -s "The certificate has been revoked (is on a CRL)"
1960
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001961# Tests for non-blocking I/O: exercise a variety of handshake flows
1962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001964 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1965 "$P_CLI nbio=2 tickets=0" \
1966 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001967 -S "mbedtls_ssl_handshake returned" \
1968 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001969 -c "Read from server: .* bytes read"
1970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001971run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001972 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1973 "$P_CLI nbio=2 tickets=0" \
1974 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001975 -S "mbedtls_ssl_handshake returned" \
1976 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001977 -c "Read from server: .* bytes read"
1978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001979run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001980 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1981 "$P_CLI nbio=2 tickets=1" \
1982 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001983 -S "mbedtls_ssl_handshake returned" \
1984 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001985 -c "Read from server: .* bytes read"
1986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001987run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001988 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1989 "$P_CLI nbio=2 tickets=1" \
1990 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001991 -S "mbedtls_ssl_handshake returned" \
1992 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001993 -c "Read from server: .* bytes read"
1994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001995run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001996 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1997 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1998 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001999 -S "mbedtls_ssl_handshake returned" \
2000 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002001 -c "Read from server: .* bytes read"
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002004 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2005 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2006 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002007 -S "mbedtls_ssl_handshake returned" \
2008 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002009 -c "Read from server: .* bytes read"
2010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002011run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002012 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2013 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2014 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002015 -S "mbedtls_ssl_handshake returned" \
2016 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002017 -c "Read from server: .* bytes read"
2018
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002019# Tests for version negotiation
2020
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002021run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002022 "$P_SRV" \
2023 "$P_CLI" \
2024 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002025 -S "mbedtls_ssl_handshake returned" \
2026 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002027 -s "Protocol is TLSv1.2" \
2028 -c "Protocol is TLSv1.2"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002031 "$P_SRV" \
2032 "$P_CLI max_version=tls1_1" \
2033 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002034 -S "mbedtls_ssl_handshake returned" \
2035 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002036 -s "Protocol is TLSv1.1" \
2037 -c "Protocol is TLSv1.1"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002040 "$P_SRV max_version=tls1_1" \
2041 "$P_CLI" \
2042 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002043 -S "mbedtls_ssl_handshake returned" \
2044 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002045 -s "Protocol is TLSv1.1" \
2046 -c "Protocol is TLSv1.1"
2047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002048run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002049 "$P_SRV max_version=tls1_1" \
2050 "$P_CLI max_version=tls1_1" \
2051 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002052 -S "mbedtls_ssl_handshake returned" \
2053 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002054 -s "Protocol is TLSv1.1" \
2055 -c "Protocol is TLSv1.1"
2056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002057run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002058 "$P_SRV min_version=tls1_1" \
2059 "$P_CLI max_version=tls1_1" \
2060 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002061 -S "mbedtls_ssl_handshake returned" \
2062 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002063 -s "Protocol is TLSv1.1" \
2064 -c "Protocol is TLSv1.1"
2065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002066run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002067 "$P_SRV max_version=tls1_1" \
2068 "$P_CLI min_version=tls1_1" \
2069 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002070 -S "mbedtls_ssl_handshake returned" \
2071 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002072 -s "Protocol is TLSv1.1" \
2073 -c "Protocol is TLSv1.1"
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002076 "$P_SRV max_version=tls1_1" \
2077 "$P_CLI min_version=tls1_2" \
2078 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002079 -s "mbedtls_ssl_handshake returned" \
2080 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002081 -c "SSL - Handshake protocol not within min/max boundaries"
2082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002083run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002084 "$P_SRV min_version=tls1_2" \
2085 "$P_CLI max_version=tls1_1" \
2086 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002087 -s "mbedtls_ssl_handshake returned" \
2088 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002089 -s "SSL - Handshake protocol not within min/max boundaries"
2090
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002091# Tests for ALPN extension
2092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002093run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002094 "$P_SRV debug_level=3" \
2095 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002096 0 \
2097 -C "client hello, adding alpn extension" \
2098 -S "found alpn extension" \
2099 -C "got an alert message, type: \\[2:120]" \
2100 -S "server hello, adding alpn extension" \
2101 -C "found alpn extension " \
2102 -C "Application Layer Protocol is" \
2103 -S "Application Layer Protocol is"
2104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002105run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002106 "$P_SRV debug_level=3" \
2107 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002108 0 \
2109 -c "client hello, adding alpn extension" \
2110 -s "found alpn extension" \
2111 -C "got an alert message, type: \\[2:120]" \
2112 -S "server hello, adding alpn extension" \
2113 -C "found alpn extension " \
2114 -c "Application Layer Protocol is (none)" \
2115 -S "Application Layer Protocol is"
2116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002117run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002118 "$P_SRV debug_level=3 alpn=abc,1234" \
2119 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002120 0 \
2121 -C "client hello, adding alpn extension" \
2122 -S "found alpn extension" \
2123 -C "got an alert message, type: \\[2:120]" \
2124 -S "server hello, adding alpn extension" \
2125 -C "found alpn extension " \
2126 -C "Application Layer Protocol is" \
2127 -s "Application Layer Protocol is (none)"
2128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002130 "$P_SRV debug_level=3 alpn=abc,1234" \
2131 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002132 0 \
2133 -c "client hello, adding alpn extension" \
2134 -s "found alpn extension" \
2135 -C "got an alert message, type: \\[2:120]" \
2136 -s "server hello, adding alpn extension" \
2137 -c "found alpn extension" \
2138 -c "Application Layer Protocol is abc" \
2139 -s "Application Layer Protocol is abc"
2140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_SRV debug_level=3 alpn=abc,1234" \
2143 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002144 0 \
2145 -c "client hello, adding alpn extension" \
2146 -s "found alpn extension" \
2147 -C "got an alert message, type: \\[2:120]" \
2148 -s "server hello, adding alpn extension" \
2149 -c "found alpn extension" \
2150 -c "Application Layer Protocol is abc" \
2151 -s "Application Layer Protocol is abc"
2152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002154 "$P_SRV debug_level=3 alpn=abc,1234" \
2155 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002156 0 \
2157 -c "client hello, adding alpn extension" \
2158 -s "found alpn extension" \
2159 -C "got an alert message, type: \\[2:120]" \
2160 -s "server hello, adding alpn extension" \
2161 -c "found alpn extension" \
2162 -c "Application Layer Protocol is 1234" \
2163 -s "Application Layer Protocol is 1234"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002166 "$P_SRV debug_level=3 alpn=abc,123" \
2167 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002168 1 \
2169 -c "client hello, adding alpn extension" \
2170 -s "found alpn extension" \
2171 -c "got an alert message, type: \\[2:120]" \
2172 -S "server hello, adding alpn extension" \
2173 -C "found alpn extension" \
2174 -C "Application Layer Protocol is 1234" \
2175 -S "Application Layer Protocol is 1234"
2176
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002177
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002178# Tests for keyUsage in leaf certificates, part 1:
2179# server-side certificate/suite selection
2180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002181run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002182 "$P_SRV key_file=data_files/server2.key \
2183 crt_file=data_files/server2.ku-ds.crt" \
2184 "$P_CLI" \
2185 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002186 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002187
2188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002189run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002190 "$P_SRV key_file=data_files/server2.key \
2191 crt_file=data_files/server2.ku-ke.crt" \
2192 "$P_CLI" \
2193 0 \
2194 -c "Ciphersuite is TLS-RSA-WITH-"
2195
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002196run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002197 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002198 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002199 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002200 1 \
2201 -C "Ciphersuite is "
2202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002204 "$P_SRV key_file=data_files/server5.key \
2205 crt_file=data_files/server5.ku-ds.crt" \
2206 "$P_CLI" \
2207 0 \
2208 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2209
2210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002212 "$P_SRV key_file=data_files/server5.key \
2213 crt_file=data_files/server5.ku-ka.crt" \
2214 "$P_CLI" \
2215 0 \
2216 -c "Ciphersuite is TLS-ECDH-"
2217
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002218run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002219 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002220 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002221 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002222 1 \
2223 -C "Ciphersuite is "
2224
2225# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002226# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002227
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002228run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002229 "$O_SRV -key data_files/server2.key \
2230 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002231 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002232 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2233 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002234 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002235 -C "Processing of the Certificate handshake message failed" \
2236 -c "Ciphersuite is TLS-"
2237
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002238run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002239 "$O_SRV -key data_files/server2.key \
2240 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002241 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002242 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2243 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002244 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002245 -C "Processing of the Certificate handshake message failed" \
2246 -c "Ciphersuite is TLS-"
2247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002248run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002249 "$O_SRV -key data_files/server2.key \
2250 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002251 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002252 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2253 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002254 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002255 -C "Processing of the Certificate handshake message failed" \
2256 -c "Ciphersuite is TLS-"
2257
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002258run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002259 "$O_SRV -key data_files/server2.key \
2260 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002261 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002262 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2263 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002264 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002265 -c "Processing of the Certificate handshake message failed" \
2266 -C "Ciphersuite is TLS-"
2267
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002268run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2269 "$O_SRV -key data_files/server2.key \
2270 -cert data_files/server2.ku-ke.crt" \
2271 "$P_CLI debug_level=1 auth_mode=optional \
2272 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2273 0 \
2274 -c "bad certificate (usage extensions)" \
2275 -C "Processing of the Certificate handshake message failed" \
2276 -c "Ciphersuite is TLS-" \
2277 -c "! Usage does not match the keyUsage extension"
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002280 "$O_SRV -key data_files/server2.key \
2281 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002282 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002283 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2284 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002285 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002286 -C "Processing of the Certificate handshake message failed" \
2287 -c "Ciphersuite is TLS-"
2288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002289run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002290 "$O_SRV -key data_files/server2.key \
2291 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002292 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002293 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2294 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002295 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002296 -c "Processing of the Certificate handshake message failed" \
2297 -C "Ciphersuite is TLS-"
2298
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002299run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2300 "$O_SRV -key data_files/server2.key \
2301 -cert data_files/server2.ku-ds.crt" \
2302 "$P_CLI debug_level=1 auth_mode=optional \
2303 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2304 0 \
2305 -c "bad certificate (usage extensions)" \
2306 -C "Processing of the Certificate handshake message failed" \
2307 -c "Ciphersuite is TLS-" \
2308 -c "! Usage does not match the keyUsage extension"
2309
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002310# Tests for keyUsage in leaf certificates, part 3:
2311# server-side checking of client cert
2312
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002313run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002315 "$O_CLI -key data_files/server2.key \
2316 -cert data_files/server2.ku-ds.crt" \
2317 0 \
2318 -S "bad certificate (usage extensions)" \
2319 -S "Processing of the Certificate handshake message failed"
2320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002323 "$O_CLI -key data_files/server2.key \
2324 -cert data_files/server2.ku-ke.crt" \
2325 0 \
2326 -s "bad certificate (usage extensions)" \
2327 -S "Processing of the Certificate handshake message failed"
2328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002329run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002330 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002331 "$O_CLI -key data_files/server2.key \
2332 -cert data_files/server2.ku-ke.crt" \
2333 1 \
2334 -s "bad certificate (usage extensions)" \
2335 -s "Processing of the Certificate handshake message failed"
2336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002337run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002338 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002339 "$O_CLI -key data_files/server5.key \
2340 -cert data_files/server5.ku-ds.crt" \
2341 0 \
2342 -S "bad certificate (usage extensions)" \
2343 -S "Processing of the Certificate handshake message failed"
2344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002345run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002346 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002347 "$O_CLI -key data_files/server5.key \
2348 -cert data_files/server5.ku-ka.crt" \
2349 0 \
2350 -s "bad certificate (usage extensions)" \
2351 -S "Processing of the Certificate handshake message failed"
2352
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002353# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002355run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002356 "$P_SRV key_file=data_files/server5.key \
2357 crt_file=data_files/server5.eku-srv.crt" \
2358 "$P_CLI" \
2359 0
2360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002362 "$P_SRV key_file=data_files/server5.key \
2363 crt_file=data_files/server5.eku-srv.crt" \
2364 "$P_CLI" \
2365 0
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002368 "$P_SRV key_file=data_files/server5.key \
2369 crt_file=data_files/server5.eku-cs_any.crt" \
2370 "$P_CLI" \
2371 0
2372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002373run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002374 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002375 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002376 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002377 1
2378
2379# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002381run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002382 "$O_SRV -key data_files/server5.key \
2383 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002384 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002385 0 \
2386 -C "bad certificate (usage extensions)" \
2387 -C "Processing of the Certificate handshake message failed" \
2388 -c "Ciphersuite is TLS-"
2389
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002391 "$O_SRV -key data_files/server5.key \
2392 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002393 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002394 0 \
2395 -C "bad certificate (usage extensions)" \
2396 -C "Processing of the Certificate handshake message failed" \
2397 -c "Ciphersuite is TLS-"
2398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002399run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002400 "$O_SRV -key data_files/server5.key \
2401 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002402 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002403 0 \
2404 -C "bad certificate (usage extensions)" \
2405 -C "Processing of the Certificate handshake message failed" \
2406 -c "Ciphersuite is TLS-"
2407
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002409 "$O_SRV -key data_files/server5.key \
2410 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002411 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002412 1 \
2413 -c "bad certificate (usage extensions)" \
2414 -c "Processing of the Certificate handshake message failed" \
2415 -C "Ciphersuite is TLS-"
2416
2417# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2418
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002419run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002420 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002421 "$O_CLI -key data_files/server5.key \
2422 -cert data_files/server5.eku-cli.crt" \
2423 0 \
2424 -S "bad certificate (usage extensions)" \
2425 -S "Processing of the Certificate handshake message failed"
2426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002427run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002428 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002429 "$O_CLI -key data_files/server5.key \
2430 -cert data_files/server5.eku-srv_cli.crt" \
2431 0 \
2432 -S "bad certificate (usage extensions)" \
2433 -S "Processing of the Certificate handshake message failed"
2434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002435run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002436 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002437 "$O_CLI -key data_files/server5.key \
2438 -cert data_files/server5.eku-cs_any.crt" \
2439 0 \
2440 -S "bad certificate (usage extensions)" \
2441 -S "Processing of the Certificate handshake message failed"
2442
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002443run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002444 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002445 "$O_CLI -key data_files/server5.key \
2446 -cert data_files/server5.eku-cs.crt" \
2447 0 \
2448 -s "bad certificate (usage extensions)" \
2449 -S "Processing of the Certificate handshake message failed"
2450
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002451run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002452 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002453 "$O_CLI -key data_files/server5.key \
2454 -cert data_files/server5.eku-cs.crt" \
2455 1 \
2456 -s "bad certificate (usage extensions)" \
2457 -s "Processing of the Certificate handshake message failed"
2458
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002459# Tests for DHM parameters loading
2460
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002461run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002462 "$P_SRV" \
2463 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2464 debug_level=3" \
2465 0 \
2466 -c "value of 'DHM: P ' (2048 bits)" \
2467 -c "value of 'DHM: G ' (2048 bits)"
2468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002469run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002470 "$P_SRV dhm_file=data_files/dhparams.pem" \
2471 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2472 debug_level=3" \
2473 0 \
2474 -c "value of 'DHM: P ' (1024 bits)" \
2475 -c "value of 'DHM: G ' (2 bits)"
2476
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002477# Tests for DHM client-side size checking
2478
2479run_test "DHM size: server default, client default, OK" \
2480 "$P_SRV" \
2481 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2482 debug_level=1" \
2483 0 \
2484 -C "DHM prime too short:"
2485
2486run_test "DHM size: server default, client 2048, OK" \
2487 "$P_SRV" \
2488 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2489 debug_level=1 dhmlen=2048" \
2490 0 \
2491 -C "DHM prime too short:"
2492
2493run_test "DHM size: server 1024, client default, OK" \
2494 "$P_SRV dhm_file=data_files/dhparams.pem" \
2495 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2496 debug_level=1" \
2497 0 \
2498 -C "DHM prime too short:"
2499
2500run_test "DHM size: server 1000, client default, rejected" \
2501 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2502 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2503 debug_level=1" \
2504 1 \
2505 -c "DHM prime too short:"
2506
2507run_test "DHM size: server default, client 2049, rejected" \
2508 "$P_SRV" \
2509 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2510 debug_level=1 dhmlen=2049" \
2511 1 \
2512 -c "DHM prime too short:"
2513
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002514# Tests for PSK callback
2515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002516run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002517 "$P_SRV psk=abc123 psk_identity=foo" \
2518 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2519 psk_identity=foo psk=abc123" \
2520 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002521 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002522 -S "SSL - Unknown identity received" \
2523 -S "SSL - Verification of the message MAC failed"
2524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002525run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002526 "$P_SRV" \
2527 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2528 psk_identity=foo psk=abc123" \
2529 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002530 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002531 -S "SSL - Unknown identity received" \
2532 -S "SSL - Verification of the message MAC failed"
2533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002534run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002535 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2536 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2537 psk_identity=foo psk=abc123" \
2538 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002539 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002540 -s "SSL - Unknown identity received" \
2541 -S "SSL - Verification of the message MAC failed"
2542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002543run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002544 "$P_SRV psk_list=abc,dead,def,beef" \
2545 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2546 psk_identity=abc psk=dead" \
2547 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002548 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002549 -S "SSL - Unknown identity received" \
2550 -S "SSL - Verification of the message MAC failed"
2551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002552run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002553 "$P_SRV psk_list=abc,dead,def,beef" \
2554 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2555 psk_identity=def psk=beef" \
2556 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002557 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002558 -S "SSL - Unknown identity received" \
2559 -S "SSL - Verification of the message MAC failed"
2560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002561run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002562 "$P_SRV psk_list=abc,dead,def,beef" \
2563 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2564 psk_identity=ghi psk=beef" \
2565 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002566 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002567 -s "SSL - Unknown identity received" \
2568 -S "SSL - Verification of the message MAC failed"
2569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002570run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002571 "$P_SRV psk_list=abc,dead,def,beef" \
2572 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2573 psk_identity=abc psk=beef" \
2574 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002575 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002576 -S "SSL - Unknown identity received" \
2577 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002578
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002579# Tests for EC J-PAKE
2580
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002581requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002582run_test "ECJPAKE: client not configured" \
2583 "$P_SRV debug_level=3" \
2584 "$P_CLI debug_level=3" \
2585 0 \
2586 -C "add ciphersuite: c0ff" \
2587 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002588 -S "found ecjpake kkpp extension" \
2589 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002590 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002591 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002592 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002593 -S "None of the common ciphersuites is usable"
2594
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002595requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002596run_test "ECJPAKE: server not configured" \
2597 "$P_SRV debug_level=3" \
2598 "$P_CLI debug_level=3 ecjpake_pw=bla \
2599 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2600 1 \
2601 -c "add ciphersuite: c0ff" \
2602 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002603 -s "found ecjpake kkpp extension" \
2604 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002605 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002606 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002607 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002608 -s "None of the common ciphersuites is usable"
2609
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002610requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002611run_test "ECJPAKE: working, TLS" \
2612 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2613 "$P_CLI debug_level=3 ecjpake_pw=bla \
2614 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002615 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002616 -c "add ciphersuite: c0ff" \
2617 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002618 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002619 -s "found ecjpake kkpp extension" \
2620 -S "skip ecjpake kkpp extension" \
2621 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002622 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002623 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002624 -S "None of the common ciphersuites is usable" \
2625 -S "SSL - Verification of the message MAC failed"
2626
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002627requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002628run_test "ECJPAKE: password mismatch, TLS" \
2629 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2630 "$P_CLI debug_level=3 ecjpake_pw=bad \
2631 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2632 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002633 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002634 -s "SSL - Verification of the message MAC failed"
2635
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002636requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002637run_test "ECJPAKE: working, DTLS" \
2638 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2639 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2640 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2641 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002642 -c "re-using cached ecjpake parameters" \
2643 -S "SSL - Verification of the message MAC failed"
2644
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002645requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002646run_test "ECJPAKE: working, DTLS, no cookie" \
2647 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2648 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2649 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2650 0 \
2651 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002652 -S "SSL - Verification of the message MAC failed"
2653
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002654requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002655run_test "ECJPAKE: password mismatch, DTLS" \
2656 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2657 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2658 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2659 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002660 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002661 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002662
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002663# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002664requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002665run_test "ECJPAKE: working, DTLS, nolog" \
2666 "$P_SRV dtls=1 ecjpake_pw=bla" \
2667 "$P_CLI dtls=1 ecjpake_pw=bla \
2668 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2669 0
2670
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002671# Tests for ciphersuites per version
2672
Janos Follathe2681a42016-03-07 15:57:05 +00002673requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002675 "$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 +02002676 "$P_CLI force_version=ssl3" \
2677 0 \
2678 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002680run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002681 "$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 +01002682 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002683 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002684 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002686run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002687 "$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 +02002688 "$P_CLI force_version=tls1_1" \
2689 0 \
2690 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002693 "$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 +02002694 "$P_CLI force_version=tls1_2" \
2695 0 \
2696 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2697
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002698# Test for ClientHello without extensions
2699
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002700requires_gnutls
2701run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002702 "$P_SRV debug_level=3" \
2703 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2704 0 \
2705 -s "dumping 'client hello extensions' (0 bytes)"
2706
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002707# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002708
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002709run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002710 "$P_SRV" \
2711 "$P_CLI request_size=100" \
2712 0 \
2713 -s "Read from client: 100 bytes read$"
2714
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002715run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002716 "$P_SRV" \
2717 "$P_CLI request_size=500" \
2718 0 \
2719 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002720
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002721# Tests for small packets
2722
Janos Follathe2681a42016-03-07 15:57:05 +00002723requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002724run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002725 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002726 "$P_CLI request_size=1 force_version=ssl3 \
2727 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2728 0 \
2729 -s "Read from client: 1 bytes read"
2730
Janos Follathe2681a42016-03-07 15:57:05 +00002731requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002732run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002733 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002734 "$P_CLI request_size=1 force_version=ssl3 \
2735 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2736 0 \
2737 -s "Read from client: 1 bytes read"
2738
2739run_test "Small packet TLS 1.0 BlockCipher" \
2740 "$P_SRV" \
2741 "$P_CLI request_size=1 force_version=tls1 \
2742 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2743 0 \
2744 -s "Read from client: 1 bytes read"
2745
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002746run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2747 "$P_SRV" \
2748 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2749 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2750 0 \
2751 -s "Read from client: 1 bytes read"
2752
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002753run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2754 "$P_SRV" \
2755 "$P_CLI request_size=1 force_version=tls1 \
2756 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2757 trunc_hmac=1" \
2758 0 \
2759 -s "Read from client: 1 bytes read"
2760
2761run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002762 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002763 "$P_CLI request_size=1 force_version=tls1 \
2764 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2765 trunc_hmac=1" \
2766 0 \
2767 -s "Read from client: 1 bytes read"
2768
2769run_test "Small packet TLS 1.1 BlockCipher" \
2770 "$P_SRV" \
2771 "$P_CLI request_size=1 force_version=tls1_1 \
2772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2773 0 \
2774 -s "Read from client: 1 bytes read"
2775
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002776run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2777 "$P_SRV" \
2778 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2779 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2780 0 \
2781 -s "Read from client: 1 bytes read"
2782
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002783run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002784 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002785 "$P_CLI request_size=1 force_version=tls1_1 \
2786 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2787 0 \
2788 -s "Read from client: 1 bytes read"
2789
2790run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2791 "$P_SRV" \
2792 "$P_CLI request_size=1 force_version=tls1_1 \
2793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2794 trunc_hmac=1" \
2795 0 \
2796 -s "Read from client: 1 bytes read"
2797
2798run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002799 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002800 "$P_CLI request_size=1 force_version=tls1_1 \
2801 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2802 trunc_hmac=1" \
2803 0 \
2804 -s "Read from client: 1 bytes read"
2805
2806run_test "Small packet TLS 1.2 BlockCipher" \
2807 "$P_SRV" \
2808 "$P_CLI request_size=1 force_version=tls1_2 \
2809 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2810 0 \
2811 -s "Read from client: 1 bytes read"
2812
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002813run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2814 "$P_SRV" \
2815 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2817 0 \
2818 -s "Read from client: 1 bytes read"
2819
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002820run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2821 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002822 "$P_CLI request_size=1 force_version=tls1_2 \
2823 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002824 0 \
2825 -s "Read from client: 1 bytes read"
2826
2827run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2828 "$P_SRV" \
2829 "$P_CLI request_size=1 force_version=tls1_2 \
2830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2831 trunc_hmac=1" \
2832 0 \
2833 -s "Read from client: 1 bytes read"
2834
2835run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002836 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002837 "$P_CLI request_size=1 force_version=tls1_2 \
2838 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2839 0 \
2840 -s "Read from client: 1 bytes read"
2841
2842run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002843 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002844 "$P_CLI request_size=1 force_version=tls1_2 \
2845 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2846 trunc_hmac=1" \
2847 0 \
2848 -s "Read from client: 1 bytes read"
2849
2850run_test "Small packet TLS 1.2 AEAD" \
2851 "$P_SRV" \
2852 "$P_CLI request_size=1 force_version=tls1_2 \
2853 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2854 0 \
2855 -s "Read from client: 1 bytes read"
2856
2857run_test "Small packet TLS 1.2 AEAD shorter tag" \
2858 "$P_SRV" \
2859 "$P_CLI request_size=1 force_version=tls1_2 \
2860 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2861 0 \
2862 -s "Read from client: 1 bytes read"
2863
Janos Follath00efff72016-05-06 13:48:23 +01002864# A test for extensions in SSLv3
2865
2866requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2867run_test "SSLv3 with extensions, server side" \
2868 "$P_SRV min_version=ssl3 debug_level=3" \
2869 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2870 0 \
2871 -S "dumping 'client hello extensions'" \
2872 -S "server hello, total extension length:"
2873
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002874# Test for large packets
2875
Janos Follathe2681a42016-03-07 15:57:05 +00002876requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002877run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002878 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002879 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2881 0 \
2882 -s "Read from client: 16384 bytes read"
2883
Janos Follathe2681a42016-03-07 15:57:05 +00002884requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002885run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002886 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002887 "$P_CLI request_size=16384 force_version=ssl3 \
2888 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2889 0 \
2890 -s "Read from client: 16384 bytes read"
2891
2892run_test "Large packet TLS 1.0 BlockCipher" \
2893 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002894 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002895 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2896 0 \
2897 -s "Read from client: 16384 bytes read"
2898
2899run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2900 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002901 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002902 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2903 trunc_hmac=1" \
2904 0 \
2905 -s "Read from client: 16384 bytes read"
2906
2907run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002908 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002909 "$P_CLI request_size=16384 force_version=tls1 \
2910 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2911 trunc_hmac=1" \
2912 0 \
2913 -s "Read from client: 16384 bytes read"
2914
2915run_test "Large packet TLS 1.1 BlockCipher" \
2916 "$P_SRV" \
2917 "$P_CLI request_size=16384 force_version=tls1_1 \
2918 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.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002923 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002924 "$P_CLI request_size=16384 force_version=tls1_1 \
2925 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2926 0 \
2927 -s "Read from client: 16384 bytes read"
2928
2929run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2930 "$P_SRV" \
2931 "$P_CLI request_size=16384 force_version=tls1_1 \
2932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2933 trunc_hmac=1" \
2934 0 \
2935 -s "Read from client: 16384 bytes read"
2936
2937run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002938 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002939 "$P_CLI request_size=16384 force_version=tls1_1 \
2940 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2941 trunc_hmac=1" \
2942 0 \
2943 -s "Read from client: 16384 bytes read"
2944
2945run_test "Large packet TLS 1.2 BlockCipher" \
2946 "$P_SRV" \
2947 "$P_CLI request_size=16384 force_version=tls1_2 \
2948 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2949 0 \
2950 -s "Read from client: 16384 bytes read"
2951
2952run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2953 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002954 "$P_CLI request_size=16384 force_version=tls1_2 \
2955 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002956 0 \
2957 -s "Read from client: 16384 bytes read"
2958
2959run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2960 "$P_SRV" \
2961 "$P_CLI request_size=16384 force_version=tls1_2 \
2962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2963 trunc_hmac=1" \
2964 0 \
2965 -s "Read from client: 16384 bytes read"
2966
2967run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002968 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002969 "$P_CLI request_size=16384 force_version=tls1_2 \
2970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2971 0 \
2972 -s "Read from client: 16384 bytes read"
2973
2974run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002975 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002976 "$P_CLI request_size=16384 force_version=tls1_2 \
2977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2978 trunc_hmac=1" \
2979 0 \
2980 -s "Read from client: 16384 bytes read"
2981
2982run_test "Large packet TLS 1.2 AEAD" \
2983 "$P_SRV" \
2984 "$P_CLI request_size=16384 force_version=tls1_2 \
2985 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2986 0 \
2987 -s "Read from client: 16384 bytes read"
2988
2989run_test "Large packet TLS 1.2 AEAD shorter tag" \
2990 "$P_SRV" \
2991 "$P_CLI request_size=16384 force_version=tls1_2 \
2992 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2993 0 \
2994 -s "Read from client: 16384 bytes read"
2995
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002996# Tests for DTLS HelloVerifyRequest
2997
2998run_test "DTLS cookie: enabled" \
2999 "$P_SRV dtls=1 debug_level=2" \
3000 "$P_CLI dtls=1 debug_level=2" \
3001 0 \
3002 -s "cookie verification failed" \
3003 -s "cookie verification passed" \
3004 -S "cookie verification skipped" \
3005 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003006 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003007 -S "SSL - The requested feature is not available"
3008
3009run_test "DTLS cookie: disabled" \
3010 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3011 "$P_CLI dtls=1 debug_level=2" \
3012 0 \
3013 -S "cookie verification failed" \
3014 -S "cookie verification passed" \
3015 -s "cookie verification skipped" \
3016 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003017 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003018 -S "SSL - The requested feature is not available"
3019
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003020run_test "DTLS cookie: default (failing)" \
3021 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3022 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3023 1 \
3024 -s "cookie verification failed" \
3025 -S "cookie verification passed" \
3026 -S "cookie verification skipped" \
3027 -C "received hello verify request" \
3028 -S "hello verification requested" \
3029 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003030
3031requires_ipv6
3032run_test "DTLS cookie: enabled, IPv6" \
3033 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3034 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
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é-Gonnard579950c2014-09-29 17:47:33 +02003043run_test "DTLS cookie: enabled, nbio" \
3044 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3045 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3046 0 \
3047 -s "cookie verification failed" \
3048 -s "cookie verification passed" \
3049 -S "cookie verification skipped" \
3050 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003051 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003052 -S "SSL - The requested feature is not available"
3053
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003054# Tests for client reconnecting from the same port with DTLS
3055
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003056not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003057run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003058 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3059 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003060 0 \
3061 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003062 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003063 -S "Client initiated reconnection from same port"
3064
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003065not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003066run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003067 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3068 "$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 +02003069 0 \
3070 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003071 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003072 -s "Client initiated reconnection from same port"
3073
3074run_test "DTLS client reconnect from same port: reconnect, nbio" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003075 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3076 "$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 +02003077 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003078 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003079 -s "Client initiated reconnection from same port"
3080
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003081run_test "DTLS client reconnect from same port: no cookies" \
3082 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003083 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3084 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003085 -s "The operation timed out" \
3086 -S "Client initiated reconnection from same port"
3087
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003088# Tests for various cases of client authentication with DTLS
3089# (focused on handshake flows and message parsing)
3090
3091run_test "DTLS client auth: required" \
3092 "$P_SRV dtls=1 auth_mode=required" \
3093 "$P_CLI dtls=1" \
3094 0 \
3095 -s "Verifying peer X.509 certificate... ok"
3096
3097run_test "DTLS client auth: optional, client has no cert" \
3098 "$P_SRV dtls=1 auth_mode=optional" \
3099 "$P_CLI dtls=1 crt_file=none key_file=none" \
3100 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003101 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003102
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003103run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003104 "$P_SRV dtls=1 auth_mode=none" \
3105 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3106 0 \
3107 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003108 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003109
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003110run_test "DTLS wrong PSK: badmac alert" \
3111 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3112 "$P_CLI dtls=1 psk=abc124" \
3113 1 \
3114 -s "SSL - Verification of the message MAC failed" \
3115 -c "SSL - A fatal alert message was received from our peer"
3116
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003117# Tests for receiving fragmented handshake messages with DTLS
3118
3119requires_gnutls
3120run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3121 "$G_SRV -u --mtu 2048 -a" \
3122 "$P_CLI dtls=1 debug_level=2" \
3123 0 \
3124 -C "found fragmented DTLS handshake message" \
3125 -C "error"
3126
3127requires_gnutls
3128run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3129 "$G_SRV -u --mtu 512" \
3130 "$P_CLI dtls=1 debug_level=2" \
3131 0 \
3132 -c "found fragmented DTLS handshake message" \
3133 -C "error"
3134
3135requires_gnutls
3136run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3137 "$G_SRV -u --mtu 128" \
3138 "$P_CLI dtls=1 debug_level=2" \
3139 0 \
3140 -c "found fragmented DTLS handshake message" \
3141 -C "error"
3142
3143requires_gnutls
3144run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3145 "$G_SRV -u --mtu 128" \
3146 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3147 0 \
3148 -c "found fragmented DTLS handshake message" \
3149 -C "error"
3150
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003151requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003152run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3153 "$G_SRV -u --mtu 256" \
3154 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3155 0 \
3156 -c "found fragmented DTLS handshake message" \
3157 -c "client hello, adding renegotiation extension" \
3158 -c "found renegotiation extension" \
3159 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003160 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003161 -C "error" \
3162 -s "Extra-header:"
3163
3164requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003165run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3166 "$G_SRV -u --mtu 256" \
3167 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3168 0 \
3169 -c "found fragmented DTLS handshake message" \
3170 -c "client hello, adding renegotiation extension" \
3171 -c "found renegotiation extension" \
3172 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003173 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003174 -C "error" \
3175 -s "Extra-header:"
3176
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003177run_test "DTLS reassembly: no fragmentation (openssl server)" \
3178 "$O_SRV -dtls1 -mtu 2048" \
3179 "$P_CLI dtls=1 debug_level=2" \
3180 0 \
3181 -C "found fragmented DTLS handshake message" \
3182 -C "error"
3183
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003184run_test "DTLS reassembly: some fragmentation (openssl server)" \
3185 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003186 "$P_CLI dtls=1 debug_level=2" \
3187 0 \
3188 -c "found fragmented DTLS handshake message" \
3189 -C "error"
3190
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003191run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003192 "$O_SRV -dtls1 -mtu 256" \
3193 "$P_CLI dtls=1 debug_level=2" \
3194 0 \
3195 -c "found fragmented DTLS handshake message" \
3196 -C "error"
3197
3198run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3199 "$O_SRV -dtls1 -mtu 256" \
3200 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3201 0 \
3202 -c "found fragmented DTLS handshake message" \
3203 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003204
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003205# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003206
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003207not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003208run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003209 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003210 "$P_SRV dtls=1 debug_level=2" \
3211 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003212 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003213 -C "replayed record" \
3214 -S "replayed record" \
3215 -C "record from another epoch" \
3216 -S "record from another epoch" \
3217 -C "discarding invalid record" \
3218 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003219 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003220 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003221 -c "HTTP/1.0 200 OK"
3222
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003223not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003224run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003225 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003226 "$P_SRV dtls=1 debug_level=2" \
3227 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003228 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003229 -c "replayed record" \
3230 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003231 -c "discarding invalid record" \
3232 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003233 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003234 -s "Extra-header:" \
3235 -c "HTTP/1.0 200 OK"
3236
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003237run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3238 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003239 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3240 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003241 0 \
3242 -c "replayed record" \
3243 -S "replayed record" \
3244 -c "discarding invalid record" \
3245 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003246 -c "resend" \
3247 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003248 -s "Extra-header:" \
3249 -c "HTTP/1.0 200 OK"
3250
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003251run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003252 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003253 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003254 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003255 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003256 -c "discarding invalid record (mac)" \
3257 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003258 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003259 -c "HTTP/1.0 200 OK" \
3260 -S "too many records with bad MAC" \
3261 -S "Verification of the message MAC failed"
3262
3263run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3264 -p "$P_PXY bad_ad=1" \
3265 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3266 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3267 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003268 -C "discarding invalid record (mac)" \
3269 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003270 -S "Extra-header:" \
3271 -C "HTTP/1.0 200 OK" \
3272 -s "too many records with bad MAC" \
3273 -s "Verification of the message MAC failed"
3274
3275run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3276 -p "$P_PXY bad_ad=1" \
3277 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3278 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3279 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003280 -c "discarding invalid record (mac)" \
3281 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003282 -s "Extra-header:" \
3283 -c "HTTP/1.0 200 OK" \
3284 -S "too many records with bad MAC" \
3285 -S "Verification of the message MAC failed"
3286
3287run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3288 -p "$P_PXY bad_ad=1" \
3289 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3290 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3291 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003292 -c "discarding invalid record (mac)" \
3293 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003294 -s "Extra-header:" \
3295 -c "HTTP/1.0 200 OK" \
3296 -s "too many records with bad MAC" \
3297 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003298
3299run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003300 -p "$P_PXY delay_ccs=1" \
3301 "$P_SRV dtls=1 debug_level=1" \
3302 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003303 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003304 -c "record from another epoch" \
3305 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003306 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003307 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003308 -s "Extra-header:" \
3309 -c "HTTP/1.0 200 OK"
3310
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003311# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003312
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003313needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003314run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003315 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003316 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3317 psk=abc123" \
3318 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003319 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3320 0 \
3321 -s "Extra-header:" \
3322 -c "HTTP/1.0 200 OK"
3323
3324needs_more_time 2
3325run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3326 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003327 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3328 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003329 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3330 0 \
3331 -s "Extra-header:" \
3332 -c "HTTP/1.0 200 OK"
3333
3334needs_more_time 2
3335run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3336 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003337 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3338 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003339 0 \
3340 -s "Extra-header:" \
3341 -c "HTTP/1.0 200 OK"
3342
3343needs_more_time 2
3344run_test "DTLS proxy: 3d, FS, client auth" \
3345 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003346 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3347 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003348 0 \
3349 -s "Extra-header:" \
3350 -c "HTTP/1.0 200 OK"
3351
3352needs_more_time 2
3353run_test "DTLS proxy: 3d, FS, ticket" \
3354 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003355 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3356 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003357 0 \
3358 -s "Extra-header:" \
3359 -c "HTTP/1.0 200 OK"
3360
3361needs_more_time 2
3362run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3363 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003364 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3365 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003366 0 \
3367 -s "Extra-header:" \
3368 -c "HTTP/1.0 200 OK"
3369
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003370needs_more_time 2
3371run_test "DTLS proxy: 3d, max handshake, nbio" \
3372 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003373 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3374 auth_mode=required" \
3375 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003376 0 \
3377 -s "Extra-header:" \
3378 -c "HTTP/1.0 200 OK"
3379
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003380needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003381run_test "DTLS proxy: 3d, min handshake, resumption" \
3382 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3383 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3384 psk=abc123 debug_level=3" \
3385 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3386 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3387 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3388 0 \
3389 -s "a session has been resumed" \
3390 -c "a session has been resumed" \
3391 -s "Extra-header:" \
3392 -c "HTTP/1.0 200 OK"
3393
3394needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003395run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3396 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3397 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3398 psk=abc123 debug_level=3 nbio=2" \
3399 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3400 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3401 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3402 0 \
3403 -s "a session has been resumed" \
3404 -c "a session has been resumed" \
3405 -s "Extra-header:" \
3406 -c "HTTP/1.0 200 OK"
3407
3408needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003409run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003411 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3412 psk=abc123 renegotiation=1 debug_level=2" \
3413 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3414 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003415 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3416 0 \
3417 -c "=> renegotiate" \
3418 -s "=> renegotiate" \
3419 -s "Extra-header:" \
3420 -c "HTTP/1.0 200 OK"
3421
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003422needs_more_time 4
3423run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3424 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003425 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3426 psk=abc123 renegotiation=1 debug_level=2" \
3427 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3428 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003429 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3430 0 \
3431 -c "=> renegotiate" \
3432 -s "=> renegotiate" \
3433 -s "Extra-header:" \
3434 -c "HTTP/1.0 200 OK"
3435
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003436needs_more_time 4
3437run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003438 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003439 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003440 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003441 debug_level=2" \
3442 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003443 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003444 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3445 0 \
3446 -c "=> renegotiate" \
3447 -s "=> renegotiate" \
3448 -s "Extra-header:" \
3449 -c "HTTP/1.0 200 OK"
3450
3451needs_more_time 4
3452run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003453 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003454 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003455 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003456 debug_level=2 nbio=2" \
3457 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003458 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003459 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3460 0 \
3461 -c "=> renegotiate" \
3462 -s "=> renegotiate" \
3463 -s "Extra-header:" \
3464 -c "HTTP/1.0 200 OK"
3465
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003466needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003467not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003468run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003469 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3470 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003471 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003472 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003473 -c "HTTP/1.0 200 OK"
3474
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003475needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003476not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003477run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3478 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3479 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003480 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003481 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003482 -c "HTTP/1.0 200 OK"
3483
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003484needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003485not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003486run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3487 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3488 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003489 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003490 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003491 -c "HTTP/1.0 200 OK"
3492
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003493requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003494needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003495not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003496run_test "DTLS proxy: 3d, gnutls server" \
3497 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3498 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003499 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003500 0 \
3501 -s "Extra-header:" \
3502 -c "Extra-header:"
3503
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003504requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003505needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003506not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003507run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3508 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3509 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003510 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003511 0 \
3512 -s "Extra-header:" \
3513 -c "Extra-header:"
3514
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003515requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003516needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003517not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003518run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3519 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3520 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003521 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003522 0 \
3523 -s "Extra-header:" \
3524 -c "Extra-header:"
3525
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003526# Final report
3527
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003528echo "------------------------------------------------------------------------"
3529
3530if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003531 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003532else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003533 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003534fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003535PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003536echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003537
3538exit $FAILS