blob: d9c45cd7a2403603493b4aa73ebb141b521bf0e0 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010031
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020032O_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 +010033O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020034G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010035G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010036
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010037TESTS=0
38FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020039SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010040
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000041CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020042
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010043MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010044FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020045EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010046
Paul Bakkere20310a2016-05-10 11:18:17 +010047SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010048RUN_TEST_NUMBER=''
49
Paul Bakkeracaac852016-05-10 11:47:13 +010050PRESERVE_LOGS=0
51
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010052print_usage() {
53 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010054 printf " -h|--help\tPrint this help.\n"
55 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
56 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
57 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010058 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010059 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010060 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010061}
62
63get_options() {
64 while [ $# -gt 0 ]; do
65 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010066 -f|--filter)
67 shift; FILTER=$1
68 ;;
69 -e|--exclude)
70 shift; EXCLUDE=$1
71 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072 -m|--memcheck)
73 MEMCHECK=1
74 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010075 -n|--number)
76 shift; RUN_TEST_NUMBER=$1
77 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010078 -s|--show-numbers)
79 SHOW_TEST_NUMBER=1
80 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010081 -p|--preserve-logs)
82 PRESERVE_LOGS=1
83 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010084 -h|--help)
85 print_usage
86 exit 0
87 ;;
88 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020089 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010090 print_usage
91 exit 1
92 ;;
93 esac
94 shift
95 done
96}
97
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010098# skip next test if the flag is not enabled in config.h
99requires_config_enabled() {
100 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200105# skip next test if OpenSSL doesn't support FALLBACK_SCSV
106requires_openssl_with_fallback_scsv() {
107 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
108 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
109 then
110 OPENSSL_HAS_FBSCSV="YES"
111 else
112 OPENSSL_HAS_FBSCSV="NO"
113 fi
114 fi
115 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
116 SKIP_NEXT="YES"
117 fi
118}
119
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200120# skip next test if GnuTLS isn't available
121requires_gnutls() {
122 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200123 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200124 GNUTLS_AVAILABLE="YES"
125 else
126 GNUTLS_AVAILABLE="NO"
127 fi
128 fi
129 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
130 SKIP_NEXT="YES"
131 fi
132}
133
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200134# skip next test if IPv6 isn't available on this host
135requires_ipv6() {
136 if [ -z "${HAS_IPV6:-}" ]; then
137 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
138 SRV_PID=$!
139 sleep 1
140 kill $SRV_PID >/dev/null 2>&1
141 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
142 HAS_IPV6="NO"
143 else
144 HAS_IPV6="YES"
145 fi
146 rm -r $SRV_OUT
147 fi
148
149 if [ "$HAS_IPV6" = "NO" ]; then
150 SKIP_NEXT="YES"
151 fi
152}
153
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200154# skip the next test if valgrind is in use
155not_with_valgrind() {
156 if [ "$MEMCHECK" -gt 0 ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Paul Bakker362689d2016-05-13 10:33:25 +0100161# skip the next test if valgrind is NOT in use
162only_with_valgrind() {
163 if [ "$MEMCHECK" -eq 0 ]; then
164 SKIP_NEXT="YES"
165 fi
166}
167
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200168# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100169client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200170 CLI_DELAY_FACTOR=$1
171}
172
Janos Follath74537a62016-09-02 13:45:28 +0100173# wait for the given seconds after the client finished in the next test
174server_needs_more_time() {
175 SRV_DELAY_SECONDS=$1
176}
177
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100178# print_name <name>
179print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100180 TESTS=$(( $TESTS + 1 ))
181 LINE=""
182
183 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
184 LINE="$TESTS "
185 fi
186
187 LINE="$LINE$1"
188 printf "$LINE "
189 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100190 for i in `seq 1 $LEN`; do printf '.'; done
191 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100192
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100193}
194
195# fail <message>
196fail() {
197 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100198 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100199
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200200 mv $SRV_OUT o-srv-${TESTS}.log
201 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200202 if [ -n "$PXY_CMD" ]; then
203 mv $PXY_OUT o-pxy-${TESTS}.log
204 fi
205 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100206
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200207 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
208 echo " ! server output:"
209 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200210 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200211 echo " ! client output:"
212 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200213 if [ -n "$PXY_CMD" ]; then
214 echo " ! ========================================================"
215 echo " ! proxy output:"
216 cat o-pxy-${TESTS}.log
217 fi
218 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200219 fi
220
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200221 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100222}
223
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100224# is_polar <cmd_line>
225is_polar() {
226 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
227}
228
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200229# openssl s_server doesn't have -www with DTLS
230check_osrv_dtls() {
231 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
232 NEEDS_INPUT=1
233 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
234 else
235 NEEDS_INPUT=0
236 fi
237}
238
239# provide input to commands that need it
240provide_input() {
241 if [ $NEEDS_INPUT -eq 0 ]; then
242 return
243 fi
244
245 while true; do
246 echo "HTTP/1.0 200 OK"
247 sleep 1
248 done
249}
250
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100251# has_mem_err <log_file_name>
252has_mem_err() {
253 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
254 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
255 then
256 return 1 # false: does not have errors
257 else
258 return 0 # true: has errors
259 fi
260}
261
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200262# wait for server to start: two versions depending on lsof availability
263wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200264 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200265 START_TIME=$( date +%s )
266 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200267
268 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200269 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200270 while [ $DONE -eq 0 ]; do
271 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
272 then
273 DONE=1
274 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
275 echo "SERVERSTART TIMEOUT"
276 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
277 DONE=1
278 fi
279 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200280 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200281 while [ $DONE -eq 0 ]; do
282 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
283 then
284 DONE=1
285 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
286 echo "SERVERSTART TIMEOUT"
287 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
288 DONE=1
289 fi
290 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200291 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200292 else
293 sleep "$START_DELAY"
294 fi
295}
296
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200297# wait for client to terminate and set CLI_EXIT
298# must be called right after starting the client
299wait_client_done() {
300 CLI_PID=$!
301
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200302 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
303 CLI_DELAY_FACTOR=1
304
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200305 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200306 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200307
308 wait $CLI_PID
309 CLI_EXIT=$?
310
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200311 kill $DOG_PID >/dev/null 2>&1
312 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200313
314 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100315
316 sleep $SRV_DELAY_SECONDS
317 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200318}
319
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200320# check if the given command uses dtls and sets global variable DTLS
321detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200322 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200323 DTLS=1
324 else
325 DTLS=0
326 fi
327}
328
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200329# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100330# Options: -s pattern pattern that must be present in server output
331# -c pattern pattern that must be present in client output
332# -S pattern pattern that must be absent in server output
333# -C pattern pattern that must be absent in client output
334run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100335 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200336 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100337
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100338 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
339 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200340 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100341 return
342 fi
343
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100344 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100345
Paul Bakkerb7584a52016-05-10 10:50:43 +0100346 # Do we only run numbered tests?
347 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
348 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
349 else
350 SKIP_NEXT="YES"
351 fi
352
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200353 # should we skip?
354 if [ "X$SKIP_NEXT" = "XYES" ]; then
355 SKIP_NEXT="NO"
356 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200357 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200358 return
359 fi
360
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200361 # does this test use a proxy?
362 if [ "X$1" = "X-p" ]; then
363 PXY_CMD="$2"
364 shift 2
365 else
366 PXY_CMD=""
367 fi
368
369 # get commands and client output
370 SRV_CMD="$1"
371 CLI_CMD="$2"
372 CLI_EXPECT="$3"
373 shift 3
374
375 # fix client port
376 if [ -n "$PXY_CMD" ]; then
377 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
378 else
379 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
380 fi
381
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200382 # update DTLS variable
383 detect_dtls "$SRV_CMD"
384
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100385 # prepend valgrind to our commands if active
386 if [ "$MEMCHECK" -gt 0 ]; then
387 if is_polar "$SRV_CMD"; then
388 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
389 fi
390 if is_polar "$CLI_CMD"; then
391 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
392 fi
393 fi
394
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200395 TIMES_LEFT=2
396 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200397 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200398
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200399 # run the commands
400 if [ -n "$PXY_CMD" ]; then
401 echo "$PXY_CMD" > $PXY_OUT
402 $PXY_CMD >> $PXY_OUT 2>&1 &
403 PXY_PID=$!
404 # assume proxy starts faster than server
405 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200406
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200407 check_osrv_dtls
408 echo "$SRV_CMD" > $SRV_OUT
409 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
410 SRV_PID=$!
411 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200412
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200413 echo "$CLI_CMD" > $CLI_OUT
414 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
415 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100416
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200417 # terminate the server (and the proxy)
418 kill $SRV_PID
419 wait $SRV_PID
420 if [ -n "$PXY_CMD" ]; then
421 kill $PXY_PID >/dev/null 2>&1
422 wait $PXY_PID
423 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100424
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200425 # retry only on timeouts
426 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
427 printf "RETRY "
428 else
429 TIMES_LEFT=0
430 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200431 done
432
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100433 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200434 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100435 # expected client exit to incorrectly succeed in case of catastrophic
436 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100437 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200438 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100440 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100441 return
442 fi
443 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100444 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200445 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100446 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100447 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100448 return
449 fi
450 fi
451
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100452 # check server exit code
453 if [ $? != 0 ]; then
454 fail "server fail"
455 return
456 fi
457
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100458 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100459 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
460 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100461 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200462 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100463 return
464 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100465
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100466 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200467 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100468 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100469 while [ $# -gt 0 ]
470 do
471 case $1 in
472 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100473 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100474 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100475 return
476 fi
477 ;;
478
479 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100480 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100481 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100482 return
483 fi
484 ;;
485
486 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100487 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100488 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100489 return
490 fi
491 ;;
492
493 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100494 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100495 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100496 return
497 fi
498 ;;
499
500 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200501 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100502 exit 1
503 esac
504 shift 2
505 done
506
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100507 # check valgrind's results
508 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200509 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100510 fail "Server has memory errors"
511 return
512 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200513 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100514 fail "Client has memory errors"
515 return
516 fi
517 fi
518
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519 # if we're here, everything is ok
520 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100521 if [ "$PRESERVE_LOGS" -gt 0 ]; then
522 mv $SRV_OUT o-srv-${TESTS}.log
523 mv $CLI_OUT o-cli-${TESTS}.log
524 fi
525
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200526 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100527}
528
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100529cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200531 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
532 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
533 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
534 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100535 exit 1
536}
537
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100538#
539# MAIN
540#
541
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000542if cd $( dirname $0 ); then :; else
543 echo "cd $( dirname $0 ) failed" >&2
544 exit 1
545fi
546
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100547get_options "$@"
548
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100549# sanity checks, avoid an avalanche of errors
550if [ ! -x "$P_SRV" ]; then
551 echo "Command '$P_SRV' is not an executable file"
552 exit 1
553fi
554if [ ! -x "$P_CLI" ]; then
555 echo "Command '$P_CLI' is not an executable file"
556 exit 1
557fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200558if [ ! -x "$P_PXY" ]; then
559 echo "Command '$P_PXY' is not an executable file"
560 exit 1
561fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100562if [ "$MEMCHECK" -gt 0 ]; then
563 if which valgrind >/dev/null 2>&1; then :; else
564 echo "Memcheck not possible. Valgrind not found"
565 exit 1
566 fi
567fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100568if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
569 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100570 exit 1
571fi
572
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200573# used by watchdog
574MAIN_PID="$$"
575
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200576# be more patient with valgrind
577if [ "$MEMCHECK" -gt 0 ]; then
578 START_DELAY=3
579 DOG_DELAY=30
580else
581 START_DELAY=1
582 DOG_DELAY=10
583fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200584CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100585SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200586
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200587# Pick a "unique" server port in the range 10000-19999, and a proxy port
588PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000589PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200590SRV_PORT="1$PORT_BASE"
591PXY_PORT="2$PORT_BASE"
592unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200593
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200594# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000595# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200596P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
597P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
598P_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 +0200599O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200600O_CLI="$O_CLI -connect localhost:+SRV_PORT"
601G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000602G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200603
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200604# Also pick a unique name for intermediate files
605SRV_OUT="srv_out.$$"
606CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200607PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200608SESSION="session.$$"
609
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200610SKIP_NEXT="NO"
611
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100612trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100613
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200614# Basic test
615
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200616# Checks that:
617# - things work with all ciphersuites active (used with config-full in all.sh)
618# - the expected (highest security) parameters are selected
619# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200620run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200621 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200622 "$P_CLI" \
623 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200624 -s "Protocol is TLSv1.2" \
625 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
626 -s "client hello v3, signature_algorithm ext: 6" \
627 -s "ECDHE curve: secp521r1" \
628 -S "error" \
629 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200630
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000631run_test "Default, DTLS" \
632 "$P_SRV dtls=1" \
633 "$P_CLI dtls=1" \
634 0 \
635 -s "Protocol is DTLSv1.2" \
636 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
637
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100638# Tests for rc4 option
639
Simon Butchera410af52016-05-19 22:12:18 +0100640requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100641run_test "RC4: server disabled, client enabled" \
642 "$P_SRV" \
643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
644 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100645 -s "SSL - The server has no ciphersuites in common"
646
Simon Butchera410af52016-05-19 22:12:18 +0100647requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100648run_test "RC4: server half, client enabled" \
649 "$P_SRV arc4=1" \
650 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
651 1 \
652 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100653
654run_test "RC4: server enabled, client disabled" \
655 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
656 "$P_CLI" \
657 1 \
658 -s "SSL - The server has no ciphersuites in common"
659
660run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100661 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100662 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
663 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100664 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100665 -S "SSL - The server has no ciphersuites in common"
666
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100667# Tests for Truncated HMAC extension
668
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100669run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200670 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100671 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100672 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100673 -s "dumping 'computed mac' (20 bytes)" \
674 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100675
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100676run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200677 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100678 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
679 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100680 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100681 -s "dumping 'computed mac' (20 bytes)" \
682 -S "dumping 'computed mac' (10 bytes)"
683
684run_test "Truncated HMAC: client enabled, server default" \
685 "$P_SRV debug_level=4" \
686 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
687 trunc_hmac=1" \
688 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100689 -s "dumping 'computed mac' (20 bytes)" \
690 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100691
692run_test "Truncated HMAC: client enabled, server disabled" \
693 "$P_SRV debug_level=4 trunc_hmac=0" \
694 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
695 trunc_hmac=1" \
696 0 \
697 -s "dumping 'computed mac' (20 bytes)" \
698 -S "dumping 'computed mac' (10 bytes)"
699
700run_test "Truncated HMAC: client enabled, server enabled" \
701 "$P_SRV debug_level=4 trunc_hmac=1" \
702 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
703 trunc_hmac=1" \
704 0 \
705 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100706 -s "dumping 'computed mac' (10 bytes)"
707
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100708# Tests for Encrypt-then-MAC extension
709
710run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100711 "$P_SRV debug_level=3 \
712 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100713 "$P_CLI debug_level=3" \
714 0 \
715 -c "client hello, adding encrypt_then_mac extension" \
716 -s "found encrypt then mac extension" \
717 -s "server hello, adding encrypt then mac extension" \
718 -c "found encrypt_then_mac extension" \
719 -c "using encrypt then mac" \
720 -s "using encrypt then mac"
721
722run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100723 "$P_SRV debug_level=3 etm=0 \
724 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100725 "$P_CLI debug_level=3 etm=1" \
726 0 \
727 -c "client hello, adding encrypt_then_mac extension" \
728 -s "found encrypt then mac extension" \
729 -S "server hello, adding encrypt then mac extension" \
730 -C "found encrypt_then_mac extension" \
731 -C "using encrypt then mac" \
732 -S "using encrypt then mac"
733
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100734run_test "Encrypt then MAC: client enabled, aead cipher" \
735 "$P_SRV debug_level=3 etm=1 \
736 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
737 "$P_CLI debug_level=3 etm=1" \
738 0 \
739 -c "client hello, adding encrypt_then_mac extension" \
740 -s "found encrypt then mac extension" \
741 -S "server hello, adding encrypt then mac extension" \
742 -C "found encrypt_then_mac extension" \
743 -C "using encrypt then mac" \
744 -S "using encrypt then mac"
745
746run_test "Encrypt then MAC: client enabled, stream cipher" \
747 "$P_SRV debug_level=3 etm=1 \
748 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100749 "$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 +0100750 0 \
751 -c "client hello, adding encrypt_then_mac extension" \
752 -s "found encrypt then mac extension" \
753 -S "server hello, adding encrypt then mac extension" \
754 -C "found encrypt_then_mac extension" \
755 -C "using encrypt then mac" \
756 -S "using encrypt then mac"
757
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100758run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100759 "$P_SRV debug_level=3 etm=1 \
760 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100761 "$P_CLI debug_level=3 etm=0" \
762 0 \
763 -C "client hello, adding encrypt_then_mac extension" \
764 -S "found encrypt then mac extension" \
765 -S "server hello, adding encrypt then mac extension" \
766 -C "found encrypt_then_mac extension" \
767 -C "using encrypt then mac" \
768 -S "using encrypt then mac"
769
Janos Follathe2681a42016-03-07 15:57:05 +0000770requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100771run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100772 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100773 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100774 "$P_CLI debug_level=3 force_version=ssl3" \
775 0 \
776 -C "client hello, adding encrypt_then_mac extension" \
777 -S "found encrypt then mac extension" \
778 -S "server hello, adding encrypt then mac extension" \
779 -C "found encrypt_then_mac extension" \
780 -C "using encrypt then mac" \
781 -S "using encrypt then mac"
782
Janos Follathe2681a42016-03-07 15:57:05 +0000783requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100784run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100785 "$P_SRV debug_level=3 force_version=ssl3 \
786 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100787 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100788 0 \
789 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100790 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100791 -S "server hello, adding encrypt then mac extension" \
792 -C "found encrypt_then_mac extension" \
793 -C "using encrypt then mac" \
794 -S "using encrypt then mac"
795
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200796# Tests for Extended Master Secret extension
797
798run_test "Extended Master Secret: default" \
799 "$P_SRV debug_level=3" \
800 "$P_CLI debug_level=3" \
801 0 \
802 -c "client hello, adding extended_master_secret extension" \
803 -s "found extended master secret extension" \
804 -s "server hello, adding extended master secret extension" \
805 -c "found extended_master_secret extension" \
806 -c "using extended master secret" \
807 -s "using extended master secret"
808
809run_test "Extended Master Secret: client enabled, server disabled" \
810 "$P_SRV debug_level=3 extended_ms=0" \
811 "$P_CLI debug_level=3 extended_ms=1" \
812 0 \
813 -c "client hello, adding extended_master_secret extension" \
814 -s "found extended master secret extension" \
815 -S "server hello, adding extended master secret extension" \
816 -C "found extended_master_secret extension" \
817 -C "using extended master secret" \
818 -S "using extended master secret"
819
820run_test "Extended Master Secret: client disabled, server enabled" \
821 "$P_SRV debug_level=3 extended_ms=1" \
822 "$P_CLI debug_level=3 extended_ms=0" \
823 0 \
824 -C "client hello, adding extended_master_secret extension" \
825 -S "found extended master secret extension" \
826 -S "server hello, adding extended master secret extension" \
827 -C "found extended_master_secret extension" \
828 -C "using extended master secret" \
829 -S "using extended master secret"
830
Janos Follathe2681a42016-03-07 15:57:05 +0000831requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200832run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100833 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200834 "$P_CLI debug_level=3 force_version=ssl3" \
835 0 \
836 -C "client hello, adding extended_master_secret extension" \
837 -S "found extended master secret extension" \
838 -S "server hello, adding extended master secret extension" \
839 -C "found extended_master_secret extension" \
840 -C "using extended master secret" \
841 -S "using extended master secret"
842
Janos Follathe2681a42016-03-07 15:57:05 +0000843requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200844run_test "Extended Master Secret: client enabled, server SSLv3" \
845 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100846 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200847 0 \
848 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100849 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200850 -S "server hello, adding extended master secret extension" \
851 -C "found extended_master_secret extension" \
852 -C "using extended master secret" \
853 -S "using extended master secret"
854
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200855# Tests for FALLBACK_SCSV
856
857run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200858 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200859 "$P_CLI debug_level=3 force_version=tls1_1" \
860 0 \
861 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200862 -S "received FALLBACK_SCSV" \
863 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200864 -C "is a fatal alert message (msg 86)"
865
866run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200867 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200868 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
869 0 \
870 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200871 -S "received FALLBACK_SCSV" \
872 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200873 -C "is a fatal alert message (msg 86)"
874
875run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200876 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200877 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200878 1 \
879 -c "adding FALLBACK_SCSV" \
880 -s "received FALLBACK_SCSV" \
881 -s "inapropriate fallback" \
882 -c "is a fatal alert message (msg 86)"
883
884run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200885 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200886 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200887 0 \
888 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200889 -s "received FALLBACK_SCSV" \
890 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200891 -C "is a fatal alert message (msg 86)"
892
893requires_openssl_with_fallback_scsv
894run_test "Fallback SCSV: default, openssl server" \
895 "$O_SRV" \
896 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
897 0 \
898 -C "adding FALLBACK_SCSV" \
899 -C "is a fatal alert message (msg 86)"
900
901requires_openssl_with_fallback_scsv
902run_test "Fallback SCSV: enabled, openssl server" \
903 "$O_SRV" \
904 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
905 1 \
906 -c "adding FALLBACK_SCSV" \
907 -c "is a fatal alert message (msg 86)"
908
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200909requires_openssl_with_fallback_scsv
910run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200911 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200912 "$O_CLI -tls1_1" \
913 0 \
914 -S "received FALLBACK_SCSV" \
915 -S "inapropriate fallback"
916
917requires_openssl_with_fallback_scsv
918run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200919 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200920 "$O_CLI -tls1_1 -fallback_scsv" \
921 1 \
922 -s "received FALLBACK_SCSV" \
923 -s "inapropriate fallback"
924
925requires_openssl_with_fallback_scsv
926run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200927 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200928 "$O_CLI -fallback_scsv" \
929 0 \
930 -s "received FALLBACK_SCSV" \
931 -S "inapropriate fallback"
932
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100933# Tests for CBC 1/n-1 record splitting
934
935run_test "CBC Record splitting: TLS 1.2, no splitting" \
936 "$P_SRV" \
937 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
938 request_size=123 force_version=tls1_2" \
939 0 \
940 -s "Read from client: 123 bytes read" \
941 -S "Read from client: 1 bytes read" \
942 -S "122 bytes read"
943
944run_test "CBC Record splitting: TLS 1.1, no splitting" \
945 "$P_SRV" \
946 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
947 request_size=123 force_version=tls1_1" \
948 0 \
949 -s "Read from client: 123 bytes read" \
950 -S "Read from client: 1 bytes read" \
951 -S "122 bytes read"
952
953run_test "CBC Record splitting: TLS 1.0, splitting" \
954 "$P_SRV" \
955 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
956 request_size=123 force_version=tls1" \
957 0 \
958 -S "Read from client: 123 bytes read" \
959 -s "Read from client: 1 bytes read" \
960 -s "122 bytes read"
961
Janos Follathe2681a42016-03-07 15:57:05 +0000962requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100963run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100964 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100965 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
966 request_size=123 force_version=ssl3" \
967 0 \
968 -S "Read from client: 123 bytes read" \
969 -s "Read from client: 1 bytes read" \
970 -s "122 bytes read"
971
972run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100973 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100974 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
975 request_size=123 force_version=tls1" \
976 0 \
977 -s "Read from client: 123 bytes read" \
978 -S "Read from client: 1 bytes read" \
979 -S "122 bytes read"
980
981run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
982 "$P_SRV" \
983 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
984 request_size=123 force_version=tls1 recsplit=0" \
985 0 \
986 -s "Read from client: 123 bytes read" \
987 -S "Read from client: 1 bytes read" \
988 -S "122 bytes read"
989
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100990run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
991 "$P_SRV nbio=2" \
992 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
993 request_size=123 force_version=tls1" \
994 0 \
995 -S "Read from client: 123 bytes read" \
996 -s "Read from client: 1 bytes read" \
997 -s "122 bytes read"
998
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100999# Tests for Session Tickets
1000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001001run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001002 "$P_SRV debug_level=3 tickets=1" \
1003 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001004 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001005 -c "client hello, adding session ticket extension" \
1006 -s "found session ticket extension" \
1007 -s "server hello, adding session ticket extension" \
1008 -c "found session_ticket extension" \
1009 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001010 -S "session successfully restored from cache" \
1011 -s "session successfully restored from ticket" \
1012 -s "a session has been resumed" \
1013 -c "a session has been resumed"
1014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001015run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001016 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1017 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001018 0 \
1019 -c "client hello, adding session ticket extension" \
1020 -s "found session ticket extension" \
1021 -s "server hello, adding session ticket extension" \
1022 -c "found session_ticket extension" \
1023 -c "parse new session ticket" \
1024 -S "session successfully restored from cache" \
1025 -s "session successfully restored from ticket" \
1026 -s "a session has been resumed" \
1027 -c "a session has been resumed"
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1031 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001032 0 \
1033 -c "client hello, adding session ticket extension" \
1034 -s "found session ticket extension" \
1035 -s "server hello, adding session ticket extension" \
1036 -c "found session_ticket extension" \
1037 -c "parse new session ticket" \
1038 -S "session successfully restored from cache" \
1039 -S "session successfully restored from ticket" \
1040 -S "a session has been resumed" \
1041 -C "a session has been resumed"
1042
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001043run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001044 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001045 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001046 0 \
1047 -c "client hello, adding session ticket extension" \
1048 -c "found session_ticket extension" \
1049 -c "parse new session ticket" \
1050 -c "a session has been resumed"
1051
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001052run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001053 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001054 "( $O_CLI -sess_out $SESSION; \
1055 $O_CLI -sess_in $SESSION; \
1056 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001057 0 \
1058 -s "found session ticket extension" \
1059 -s "server hello, adding session ticket extension" \
1060 -S "session successfully restored from cache" \
1061 -s "session successfully restored from ticket" \
1062 -s "a session has been resumed"
1063
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001064# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001066run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001067 "$P_SRV debug_level=3 tickets=0" \
1068 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001069 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001070 -c "client hello, adding session ticket extension" \
1071 -s "found session ticket extension" \
1072 -S "server hello, adding session ticket extension" \
1073 -C "found session_ticket extension" \
1074 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001075 -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: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001081 "$P_SRV debug_level=3 tickets=1" \
1082 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001083 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001084 -C "client hello, adding session ticket extension" \
1085 -S "found session ticket extension" \
1086 -S "server hello, adding session ticket extension" \
1087 -C "found session_ticket extension" \
1088 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001089 -s "session successfully restored from cache" \
1090 -S "session successfully restored from ticket" \
1091 -s "a session has been resumed" \
1092 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001094run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001095 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1096 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001097 0 \
1098 -S "session successfully restored from cache" \
1099 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001100 -S "a session has been resumed" \
1101 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001103run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001104 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1105 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001106 0 \
1107 -s "session successfully restored from cache" \
1108 -S "session successfully restored from ticket" \
1109 -s "a session has been resumed" \
1110 -c "a session has been resumed"
1111
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001112run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001113 "$P_SRV debug_level=3 tickets=0" \
1114 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001115 0 \
1116 -s "session successfully restored from cache" \
1117 -S "session successfully restored from ticket" \
1118 -s "a session has been resumed" \
1119 -c "a session has been resumed"
1120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001121run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001122 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1123 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001124 0 \
1125 -S "session successfully restored from cache" \
1126 -S "session successfully restored from ticket" \
1127 -S "a session has been resumed" \
1128 -C "a session has been resumed"
1129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001131 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1132 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001133 0 \
1134 -s "session successfully restored from cache" \
1135 -S "session successfully restored from ticket" \
1136 -s "a session has been resumed" \
1137 -c "a session has been resumed"
1138
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001139run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001140 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001141 "( $O_CLI -sess_out $SESSION; \
1142 $O_CLI -sess_in $SESSION; \
1143 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001144 0 \
1145 -s "found session ticket extension" \
1146 -S "server hello, adding session ticket extension" \
1147 -s "session successfully restored from cache" \
1148 -S "session successfully restored from ticket" \
1149 -s "a session has been resumed"
1150
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001151run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001152 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001153 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001154 0 \
1155 -C "found session_ticket extension" \
1156 -C "parse new session ticket" \
1157 -c "a session has been resumed"
1158
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001159# Tests for Max Fragment Length extension
1160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001161run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001162 "$P_SRV debug_level=3" \
1163 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001164 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001165 -c "Maximum fragment length is 16384" \
1166 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001167 -C "client hello, adding max_fragment_length extension" \
1168 -S "found max fragment length extension" \
1169 -S "server hello, max_fragment_length extension" \
1170 -C "found max_fragment_length extension"
1171
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001172run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=3" \
1174 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001175 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001176 -c "Maximum fragment length is 4096" \
1177 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001178 -c "client hello, adding max_fragment_length extension" \
1179 -s "found max fragment length extension" \
1180 -s "server hello, max_fragment_length extension" \
1181 -c "found max_fragment_length extension"
1182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001183run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001184 "$P_SRV debug_level=3 max_frag_len=4096" \
1185 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001186 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001187 -c "Maximum fragment length is 16384" \
1188 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001189 -C "client hello, adding max_fragment_length extension" \
1190 -S "found max fragment length extension" \
1191 -S "server hello, max_fragment_length extension" \
1192 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001194requires_gnutls
1195run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001196 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001197 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001198 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001199 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001200 -c "client hello, adding max_fragment_length extension" \
1201 -c "found max_fragment_length extension"
1202
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001203run_test "Max fragment length: client, message just fits" \
1204 "$P_SRV debug_level=3" \
1205 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1206 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001207 -c "Maximum fragment length is 2048" \
1208 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001209 -c "client hello, adding max_fragment_length extension" \
1210 -s "found max fragment length extension" \
1211 -s "server hello, max_fragment_length extension" \
1212 -c "found max_fragment_length extension" \
1213 -c "2048 bytes written in 1 fragments" \
1214 -s "2048 bytes read"
1215
1216run_test "Max fragment length: client, larger message" \
1217 "$P_SRV debug_level=3" \
1218 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1219 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001220 -c "Maximum fragment length is 2048" \
1221 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001222 -c "client hello, adding max_fragment_length extension" \
1223 -s "found max fragment length extension" \
1224 -s "server hello, max_fragment_length extension" \
1225 -c "found max_fragment_length extension" \
1226 -c "2345 bytes written in 2 fragments" \
1227 -s "2048 bytes read" \
1228 -s "297 bytes read"
1229
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001230run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001231 "$P_SRV debug_level=3 dtls=1" \
1232 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1233 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001234 -c "Maximum fragment length is 2048" \
1235 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001236 -c "client hello, adding max_fragment_length extension" \
1237 -s "found max fragment length extension" \
1238 -s "server hello, max_fragment_length extension" \
1239 -c "found max_fragment_length extension" \
1240 -c "fragment larger than.*maximum"
1241
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001242# Tests for renegotiation
1243
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001244run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001245 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001247 0 \
1248 -C "client hello, adding renegotiation extension" \
1249 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1250 -S "found renegotiation extension" \
1251 -s "server hello, secure renegotiation extension" \
1252 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001253 -C "=> renegotiate" \
1254 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001255 -S "write hello request"
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001258 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001259 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001260 0 \
1261 -c "client hello, adding renegotiation extension" \
1262 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1263 -s "found renegotiation extension" \
1264 -s "server hello, secure renegotiation extension" \
1265 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001266 -c "=> renegotiate" \
1267 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001268 -S "write hello request"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001271 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001272 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001273 0 \
1274 -c "client hello, adding renegotiation extension" \
1275 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1276 -s "found renegotiation extension" \
1277 -s "server hello, secure renegotiation extension" \
1278 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001279 -c "=> renegotiate" \
1280 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001281 -s "write hello request"
1282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001283run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001284 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001286 0 \
1287 -c "client hello, adding renegotiation extension" \
1288 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1289 -s "found renegotiation extension" \
1290 -s "server hello, secure renegotiation extension" \
1291 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001292 -c "=> renegotiate" \
1293 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001294 -s "write hello request"
1295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001297 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001298 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001299 1 \
1300 -c "client hello, adding renegotiation extension" \
1301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1302 -S "found renegotiation extension" \
1303 -s "server hello, secure renegotiation extension" \
1304 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001305 -c "=> renegotiate" \
1306 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001307 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001308 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001309 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001312 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001313 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001314 0 \
1315 -C "client hello, adding renegotiation extension" \
1316 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1317 -S "found renegotiation extension" \
1318 -s "server hello, secure renegotiation extension" \
1319 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001320 -C "=> renegotiate" \
1321 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001322 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001323 -S "SSL - An unexpected message was received from our peer" \
1324 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001325
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001326run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001327 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001328 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001329 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001330 0 \
1331 -C "client hello, adding renegotiation extension" \
1332 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1333 -S "found renegotiation extension" \
1334 -s "server hello, secure renegotiation extension" \
1335 -c "found renegotiation extension" \
1336 -C "=> renegotiate" \
1337 -S "=> renegotiate" \
1338 -s "write hello request" \
1339 -S "SSL - An unexpected message was received from our peer" \
1340 -S "failed"
1341
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001342# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001343run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001344 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001345 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001346 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001347 0 \
1348 -C "client hello, adding renegotiation extension" \
1349 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1350 -S "found renegotiation extension" \
1351 -s "server hello, secure renegotiation extension" \
1352 -c "found renegotiation extension" \
1353 -C "=> renegotiate" \
1354 -S "=> renegotiate" \
1355 -s "write hello request" \
1356 -S "SSL - An unexpected message was received from our peer" \
1357 -S "failed"
1358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001359run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001360 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001361 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001362 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001363 0 \
1364 -C "client hello, adding renegotiation extension" \
1365 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1366 -S "found renegotiation extension" \
1367 -s "server hello, secure renegotiation extension" \
1368 -c "found renegotiation extension" \
1369 -C "=> renegotiate" \
1370 -S "=> renegotiate" \
1371 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001372 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001373
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001374run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001375 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001376 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001377 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001378 0 \
1379 -c "client hello, adding renegotiation extension" \
1380 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1381 -s "found renegotiation extension" \
1382 -s "server hello, secure renegotiation extension" \
1383 -c "found renegotiation extension" \
1384 -c "=> renegotiate" \
1385 -s "=> renegotiate" \
1386 -s "write hello request" \
1387 -S "SSL - An unexpected message was received from our peer" \
1388 -S "failed"
1389
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001390run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001391 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001392 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1393 0 \
1394 -C "client hello, adding renegotiation extension" \
1395 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1396 -S "found renegotiation extension" \
1397 -s "server hello, secure renegotiation extension" \
1398 -c "found renegotiation extension" \
1399 -S "record counter limit reached: renegotiate" \
1400 -C "=> renegotiate" \
1401 -S "=> renegotiate" \
1402 -S "write hello request" \
1403 -S "SSL - An unexpected message was received from our peer" \
1404 -S "failed"
1405
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001406# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001407run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001408 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001409 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001410 0 \
1411 -c "client hello, adding renegotiation extension" \
1412 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1413 -s "found renegotiation extension" \
1414 -s "server hello, secure renegotiation extension" \
1415 -c "found renegotiation extension" \
1416 -s "record counter limit reached: renegotiate" \
1417 -c "=> renegotiate" \
1418 -s "=> renegotiate" \
1419 -s "write hello request" \
1420 -S "SSL - An unexpected message was received from our peer" \
1421 -S "failed"
1422
1423run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001424 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001425 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001426 0 \
1427 -c "client hello, adding renegotiation extension" \
1428 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1429 -s "found renegotiation extension" \
1430 -s "server hello, secure renegotiation extension" \
1431 -c "found renegotiation extension" \
1432 -s "record counter limit reached: renegotiate" \
1433 -c "=> renegotiate" \
1434 -s "=> renegotiate" \
1435 -s "write hello request" \
1436 -S "SSL - An unexpected message was received from our peer" \
1437 -S "failed"
1438
1439run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001440 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001441 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1442 0 \
1443 -C "client hello, adding renegotiation extension" \
1444 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1445 -S "found renegotiation extension" \
1446 -s "server hello, secure renegotiation extension" \
1447 -c "found renegotiation extension" \
1448 -S "record counter limit reached: renegotiate" \
1449 -C "=> renegotiate" \
1450 -S "=> renegotiate" \
1451 -S "write hello request" \
1452 -S "SSL - An unexpected message was received from our peer" \
1453 -S "failed"
1454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001455run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001456 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001457 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001458 0 \
1459 -c "client hello, adding renegotiation extension" \
1460 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1461 -s "found renegotiation extension" \
1462 -s "server hello, secure renegotiation extension" \
1463 -c "found renegotiation extension" \
1464 -c "=> renegotiate" \
1465 -s "=> renegotiate" \
1466 -S "write hello request"
1467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001468run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001469 "$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 +02001470 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001471 0 \
1472 -c "client hello, adding renegotiation extension" \
1473 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1474 -s "found renegotiation extension" \
1475 -s "server hello, secure renegotiation extension" \
1476 -c "found renegotiation extension" \
1477 -c "=> renegotiate" \
1478 -s "=> renegotiate" \
1479 -s "write hello request"
1480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001481run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001482 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001483 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001484 0 \
1485 -c "client hello, adding renegotiation extension" \
1486 -c "found renegotiation extension" \
1487 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001488 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001489 -C "error" \
1490 -c "HTTP/1.0 200 [Oo][Kk]"
1491
Paul Bakker539d9722015-02-08 16:18:35 +01001492requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001493run_test "Renegotiation: gnutls server strict, client-initiated" \
1494 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001495 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001496 0 \
1497 -c "client hello, adding renegotiation extension" \
1498 -c "found renegotiation extension" \
1499 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001500 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001501 -C "error" \
1502 -c "HTTP/1.0 200 [Oo][Kk]"
1503
Paul Bakker539d9722015-02-08 16:18:35 +01001504requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001505run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1506 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1507 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1508 1 \
1509 -c "client hello, adding renegotiation extension" \
1510 -C "found renegotiation extension" \
1511 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001512 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001513 -c "error" \
1514 -C "HTTP/1.0 200 [Oo][Kk]"
1515
Paul Bakker539d9722015-02-08 16:18:35 +01001516requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001517run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1518 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1519 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1520 allow_legacy=0" \
1521 1 \
1522 -c "client hello, adding renegotiation extension" \
1523 -C "found renegotiation extension" \
1524 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001525 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001526 -c "error" \
1527 -C "HTTP/1.0 200 [Oo][Kk]"
1528
Paul Bakker539d9722015-02-08 16:18:35 +01001529requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001530run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1531 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1532 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1533 allow_legacy=1" \
1534 0 \
1535 -c "client hello, adding renegotiation extension" \
1536 -C "found renegotiation extension" \
1537 -c "=> renegotiate" \
1538 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001539 -C "error" \
1540 -c "HTTP/1.0 200 [Oo][Kk]"
1541
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001542run_test "Renegotiation: DTLS, client-initiated" \
1543 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1544 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1545 0 \
1546 -c "client hello, adding renegotiation extension" \
1547 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1548 -s "found renegotiation extension" \
1549 -s "server hello, secure renegotiation extension" \
1550 -c "found renegotiation extension" \
1551 -c "=> renegotiate" \
1552 -s "=> renegotiate" \
1553 -S "write hello request"
1554
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001555run_test "Renegotiation: DTLS, server-initiated" \
1556 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001557 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1558 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001559 0 \
1560 -c "client hello, adding renegotiation extension" \
1561 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1562 -s "found renegotiation extension" \
1563 -s "server hello, secure renegotiation extension" \
1564 -c "found renegotiation extension" \
1565 -c "=> renegotiate" \
1566 -s "=> renegotiate" \
1567 -s "write hello request"
1568
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001569requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001570run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1571 "$G_SRV -u --mtu 4096" \
1572 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1573 0 \
1574 -c "client hello, adding renegotiation extension" \
1575 -c "found renegotiation extension" \
1576 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001577 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001578 -C "error" \
1579 -s "Extra-header:"
1580
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001581# Test for the "secure renegotation" extension only (no actual renegotiation)
1582
Paul Bakker539d9722015-02-08 16:18:35 +01001583requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001584run_test "Renego ext: gnutls server strict, client default" \
1585 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1586 "$P_CLI debug_level=3" \
1587 0 \
1588 -c "found renegotiation extension" \
1589 -C "error" \
1590 -c "HTTP/1.0 200 [Oo][Kk]"
1591
Paul Bakker539d9722015-02-08 16:18:35 +01001592requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001593run_test "Renego ext: gnutls server unsafe, client default" \
1594 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1595 "$P_CLI debug_level=3" \
1596 0 \
1597 -C "found renegotiation extension" \
1598 -C "error" \
1599 -c "HTTP/1.0 200 [Oo][Kk]"
1600
Paul Bakker539d9722015-02-08 16:18:35 +01001601requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001602run_test "Renego ext: gnutls server unsafe, client break legacy" \
1603 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1604 "$P_CLI debug_level=3 allow_legacy=-1" \
1605 1 \
1606 -C "found renegotiation extension" \
1607 -c "error" \
1608 -C "HTTP/1.0 200 [Oo][Kk]"
1609
Paul Bakker539d9722015-02-08 16:18:35 +01001610requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001611run_test "Renego ext: gnutls client strict, server default" \
1612 "$P_SRV debug_level=3" \
1613 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1614 0 \
1615 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1616 -s "server hello, secure renegotiation extension"
1617
Paul Bakker539d9722015-02-08 16:18:35 +01001618requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001619run_test "Renego ext: gnutls client unsafe, server default" \
1620 "$P_SRV debug_level=3" \
1621 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1622 0 \
1623 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1624 -S "server hello, secure renegotiation extension"
1625
Paul Bakker539d9722015-02-08 16:18:35 +01001626requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001627run_test "Renego ext: gnutls client unsafe, server break legacy" \
1628 "$P_SRV debug_level=3 allow_legacy=-1" \
1629 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1630 1 \
1631 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1632 -S "server hello, secure renegotiation extension"
1633
Janos Follath0b242342016-02-17 10:11:21 +00001634# Tests for silently dropping trailing extra bytes in .der certificates
1635
1636requires_gnutls
1637run_test "DER format: no trailing bytes" \
1638 "$P_SRV crt_file=data_files/server5-der0.crt \
1639 key_file=data_files/server5.key" \
1640 "$G_CLI " \
1641 0 \
1642 -c "Handshake was completed" \
1643
1644requires_gnutls
1645run_test "DER format: with a trailing zero byte" \
1646 "$P_SRV crt_file=data_files/server5-der1a.crt \
1647 key_file=data_files/server5.key" \
1648 "$G_CLI " \
1649 0 \
1650 -c "Handshake was completed" \
1651
1652requires_gnutls
1653run_test "DER format: with a trailing random byte" \
1654 "$P_SRV crt_file=data_files/server5-der1b.crt \
1655 key_file=data_files/server5.key" \
1656 "$G_CLI " \
1657 0 \
1658 -c "Handshake was completed" \
1659
1660requires_gnutls
1661run_test "DER format: with 2 trailing random bytes" \
1662 "$P_SRV crt_file=data_files/server5-der2.crt \
1663 key_file=data_files/server5.key" \
1664 "$G_CLI " \
1665 0 \
1666 -c "Handshake was completed" \
1667
1668requires_gnutls
1669run_test "DER format: with 4 trailing random bytes" \
1670 "$P_SRV crt_file=data_files/server5-der4.crt \
1671 key_file=data_files/server5.key" \
1672 "$G_CLI " \
1673 0 \
1674 -c "Handshake was completed" \
1675
1676requires_gnutls
1677run_test "DER format: with 8 trailing random bytes" \
1678 "$P_SRV crt_file=data_files/server5-der8.crt \
1679 key_file=data_files/server5.key" \
1680 "$G_CLI " \
1681 0 \
1682 -c "Handshake was completed" \
1683
1684requires_gnutls
1685run_test "DER format: with 9 trailing random bytes" \
1686 "$P_SRV crt_file=data_files/server5-der9.crt \
1687 key_file=data_files/server5.key" \
1688 "$G_CLI " \
1689 0 \
1690 -c "Handshake was completed" \
1691
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001692# Tests for auth_mode
1693
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001694run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001695 "$P_SRV crt_file=data_files/server5-badsign.crt \
1696 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001697 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001698 1 \
1699 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001700 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001701 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001702 -c "X509 - Certificate verification failed"
1703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001704run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001705 "$P_SRV crt_file=data_files/server5-badsign.crt \
1706 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001707 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001708 0 \
1709 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001710 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001711 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001712 -C "X509 - Certificate verification failed"
1713
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001714run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001715 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001716 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001717 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001718 0 \
1719 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001720 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001721 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001722 -C "X509 - Certificate verification failed"
1723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001725 "$P_SRV debug_level=3 auth_mode=required" \
1726 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001727 key_file=data_files/server5.key" \
1728 1 \
1729 -S "skip write certificate request" \
1730 -C "skip parse certificate request" \
1731 -c "got a certificate request" \
1732 -C "skip write certificate" \
1733 -C "skip write certificate verify" \
1734 -S "skip parse certificate verify" \
1735 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001736 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001737 -s "! mbedtls_ssl_handshake returned" \
1738 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001739 -s "X509 - Certificate verification failed"
1740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001741run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001742 "$P_SRV debug_level=3 auth_mode=optional" \
1743 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001744 key_file=data_files/server5.key" \
1745 0 \
1746 -S "skip write certificate request" \
1747 -C "skip parse certificate request" \
1748 -c "got a certificate request" \
1749 -C "skip write certificate" \
1750 -C "skip write certificate verify" \
1751 -S "skip parse certificate verify" \
1752 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001753 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001754 -S "! mbedtls_ssl_handshake returned" \
1755 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001756 -S "X509 - Certificate verification failed"
1757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_SRV debug_level=3 auth_mode=none" \
1760 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001761 key_file=data_files/server5.key" \
1762 0 \
1763 -s "skip write certificate request" \
1764 -C "skip parse certificate request" \
1765 -c "got no certificate request" \
1766 -c "skip write certificate" \
1767 -c "skip write certificate verify" \
1768 -s "skip parse certificate verify" \
1769 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001770 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001771 -S "! mbedtls_ssl_handshake returned" \
1772 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001773 -S "X509 - Certificate verification failed"
1774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001776 "$P_SRV debug_level=3 auth_mode=optional" \
1777 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001778 0 \
1779 -S "skip write certificate request" \
1780 -C "skip parse certificate request" \
1781 -c "got a certificate request" \
1782 -C "skip write certificate$" \
1783 -C "got no certificate to send" \
1784 -S "SSLv3 client has no certificate" \
1785 -c "skip write certificate verify" \
1786 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001787 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001788 -S "! mbedtls_ssl_handshake returned" \
1789 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001790 -S "X509 - Certificate verification failed"
1791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001792run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001793 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001794 "$O_CLI" \
1795 0 \
1796 -S "skip write certificate request" \
1797 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001798 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001799 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001800 -S "X509 - Certificate verification failed"
1801
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001802run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001803 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001804 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001805 0 \
1806 -C "skip parse certificate request" \
1807 -c "got a certificate request" \
1808 -C "skip write certificate$" \
1809 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001810 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001811
Janos Follathe2681a42016-03-07 15:57:05 +00001812requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001813run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001814 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001815 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001816 0 \
1817 -S "skip write certificate request" \
1818 -C "skip parse certificate request" \
1819 -c "got a certificate request" \
1820 -C "skip write certificate$" \
1821 -c "skip write certificate verify" \
1822 -c "got no certificate to send" \
1823 -s "SSLv3 client has no certificate" \
1824 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001825 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001826 -S "! mbedtls_ssl_handshake returned" \
1827 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001828 -S "X509 - Certificate verification failed"
1829
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001830# Tests for certificate selection based on SHA verson
1831
1832run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1833 "$P_SRV crt_file=data_files/server5.crt \
1834 key_file=data_files/server5.key \
1835 crt_file2=data_files/server5-sha1.crt \
1836 key_file2=data_files/server5.key" \
1837 "$P_CLI force_version=tls1_2" \
1838 0 \
1839 -c "signed using.*ECDSA with SHA256" \
1840 -C "signed using.*ECDSA with SHA1"
1841
1842run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1843 "$P_SRV crt_file=data_files/server5.crt \
1844 key_file=data_files/server5.key \
1845 crt_file2=data_files/server5-sha1.crt \
1846 key_file2=data_files/server5.key" \
1847 "$P_CLI force_version=tls1_1" \
1848 0 \
1849 -C "signed using.*ECDSA with SHA256" \
1850 -c "signed using.*ECDSA with SHA1"
1851
1852run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1853 "$P_SRV crt_file=data_files/server5.crt \
1854 key_file=data_files/server5.key \
1855 crt_file2=data_files/server5-sha1.crt \
1856 key_file2=data_files/server5.key" \
1857 "$P_CLI force_version=tls1" \
1858 0 \
1859 -C "signed using.*ECDSA with SHA256" \
1860 -c "signed using.*ECDSA with SHA1"
1861
1862run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1863 "$P_SRV crt_file=data_files/server5.crt \
1864 key_file=data_files/server5.key \
1865 crt_file2=data_files/server6.crt \
1866 key_file2=data_files/server6.key" \
1867 "$P_CLI force_version=tls1_1" \
1868 0 \
1869 -c "serial number.*09" \
1870 -c "signed using.*ECDSA with SHA256" \
1871 -C "signed using.*ECDSA with SHA1"
1872
1873run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1874 "$P_SRV crt_file=data_files/server6.crt \
1875 key_file=data_files/server6.key \
1876 crt_file2=data_files/server5.crt \
1877 key_file2=data_files/server5.key" \
1878 "$P_CLI force_version=tls1_1" \
1879 0 \
1880 -c "serial number.*0A" \
1881 -c "signed using.*ECDSA with SHA256" \
1882 -C "signed using.*ECDSA with SHA1"
1883
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001884# tests for SNI
1885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001886run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001887 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001888 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001889 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001890 0 \
1891 -S "parse ServerName extension" \
1892 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1893 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001895run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001896 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001897 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001898 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 +02001899 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001900 0 \
1901 -s "parse ServerName extension" \
1902 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1903 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001905run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001906 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001907 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001908 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 +02001909 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001910 0 \
1911 -s "parse ServerName extension" \
1912 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1913 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001914
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001915run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001916 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001917 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001918 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 +02001919 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001920 1 \
1921 -s "parse ServerName extension" \
1922 -s "ssl_sni_wrapper() returned" \
1923 -s "mbedtls_ssl_handshake returned" \
1924 -c "mbedtls_ssl_handshake returned" \
1925 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001926
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001927run_test "SNI: client auth no override: optional" \
1928 "$P_SRV debug_level=3 auth_mode=optional \
1929 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1930 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1931 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001932 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001933 -S "skip write certificate request" \
1934 -C "skip parse certificate request" \
1935 -c "got a certificate request" \
1936 -C "skip write certificate" \
1937 -C "skip write certificate verify" \
1938 -S "skip parse certificate verify"
1939
1940run_test "SNI: client auth override: none -> optional" \
1941 "$P_SRV debug_level=3 auth_mode=none \
1942 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1943 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1944 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001945 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001946 -S "skip write certificate request" \
1947 -C "skip parse certificate request" \
1948 -c "got a certificate request" \
1949 -C "skip write certificate" \
1950 -C "skip write certificate verify" \
1951 -S "skip parse certificate verify"
1952
1953run_test "SNI: client auth override: optional -> none" \
1954 "$P_SRV debug_level=3 auth_mode=optional \
1955 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1956 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1957 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001958 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001959 -s "skip write certificate request" \
1960 -C "skip parse certificate request" \
1961 -c "got no certificate request" \
1962 -c "skip write certificate" \
1963 -c "skip write certificate verify" \
1964 -s "skip parse certificate verify"
1965
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001966run_test "SNI: CA no override" \
1967 "$P_SRV debug_level=3 auth_mode=optional \
1968 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1969 ca_file=data_files/test-ca.crt \
1970 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1971 "$P_CLI debug_level=3 server_name=localhost \
1972 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1973 1 \
1974 -S "skip write certificate request" \
1975 -C "skip parse certificate request" \
1976 -c "got a certificate request" \
1977 -C "skip write certificate" \
1978 -C "skip write certificate verify" \
1979 -S "skip parse certificate verify" \
1980 -s "x509_verify_cert() returned" \
1981 -s "! The certificate is not correctly signed by the trusted CA" \
1982 -S "The certificate has been revoked (is on a CRL)"
1983
1984run_test "SNI: CA override" \
1985 "$P_SRV debug_level=3 auth_mode=optional \
1986 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1987 ca_file=data_files/test-ca.crt \
1988 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1989 "$P_CLI debug_level=3 server_name=localhost \
1990 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1991 0 \
1992 -S "skip write certificate request" \
1993 -C "skip parse certificate request" \
1994 -c "got a certificate request" \
1995 -C "skip write certificate" \
1996 -C "skip write certificate verify" \
1997 -S "skip parse certificate verify" \
1998 -S "x509_verify_cert() returned" \
1999 -S "! The certificate is not correctly signed by the trusted CA" \
2000 -S "The certificate has been revoked (is on a CRL)"
2001
2002run_test "SNI: CA override with CRL" \
2003 "$P_SRV debug_level=3 auth_mode=optional \
2004 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2005 ca_file=data_files/test-ca.crt \
2006 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2007 "$P_CLI debug_level=3 server_name=localhost \
2008 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2009 1 \
2010 -S "skip write certificate request" \
2011 -C "skip parse certificate request" \
2012 -c "got a certificate request" \
2013 -C "skip write certificate" \
2014 -C "skip write certificate verify" \
2015 -S "skip parse certificate verify" \
2016 -s "x509_verify_cert() returned" \
2017 -S "! The certificate is not correctly signed by the trusted CA" \
2018 -s "The certificate has been revoked (is on a CRL)"
2019
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002020# Tests for non-blocking I/O: exercise a variety of handshake flows
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002023 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2024 "$P_CLI nbio=2 tickets=0" \
2025 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002026 -S "mbedtls_ssl_handshake returned" \
2027 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002028 -c "Read from server: .* bytes read"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002031 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2032 "$P_CLI nbio=2 tickets=0" \
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é-Gonnard0b6609b2014-02-26 14:45:12 +01002036 -c "Read from server: .* bytes read"
2037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002038run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002039 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2040 "$P_CLI nbio=2 tickets=1" \
2041 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002042 -S "mbedtls_ssl_handshake returned" \
2043 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002044 -c "Read from server: .* bytes read"
2045
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002046run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002047 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2048 "$P_CLI nbio=2 tickets=1" \
2049 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002050 -S "mbedtls_ssl_handshake returned" \
2051 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002052 -c "Read from server: .* bytes read"
2053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002054run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002055 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2056 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2057 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002058 -S "mbedtls_ssl_handshake returned" \
2059 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002060 -c "Read from server: .* bytes read"
2061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002063 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2064 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2065 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002066 -S "mbedtls_ssl_handshake returned" \
2067 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002068 -c "Read from server: .* bytes read"
2069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002070run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002071 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2072 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2073 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002074 -S "mbedtls_ssl_handshake returned" \
2075 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002076 -c "Read from server: .* bytes read"
2077
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002078# Tests for version negotiation
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002081 "$P_SRV" \
2082 "$P_CLI" \
2083 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002084 -S "mbedtls_ssl_handshake returned" \
2085 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002086 -s "Protocol is TLSv1.2" \
2087 -c "Protocol is TLSv1.2"
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002090 "$P_SRV" \
2091 "$P_CLI max_version=tls1_1" \
2092 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002093 -S "mbedtls_ssl_handshake returned" \
2094 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002095 -s "Protocol is TLSv1.1" \
2096 -c "Protocol is TLSv1.1"
2097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002098run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002099 "$P_SRV max_version=tls1_1" \
2100 "$P_CLI" \
2101 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002102 -S "mbedtls_ssl_handshake returned" \
2103 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002104 -s "Protocol is TLSv1.1" \
2105 -c "Protocol is TLSv1.1"
2106
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002108 "$P_SRV max_version=tls1_1" \
2109 "$P_CLI max_version=tls1_1" \
2110 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002111 -S "mbedtls_ssl_handshake returned" \
2112 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002113 -s "Protocol is TLSv1.1" \
2114 -c "Protocol is TLSv1.1"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002117 "$P_SRV min_version=tls1_1" \
2118 "$P_CLI max_version=tls1_1" \
2119 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002120 -S "mbedtls_ssl_handshake returned" \
2121 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002122 -s "Protocol is TLSv1.1" \
2123 -c "Protocol is TLSv1.1"
2124
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002126 "$P_SRV max_version=tls1_1" \
2127 "$P_CLI min_version=tls1_1" \
2128 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002129 -S "mbedtls_ssl_handshake returned" \
2130 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002131 -s "Protocol is TLSv1.1" \
2132 -c "Protocol is TLSv1.1"
2133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002134run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002135 "$P_SRV max_version=tls1_1" \
2136 "$P_CLI min_version=tls1_2" \
2137 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002138 -s "mbedtls_ssl_handshake returned" \
2139 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002140 -c "SSL - Handshake protocol not within min/max boundaries"
2141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002142run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002143 "$P_SRV min_version=tls1_2" \
2144 "$P_CLI max_version=tls1_1" \
2145 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002146 -s "mbedtls_ssl_handshake returned" \
2147 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002148 -s "SSL - Handshake protocol not within min/max boundaries"
2149
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002150# Tests for ALPN extension
2151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002152run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002153 "$P_SRV debug_level=3" \
2154 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002155 0 \
2156 -C "client hello, adding alpn extension" \
2157 -S "found alpn extension" \
2158 -C "got an alert message, type: \\[2:120]" \
2159 -S "server hello, adding alpn extension" \
2160 -C "found alpn extension " \
2161 -C "Application Layer Protocol is" \
2162 -S "Application Layer Protocol is"
2163
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002165 "$P_SRV debug_level=3" \
2166 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002167 0 \
2168 -c "client hello, adding alpn extension" \
2169 -s "found alpn extension" \
2170 -C "got an alert message, type: \\[2:120]" \
2171 -S "server hello, adding alpn extension" \
2172 -C "found alpn extension " \
2173 -c "Application Layer Protocol is (none)" \
2174 -S "Application Layer Protocol is"
2175
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002176run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002177 "$P_SRV debug_level=3 alpn=abc,1234" \
2178 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002179 0 \
2180 -C "client hello, adding alpn extension" \
2181 -S "found alpn extension" \
2182 -C "got an alert message, type: \\[2:120]" \
2183 -S "server hello, adding alpn extension" \
2184 -C "found alpn extension " \
2185 -C "Application Layer Protocol is" \
2186 -s "Application Layer Protocol is (none)"
2187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_SRV debug_level=3 alpn=abc,1234" \
2190 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002191 0 \
2192 -c "client hello, adding alpn extension" \
2193 -s "found alpn extension" \
2194 -C "got an alert message, type: \\[2:120]" \
2195 -s "server hello, adding alpn extension" \
2196 -c "found alpn extension" \
2197 -c "Application Layer Protocol is abc" \
2198 -s "Application Layer Protocol is abc"
2199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002200run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002201 "$P_SRV debug_level=3 alpn=abc,1234" \
2202 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002203 0 \
2204 -c "client hello, adding alpn extension" \
2205 -s "found alpn extension" \
2206 -C "got an alert message, type: \\[2:120]" \
2207 -s "server hello, adding alpn extension" \
2208 -c "found alpn extension" \
2209 -c "Application Layer Protocol is abc" \
2210 -s "Application Layer Protocol is abc"
2211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002212run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002213 "$P_SRV debug_level=3 alpn=abc,1234" \
2214 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002215 0 \
2216 -c "client hello, adding alpn extension" \
2217 -s "found alpn extension" \
2218 -C "got an alert message, type: \\[2:120]" \
2219 -s "server hello, adding alpn extension" \
2220 -c "found alpn extension" \
2221 -c "Application Layer Protocol is 1234" \
2222 -s "Application Layer Protocol is 1234"
2223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002224run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002225 "$P_SRV debug_level=3 alpn=abc,123" \
2226 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002227 1 \
2228 -c "client hello, adding alpn extension" \
2229 -s "found alpn extension" \
2230 -c "got an alert message, type: \\[2:120]" \
2231 -S "server hello, adding alpn extension" \
2232 -C "found alpn extension" \
2233 -C "Application Layer Protocol is 1234" \
2234 -S "Application Layer Protocol is 1234"
2235
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002236
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002237# Tests for keyUsage in leaf certificates, part 1:
2238# server-side certificate/suite selection
2239
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002240run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002241 "$P_SRV key_file=data_files/server2.key \
2242 crt_file=data_files/server2.ku-ds.crt" \
2243 "$P_CLI" \
2244 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002245 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002246
2247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002248run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002249 "$P_SRV key_file=data_files/server2.key \
2250 crt_file=data_files/server2.ku-ke.crt" \
2251 "$P_CLI" \
2252 0 \
2253 -c "Ciphersuite is TLS-RSA-WITH-"
2254
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002255run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002256 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002257 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002258 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002259 1 \
2260 -C "Ciphersuite is "
2261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002262run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002263 "$P_SRV key_file=data_files/server5.key \
2264 crt_file=data_files/server5.ku-ds.crt" \
2265 "$P_CLI" \
2266 0 \
2267 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2268
2269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002270run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002271 "$P_SRV key_file=data_files/server5.key \
2272 crt_file=data_files/server5.ku-ka.crt" \
2273 "$P_CLI" \
2274 0 \
2275 -c "Ciphersuite is TLS-ECDH-"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002278 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002279 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002280 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002281 1 \
2282 -C "Ciphersuite is "
2283
2284# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002285# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002286
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002287run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002288 "$O_SRV -key data_files/server2.key \
2289 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002290 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002291 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2292 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002293 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002294 -C "Processing of the Certificate handshake message failed" \
2295 -c "Ciphersuite is TLS-"
2296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002297run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002298 "$O_SRV -key data_files/server2.key \
2299 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002300 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002301 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2302 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002303 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002304 -C "Processing of the Certificate handshake message failed" \
2305 -c "Ciphersuite is TLS-"
2306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002308 "$O_SRV -key data_files/server2.key \
2309 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002310 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002311 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2312 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002313 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002314 -C "Processing of the Certificate handshake message failed" \
2315 -c "Ciphersuite is TLS-"
2316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002317run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002318 "$O_SRV -key data_files/server2.key \
2319 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002320 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002321 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2322 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002323 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002324 -c "Processing of the Certificate handshake message failed" \
2325 -C "Ciphersuite is TLS-"
2326
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002327run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2328 "$O_SRV -key data_files/server2.key \
2329 -cert data_files/server2.ku-ke.crt" \
2330 "$P_CLI debug_level=1 auth_mode=optional \
2331 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2332 0 \
2333 -c "bad certificate (usage extensions)" \
2334 -C "Processing of the Certificate handshake message failed" \
2335 -c "Ciphersuite is TLS-" \
2336 -c "! Usage does not match the keyUsage extension"
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002339 "$O_SRV -key data_files/server2.key \
2340 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002341 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002342 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2343 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002344 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002345 -C "Processing of the Certificate handshake message failed" \
2346 -c "Ciphersuite is TLS-"
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002349 "$O_SRV -key data_files/server2.key \
2350 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002351 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002352 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2353 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002354 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002355 -c "Processing of the Certificate handshake message failed" \
2356 -C "Ciphersuite is TLS-"
2357
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002358run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2359 "$O_SRV -key data_files/server2.key \
2360 -cert data_files/server2.ku-ds.crt" \
2361 "$P_CLI debug_level=1 auth_mode=optional \
2362 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2363 0 \
2364 -c "bad certificate (usage extensions)" \
2365 -C "Processing of the Certificate handshake message failed" \
2366 -c "Ciphersuite is TLS-" \
2367 -c "! Usage does not match the keyUsage extension"
2368
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002369# Tests for keyUsage in leaf certificates, part 3:
2370# server-side checking of client cert
2371
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002372run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002373 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002374 "$O_CLI -key data_files/server2.key \
2375 -cert data_files/server2.ku-ds.crt" \
2376 0 \
2377 -S "bad certificate (usage extensions)" \
2378 -S "Processing of the Certificate handshake message failed"
2379
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002380run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002381 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002382 "$O_CLI -key data_files/server2.key \
2383 -cert data_files/server2.ku-ke.crt" \
2384 0 \
2385 -s "bad certificate (usage extensions)" \
2386 -S "Processing of the Certificate handshake message failed"
2387
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002388run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002389 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002390 "$O_CLI -key data_files/server2.key \
2391 -cert data_files/server2.ku-ke.crt" \
2392 1 \
2393 -s "bad certificate (usage extensions)" \
2394 -s "Processing of the Certificate handshake message failed"
2395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002396run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002397 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002398 "$O_CLI -key data_files/server5.key \
2399 -cert data_files/server5.ku-ds.crt" \
2400 0 \
2401 -S "bad certificate (usage extensions)" \
2402 -S "Processing of the Certificate handshake message failed"
2403
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002404run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002405 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002406 "$O_CLI -key data_files/server5.key \
2407 -cert data_files/server5.ku-ka.crt" \
2408 0 \
2409 -s "bad certificate (usage extensions)" \
2410 -S "Processing of the Certificate handshake message failed"
2411
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002412# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002414run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002415 "$P_SRV key_file=data_files/server5.key \
2416 crt_file=data_files/server5.eku-srv.crt" \
2417 "$P_CLI" \
2418 0
2419
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002421 "$P_SRV key_file=data_files/server5.key \
2422 crt_file=data_files/server5.eku-srv.crt" \
2423 "$P_CLI" \
2424 0
2425
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002426run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002427 "$P_SRV key_file=data_files/server5.key \
2428 crt_file=data_files/server5.eku-cs_any.crt" \
2429 "$P_CLI" \
2430 0
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002433 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002434 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002435 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002436 1
2437
2438# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002440run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002441 "$O_SRV -key data_files/server5.key \
2442 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002443 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002444 0 \
2445 -C "bad certificate (usage extensions)" \
2446 -C "Processing of the Certificate handshake message failed" \
2447 -c "Ciphersuite is TLS-"
2448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002449run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002450 "$O_SRV -key data_files/server5.key \
2451 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002452 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002453 0 \
2454 -C "bad certificate (usage extensions)" \
2455 -C "Processing of the Certificate handshake message failed" \
2456 -c "Ciphersuite is TLS-"
2457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002458run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002459 "$O_SRV -key data_files/server5.key \
2460 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002461 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002462 0 \
2463 -C "bad certificate (usage extensions)" \
2464 -C "Processing of the Certificate handshake message failed" \
2465 -c "Ciphersuite is TLS-"
2466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002467run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002468 "$O_SRV -key data_files/server5.key \
2469 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002470 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002471 1 \
2472 -c "bad certificate (usage extensions)" \
2473 -c "Processing of the Certificate handshake message failed" \
2474 -C "Ciphersuite is TLS-"
2475
2476# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002478run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002479 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002480 "$O_CLI -key data_files/server5.key \
2481 -cert data_files/server5.eku-cli.crt" \
2482 0 \
2483 -S "bad certificate (usage extensions)" \
2484 -S "Processing of the Certificate handshake message failed"
2485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002486run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002487 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002488 "$O_CLI -key data_files/server5.key \
2489 -cert data_files/server5.eku-srv_cli.crt" \
2490 0 \
2491 -S "bad certificate (usage extensions)" \
2492 -S "Processing of the Certificate handshake message failed"
2493
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002494run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002495 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002496 "$O_CLI -key data_files/server5.key \
2497 -cert data_files/server5.eku-cs_any.crt" \
2498 0 \
2499 -S "bad certificate (usage extensions)" \
2500 -S "Processing of the Certificate handshake message failed"
2501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002502run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002503 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002504 "$O_CLI -key data_files/server5.key \
2505 -cert data_files/server5.eku-cs.crt" \
2506 0 \
2507 -s "bad certificate (usage extensions)" \
2508 -S "Processing of the Certificate handshake message failed"
2509
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002510run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002511 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002512 "$O_CLI -key data_files/server5.key \
2513 -cert data_files/server5.eku-cs.crt" \
2514 1 \
2515 -s "bad certificate (usage extensions)" \
2516 -s "Processing of the Certificate handshake message failed"
2517
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002518# Tests for DHM parameters loading
2519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002520run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002521 "$P_SRV" \
2522 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2523 debug_level=3" \
2524 0 \
2525 -c "value of 'DHM: P ' (2048 bits)" \
2526 -c "value of 'DHM: G ' (2048 bits)"
2527
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002528run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002529 "$P_SRV dhm_file=data_files/dhparams.pem" \
2530 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2531 debug_level=3" \
2532 0 \
2533 -c "value of 'DHM: P ' (1024 bits)" \
2534 -c "value of 'DHM: G ' (2 bits)"
2535
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002536# Tests for DHM client-side size checking
2537
2538run_test "DHM size: server default, client default, OK" \
2539 "$P_SRV" \
2540 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2541 debug_level=1" \
2542 0 \
2543 -C "DHM prime too short:"
2544
2545run_test "DHM size: server default, client 2048, OK" \
2546 "$P_SRV" \
2547 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2548 debug_level=1 dhmlen=2048" \
2549 0 \
2550 -C "DHM prime too short:"
2551
2552run_test "DHM size: server 1024, client default, OK" \
2553 "$P_SRV dhm_file=data_files/dhparams.pem" \
2554 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2555 debug_level=1" \
2556 0 \
2557 -C "DHM prime too short:"
2558
2559run_test "DHM size: server 1000, client default, rejected" \
2560 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2561 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2562 debug_level=1" \
2563 1 \
2564 -c "DHM prime too short:"
2565
2566run_test "DHM size: server default, client 2049, rejected" \
2567 "$P_SRV" \
2568 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2569 debug_level=1 dhmlen=2049" \
2570 1 \
2571 -c "DHM prime too short:"
2572
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002573# Tests for PSK callback
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002576 "$P_SRV psk=abc123 psk_identity=foo" \
2577 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2578 psk_identity=foo psk=abc123" \
2579 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002580 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002581 -S "SSL - Unknown identity received" \
2582 -S "SSL - Verification of the message MAC failed"
2583
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002584run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002585 "$P_SRV" \
2586 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2587 psk_identity=foo psk=abc123" \
2588 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002589 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002590 -S "SSL - Unknown identity received" \
2591 -S "SSL - Verification of the message MAC failed"
2592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002593run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002594 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2595 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2596 psk_identity=foo psk=abc123" \
2597 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002598 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002599 -s "SSL - Unknown identity received" \
2600 -S "SSL - Verification of the message MAC failed"
2601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002602run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002603 "$P_SRV psk_list=abc,dead,def,beef" \
2604 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2605 psk_identity=abc psk=dead" \
2606 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002607 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002608 -S "SSL - Unknown identity received" \
2609 -S "SSL - Verification of the message MAC failed"
2610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002611run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002612 "$P_SRV psk_list=abc,dead,def,beef" \
2613 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2614 psk_identity=def psk=beef" \
2615 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002616 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002617 -S "SSL - Unknown identity received" \
2618 -S "SSL - Verification of the message MAC failed"
2619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002620run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002621 "$P_SRV psk_list=abc,dead,def,beef" \
2622 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2623 psk_identity=ghi psk=beef" \
2624 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002625 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002626 -s "SSL - Unknown identity received" \
2627 -S "SSL - Verification of the message MAC failed"
2628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002629run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002630 "$P_SRV psk_list=abc,dead,def,beef" \
2631 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2632 psk_identity=abc psk=beef" \
2633 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002634 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002635 -S "SSL - Unknown identity received" \
2636 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002637
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002638# Tests for EC J-PAKE
2639
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002640requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002641run_test "ECJPAKE: client not configured" \
2642 "$P_SRV debug_level=3" \
2643 "$P_CLI debug_level=3" \
2644 0 \
2645 -C "add ciphersuite: c0ff" \
2646 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002647 -S "found ecjpake kkpp extension" \
2648 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002649 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002650 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002651 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002652 -S "None of the common ciphersuites is usable"
2653
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002654requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002655run_test "ECJPAKE: server not configured" \
2656 "$P_SRV debug_level=3" \
2657 "$P_CLI debug_level=3 ecjpake_pw=bla \
2658 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2659 1 \
2660 -c "add ciphersuite: c0ff" \
2661 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002662 -s "found ecjpake kkpp extension" \
2663 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002664 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002665 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002666 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002667 -s "None of the common ciphersuites is usable"
2668
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002669requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002670run_test "ECJPAKE: working, TLS" \
2671 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2672 "$P_CLI debug_level=3 ecjpake_pw=bla \
2673 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002674 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002675 -c "add ciphersuite: c0ff" \
2676 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002677 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002678 -s "found ecjpake kkpp extension" \
2679 -S "skip ecjpake kkpp extension" \
2680 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002681 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002682 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002683 -S "None of the common ciphersuites is usable" \
2684 -S "SSL - Verification of the message MAC failed"
2685
Janos Follath74537a62016-09-02 13:45:28 +01002686server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002687requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002688run_test "ECJPAKE: password mismatch, TLS" \
2689 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2690 "$P_CLI debug_level=3 ecjpake_pw=bad \
2691 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2692 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002693 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002694 -s "SSL - Verification of the message MAC failed"
2695
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002696requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002697run_test "ECJPAKE: working, DTLS" \
2698 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2699 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2700 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2701 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002702 -c "re-using cached ecjpake parameters" \
2703 -S "SSL - Verification of the message MAC failed"
2704
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002705requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002706run_test "ECJPAKE: working, DTLS, no cookie" \
2707 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2708 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2709 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2710 0 \
2711 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002712 -S "SSL - Verification of the message MAC failed"
2713
Janos Follath74537a62016-09-02 13:45:28 +01002714server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002715requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002716run_test "ECJPAKE: password mismatch, DTLS" \
2717 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2718 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2719 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2720 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002721 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002722 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002723
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002724# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002725requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002726run_test "ECJPAKE: working, DTLS, nolog" \
2727 "$P_SRV dtls=1 ecjpake_pw=bla" \
2728 "$P_CLI dtls=1 ecjpake_pw=bla \
2729 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2730 0
2731
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002732# Tests for ciphersuites per version
2733
Janos Follathe2681a42016-03-07 15:57:05 +00002734requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002736 "$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 +02002737 "$P_CLI force_version=ssl3" \
2738 0 \
2739 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2740
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002741run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002742 "$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 +01002743 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002744 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002745 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002748 "$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 +02002749 "$P_CLI force_version=tls1_1" \
2750 0 \
2751 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002753run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002754 "$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 +02002755 "$P_CLI force_version=tls1_2" \
2756 0 \
2757 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2758
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002759# Test for ClientHello without extensions
2760
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002761requires_gnutls
2762run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002763 "$P_SRV debug_level=3" \
2764 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2765 0 \
2766 -s "dumping 'client hello extensions' (0 bytes)"
2767
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002768# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002769
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002770run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002771 "$P_SRV" \
2772 "$P_CLI request_size=100" \
2773 0 \
2774 -s "Read from client: 100 bytes read$"
2775
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002776run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002777 "$P_SRV" \
2778 "$P_CLI request_size=500" \
2779 0 \
2780 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002781
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002782# Tests for small packets
2783
Janos Follathe2681a42016-03-07 15:57:05 +00002784requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002785run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002786 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002787 "$P_CLI request_size=1 force_version=ssl3 \
2788 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2789 0 \
2790 -s "Read from client: 1 bytes read"
2791
Janos Follathe2681a42016-03-07 15:57:05 +00002792requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002793run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002794 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002795 "$P_CLI request_size=1 force_version=ssl3 \
2796 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2797 0 \
2798 -s "Read from client: 1 bytes read"
2799
2800run_test "Small packet TLS 1.0 BlockCipher" \
2801 "$P_SRV" \
2802 "$P_CLI request_size=1 force_version=tls1 \
2803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2804 0 \
2805 -s "Read from client: 1 bytes read"
2806
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002807run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2808 "$P_SRV" \
2809 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2811 0 \
2812 -s "Read from client: 1 bytes read"
2813
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002814run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2815 "$P_SRV" \
2816 "$P_CLI request_size=1 force_version=tls1 \
2817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2818 trunc_hmac=1" \
2819 0 \
2820 -s "Read from client: 1 bytes read"
2821
2822run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002823 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002824 "$P_CLI request_size=1 force_version=tls1 \
2825 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2826 trunc_hmac=1" \
2827 0 \
2828 -s "Read from client: 1 bytes read"
2829
2830run_test "Small packet TLS 1.1 BlockCipher" \
2831 "$P_SRV" \
2832 "$P_CLI request_size=1 force_version=tls1_1 \
2833 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2834 0 \
2835 -s "Read from client: 1 bytes read"
2836
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002837run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2838 "$P_SRV" \
2839 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2840 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2841 0 \
2842 -s "Read from client: 1 bytes read"
2843
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002844run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002845 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002846 "$P_CLI request_size=1 force_version=tls1_1 \
2847 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2848 0 \
2849 -s "Read from client: 1 bytes read"
2850
2851run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2852 "$P_SRV" \
2853 "$P_CLI request_size=1 force_version=tls1_1 \
2854 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2855 trunc_hmac=1" \
2856 0 \
2857 -s "Read from client: 1 bytes read"
2858
2859run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002860 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002861 "$P_CLI request_size=1 force_version=tls1_1 \
2862 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2863 trunc_hmac=1" \
2864 0 \
2865 -s "Read from client: 1 bytes read"
2866
2867run_test "Small packet TLS 1.2 BlockCipher" \
2868 "$P_SRV" \
2869 "$P_CLI request_size=1 force_version=tls1_2 \
2870 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2871 0 \
2872 -s "Read from client: 1 bytes read"
2873
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002874run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2875 "$P_SRV" \
2876 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2877 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2878 0 \
2879 -s "Read from client: 1 bytes read"
2880
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002881run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2882 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002883 "$P_CLI request_size=1 force_version=tls1_2 \
2884 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002885 0 \
2886 -s "Read from client: 1 bytes read"
2887
2888run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2889 "$P_SRV" \
2890 "$P_CLI request_size=1 force_version=tls1_2 \
2891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2892 trunc_hmac=1" \
2893 0 \
2894 -s "Read from client: 1 bytes read"
2895
2896run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002897 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002898 "$P_CLI request_size=1 force_version=tls1_2 \
2899 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2900 0 \
2901 -s "Read from client: 1 bytes read"
2902
2903run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002904 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002905 "$P_CLI request_size=1 force_version=tls1_2 \
2906 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2907 trunc_hmac=1" \
2908 0 \
2909 -s "Read from client: 1 bytes read"
2910
2911run_test "Small packet TLS 1.2 AEAD" \
2912 "$P_SRV" \
2913 "$P_CLI request_size=1 force_version=tls1_2 \
2914 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2915 0 \
2916 -s "Read from client: 1 bytes read"
2917
2918run_test "Small packet TLS 1.2 AEAD shorter tag" \
2919 "$P_SRV" \
2920 "$P_CLI request_size=1 force_version=tls1_2 \
2921 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2922 0 \
2923 -s "Read from client: 1 bytes read"
2924
Janos Follath00efff72016-05-06 13:48:23 +01002925# A test for extensions in SSLv3
2926
2927requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2928run_test "SSLv3 with extensions, server side" \
2929 "$P_SRV min_version=ssl3 debug_level=3" \
2930 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
2931 0 \
2932 -S "dumping 'client hello extensions'" \
2933 -S "server hello, total extension length:"
2934
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002935# Test for large packets
2936
Janos Follathe2681a42016-03-07 15:57:05 +00002937requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002938run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002939 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002940 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002941 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2942 0 \
2943 -s "Read from client: 16384 bytes read"
2944
Janos Follathe2681a42016-03-07 15:57:05 +00002945requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002946run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002947 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002948 "$P_CLI request_size=16384 force_version=ssl3 \
2949 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2950 0 \
2951 -s "Read from client: 16384 bytes read"
2952
2953run_test "Large packet TLS 1.0 BlockCipher" \
2954 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002955 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002956 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2957 0 \
2958 -s "Read from client: 16384 bytes read"
2959
2960run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2961 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002962 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002963 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2964 trunc_hmac=1" \
2965 0 \
2966 -s "Read from client: 16384 bytes read"
2967
2968run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002969 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002970 "$P_CLI request_size=16384 force_version=tls1 \
2971 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2972 trunc_hmac=1" \
2973 0 \
2974 -s "Read from client: 16384 bytes read"
2975
2976run_test "Large packet TLS 1.1 BlockCipher" \
2977 "$P_SRV" \
2978 "$P_CLI request_size=16384 force_version=tls1_1 \
2979 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2980 0 \
2981 -s "Read from client: 16384 bytes read"
2982
2983run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002984 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002985 "$P_CLI request_size=16384 force_version=tls1_1 \
2986 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2987 0 \
2988 -s "Read from client: 16384 bytes read"
2989
2990run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2991 "$P_SRV" \
2992 "$P_CLI request_size=16384 force_version=tls1_1 \
2993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2994 trunc_hmac=1" \
2995 0 \
2996 -s "Read from client: 16384 bytes read"
2997
2998run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002999 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003000 "$P_CLI request_size=16384 force_version=tls1_1 \
3001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3002 trunc_hmac=1" \
3003 0 \
3004 -s "Read from client: 16384 bytes read"
3005
3006run_test "Large packet TLS 1.2 BlockCipher" \
3007 "$P_SRV" \
3008 "$P_CLI request_size=16384 force_version=tls1_2 \
3009 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3010 0 \
3011 -s "Read from client: 16384 bytes read"
3012
3013run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3014 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003015 "$P_CLI request_size=16384 force_version=tls1_2 \
3016 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003017 0 \
3018 -s "Read from client: 16384 bytes read"
3019
3020run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3021 "$P_SRV" \
3022 "$P_CLI request_size=16384 force_version=tls1_2 \
3023 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3024 trunc_hmac=1" \
3025 0 \
3026 -s "Read from client: 16384 bytes read"
3027
3028run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003029 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003030 "$P_CLI request_size=16384 force_version=tls1_2 \
3031 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3032 0 \
3033 -s "Read from client: 16384 bytes read"
3034
3035run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003036 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003037 "$P_CLI request_size=16384 force_version=tls1_2 \
3038 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3039 trunc_hmac=1" \
3040 0 \
3041 -s "Read from client: 16384 bytes read"
3042
3043run_test "Large packet TLS 1.2 AEAD" \
3044 "$P_SRV" \
3045 "$P_CLI request_size=16384 force_version=tls1_2 \
3046 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3047 0 \
3048 -s "Read from client: 16384 bytes read"
3049
3050run_test "Large packet TLS 1.2 AEAD shorter tag" \
3051 "$P_SRV" \
3052 "$P_CLI request_size=16384 force_version=tls1_2 \
3053 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3054 0 \
3055 -s "Read from client: 16384 bytes read"
3056
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003057# Tests for DTLS HelloVerifyRequest
3058
3059run_test "DTLS cookie: enabled" \
3060 "$P_SRV dtls=1 debug_level=2" \
3061 "$P_CLI dtls=1 debug_level=2" \
3062 0 \
3063 -s "cookie verification failed" \
3064 -s "cookie verification passed" \
3065 -S "cookie verification skipped" \
3066 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003067 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003068 -S "SSL - The requested feature is not available"
3069
3070run_test "DTLS cookie: disabled" \
3071 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3072 "$P_CLI dtls=1 debug_level=2" \
3073 0 \
3074 -S "cookie verification failed" \
3075 -S "cookie verification passed" \
3076 -s "cookie verification skipped" \
3077 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003078 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003079 -S "SSL - The requested feature is not available"
3080
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003081run_test "DTLS cookie: default (failing)" \
3082 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3083 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3084 1 \
3085 -s "cookie verification failed" \
3086 -S "cookie verification passed" \
3087 -S "cookie verification skipped" \
3088 -C "received hello verify request" \
3089 -S "hello verification requested" \
3090 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003091
3092requires_ipv6
3093run_test "DTLS cookie: enabled, IPv6" \
3094 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3095 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3096 0 \
3097 -s "cookie verification failed" \
3098 -s "cookie verification passed" \
3099 -S "cookie verification skipped" \
3100 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003101 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003102 -S "SSL - The requested feature is not available"
3103
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003104run_test "DTLS cookie: enabled, nbio" \
3105 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3106 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3107 0 \
3108 -s "cookie verification failed" \
3109 -s "cookie verification passed" \
3110 -S "cookie verification skipped" \
3111 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003112 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003113 -S "SSL - The requested feature is not available"
3114
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003115# Tests for client reconnecting from the same port with DTLS
3116
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003117not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003118run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003119 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3120 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003121 0 \
3122 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003123 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003124 -S "Client initiated reconnection from same port"
3125
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003126not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003127run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003128 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3129 "$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 +02003130 0 \
3131 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003132 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003133 -s "Client initiated reconnection from same port"
3134
Paul Bakker362689d2016-05-13 10:33:25 +01003135not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3136run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003137 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3138 "$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 +02003139 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003140 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003141 -s "Client initiated reconnection from same port"
3142
Paul Bakker362689d2016-05-13 10:33:25 +01003143only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3144run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3145 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3146 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3147 0 \
3148 -S "The operation timed out" \
3149 -s "Client initiated reconnection from same port"
3150
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003151run_test "DTLS client reconnect from same port: no cookies" \
3152 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003153 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3154 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003155 -s "The operation timed out" \
3156 -S "Client initiated reconnection from same port"
3157
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003158# Tests for various cases of client authentication with DTLS
3159# (focused on handshake flows and message parsing)
3160
3161run_test "DTLS client auth: required" \
3162 "$P_SRV dtls=1 auth_mode=required" \
3163 "$P_CLI dtls=1" \
3164 0 \
3165 -s "Verifying peer X.509 certificate... ok"
3166
3167run_test "DTLS client auth: optional, client has no cert" \
3168 "$P_SRV dtls=1 auth_mode=optional" \
3169 "$P_CLI dtls=1 crt_file=none key_file=none" \
3170 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003171 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003172
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003173run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003174 "$P_SRV dtls=1 auth_mode=none" \
3175 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3176 0 \
3177 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003178 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003179
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003180run_test "DTLS wrong PSK: badmac alert" \
3181 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3182 "$P_CLI dtls=1 psk=abc124" \
3183 1 \
3184 -s "SSL - Verification of the message MAC failed" \
3185 -c "SSL - A fatal alert message was received from our peer"
3186
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003187# Tests for receiving fragmented handshake messages with DTLS
3188
3189requires_gnutls
3190run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3191 "$G_SRV -u --mtu 2048 -a" \
3192 "$P_CLI dtls=1 debug_level=2" \
3193 0 \
3194 -C "found fragmented DTLS handshake message" \
3195 -C "error"
3196
3197requires_gnutls
3198run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3199 "$G_SRV -u --mtu 512" \
3200 "$P_CLI dtls=1 debug_level=2" \
3201 0 \
3202 -c "found fragmented DTLS handshake message" \
3203 -C "error"
3204
3205requires_gnutls
3206run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3207 "$G_SRV -u --mtu 128" \
3208 "$P_CLI dtls=1 debug_level=2" \
3209 0 \
3210 -c "found fragmented DTLS handshake message" \
3211 -C "error"
3212
3213requires_gnutls
3214run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3215 "$G_SRV -u --mtu 128" \
3216 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3217 0 \
3218 -c "found fragmented DTLS handshake message" \
3219 -C "error"
3220
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003221requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003222run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3223 "$G_SRV -u --mtu 256" \
3224 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3225 0 \
3226 -c "found fragmented DTLS handshake message" \
3227 -c "client hello, adding renegotiation extension" \
3228 -c "found renegotiation extension" \
3229 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003230 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003231 -C "error" \
3232 -s "Extra-header:"
3233
3234requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003235run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3236 "$G_SRV -u --mtu 256" \
3237 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3238 0 \
3239 -c "found fragmented DTLS handshake message" \
3240 -c "client hello, adding renegotiation extension" \
3241 -c "found renegotiation extension" \
3242 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003243 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003244 -C "error" \
3245 -s "Extra-header:"
3246
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003247run_test "DTLS reassembly: no fragmentation (openssl server)" \
3248 "$O_SRV -dtls1 -mtu 2048" \
3249 "$P_CLI dtls=1 debug_level=2" \
3250 0 \
3251 -C "found fragmented DTLS handshake message" \
3252 -C "error"
3253
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003254run_test "DTLS reassembly: some fragmentation (openssl server)" \
3255 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003256 "$P_CLI dtls=1 debug_level=2" \
3257 0 \
3258 -c "found fragmented DTLS handshake message" \
3259 -C "error"
3260
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003261run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003262 "$O_SRV -dtls1 -mtu 256" \
3263 "$P_CLI dtls=1 debug_level=2" \
3264 0 \
3265 -c "found fragmented DTLS handshake message" \
3266 -C "error"
3267
3268run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3269 "$O_SRV -dtls1 -mtu 256" \
3270 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3271 0 \
3272 -c "found fragmented DTLS handshake message" \
3273 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003274
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003275# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003276
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003277not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003278run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003279 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003280 "$P_SRV dtls=1 debug_level=2" \
3281 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003282 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003283 -C "replayed record" \
3284 -S "replayed record" \
3285 -C "record from another epoch" \
3286 -S "record from another epoch" \
3287 -C "discarding invalid record" \
3288 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003289 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003290 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003291 -c "HTTP/1.0 200 OK"
3292
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003293not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003294run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003295 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003296 "$P_SRV dtls=1 debug_level=2" \
3297 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003298 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003299 -c "replayed record" \
3300 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003301 -c "discarding invalid record" \
3302 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003303 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003304 -s "Extra-header:" \
3305 -c "HTTP/1.0 200 OK"
3306
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003307run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3308 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003309 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3310 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003311 0 \
3312 -c "replayed record" \
3313 -S "replayed record" \
3314 -c "discarding invalid record" \
3315 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003316 -c "resend" \
3317 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003318 -s "Extra-header:" \
3319 -c "HTTP/1.0 200 OK"
3320
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003321run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003322 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003323 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003324 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003325 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003326 -c "discarding invalid record (mac)" \
3327 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003328 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003329 -c "HTTP/1.0 200 OK" \
3330 -S "too many records with bad MAC" \
3331 -S "Verification of the message MAC failed"
3332
3333run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3334 -p "$P_PXY bad_ad=1" \
3335 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3336 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3337 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003338 -C "discarding invalid record (mac)" \
3339 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003340 -S "Extra-header:" \
3341 -C "HTTP/1.0 200 OK" \
3342 -s "too many records with bad MAC" \
3343 -s "Verification of the message MAC failed"
3344
3345run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3346 -p "$P_PXY bad_ad=1" \
3347 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3348 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3349 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003350 -c "discarding invalid record (mac)" \
3351 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003352 -s "Extra-header:" \
3353 -c "HTTP/1.0 200 OK" \
3354 -S "too many records with bad MAC" \
3355 -S "Verification of the message MAC failed"
3356
3357run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3358 -p "$P_PXY bad_ad=1" \
3359 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3360 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3361 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003362 -c "discarding invalid record (mac)" \
3363 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003364 -s "Extra-header:" \
3365 -c "HTTP/1.0 200 OK" \
3366 -s "too many records with bad MAC" \
3367 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003368
3369run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003370 -p "$P_PXY delay_ccs=1" \
3371 "$P_SRV dtls=1 debug_level=1" \
3372 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003373 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003374 -c "record from another epoch" \
3375 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003376 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003377 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003378 -s "Extra-header:" \
3379 -c "HTTP/1.0 200 OK"
3380
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003381# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003382
Janos Follath74537a62016-09-02 13:45:28 +01003383client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003384run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003385 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003386 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3387 psk=abc123" \
3388 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003389 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3390 0 \
3391 -s "Extra-header:" \
3392 -c "HTTP/1.0 200 OK"
3393
Janos Follath74537a62016-09-02 13:45:28 +01003394client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003395run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3396 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003397 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3398 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003399 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3400 0 \
3401 -s "Extra-header:" \
3402 -c "HTTP/1.0 200 OK"
3403
Janos Follath74537a62016-09-02 13:45:28 +01003404client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003405run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3406 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003407 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3408 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003409 0 \
3410 -s "Extra-header:" \
3411 -c "HTTP/1.0 200 OK"
3412
Janos Follath74537a62016-09-02 13:45:28 +01003413client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003414run_test "DTLS proxy: 3d, FS, client auth" \
3415 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003416 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3417 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003418 0 \
3419 -s "Extra-header:" \
3420 -c "HTTP/1.0 200 OK"
3421
Janos Follath74537a62016-09-02 13:45:28 +01003422client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003423run_test "DTLS proxy: 3d, FS, ticket" \
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=1 auth_mode=none" \
3426 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003427 0 \
3428 -s "Extra-header:" \
3429 -c "HTTP/1.0 200 OK"
3430
Janos Follath74537a62016-09-02 13:45:28 +01003431client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003432run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3433 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003434 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3435 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003436 0 \
3437 -s "Extra-header:" \
3438 -c "HTTP/1.0 200 OK"
3439
Janos Follath74537a62016-09-02 13:45:28 +01003440client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003441run_test "DTLS proxy: 3d, max handshake, nbio" \
3442 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003443 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3444 auth_mode=required" \
3445 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003446 0 \
3447 -s "Extra-header:" \
3448 -c "HTTP/1.0 200 OK"
3449
Janos Follath74537a62016-09-02 13:45:28 +01003450client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003451run_test "DTLS proxy: 3d, min handshake, resumption" \
3452 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3453 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3454 psk=abc123 debug_level=3" \
3455 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3456 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3457 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3458 0 \
3459 -s "a session has been resumed" \
3460 -c "a session has been resumed" \
3461 -s "Extra-header:" \
3462 -c "HTTP/1.0 200 OK"
3463
Janos Follath74537a62016-09-02 13:45:28 +01003464client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003465run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3466 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3467 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3468 psk=abc123 debug_level=3 nbio=2" \
3469 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3470 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3471 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3472 0 \
3473 -s "a session has been resumed" \
3474 -c "a session has been resumed" \
3475 -s "Extra-header:" \
3476 -c "HTTP/1.0 200 OK"
3477
Janos Follath74537a62016-09-02 13:45:28 +01003478client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003479run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003480 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003481 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3482 psk=abc123 renegotiation=1 debug_level=2" \
3483 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3484 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003485 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3486 0 \
3487 -c "=> renegotiate" \
3488 -s "=> renegotiate" \
3489 -s "Extra-header:" \
3490 -c "HTTP/1.0 200 OK"
3491
Janos Follath74537a62016-09-02 13:45:28 +01003492client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003493run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3494 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003495 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3496 psk=abc123 renegotiation=1 debug_level=2" \
3497 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3498 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003499 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3500 0 \
3501 -c "=> renegotiate" \
3502 -s "=> renegotiate" \
3503 -s "Extra-header:" \
3504 -c "HTTP/1.0 200 OK"
3505
Janos Follath74537a62016-09-02 13:45:28 +01003506client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003507run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003508 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003509 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003510 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003511 debug_level=2" \
3512 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003513 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003514 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3515 0 \
3516 -c "=> renegotiate" \
3517 -s "=> renegotiate" \
3518 -s "Extra-header:" \
3519 -c "HTTP/1.0 200 OK"
3520
Janos Follath74537a62016-09-02 13:45:28 +01003521client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003522run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003523 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003524 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003525 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003526 debug_level=2 nbio=2" \
3527 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003528 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003529 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3530 0 \
3531 -c "=> renegotiate" \
3532 -s "=> renegotiate" \
3533 -s "Extra-header:" \
3534 -c "HTTP/1.0 200 OK"
3535
Janos Follath74537a62016-09-02 13:45:28 +01003536client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003537not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003538run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003539 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3540 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003541 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003542 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003543 -c "HTTP/1.0 200 OK"
3544
Janos Follath74537a62016-09-02 13:45:28 +01003545client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003546not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003547run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3548 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3549 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003550 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003551 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003552 -c "HTTP/1.0 200 OK"
3553
Janos Follath74537a62016-09-02 13:45:28 +01003554client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003555not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003556run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3557 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3558 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003559 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003560 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003561 -c "HTTP/1.0 200 OK"
3562
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003563requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003564client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003565not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003566run_test "DTLS proxy: 3d, gnutls server" \
3567 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3568 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003569 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003570 0 \
3571 -s "Extra-header:" \
3572 -c "Extra-header:"
3573
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003574requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003575client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003576not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003577run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3578 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3579 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003580 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003581 0 \
3582 -s "Extra-header:" \
3583 -c "Extra-header:"
3584
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003585requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003586client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003587not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003588run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3589 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3590 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003591 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003592 0 \
3593 -s "Extra-header:" \
3594 -c "Extra-header:"
3595
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003596# Final report
3597
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003598echo "------------------------------------------------------------------------"
3599
3600if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003601 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003602else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003603 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003604fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003605PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003606echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003607
3608exit $FAILS