blob: 953ebe816805de890e673311d11c0c649137035a [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010070# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020077# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020092# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020095 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020096 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200133# multiply the client timeout delay by the given factor for the next test
134needs_more_time() {
135 CLI_DELAY_FACTOR=$1
136}
137
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100138# print_name <name>
139print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100140 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200141 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100142 for i in `seq 1 $LEN`; do printf '.'; done
143 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100144
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200145 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146}
147
148# fail <message>
149fail() {
150 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100151 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200153 mv $SRV_OUT o-srv-${TESTS}.log
154 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200155 if [ -n "$PXY_CMD" ]; then
156 mv $PXY_OUT o-pxy-${TESTS}.log
157 fi
158 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200160 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
161 echo " ! server output:"
162 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200164 echo " ! client output:"
165 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200166 if [ -n "$PXY_CMD" ]; then
167 echo " ! ========================================================"
168 echo " ! proxy output:"
169 cat o-pxy-${TESTS}.log
170 fi
171 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 fi
173
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200174 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100175}
176
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100177# is_polar <cmd_line>
178is_polar() {
179 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
180}
181
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200182# openssl s_server doesn't have -www with DTLS
183check_osrv_dtls() {
184 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
185 NEEDS_INPUT=1
186 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
187 else
188 NEEDS_INPUT=0
189 fi
190}
191
192# provide input to commands that need it
193provide_input() {
194 if [ $NEEDS_INPUT -eq 0 ]; then
195 return
196 fi
197
198 while true; do
199 echo "HTTP/1.0 200 OK"
200 sleep 1
201 done
202}
203
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100204# has_mem_err <log_file_name>
205has_mem_err() {
206 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
207 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
208 then
209 return 1 # false: does not have errors
210 else
211 return 0 # true: has errors
212 fi
213}
214
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200215# wait for server to start: two versions depending on lsof availability
216wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200217 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200218 START_TIME=$( date +%s )
219 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200220
221 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200222 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200223 while [ $DONE -eq 0 ]; do
224 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
225 then
226 DONE=1
227 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
228 echo "SERVERSTART TIMEOUT"
229 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
230 DONE=1
231 fi
232 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200233 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200234 while [ $DONE -eq 0 ]; do
235 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
236 then
237 DONE=1
238 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
239 echo "SERVERSTART TIMEOUT"
240 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
241 DONE=1
242 fi
243 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200244 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200245 else
246 sleep "$START_DELAY"
247 fi
248}
249
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200250# wait for client to terminate and set CLI_EXIT
251# must be called right after starting the client
252wait_client_done() {
253 CLI_PID=$!
254
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200255 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
256 CLI_DELAY_FACTOR=1
257
258 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200259 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200260
261 wait $CLI_PID
262 CLI_EXIT=$?
263
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200264 kill $DOG_PID >/dev/null 2>&1
265 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200266
267 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
268}
269
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200270# check if the given command uses dtls and sets global variable DTLS
271detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200272 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200273 DTLS=1
274 else
275 DTLS=0
276 fi
277}
278
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200279# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100280# Options: -s pattern pattern that must be present in server output
281# -c pattern pattern that must be present in client output
282# -S pattern pattern that must be absent in server output
283# -C pattern pattern that must be absent in client output
284run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100285 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200286 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100287
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100288 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
289 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200290 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100291 return
292 fi
293
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100294 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200296 # should we skip?
297 if [ "X$SKIP_NEXT" = "XYES" ]; then
298 SKIP_NEXT="NO"
299 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200300 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200301 return
302 fi
303
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200304 # does this test use a proxy?
305 if [ "X$1" = "X-p" ]; then
306 PXY_CMD="$2"
307 shift 2
308 else
309 PXY_CMD=""
310 fi
311
312 # get commands and client output
313 SRV_CMD="$1"
314 CLI_CMD="$2"
315 CLI_EXPECT="$3"
316 shift 3
317
318 # fix client port
319 if [ -n "$PXY_CMD" ]; then
320 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
321 else
322 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
323 fi
324
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200325 # update DTLS variable
326 detect_dtls "$SRV_CMD"
327
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100328 # prepend valgrind to our commands if active
329 if [ "$MEMCHECK" -gt 0 ]; then
330 if is_polar "$SRV_CMD"; then
331 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
332 fi
333 if is_polar "$CLI_CMD"; then
334 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
335 fi
336 fi
337
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100338 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200339 if [ -n "$PXY_CMD" ]; then
340 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200341 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200342 PXY_PID=$!
343 # assume proxy starts faster than server
344 fi
345
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200346 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200347 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200348 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100349 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200350 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200351
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200352 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200353 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
354 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100355
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200356 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200357 kill $SRV_PID
358 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200359 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200360 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200361 wait $PXY_PID
362 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100363
364 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200365 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100366 # expected client exit to incorrectly succeed in case of catastrophic
367 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100368 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200369 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100370 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100371 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100372 return
373 fi
374 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100375 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200376 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100377 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100378 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100379 return
380 fi
381 fi
382
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100383 # check server exit code
384 if [ $? != 0 ]; then
385 fail "server fail"
386 return
387 fi
388
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100389 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100390 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
391 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100392 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200393 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100394 return
395 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100396
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100397 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200398 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100399 while [ $# -gt 0 ]
400 do
401 case $1 in
402 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200403 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100404 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100405 return
406 fi
407 ;;
408
409 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200410 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100411 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100412 return
413 fi
414 ;;
415
416 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200417 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100418 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100419 return
420 fi
421 ;;
422
423 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200424 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100425 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100426 return
427 fi
428 ;;
429
430 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200431 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100432 exit 1
433 esac
434 shift 2
435 done
436
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100437 # check valgrind's results
438 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200439 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100440 fail "Server has memory errors"
441 return
442 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200443 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100444 fail "Client has memory errors"
445 return
446 fi
447 fi
448
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100449 # if we're here, everything is ok
450 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200451 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100452}
453
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100454cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200455 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200456 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
457 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
458 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
459 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100460 exit 1
461}
462
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100463#
464# MAIN
465#
466
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000467if cd $( dirname $0 ); then :; else
468 echo "cd $( dirname $0 ) failed" >&2
469 exit 1
470fi
471
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100472get_options "$@"
473
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100474# sanity checks, avoid an avalanche of errors
475if [ ! -x "$P_SRV" ]; then
476 echo "Command '$P_SRV' is not an executable file"
477 exit 1
478fi
479if [ ! -x "$P_CLI" ]; then
480 echo "Command '$P_CLI' is not an executable file"
481 exit 1
482fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200483if [ ! -x "$P_PXY" ]; then
484 echo "Command '$P_PXY' is not an executable file"
485 exit 1
486fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100487if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
488 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100489 exit 1
490fi
491
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200492# used by watchdog
493MAIN_PID="$$"
494
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200495# be more patient with valgrind
496if [ "$MEMCHECK" -gt 0 ]; then
497 START_DELAY=3
498 DOG_DELAY=30
499else
500 START_DELAY=1
501 DOG_DELAY=10
502fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200503CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200504
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200505# Pick a "unique" server port in the range 10000-19999, and a proxy port
506PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000507PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200508SRV_PORT="1$PORT_BASE"
509PXY_PORT="2$PORT_BASE"
510unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200511
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200512# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000513# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200514P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
515P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
516P_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 +0200517O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200518O_CLI="$O_CLI -connect localhost:+SRV_PORT"
519G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000520G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200521
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200522# Also pick a unique name for intermediate files
523SRV_OUT="srv_out.$$"
524CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200525PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200526SESSION="session.$$"
527
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200528SKIP_NEXT="NO"
529
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100530trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100531
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200532# Basic test
533
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200534# Checks that:
535# - things work with all ciphersuites active (used with config-full in all.sh)
536# - the expected (highest security) parameters are selected
537# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200538run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200539 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200540 "$P_CLI" \
541 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200542 -s "Protocol is TLSv1.2" \
543 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
544 -s "client hello v3, signature_algorithm ext: 6" \
545 -s "ECDHE curve: secp521r1" \
546 -S "error" \
547 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200548
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000549run_test "Default, DTLS" \
550 "$P_SRV dtls=1" \
551 "$P_CLI dtls=1" \
552 0 \
553 -s "Protocol is DTLSv1.2" \
554 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
555
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100556# Tests for rc4 option
557
558run_test "RC4: server disabled, client enabled" \
559 "$P_SRV" \
560 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
561 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100562 -s "SSL - The server has no ciphersuites in common"
563
564run_test "RC4: server half, client enabled" \
565 "$P_SRV arc4=1" \
566 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
567 1 \
568 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100569
570run_test "RC4: server enabled, client disabled" \
571 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
572 "$P_CLI" \
573 1 \
574 -s "SSL - The server has no ciphersuites in common"
575
576run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100577 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
579 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100580 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100581 -S "SSL - The server has no ciphersuites in common"
582
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100583# Tests for Truncated HMAC extension
584
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100585run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200586 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100587 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100588 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100589 -s "dumping 'computed mac' (20 bytes)" \
590 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100591
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100592run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200593 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100594 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
595 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100596 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100597 -s "dumping 'computed mac' (20 bytes)" \
598 -S "dumping 'computed mac' (10 bytes)"
599
600run_test "Truncated HMAC: client enabled, server default" \
601 "$P_SRV debug_level=4" \
602 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
603 trunc_hmac=1" \
604 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100605 -s "dumping 'computed mac' (20 bytes)" \
606 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100607
608run_test "Truncated HMAC: client enabled, server disabled" \
609 "$P_SRV debug_level=4 trunc_hmac=0" \
610 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
611 trunc_hmac=1" \
612 0 \
613 -s "dumping 'computed mac' (20 bytes)" \
614 -S "dumping 'computed mac' (10 bytes)"
615
616run_test "Truncated HMAC: client enabled, server enabled" \
617 "$P_SRV debug_level=4 trunc_hmac=1" \
618 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
619 trunc_hmac=1" \
620 0 \
621 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100622 -s "dumping 'computed mac' (10 bytes)"
623
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100624# Tests for Encrypt-then-MAC extension
625
626run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100627 "$P_SRV debug_level=3 \
628 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100629 "$P_CLI debug_level=3" \
630 0 \
631 -c "client hello, adding encrypt_then_mac extension" \
632 -s "found encrypt then mac extension" \
633 -s "server hello, adding encrypt then mac extension" \
634 -c "found encrypt_then_mac extension" \
635 -c "using encrypt then mac" \
636 -s "using encrypt then mac"
637
638run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100639 "$P_SRV debug_level=3 etm=0 \
640 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100641 "$P_CLI debug_level=3 etm=1" \
642 0 \
643 -c "client hello, adding encrypt_then_mac extension" \
644 -s "found encrypt then mac extension" \
645 -S "server hello, adding encrypt then mac extension" \
646 -C "found encrypt_then_mac extension" \
647 -C "using encrypt then mac" \
648 -S "using encrypt then mac"
649
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100650run_test "Encrypt then MAC: client enabled, aead cipher" \
651 "$P_SRV debug_level=3 etm=1 \
652 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
653 "$P_CLI debug_level=3 etm=1" \
654 0 \
655 -c "client hello, adding encrypt_then_mac extension" \
656 -s "found encrypt then mac extension" \
657 -S "server hello, adding encrypt then mac extension" \
658 -C "found encrypt_then_mac extension" \
659 -C "using encrypt then mac" \
660 -S "using encrypt then mac"
661
662run_test "Encrypt then MAC: client enabled, stream cipher" \
663 "$P_SRV debug_level=3 etm=1 \
664 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100665 "$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 +0100666 0 \
667 -c "client hello, adding encrypt_then_mac extension" \
668 -s "found encrypt then mac extension" \
669 -S "server hello, adding encrypt then mac extension" \
670 -C "found encrypt_then_mac extension" \
671 -C "using encrypt then mac" \
672 -S "using encrypt then mac"
673
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100674run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100675 "$P_SRV debug_level=3 etm=1 \
676 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100677 "$P_CLI debug_level=3 etm=0" \
678 0 \
679 -C "client hello, adding encrypt_then_mac extension" \
680 -S "found encrypt then mac extension" \
681 -S "server hello, adding encrypt then mac extension" \
682 -C "found encrypt_then_mac extension" \
683 -C "using encrypt then mac" \
684 -S "using encrypt then mac"
685
686run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100687 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100688 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100689 "$P_CLI debug_level=3 force_version=ssl3" \
690 0 \
691 -C "client hello, adding encrypt_then_mac extension" \
692 -S "found encrypt then mac extension" \
693 -S "server hello, adding encrypt then mac extension" \
694 -C "found encrypt_then_mac extension" \
695 -C "using encrypt then mac" \
696 -S "using encrypt then mac"
697
698run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100699 "$P_SRV debug_level=3 force_version=ssl3 \
700 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100701 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100702 0 \
703 -c "client hello, adding encrypt_then_mac extension" \
704 -s "found encrypt then mac extension" \
705 -S "server hello, adding encrypt then mac extension" \
706 -C "found encrypt_then_mac extension" \
707 -C "using encrypt then mac" \
708 -S "using encrypt then mac"
709
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200710# Tests for Extended Master Secret extension
711
712run_test "Extended Master Secret: default" \
713 "$P_SRV debug_level=3" \
714 "$P_CLI debug_level=3" \
715 0 \
716 -c "client hello, adding extended_master_secret extension" \
717 -s "found extended master secret extension" \
718 -s "server hello, adding extended master secret extension" \
719 -c "found extended_master_secret extension" \
720 -c "using extended master secret" \
721 -s "using extended master secret"
722
723run_test "Extended Master Secret: client enabled, server disabled" \
724 "$P_SRV debug_level=3 extended_ms=0" \
725 "$P_CLI debug_level=3 extended_ms=1" \
726 0 \
727 -c "client hello, adding extended_master_secret extension" \
728 -s "found extended master secret extension" \
729 -S "server hello, adding extended master secret extension" \
730 -C "found extended_master_secret extension" \
731 -C "using extended master secret" \
732 -S "using extended master secret"
733
734run_test "Extended Master Secret: client disabled, server enabled" \
735 "$P_SRV debug_level=3 extended_ms=1" \
736 "$P_CLI debug_level=3 extended_ms=0" \
737 0 \
738 -C "client hello, adding extended_master_secret extension" \
739 -S "found extended master secret extension" \
740 -S "server hello, adding extended master secret extension" \
741 -C "found extended_master_secret extension" \
742 -C "using extended master secret" \
743 -S "using extended master secret"
744
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200745run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100746 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200747 "$P_CLI debug_level=3 force_version=ssl3" \
748 0 \
749 -C "client hello, adding extended_master_secret extension" \
750 -S "found extended master secret extension" \
751 -S "server hello, adding extended master secret extension" \
752 -C "found extended_master_secret extension" \
753 -C "using extended master secret" \
754 -S "using extended master secret"
755
756run_test "Extended Master Secret: client enabled, server SSLv3" \
757 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100758 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200759 0 \
760 -c "client hello, adding extended_master_secret extension" \
761 -s "found extended master secret extension" \
762 -S "server hello, adding extended master secret extension" \
763 -C "found extended_master_secret extension" \
764 -C "using extended master secret" \
765 -S "using extended master secret"
766
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200767# Tests for FALLBACK_SCSV
768
769run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200770 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200771 "$P_CLI debug_level=3 force_version=tls1_1" \
772 0 \
773 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200774 -S "received FALLBACK_SCSV" \
775 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200776 -C "is a fatal alert message (msg 86)"
777
778run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200779 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200780 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
781 0 \
782 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200783 -S "received FALLBACK_SCSV" \
784 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200785 -C "is a fatal alert message (msg 86)"
786
787run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200788 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200789 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200790 1 \
791 -c "adding FALLBACK_SCSV" \
792 -s "received FALLBACK_SCSV" \
793 -s "inapropriate fallback" \
794 -c "is a fatal alert message (msg 86)"
795
796run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200797 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200798 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200799 0 \
800 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200801 -s "received FALLBACK_SCSV" \
802 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200803 -C "is a fatal alert message (msg 86)"
804
805requires_openssl_with_fallback_scsv
806run_test "Fallback SCSV: default, openssl server" \
807 "$O_SRV" \
808 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
809 0 \
810 -C "adding FALLBACK_SCSV" \
811 -C "is a fatal alert message (msg 86)"
812
813requires_openssl_with_fallback_scsv
814run_test "Fallback SCSV: enabled, openssl server" \
815 "$O_SRV" \
816 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
817 1 \
818 -c "adding FALLBACK_SCSV" \
819 -c "is a fatal alert message (msg 86)"
820
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200821requires_openssl_with_fallback_scsv
822run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200823 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200824 "$O_CLI -tls1_1" \
825 0 \
826 -S "received FALLBACK_SCSV" \
827 -S "inapropriate fallback"
828
829requires_openssl_with_fallback_scsv
830run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200831 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200832 "$O_CLI -tls1_1 -fallback_scsv" \
833 1 \
834 -s "received FALLBACK_SCSV" \
835 -s "inapropriate fallback"
836
837requires_openssl_with_fallback_scsv
838run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200839 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200840 "$O_CLI -fallback_scsv" \
841 0 \
842 -s "received FALLBACK_SCSV" \
843 -S "inapropriate fallback"
844
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100845# Tests for CBC 1/n-1 record splitting
846
847run_test "CBC Record splitting: TLS 1.2, no splitting" \
848 "$P_SRV" \
849 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
850 request_size=123 force_version=tls1_2" \
851 0 \
852 -s "Read from client: 123 bytes read" \
853 -S "Read from client: 1 bytes read" \
854 -S "122 bytes read"
855
856run_test "CBC Record splitting: TLS 1.1, no splitting" \
857 "$P_SRV" \
858 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
859 request_size=123 force_version=tls1_1" \
860 0 \
861 -s "Read from client: 123 bytes read" \
862 -S "Read from client: 1 bytes read" \
863 -S "122 bytes read"
864
865run_test "CBC Record splitting: TLS 1.0, splitting" \
866 "$P_SRV" \
867 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
868 request_size=123 force_version=tls1" \
869 0 \
870 -S "Read from client: 123 bytes read" \
871 -s "Read from client: 1 bytes read" \
872 -s "122 bytes read"
873
874run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100875 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100876 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
877 request_size=123 force_version=ssl3" \
878 0 \
879 -S "Read from client: 123 bytes read" \
880 -s "Read from client: 1 bytes read" \
881 -s "122 bytes read"
882
883run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100884 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100885 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
886 request_size=123 force_version=tls1" \
887 0 \
888 -s "Read from client: 123 bytes read" \
889 -S "Read from client: 1 bytes read" \
890 -S "122 bytes read"
891
892run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
893 "$P_SRV" \
894 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
895 request_size=123 force_version=tls1 recsplit=0" \
896 0 \
897 -s "Read from client: 123 bytes read" \
898 -S "Read from client: 1 bytes read" \
899 -S "122 bytes read"
900
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100901run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
902 "$P_SRV nbio=2" \
903 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
904 request_size=123 force_version=tls1" \
905 0 \
906 -S "Read from client: 123 bytes read" \
907 -s "Read from client: 1 bytes read" \
908 -s "122 bytes read"
909
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100910# Tests for Session Tickets
911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200912run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200913 "$P_SRV debug_level=3 tickets=1" \
914 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100915 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100916 -c "client hello, adding session ticket extension" \
917 -s "found session ticket extension" \
918 -s "server hello, adding session ticket extension" \
919 -c "found session_ticket extension" \
920 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100921 -S "session successfully restored from cache" \
922 -s "session successfully restored from ticket" \
923 -s "a session has been resumed" \
924 -c "a session has been resumed"
925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200926run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200927 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
928 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100929 0 \
930 -c "client hello, adding session ticket extension" \
931 -s "found session ticket extension" \
932 -s "server hello, adding session ticket extension" \
933 -c "found session_ticket extension" \
934 -c "parse new session ticket" \
935 -S "session successfully restored from cache" \
936 -s "session successfully restored from ticket" \
937 -s "a session has been resumed" \
938 -c "a session has been resumed"
939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200940run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200941 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
942 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100943 0 \
944 -c "client hello, adding session ticket extension" \
945 -s "found session ticket extension" \
946 -s "server hello, adding session ticket extension" \
947 -c "found session_ticket extension" \
948 -c "parse new session ticket" \
949 -S "session successfully restored from cache" \
950 -S "session successfully restored from ticket" \
951 -S "a session has been resumed" \
952 -C "a session has been resumed"
953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200954run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100955 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200956 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100957 0 \
958 -c "client hello, adding session ticket extension" \
959 -c "found session_ticket extension" \
960 -c "parse new session ticket" \
961 -c "a session has been resumed"
962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200963run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200964 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200965 "( $O_CLI -sess_out $SESSION; \
966 $O_CLI -sess_in $SESSION; \
967 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100968 0 \
969 -s "found session ticket extension" \
970 -s "server hello, adding session ticket extension" \
971 -S "session successfully restored from cache" \
972 -s "session successfully restored from ticket" \
973 -s "a session has been resumed"
974
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100975# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200977run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200978 "$P_SRV debug_level=3 tickets=0" \
979 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100980 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100981 -c "client hello, adding session ticket extension" \
982 -s "found session ticket extension" \
983 -S "server hello, adding session ticket extension" \
984 -C "found session_ticket extension" \
985 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100986 -s "session successfully restored from cache" \
987 -S "session successfully restored from ticket" \
988 -s "a session has been resumed" \
989 -c "a session has been resumed"
990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200991run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200992 "$P_SRV debug_level=3 tickets=1" \
993 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100994 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100995 -C "client hello, adding session ticket extension" \
996 -S "found session ticket extension" \
997 -S "server hello, adding session ticket extension" \
998 -C "found session_ticket extension" \
999 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001000 -s "session successfully restored from cache" \
1001 -S "session successfully restored from ticket" \
1002 -s "a session has been resumed" \
1003 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001005run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001006 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1007 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001008 0 \
1009 -S "session successfully restored from cache" \
1010 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001011 -S "a session has been resumed" \
1012 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001014run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001015 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1016 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001017 0 \
1018 -s "session successfully restored from cache" \
1019 -S "session successfully restored from ticket" \
1020 -s "a session has been resumed" \
1021 -c "a session has been resumed"
1022
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001023run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001024 "$P_SRV debug_level=3 tickets=0" \
1025 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001026 0 \
1027 -s "session successfully restored from cache" \
1028 -S "session successfully restored from ticket" \
1029 -s "a session has been resumed" \
1030 -c "a session has been resumed"
1031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001032run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001033 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1034 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001035 0 \
1036 -S "session successfully restored from cache" \
1037 -S "session successfully restored from ticket" \
1038 -S "a session has been resumed" \
1039 -C "a session has been resumed"
1040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001041run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001042 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1043 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001044 0 \
1045 -s "session successfully restored from cache" \
1046 -S "session successfully restored from ticket" \
1047 -s "a session has been resumed" \
1048 -c "a session has been resumed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001051 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001052 "( $O_CLI -sess_out $SESSION; \
1053 $O_CLI -sess_in $SESSION; \
1054 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001055 0 \
1056 -s "found session ticket extension" \
1057 -S "server hello, adding session ticket extension" \
1058 -s "session successfully restored from cache" \
1059 -S "session successfully restored from ticket" \
1060 -s "a session has been resumed"
1061
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001062run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001063 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001064 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001065 0 \
1066 -C "found session_ticket extension" \
1067 -C "parse new session ticket" \
1068 -c "a session has been resumed"
1069
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001070# Tests for Max Fragment Length extension
1071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001072run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001073 "$P_SRV debug_level=3" \
1074 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001075 0 \
1076 -C "client hello, adding max_fragment_length extension" \
1077 -S "found max fragment length extension" \
1078 -S "server hello, max_fragment_length extension" \
1079 -C "found max_fragment_length extension"
1080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001081run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001082 "$P_SRV debug_level=3" \
1083 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001084 0 \
1085 -c "client hello, adding max_fragment_length extension" \
1086 -s "found max fragment length extension" \
1087 -s "server hello, max_fragment_length extension" \
1088 -c "found max_fragment_length extension"
1089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001090run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001091 "$P_SRV debug_level=3 max_frag_len=4096" \
1092 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001093 0 \
1094 -C "client hello, adding max_fragment_length extension" \
1095 -S "found max fragment length extension" \
1096 -S "server hello, max_fragment_length extension" \
1097 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001099requires_gnutls
1100run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001101 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001102 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001103 0 \
1104 -c "client hello, adding max_fragment_length extension" \
1105 -c "found max_fragment_length extension"
1106
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001107run_test "Max fragment length: client, message just fits" \
1108 "$P_SRV debug_level=3" \
1109 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1110 0 \
1111 -c "client hello, adding max_fragment_length extension" \
1112 -s "found max fragment length extension" \
1113 -s "server hello, max_fragment_length extension" \
1114 -c "found max_fragment_length extension" \
1115 -c "2048 bytes written in 1 fragments" \
1116 -s "2048 bytes read"
1117
1118run_test "Max fragment length: client, larger message" \
1119 "$P_SRV debug_level=3" \
1120 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1121 0 \
1122 -c "client hello, adding max_fragment_length extension" \
1123 -s "found max fragment length extension" \
1124 -s "server hello, max_fragment_length extension" \
1125 -c "found max_fragment_length extension" \
1126 -c "2345 bytes written in 2 fragments" \
1127 -s "2048 bytes read" \
1128 -s "297 bytes read"
1129
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001130run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001131 "$P_SRV debug_level=3 dtls=1" \
1132 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1133 1 \
1134 -c "client hello, adding max_fragment_length extension" \
1135 -s "found max fragment length extension" \
1136 -s "server hello, max_fragment_length extension" \
1137 -c "found max_fragment_length extension" \
1138 -c "fragment larger than.*maximum"
1139
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001140# Tests for renegotiation
1141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001143 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001144 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001145 0 \
1146 -C "client hello, adding renegotiation extension" \
1147 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1148 -S "found renegotiation extension" \
1149 -s "server hello, secure renegotiation extension" \
1150 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001151 -C "=> renegotiate" \
1152 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001153 -S "write hello request"
1154
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001155run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001156 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001157 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001158 0 \
1159 -c "client hello, adding renegotiation extension" \
1160 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1161 -s "found renegotiation extension" \
1162 -s "server hello, secure renegotiation extension" \
1163 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001164 -c "=> renegotiate" \
1165 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001166 -S "write hello request"
1167
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001168run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001169 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001170 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001171 0 \
1172 -c "client hello, adding renegotiation extension" \
1173 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1174 -s "found renegotiation extension" \
1175 -s "server hello, secure renegotiation extension" \
1176 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001177 -c "=> renegotiate" \
1178 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001179 -s "write hello request"
1180
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001181run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001182 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001183 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001184 0 \
1185 -c "client hello, adding renegotiation extension" \
1186 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1187 -s "found renegotiation extension" \
1188 -s "server hello, secure renegotiation extension" \
1189 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001190 -c "=> renegotiate" \
1191 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001192 -s "write hello request"
1193
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001194run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001195 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001196 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001197 1 \
1198 -c "client hello, adding renegotiation extension" \
1199 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1200 -S "found renegotiation extension" \
1201 -s "server hello, secure renegotiation extension" \
1202 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001203 -c "=> renegotiate" \
1204 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001205 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001206 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001207 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001208
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001209run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001210 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001211 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001212 0 \
1213 -C "client hello, adding renegotiation extension" \
1214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1215 -S "found renegotiation extension" \
1216 -s "server hello, secure renegotiation extension" \
1217 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001218 -C "=> renegotiate" \
1219 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001220 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001221 -S "SSL - An unexpected message was received from our peer" \
1222 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001223
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001224run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001225 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001226 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001227 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001228 0 \
1229 -C "client hello, adding renegotiation extension" \
1230 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1231 -S "found renegotiation extension" \
1232 -s "server hello, secure renegotiation extension" \
1233 -c "found renegotiation extension" \
1234 -C "=> renegotiate" \
1235 -S "=> renegotiate" \
1236 -s "write hello request" \
1237 -S "SSL - An unexpected message was received from our peer" \
1238 -S "failed"
1239
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001240# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001241run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001242 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001243 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001245 0 \
1246 -C "client hello, adding renegotiation extension" \
1247 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1248 -S "found renegotiation extension" \
1249 -s "server hello, secure renegotiation extension" \
1250 -c "found renegotiation extension" \
1251 -C "=> renegotiate" \
1252 -S "=> renegotiate" \
1253 -s "write hello request" \
1254 -S "SSL - An unexpected message was received from our peer" \
1255 -S "failed"
1256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001257run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001258 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001259 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001260 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001261 0 \
1262 -C "client hello, adding renegotiation extension" \
1263 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1264 -S "found renegotiation extension" \
1265 -s "server hello, secure renegotiation extension" \
1266 -c "found renegotiation extension" \
1267 -C "=> renegotiate" \
1268 -S "=> renegotiate" \
1269 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001270 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001271
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001272run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001273 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001274 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001276 0 \
1277 -c "client hello, adding renegotiation extension" \
1278 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1279 -s "found renegotiation extension" \
1280 -s "server hello, secure renegotiation extension" \
1281 -c "found renegotiation extension" \
1282 -c "=> renegotiate" \
1283 -s "=> renegotiate" \
1284 -s "write hello request" \
1285 -S "SSL - An unexpected message was received from our peer" \
1286 -S "failed"
1287
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001288run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001289 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001290 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1291 0 \
1292 -C "client hello, adding renegotiation extension" \
1293 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1294 -S "found renegotiation extension" \
1295 -s "server hello, secure renegotiation extension" \
1296 -c "found renegotiation extension" \
1297 -S "record counter limit reached: renegotiate" \
1298 -C "=> renegotiate" \
1299 -S "=> renegotiate" \
1300 -S "write hello request" \
1301 -S "SSL - An unexpected message was received from our peer" \
1302 -S "failed"
1303
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001304# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001305run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001306 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001307 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001308 0 \
1309 -c "client hello, adding renegotiation extension" \
1310 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1311 -s "found renegotiation extension" \
1312 -s "server hello, secure renegotiation extension" \
1313 -c "found renegotiation extension" \
1314 -s "record counter limit reached: renegotiate" \
1315 -c "=> renegotiate" \
1316 -s "=> renegotiate" \
1317 -s "write hello request" \
1318 -S "SSL - An unexpected message was received from our peer" \
1319 -S "failed"
1320
1321run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001322 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001323 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001324 0 \
1325 -c "client hello, adding renegotiation extension" \
1326 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1327 -s "found renegotiation extension" \
1328 -s "server hello, secure renegotiation extension" \
1329 -c "found renegotiation extension" \
1330 -s "record counter limit reached: renegotiate" \
1331 -c "=> renegotiate" \
1332 -s "=> renegotiate" \
1333 -s "write hello request" \
1334 -S "SSL - An unexpected message was received from our peer" \
1335 -S "failed"
1336
1337run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001338 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001339 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1340 0 \
1341 -C "client hello, adding renegotiation extension" \
1342 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1343 -S "found renegotiation extension" \
1344 -s "server hello, secure renegotiation extension" \
1345 -c "found renegotiation extension" \
1346 -S "record counter limit reached: renegotiate" \
1347 -C "=> renegotiate" \
1348 -S "=> renegotiate" \
1349 -S "write hello request" \
1350 -S "SSL - An unexpected message was received from our peer" \
1351 -S "failed"
1352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001353run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001354 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001355 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001356 0 \
1357 -c "client hello, adding renegotiation extension" \
1358 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1359 -s "found renegotiation extension" \
1360 -s "server hello, secure renegotiation extension" \
1361 -c "found renegotiation extension" \
1362 -c "=> renegotiate" \
1363 -s "=> renegotiate" \
1364 -S "write hello request"
1365
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001366run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001367 "$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 +02001368 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001369 0 \
1370 -c "client hello, adding renegotiation extension" \
1371 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1372 -s "found renegotiation extension" \
1373 -s "server hello, secure renegotiation extension" \
1374 -c "found renegotiation extension" \
1375 -c "=> renegotiate" \
1376 -s "=> renegotiate" \
1377 -s "write hello request"
1378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001379run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001380 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001382 0 \
1383 -c "client hello, adding renegotiation extension" \
1384 -c "found renegotiation extension" \
1385 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001386 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001387 -C "error" \
1388 -c "HTTP/1.0 200 [Oo][Kk]"
1389
Paul Bakker539d9722015-02-08 16:18:35 +01001390requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001391run_test "Renegotiation: gnutls server strict, client-initiated" \
1392 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001393 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001394 0 \
1395 -c "client hello, adding renegotiation extension" \
1396 -c "found renegotiation extension" \
1397 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001398 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001399 -C "error" \
1400 -c "HTTP/1.0 200 [Oo][Kk]"
1401
Paul Bakker539d9722015-02-08 16:18:35 +01001402requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001403run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1404 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1405 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1406 1 \
1407 -c "client hello, adding renegotiation extension" \
1408 -C "found renegotiation extension" \
1409 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001410 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001411 -c "error" \
1412 -C "HTTP/1.0 200 [Oo][Kk]"
1413
Paul Bakker539d9722015-02-08 16:18:35 +01001414requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001415run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1416 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1417 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1418 allow_legacy=0" \
1419 1 \
1420 -c "client hello, adding renegotiation extension" \
1421 -C "found renegotiation extension" \
1422 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001423 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001424 -c "error" \
1425 -C "HTTP/1.0 200 [Oo][Kk]"
1426
Paul Bakker539d9722015-02-08 16:18:35 +01001427requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001428run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1429 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1430 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1431 allow_legacy=1" \
1432 0 \
1433 -c "client hello, adding renegotiation extension" \
1434 -C "found renegotiation extension" \
1435 -c "=> renegotiate" \
1436 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001437 -C "error" \
1438 -c "HTTP/1.0 200 [Oo][Kk]"
1439
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001440run_test "Renegotiation: DTLS, client-initiated" \
1441 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1442 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1443 0 \
1444 -c "client hello, adding renegotiation extension" \
1445 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1446 -s "found renegotiation extension" \
1447 -s "server hello, secure renegotiation extension" \
1448 -c "found renegotiation extension" \
1449 -c "=> renegotiate" \
1450 -s "=> renegotiate" \
1451 -S "write hello request"
1452
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001453run_test "Renegotiation: DTLS, server-initiated" \
1454 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001455 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1456 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001457 0 \
1458 -c "client hello, adding renegotiation extension" \
1459 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1460 -s "found renegotiation extension" \
1461 -s "server hello, secure renegotiation extension" \
1462 -c "found renegotiation extension" \
1463 -c "=> renegotiate" \
1464 -s "=> renegotiate" \
1465 -s "write hello request"
1466
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001467requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001468run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1469 "$G_SRV -u --mtu 4096" \
1470 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1471 0 \
1472 -c "client hello, adding renegotiation extension" \
1473 -c "found renegotiation extension" \
1474 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001475 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001476 -C "error" \
1477 -s "Extra-header:"
1478
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001479# Test for the "secure renegotation" extension only (no actual renegotiation)
1480
Paul Bakker539d9722015-02-08 16:18:35 +01001481requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001482run_test "Renego ext: gnutls server strict, client default" \
1483 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1484 "$P_CLI debug_level=3" \
1485 0 \
1486 -c "found renegotiation extension" \
1487 -C "error" \
1488 -c "HTTP/1.0 200 [Oo][Kk]"
1489
Paul Bakker539d9722015-02-08 16:18:35 +01001490requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001491run_test "Renego ext: gnutls server unsafe, client default" \
1492 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1493 "$P_CLI debug_level=3" \
1494 0 \
1495 -C "found renegotiation extension" \
1496 -C "error" \
1497 -c "HTTP/1.0 200 [Oo][Kk]"
1498
Paul Bakker539d9722015-02-08 16:18:35 +01001499requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001500run_test "Renego ext: gnutls server unsafe, client break legacy" \
1501 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1502 "$P_CLI debug_level=3 allow_legacy=-1" \
1503 1 \
1504 -C "found renegotiation extension" \
1505 -c "error" \
1506 -C "HTTP/1.0 200 [Oo][Kk]"
1507
Paul Bakker539d9722015-02-08 16:18:35 +01001508requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001509run_test "Renego ext: gnutls client strict, server default" \
1510 "$P_SRV debug_level=3" \
1511 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1512 0 \
1513 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1514 -s "server hello, secure renegotiation extension"
1515
Paul Bakker539d9722015-02-08 16:18:35 +01001516requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001517run_test "Renego ext: gnutls client unsafe, server default" \
1518 "$P_SRV debug_level=3" \
1519 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1520 0 \
1521 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1522 -S "server hello, secure renegotiation extension"
1523
Paul Bakker539d9722015-02-08 16:18:35 +01001524requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001525run_test "Renego ext: gnutls client unsafe, server break legacy" \
1526 "$P_SRV debug_level=3 allow_legacy=-1" \
1527 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1528 1 \
1529 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1530 -S "server hello, secure renegotiation extension"
1531
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001532# Tests for auth_mode
1533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001534run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001535 "$P_SRV crt_file=data_files/server5-badsign.crt \
1536 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001537 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001538 1 \
1539 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001540 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001541 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001542 -c "X509 - Certificate verification failed"
1543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001544run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001545 "$P_SRV crt_file=data_files/server5-badsign.crt \
1546 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001547 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001548 0 \
1549 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001550 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001551 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001552 -C "X509 - Certificate verification failed"
1553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001554run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001555 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001556 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001557 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001558 0 \
1559 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001560 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001561 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001562 -C "X509 - Certificate verification failed"
1563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_SRV debug_level=3 auth_mode=required" \
1566 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001567 key_file=data_files/server5.key" \
1568 1 \
1569 -S "skip write certificate request" \
1570 -C "skip parse certificate request" \
1571 -c "got a certificate request" \
1572 -C "skip write certificate" \
1573 -C "skip write certificate verify" \
1574 -S "skip parse certificate verify" \
1575 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001576 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001577 -s "! mbedtls_ssl_handshake returned" \
1578 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001579 -s "X509 - Certificate verification failed"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001582 "$P_SRV debug_level=3 auth_mode=optional" \
1583 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001584 key_file=data_files/server5.key" \
1585 0 \
1586 -S "skip write certificate request" \
1587 -C "skip parse certificate request" \
1588 -c "got a certificate request" \
1589 -C "skip write certificate" \
1590 -C "skip write certificate verify" \
1591 -S "skip parse certificate verify" \
1592 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001593 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001594 -S "! mbedtls_ssl_handshake returned" \
1595 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001596 -S "X509 - Certificate verification failed"
1597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001598run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001599 "$P_SRV debug_level=3 auth_mode=none" \
1600 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001601 key_file=data_files/server5.key" \
1602 0 \
1603 -s "skip write certificate request" \
1604 -C "skip parse certificate request" \
1605 -c "got no certificate request" \
1606 -c "skip write certificate" \
1607 -c "skip write certificate verify" \
1608 -s "skip parse certificate verify" \
1609 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001610 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001611 -S "! mbedtls_ssl_handshake returned" \
1612 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001613 -S "X509 - Certificate verification failed"
1614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001615run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001616 "$P_SRV debug_level=3 auth_mode=optional" \
1617 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001618 0 \
1619 -S "skip write certificate request" \
1620 -C "skip parse certificate request" \
1621 -c "got a certificate request" \
1622 -C "skip write certificate$" \
1623 -C "got no certificate to send" \
1624 -S "SSLv3 client has no certificate" \
1625 -c "skip write certificate verify" \
1626 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001627 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001628 -S "! mbedtls_ssl_handshake returned" \
1629 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001630 -S "X509 - Certificate verification failed"
1631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001633 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001634 "$O_CLI" \
1635 0 \
1636 -S "skip write certificate request" \
1637 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001638 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001639 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001640 -S "X509 - Certificate verification failed"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001643 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001644 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001645 0 \
1646 -C "skip parse certificate request" \
1647 -c "got a certificate request" \
1648 -C "skip write certificate$" \
1649 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001650 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001652run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001653 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001654 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001655 0 \
1656 -S "skip write certificate request" \
1657 -C "skip parse certificate request" \
1658 -c "got a certificate request" \
1659 -C "skip write certificate$" \
1660 -c "skip write certificate verify" \
1661 -c "got no certificate to send" \
1662 -s "SSLv3 client has no certificate" \
1663 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001664 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001665 -S "! mbedtls_ssl_handshake returned" \
1666 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001667 -S "X509 - Certificate verification failed"
1668
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001669# Tests for certificate selection based on SHA verson
1670
1671run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1672 "$P_SRV crt_file=data_files/server5.crt \
1673 key_file=data_files/server5.key \
1674 crt_file2=data_files/server5-sha1.crt \
1675 key_file2=data_files/server5.key" \
1676 "$P_CLI force_version=tls1_2" \
1677 0 \
1678 -c "signed using.*ECDSA with SHA256" \
1679 -C "signed using.*ECDSA with SHA1"
1680
1681run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1682 "$P_SRV crt_file=data_files/server5.crt \
1683 key_file=data_files/server5.key \
1684 crt_file2=data_files/server5-sha1.crt \
1685 key_file2=data_files/server5.key" \
1686 "$P_CLI force_version=tls1_1" \
1687 0 \
1688 -C "signed using.*ECDSA with SHA256" \
1689 -c "signed using.*ECDSA with SHA1"
1690
1691run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1692 "$P_SRV crt_file=data_files/server5.crt \
1693 key_file=data_files/server5.key \
1694 crt_file2=data_files/server5-sha1.crt \
1695 key_file2=data_files/server5.key" \
1696 "$P_CLI force_version=tls1" \
1697 0 \
1698 -C "signed using.*ECDSA with SHA256" \
1699 -c "signed using.*ECDSA with SHA1"
1700
1701run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1702 "$P_SRV crt_file=data_files/server5.crt \
1703 key_file=data_files/server5.key \
1704 crt_file2=data_files/server6.crt \
1705 key_file2=data_files/server6.key" \
1706 "$P_CLI force_version=tls1_1" \
1707 0 \
1708 -c "serial number.*09" \
1709 -c "signed using.*ECDSA with SHA256" \
1710 -C "signed using.*ECDSA with SHA1"
1711
1712run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1713 "$P_SRV crt_file=data_files/server6.crt \
1714 key_file=data_files/server6.key \
1715 crt_file2=data_files/server5.crt \
1716 key_file2=data_files/server5.key" \
1717 "$P_CLI force_version=tls1_1" \
1718 0 \
1719 -c "serial number.*0A" \
1720 -c "signed using.*ECDSA with SHA256" \
1721 -C "signed using.*ECDSA with SHA1"
1722
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001723# tests for SNI
1724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001725run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001726 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001727 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001728 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001729 0 \
1730 -S "parse ServerName extension" \
1731 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1732 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001734run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001735 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001736 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001737 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 +02001738 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001739 0 \
1740 -s "parse ServerName extension" \
1741 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1742 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001745 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001746 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001747 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 +02001748 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001749 0 \
1750 -s "parse ServerName extension" \
1751 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1752 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001754run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001755 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001756 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001757 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 +02001758 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001759 1 \
1760 -s "parse ServerName extension" \
1761 -s "ssl_sni_wrapper() returned" \
1762 -s "mbedtls_ssl_handshake returned" \
1763 -c "mbedtls_ssl_handshake returned" \
1764 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001765
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001766run_test "SNI: client auth no override: optional" \
1767 "$P_SRV debug_level=3 auth_mode=optional \
1768 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1769 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1770 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001771 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001772 -S "skip write certificate request" \
1773 -C "skip parse certificate request" \
1774 -c "got a certificate request" \
1775 -C "skip write certificate" \
1776 -C "skip write certificate verify" \
1777 -S "skip parse certificate verify"
1778
1779run_test "SNI: client auth override: none -> optional" \
1780 "$P_SRV debug_level=3 auth_mode=none \
1781 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1782 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1783 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001784 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001785 -S "skip write certificate request" \
1786 -C "skip parse certificate request" \
1787 -c "got a certificate request" \
1788 -C "skip write certificate" \
1789 -C "skip write certificate verify" \
1790 -S "skip parse certificate verify"
1791
1792run_test "SNI: client auth override: optional -> none" \
1793 "$P_SRV debug_level=3 auth_mode=optional \
1794 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1795 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1796 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001797 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001798 -s "skip write certificate request" \
1799 -C "skip parse certificate request" \
1800 -c "got no certificate request" \
1801 -c "skip write certificate" \
1802 -c "skip write certificate verify" \
1803 -s "skip parse certificate verify"
1804
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001805run_test "SNI: CA no override" \
1806 "$P_SRV debug_level=3 auth_mode=optional \
1807 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1808 ca_file=data_files/test-ca.crt \
1809 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1810 "$P_CLI debug_level=3 server_name=localhost \
1811 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1812 1 \
1813 -S "skip write certificate request" \
1814 -C "skip parse certificate request" \
1815 -c "got a certificate request" \
1816 -C "skip write certificate" \
1817 -C "skip write certificate verify" \
1818 -S "skip parse certificate verify" \
1819 -s "x509_verify_cert() returned" \
1820 -s "! The certificate is not correctly signed by the trusted CA" \
1821 -S "The certificate has been revoked (is on a CRL)"
1822
1823run_test "SNI: CA override" \
1824 "$P_SRV debug_level=3 auth_mode=optional \
1825 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1826 ca_file=data_files/test-ca.crt \
1827 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1828 "$P_CLI debug_level=3 server_name=localhost \
1829 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1830 0 \
1831 -S "skip write certificate request" \
1832 -C "skip parse certificate request" \
1833 -c "got a certificate request" \
1834 -C "skip write certificate" \
1835 -C "skip write certificate verify" \
1836 -S "skip parse certificate verify" \
1837 -S "x509_verify_cert() returned" \
1838 -S "! The certificate is not correctly signed by the trusted CA" \
1839 -S "The certificate has been revoked (is on a CRL)"
1840
1841run_test "SNI: CA override with CRL" \
1842 "$P_SRV debug_level=3 auth_mode=optional \
1843 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1844 ca_file=data_files/test-ca.crt \
1845 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1846 "$P_CLI debug_level=3 server_name=localhost \
1847 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1848 1 \
1849 -S "skip write certificate request" \
1850 -C "skip parse certificate request" \
1851 -c "got a certificate request" \
1852 -C "skip write certificate" \
1853 -C "skip write certificate verify" \
1854 -S "skip parse certificate verify" \
1855 -s "x509_verify_cert() returned" \
1856 -S "! The certificate is not correctly signed by the trusted CA" \
1857 -s "The certificate has been revoked (is on a CRL)"
1858
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001859# Tests for non-blocking I/O: exercise a variety of handshake flows
1860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001861run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001862 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1863 "$P_CLI nbio=2 tickets=0" \
1864 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001865 -S "mbedtls_ssl_handshake returned" \
1866 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001867 -c "Read from server: .* bytes read"
1868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001869run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001870 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1871 "$P_CLI nbio=2 tickets=0" \
1872 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001873 -S "mbedtls_ssl_handshake returned" \
1874 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001875 -c "Read from server: .* bytes read"
1876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001877run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001878 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1879 "$P_CLI nbio=2 tickets=1" \
1880 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001881 -S "mbedtls_ssl_handshake returned" \
1882 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001883 -c "Read from server: .* bytes read"
1884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001885run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001886 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1887 "$P_CLI nbio=2 tickets=1" \
1888 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001889 -S "mbedtls_ssl_handshake returned" \
1890 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001891 -c "Read from server: .* bytes read"
1892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001894 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1895 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1896 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001897 -S "mbedtls_ssl_handshake returned" \
1898 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001899 -c "Read from server: .* bytes read"
1900
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001901run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001902 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1903 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1904 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001905 -S "mbedtls_ssl_handshake returned" \
1906 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001907 -c "Read from server: .* bytes read"
1908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001909run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001910 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1911 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1912 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001913 -S "mbedtls_ssl_handshake returned" \
1914 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001915 -c "Read from server: .* bytes read"
1916
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001917# Tests for version negotiation
1918
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001919run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001920 "$P_SRV" \
1921 "$P_CLI" \
1922 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001923 -S "mbedtls_ssl_handshake returned" \
1924 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001925 -s "Protocol is TLSv1.2" \
1926 -c "Protocol is TLSv1.2"
1927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001928run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001929 "$P_SRV" \
1930 "$P_CLI max_version=tls1_1" \
1931 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001932 -S "mbedtls_ssl_handshake returned" \
1933 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001934 -s "Protocol is TLSv1.1" \
1935 -c "Protocol is TLSv1.1"
1936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001937run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001938 "$P_SRV max_version=tls1_1" \
1939 "$P_CLI" \
1940 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001941 -S "mbedtls_ssl_handshake returned" \
1942 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001943 -s "Protocol is TLSv1.1" \
1944 -c "Protocol is TLSv1.1"
1945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001946run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001947 "$P_SRV max_version=tls1_1" \
1948 "$P_CLI max_version=tls1_1" \
1949 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001950 -S "mbedtls_ssl_handshake returned" \
1951 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001952 -s "Protocol is TLSv1.1" \
1953 -c "Protocol is TLSv1.1"
1954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001955run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001956 "$P_SRV min_version=tls1_1" \
1957 "$P_CLI max_version=tls1_1" \
1958 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001959 -S "mbedtls_ssl_handshake returned" \
1960 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001961 -s "Protocol is TLSv1.1" \
1962 -c "Protocol is TLSv1.1"
1963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001964run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001965 "$P_SRV max_version=tls1_1" \
1966 "$P_CLI min_version=tls1_1" \
1967 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001968 -S "mbedtls_ssl_handshake returned" \
1969 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001970 -s "Protocol is TLSv1.1" \
1971 -c "Protocol is TLSv1.1"
1972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001973run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001974 "$P_SRV max_version=tls1_1" \
1975 "$P_CLI min_version=tls1_2" \
1976 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001977 -s "mbedtls_ssl_handshake returned" \
1978 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001979 -c "SSL - Handshake protocol not within min/max boundaries"
1980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001981run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001982 "$P_SRV min_version=tls1_2" \
1983 "$P_CLI max_version=tls1_1" \
1984 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001985 -s "mbedtls_ssl_handshake returned" \
1986 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001987 -s "SSL - Handshake protocol not within min/max boundaries"
1988
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001989# Tests for ALPN extension
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001992 "$P_SRV debug_level=3" \
1993 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001994 0 \
1995 -C "client hello, adding alpn extension" \
1996 -S "found alpn extension" \
1997 -C "got an alert message, type: \\[2:120]" \
1998 -S "server hello, adding alpn extension" \
1999 -C "found alpn extension " \
2000 -C "Application Layer Protocol is" \
2001 -S "Application Layer Protocol is"
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002004 "$P_SRV debug_level=3" \
2005 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002006 0 \
2007 -c "client hello, adding alpn extension" \
2008 -s "found alpn extension" \
2009 -C "got an alert message, type: \\[2:120]" \
2010 -S "server hello, adding alpn extension" \
2011 -C "found alpn extension " \
2012 -c "Application Layer Protocol is (none)" \
2013 -S "Application Layer Protocol is"
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002016 "$P_SRV debug_level=3 alpn=abc,1234" \
2017 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002018 0 \
2019 -C "client hello, adding alpn extension" \
2020 -S "found alpn extension" \
2021 -C "got an alert message, type: \\[2:120]" \
2022 -S "server hello, adding alpn extension" \
2023 -C "found alpn extension " \
2024 -C "Application Layer Protocol is" \
2025 -s "Application Layer Protocol is (none)"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002028 "$P_SRV debug_level=3 alpn=abc,1234" \
2029 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002030 0 \
2031 -c "client hello, adding alpn extension" \
2032 -s "found alpn extension" \
2033 -C "got an alert message, type: \\[2:120]" \
2034 -s "server hello, adding alpn extension" \
2035 -c "found alpn extension" \
2036 -c "Application Layer Protocol is abc" \
2037 -s "Application Layer Protocol is abc"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002040 "$P_SRV debug_level=3 alpn=abc,1234" \
2041 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002042 0 \
2043 -c "client hello, adding alpn extension" \
2044 -s "found alpn extension" \
2045 -C "got an alert message, type: \\[2:120]" \
2046 -s "server hello, adding alpn extension" \
2047 -c "found alpn extension" \
2048 -c "Application Layer Protocol is abc" \
2049 -s "Application Layer Protocol is abc"
2050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002052 "$P_SRV debug_level=3 alpn=abc,1234" \
2053 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002054 0 \
2055 -c "client hello, adding alpn extension" \
2056 -s "found alpn extension" \
2057 -C "got an alert message, type: \\[2:120]" \
2058 -s "server hello, adding alpn extension" \
2059 -c "found alpn extension" \
2060 -c "Application Layer Protocol is 1234" \
2061 -s "Application Layer Protocol is 1234"
2062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002064 "$P_SRV debug_level=3 alpn=abc,123" \
2065 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002066 1 \
2067 -c "client hello, adding alpn extension" \
2068 -s "found alpn extension" \
2069 -c "got an alert message, type: \\[2:120]" \
2070 -S "server hello, adding alpn extension" \
2071 -C "found alpn extension" \
2072 -C "Application Layer Protocol is 1234" \
2073 -S "Application Layer Protocol is 1234"
2074
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002075
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002076# Tests for keyUsage in leaf certificates, part 1:
2077# server-side certificate/suite selection
2078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002080 "$P_SRV key_file=data_files/server2.key \
2081 crt_file=data_files/server2.ku-ds.crt" \
2082 "$P_CLI" \
2083 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002084 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002085
2086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002087run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002088 "$P_SRV key_file=data_files/server2.key \
2089 crt_file=data_files/server2.ku-ke.crt" \
2090 "$P_CLI" \
2091 0 \
2092 -c "Ciphersuite is TLS-RSA-WITH-"
2093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002094run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002095 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002096 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002097 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002098 1 \
2099 -C "Ciphersuite is "
2100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002102 "$P_SRV key_file=data_files/server5.key \
2103 crt_file=data_files/server5.ku-ds.crt" \
2104 "$P_CLI" \
2105 0 \
2106 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2107
2108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002110 "$P_SRV key_file=data_files/server5.key \
2111 crt_file=data_files/server5.ku-ka.crt" \
2112 "$P_CLI" \
2113 0 \
2114 -c "Ciphersuite is TLS-ECDH-"
2115
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002116run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002117 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002118 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002119 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002120 1 \
2121 -C "Ciphersuite is "
2122
2123# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002124# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002126run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002127 "$O_SRV -key data_files/server2.key \
2128 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002129 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002130 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2131 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002132 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002133 -C "Processing of the Certificate handshake message failed" \
2134 -c "Ciphersuite is TLS-"
2135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002136run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002137 "$O_SRV -key data_files/server2.key \
2138 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002139 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002140 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2141 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002142 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002143 -C "Processing of the Certificate handshake message failed" \
2144 -c "Ciphersuite is TLS-"
2145
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002146run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002147 "$O_SRV -key data_files/server2.key \
2148 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002149 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002150 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2151 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002152 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002153 -C "Processing of the Certificate handshake message failed" \
2154 -c "Ciphersuite is TLS-"
2155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002157 "$O_SRV -key data_files/server2.key \
2158 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002159 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002160 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2161 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002162 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002163 -c "Processing of the Certificate handshake message failed" \
2164 -C "Ciphersuite is TLS-"
2165
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002166run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2167 "$O_SRV -key data_files/server2.key \
2168 -cert data_files/server2.ku-ke.crt" \
2169 "$P_CLI debug_level=1 auth_mode=optional \
2170 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2171 0 \
2172 -c "bad certificate (usage extensions)" \
2173 -C "Processing of the Certificate handshake message failed" \
2174 -c "Ciphersuite is TLS-" \
2175 -c "! Usage does not match the keyUsage extension"
2176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002178 "$O_SRV -key data_files/server2.key \
2179 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002181 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2182 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002183 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002184 -C "Processing of the Certificate handshake message failed" \
2185 -c "Ciphersuite is TLS-"
2186
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002187run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002188 "$O_SRV -key data_files/server2.key \
2189 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002190 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002191 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2192 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002193 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002194 -c "Processing of the Certificate handshake message failed" \
2195 -C "Ciphersuite is TLS-"
2196
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002197run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2198 "$O_SRV -key data_files/server2.key \
2199 -cert data_files/server2.ku-ds.crt" \
2200 "$P_CLI debug_level=1 auth_mode=optional \
2201 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2202 0 \
2203 -c "bad certificate (usage extensions)" \
2204 -C "Processing of the Certificate handshake message failed" \
2205 -c "Ciphersuite is TLS-" \
2206 -c "! Usage does not match the keyUsage extension"
2207
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002208# Tests for keyUsage in leaf certificates, part 3:
2209# server-side checking of client cert
2210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002212 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002213 "$O_CLI -key data_files/server2.key \
2214 -cert data_files/server2.ku-ds.crt" \
2215 0 \
2216 -S "bad certificate (usage extensions)" \
2217 -S "Processing of the Certificate handshake message failed"
2218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002219run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002220 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002221 "$O_CLI -key data_files/server2.key \
2222 -cert data_files/server2.ku-ke.crt" \
2223 0 \
2224 -s "bad certificate (usage extensions)" \
2225 -S "Processing of the Certificate handshake message failed"
2226
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002228 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002229 "$O_CLI -key data_files/server2.key \
2230 -cert data_files/server2.ku-ke.crt" \
2231 1 \
2232 -s "bad certificate (usage extensions)" \
2233 -s "Processing of the Certificate handshake message failed"
2234
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002235run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002236 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002237 "$O_CLI -key data_files/server5.key \
2238 -cert data_files/server5.ku-ds.crt" \
2239 0 \
2240 -S "bad certificate (usage extensions)" \
2241 -S "Processing of the Certificate handshake message failed"
2242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002244 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002245 "$O_CLI -key data_files/server5.key \
2246 -cert data_files/server5.ku-ka.crt" \
2247 0 \
2248 -s "bad certificate (usage extensions)" \
2249 -S "Processing of the Certificate handshake message failed"
2250
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002251# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002254 "$P_SRV key_file=data_files/server5.key \
2255 crt_file=data_files/server5.eku-srv.crt" \
2256 "$P_CLI" \
2257 0
2258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002260 "$P_SRV key_file=data_files/server5.key \
2261 crt_file=data_files/server5.eku-srv.crt" \
2262 "$P_CLI" \
2263 0
2264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002265run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002266 "$P_SRV key_file=data_files/server5.key \
2267 crt_file=data_files/server5.eku-cs_any.crt" \
2268 "$P_CLI" \
2269 0
2270
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002271run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002272 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002273 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002274 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002275 1
2276
2277# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2278
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002279run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002280 "$O_SRV -key data_files/server5.key \
2281 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002282 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002283 0 \
2284 -C "bad certificate (usage extensions)" \
2285 -C "Processing of the Certificate handshake message failed" \
2286 -c "Ciphersuite is TLS-"
2287
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002288run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002289 "$O_SRV -key data_files/server5.key \
2290 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002291 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002292 0 \
2293 -C "bad certificate (usage extensions)" \
2294 -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 "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002298 "$O_SRV -key data_files/server5.key \
2299 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002300 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002301 0 \
2302 -C "bad certificate (usage extensions)" \
2303 -C "Processing of the Certificate handshake message failed" \
2304 -c "Ciphersuite is TLS-"
2305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002307 "$O_SRV -key data_files/server5.key \
2308 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002309 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002310 1 \
2311 -c "bad certificate (usage extensions)" \
2312 -c "Processing of the Certificate handshake message failed" \
2313 -C "Ciphersuite is TLS-"
2314
2315# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002317run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002318 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002319 "$O_CLI -key data_files/server5.key \
2320 -cert data_files/server5.eku-cli.crt" \
2321 0 \
2322 -S "bad certificate (usage extensions)" \
2323 -S "Processing of the Certificate handshake message failed"
2324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002325run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002326 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002327 "$O_CLI -key data_files/server5.key \
2328 -cert data_files/server5.eku-srv_cli.crt" \
2329 0 \
2330 -S "bad certificate (usage extensions)" \
2331 -S "Processing of the Certificate handshake message failed"
2332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002333run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002334 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002335 "$O_CLI -key data_files/server5.key \
2336 -cert data_files/server5.eku-cs_any.crt" \
2337 0 \
2338 -S "bad certificate (usage extensions)" \
2339 -S "Processing of the Certificate handshake message failed"
2340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002341run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002342 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002343 "$O_CLI -key data_files/server5.key \
2344 -cert data_files/server5.eku-cs.crt" \
2345 0 \
2346 -s "bad certificate (usage extensions)" \
2347 -S "Processing of the Certificate handshake message failed"
2348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002349run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002350 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002351 "$O_CLI -key data_files/server5.key \
2352 -cert data_files/server5.eku-cs.crt" \
2353 1 \
2354 -s "bad certificate (usage extensions)" \
2355 -s "Processing of the Certificate handshake message failed"
2356
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002357# Tests for DHM parameters loading
2358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002359run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002360 "$P_SRV" \
2361 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2362 debug_level=3" \
2363 0 \
2364 -c "value of 'DHM: P ' (2048 bits)" \
2365 -c "value of 'DHM: G ' (2048 bits)"
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002368 "$P_SRV dhm_file=data_files/dhparams.pem" \
2369 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2370 debug_level=3" \
2371 0 \
2372 -c "value of 'DHM: P ' (1024 bits)" \
2373 -c "value of 'DHM: G ' (2 bits)"
2374
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002375# Tests for DHM client-side size checking
2376
2377run_test "DHM size: server default, client default, OK" \
2378 "$P_SRV" \
2379 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2380 debug_level=1" \
2381 0 \
2382 -C "DHM prime too short:"
2383
2384run_test "DHM size: server default, client 2048, OK" \
2385 "$P_SRV" \
2386 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2387 debug_level=1 dhmlen=2048" \
2388 0 \
2389 -C "DHM prime too short:"
2390
2391run_test "DHM size: server 1024, client default, OK" \
2392 "$P_SRV dhm_file=data_files/dhparams.pem" \
2393 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2394 debug_level=1" \
2395 0 \
2396 -C "DHM prime too short:"
2397
2398run_test "DHM size: server 1000, client default, rejected" \
2399 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2400 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2401 debug_level=1" \
2402 1 \
2403 -c "DHM prime too short:"
2404
2405run_test "DHM size: server default, client 2049, rejected" \
2406 "$P_SRV" \
2407 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2408 debug_level=1 dhmlen=2049" \
2409 1 \
2410 -c "DHM prime too short:"
2411
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002412# Tests for PSK callback
2413
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002414run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002415 "$P_SRV psk=abc123 psk_identity=foo" \
2416 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2417 psk_identity=foo psk=abc123" \
2418 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002419 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002420 -S "SSL - Unknown identity received" \
2421 -S "SSL - Verification of the message MAC failed"
2422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002423run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002424 "$P_SRV" \
2425 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2426 psk_identity=foo psk=abc123" \
2427 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002428 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002429 -S "SSL - Unknown identity received" \
2430 -S "SSL - Verification of the message MAC failed"
2431
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002432run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002433 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2434 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2435 psk_identity=foo psk=abc123" \
2436 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002437 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002438 -s "SSL - Unknown identity received" \
2439 -S "SSL - Verification of the message MAC failed"
2440
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002441run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002442 "$P_SRV psk_list=abc,dead,def,beef" \
2443 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2444 psk_identity=abc psk=dead" \
2445 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002446 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002447 -S "SSL - Unknown identity received" \
2448 -S "SSL - Verification of the message MAC failed"
2449
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002450run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002451 "$P_SRV psk_list=abc,dead,def,beef" \
2452 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2453 psk_identity=def psk=beef" \
2454 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002455 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002456 -S "SSL - Unknown identity received" \
2457 -S "SSL - Verification of the message MAC failed"
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002460 "$P_SRV psk_list=abc,dead,def,beef" \
2461 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2462 psk_identity=ghi psk=beef" \
2463 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002464 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002465 -s "SSL - Unknown identity received" \
2466 -S "SSL - Verification of the message MAC failed"
2467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002468run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002469 "$P_SRV psk_list=abc,dead,def,beef" \
2470 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2471 psk_identity=abc psk=beef" \
2472 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002473 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002474 -S "SSL - Unknown identity received" \
2475 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002476
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002477# Tests for ciphersuites per version
2478
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002479run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002480 "$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 +02002481 "$P_CLI force_version=ssl3" \
2482 0 \
2483 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002485run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002486 "$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 +01002487 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002488 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002489 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002491run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002492 "$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 +02002493 "$P_CLI force_version=tls1_1" \
2494 0 \
2495 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002497run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002498 "$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 +02002499 "$P_CLI force_version=tls1_2" \
2500 0 \
2501 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2502
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002503# Test for ClientHello without extensions
2504
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002505requires_gnutls
2506run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002507 "$P_SRV debug_level=3" \
2508 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2509 0 \
2510 -s "dumping 'client hello extensions' (0 bytes)"
2511
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002512# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002513
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002514run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002515 "$P_SRV" \
2516 "$P_CLI request_size=100" \
2517 0 \
2518 -s "Read from client: 100 bytes read$"
2519
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002520run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002521 "$P_SRV" \
2522 "$P_CLI request_size=500" \
2523 0 \
2524 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002525
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002526# Tests for small packets
2527
2528run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002529 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002530 "$P_CLI request_size=1 force_version=ssl3 \
2531 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2532 0 \
2533 -s "Read from client: 1 bytes read"
2534
2535run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002536 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002537 "$P_CLI request_size=1 force_version=ssl3 \
2538 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2539 0 \
2540 -s "Read from client: 1 bytes read"
2541
2542run_test "Small packet TLS 1.0 BlockCipher" \
2543 "$P_SRV" \
2544 "$P_CLI request_size=1 force_version=tls1 \
2545 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2546 0 \
2547 -s "Read from client: 1 bytes read"
2548
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002549run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2550 "$P_SRV" \
2551 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2552 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2553 0 \
2554 -s "Read from client: 1 bytes read"
2555
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002556run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2557 "$P_SRV" \
2558 "$P_CLI request_size=1 force_version=tls1 \
2559 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2560 trunc_hmac=1" \
2561 0 \
2562 -s "Read from client: 1 bytes read"
2563
2564run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002565 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002566 "$P_CLI request_size=1 force_version=tls1 \
2567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2568 trunc_hmac=1" \
2569 0 \
2570 -s "Read from client: 1 bytes read"
2571
2572run_test "Small packet TLS 1.1 BlockCipher" \
2573 "$P_SRV" \
2574 "$P_CLI request_size=1 force_version=tls1_1 \
2575 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2576 0 \
2577 -s "Read from client: 1 bytes read"
2578
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002579run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2580 "$P_SRV" \
2581 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2582 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2583 0 \
2584 -s "Read from client: 1 bytes read"
2585
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002586run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002587 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002588 "$P_CLI request_size=1 force_version=tls1_1 \
2589 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2590 0 \
2591 -s "Read from client: 1 bytes read"
2592
2593run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2594 "$P_SRV" \
2595 "$P_CLI request_size=1 force_version=tls1_1 \
2596 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2597 trunc_hmac=1" \
2598 0 \
2599 -s "Read from client: 1 bytes read"
2600
2601run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002602 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002603 "$P_CLI request_size=1 force_version=tls1_1 \
2604 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2605 trunc_hmac=1" \
2606 0 \
2607 -s "Read from client: 1 bytes read"
2608
2609run_test "Small packet TLS 1.2 BlockCipher" \
2610 "$P_SRV" \
2611 "$P_CLI request_size=1 force_version=tls1_2 \
2612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2613 0 \
2614 -s "Read from client: 1 bytes read"
2615
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002616run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2617 "$P_SRV" \
2618 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2619 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2620 0 \
2621 -s "Read from client: 1 bytes read"
2622
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002623run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2624 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002625 "$P_CLI request_size=1 force_version=tls1_2 \
2626 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002627 0 \
2628 -s "Read from client: 1 bytes read"
2629
2630run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2631 "$P_SRV" \
2632 "$P_CLI request_size=1 force_version=tls1_2 \
2633 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2634 trunc_hmac=1" \
2635 0 \
2636 -s "Read from client: 1 bytes read"
2637
2638run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002639 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002640 "$P_CLI request_size=1 force_version=tls1_2 \
2641 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2642 0 \
2643 -s "Read from client: 1 bytes read"
2644
2645run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002646 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002647 "$P_CLI request_size=1 force_version=tls1_2 \
2648 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2649 trunc_hmac=1" \
2650 0 \
2651 -s "Read from client: 1 bytes read"
2652
2653run_test "Small packet TLS 1.2 AEAD" \
2654 "$P_SRV" \
2655 "$P_CLI request_size=1 force_version=tls1_2 \
2656 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2657 0 \
2658 -s "Read from client: 1 bytes read"
2659
2660run_test "Small packet TLS 1.2 AEAD shorter tag" \
2661 "$P_SRV" \
2662 "$P_CLI request_size=1 force_version=tls1_2 \
2663 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2664 0 \
2665 -s "Read from client: 1 bytes read"
2666
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002667# Test for large packets
2668
2669run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002670 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002671 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2673 0 \
2674 -s "Read from client: 16384 bytes read"
2675
2676run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002677 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002678 "$P_CLI request_size=16384 force_version=ssl3 \
2679 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2680 0 \
2681 -s "Read from client: 16384 bytes read"
2682
2683run_test "Large packet TLS 1.0 BlockCipher" \
2684 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002685 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2687 0 \
2688 -s "Read from client: 16384 bytes read"
2689
2690run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2691 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002692 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002693 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2694 trunc_hmac=1" \
2695 0 \
2696 -s "Read from client: 16384 bytes read"
2697
2698run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002699 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002700 "$P_CLI request_size=16384 force_version=tls1 \
2701 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2702 trunc_hmac=1" \
2703 0 \
2704 -s "Read from client: 16384 bytes read"
2705
2706run_test "Large packet TLS 1.1 BlockCipher" \
2707 "$P_SRV" \
2708 "$P_CLI request_size=16384 force_version=tls1_1 \
2709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2710 0 \
2711 -s "Read from client: 16384 bytes read"
2712
2713run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002714 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002715 "$P_CLI request_size=16384 force_version=tls1_1 \
2716 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2717 0 \
2718 -s "Read from client: 16384 bytes read"
2719
2720run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2721 "$P_SRV" \
2722 "$P_CLI request_size=16384 force_version=tls1_1 \
2723 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2724 trunc_hmac=1" \
2725 0 \
2726 -s "Read from client: 16384 bytes read"
2727
2728run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002729 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002730 "$P_CLI request_size=16384 force_version=tls1_1 \
2731 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2732 trunc_hmac=1" \
2733 0 \
2734 -s "Read from client: 16384 bytes read"
2735
2736run_test "Large packet TLS 1.2 BlockCipher" \
2737 "$P_SRV" \
2738 "$P_CLI request_size=16384 force_version=tls1_2 \
2739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2740 0 \
2741 -s "Read from client: 16384 bytes read"
2742
2743run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2744 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002745 "$P_CLI request_size=16384 force_version=tls1_2 \
2746 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002747 0 \
2748 -s "Read from client: 16384 bytes read"
2749
2750run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2751 "$P_SRV" \
2752 "$P_CLI request_size=16384 force_version=tls1_2 \
2753 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2754 trunc_hmac=1" \
2755 0 \
2756 -s "Read from client: 16384 bytes read"
2757
2758run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002759 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002760 "$P_CLI request_size=16384 force_version=tls1_2 \
2761 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2762 0 \
2763 -s "Read from client: 16384 bytes read"
2764
2765run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002766 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002767 "$P_CLI request_size=16384 force_version=tls1_2 \
2768 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2769 trunc_hmac=1" \
2770 0 \
2771 -s "Read from client: 16384 bytes read"
2772
2773run_test "Large packet TLS 1.2 AEAD" \
2774 "$P_SRV" \
2775 "$P_CLI request_size=16384 force_version=tls1_2 \
2776 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2777 0 \
2778 -s "Read from client: 16384 bytes read"
2779
2780run_test "Large packet TLS 1.2 AEAD shorter tag" \
2781 "$P_SRV" \
2782 "$P_CLI request_size=16384 force_version=tls1_2 \
2783 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2784 0 \
2785 -s "Read from client: 16384 bytes read"
2786
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002787# Tests for DTLS HelloVerifyRequest
2788
2789run_test "DTLS cookie: enabled" \
2790 "$P_SRV dtls=1 debug_level=2" \
2791 "$P_CLI dtls=1 debug_level=2" \
2792 0 \
2793 -s "cookie verification failed" \
2794 -s "cookie verification passed" \
2795 -S "cookie verification skipped" \
2796 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002797 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002798 -S "SSL - The requested feature is not available"
2799
2800run_test "DTLS cookie: disabled" \
2801 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2802 "$P_CLI dtls=1 debug_level=2" \
2803 0 \
2804 -S "cookie verification failed" \
2805 -S "cookie verification passed" \
2806 -s "cookie verification skipped" \
2807 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002808 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002809 -S "SSL - The requested feature is not available"
2810
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002811run_test "DTLS cookie: default (failing)" \
2812 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2813 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2814 1 \
2815 -s "cookie verification failed" \
2816 -S "cookie verification passed" \
2817 -S "cookie verification skipped" \
2818 -C "received hello verify request" \
2819 -S "hello verification requested" \
2820 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002821
2822requires_ipv6
2823run_test "DTLS cookie: enabled, IPv6" \
2824 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2825 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2826 0 \
2827 -s "cookie verification failed" \
2828 -s "cookie verification passed" \
2829 -S "cookie verification skipped" \
2830 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002831 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002832 -S "SSL - The requested feature is not available"
2833
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002834run_test "DTLS cookie: enabled, nbio" \
2835 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2836 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2837 0 \
2838 -s "cookie verification failed" \
2839 -s "cookie verification passed" \
2840 -S "cookie verification skipped" \
2841 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002842 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002843 -S "SSL - The requested feature is not available"
2844
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002845# Tests for various cases of client authentication with DTLS
2846# (focused on handshake flows and message parsing)
2847
2848run_test "DTLS client auth: required" \
2849 "$P_SRV dtls=1 auth_mode=required" \
2850 "$P_CLI dtls=1" \
2851 0 \
2852 -s "Verifying peer X.509 certificate... ok"
2853
2854run_test "DTLS client auth: optional, client has no cert" \
2855 "$P_SRV dtls=1 auth_mode=optional" \
2856 "$P_CLI dtls=1 crt_file=none key_file=none" \
2857 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002858 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002859
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002860run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002861 "$P_SRV dtls=1 auth_mode=none" \
2862 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2863 0 \
2864 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002865 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002866
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02002867run_test "DTLS wrong PSK: badmac alert" \
2868 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
2869 "$P_CLI dtls=1 psk=abc124" \
2870 1 \
2871 -s "SSL - Verification of the message MAC failed" \
2872 -c "SSL - A fatal alert message was received from our peer"
2873
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002874# Tests for receiving fragmented handshake messages with DTLS
2875
2876requires_gnutls
2877run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2878 "$G_SRV -u --mtu 2048 -a" \
2879 "$P_CLI dtls=1 debug_level=2" \
2880 0 \
2881 -C "found fragmented DTLS handshake message" \
2882 -C "error"
2883
2884requires_gnutls
2885run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2886 "$G_SRV -u --mtu 512" \
2887 "$P_CLI dtls=1 debug_level=2" \
2888 0 \
2889 -c "found fragmented DTLS handshake message" \
2890 -C "error"
2891
2892requires_gnutls
2893run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2894 "$G_SRV -u --mtu 128" \
2895 "$P_CLI dtls=1 debug_level=2" \
2896 0 \
2897 -c "found fragmented DTLS handshake message" \
2898 -C "error"
2899
2900requires_gnutls
2901run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2902 "$G_SRV -u --mtu 128" \
2903 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2904 0 \
2905 -c "found fragmented DTLS handshake message" \
2906 -C "error"
2907
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002908requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002909run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2910 "$G_SRV -u --mtu 256" \
2911 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2912 0 \
2913 -c "found fragmented DTLS handshake message" \
2914 -c "client hello, adding renegotiation extension" \
2915 -c "found renegotiation extension" \
2916 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002917 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002918 -C "error" \
2919 -s "Extra-header:"
2920
2921requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002922run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2923 "$G_SRV -u --mtu 256" \
2924 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2925 0 \
2926 -c "found fragmented DTLS handshake message" \
2927 -c "client hello, adding renegotiation extension" \
2928 -c "found renegotiation extension" \
2929 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002930 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002931 -C "error" \
2932 -s "Extra-header:"
2933
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002934run_test "DTLS reassembly: no fragmentation (openssl server)" \
2935 "$O_SRV -dtls1 -mtu 2048" \
2936 "$P_CLI dtls=1 debug_level=2" \
2937 0 \
2938 -C "found fragmented DTLS handshake message" \
2939 -C "error"
2940
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002941run_test "DTLS reassembly: some fragmentation (openssl server)" \
2942 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002943 "$P_CLI dtls=1 debug_level=2" \
2944 0 \
2945 -c "found fragmented DTLS handshake message" \
2946 -C "error"
2947
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002948run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002949 "$O_SRV -dtls1 -mtu 256" \
2950 "$P_CLI dtls=1 debug_level=2" \
2951 0 \
2952 -c "found fragmented DTLS handshake message" \
2953 -C "error"
2954
2955run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2956 "$O_SRV -dtls1 -mtu 256" \
2957 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2958 0 \
2959 -c "found fragmented DTLS handshake message" \
2960 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002961
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002962# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002963
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002964not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002965run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002966 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002967 "$P_SRV dtls=1 debug_level=2" \
2968 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002969 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002970 -C "replayed record" \
2971 -S "replayed record" \
2972 -C "record from another epoch" \
2973 -S "record from another epoch" \
2974 -C "discarding invalid record" \
2975 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002976 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002977 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002978 -c "HTTP/1.0 200 OK"
2979
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002980not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002981run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002982 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002983 "$P_SRV dtls=1 debug_level=2" \
2984 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002985 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002986 -c "replayed record" \
2987 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002988 -c "discarding invalid record" \
2989 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002990 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002991 -s "Extra-header:" \
2992 -c "HTTP/1.0 200 OK"
2993
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002994run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2995 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002996 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2997 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002998 0 \
2999 -c "replayed record" \
3000 -S "replayed record" \
3001 -c "discarding invalid record" \
3002 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003003 -c "resend" \
3004 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003005 -s "Extra-header:" \
3006 -c "HTTP/1.0 200 OK"
3007
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003008run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003009 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003010 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003011 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003012 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003013 -c "discarding invalid record (mac)" \
3014 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003015 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003016 -c "HTTP/1.0 200 OK" \
3017 -S "too many records with bad MAC" \
3018 -S "Verification of the message MAC failed"
3019
3020run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3021 -p "$P_PXY bad_ad=1" \
3022 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3023 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3024 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003025 -C "discarding invalid record (mac)" \
3026 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003027 -S "Extra-header:" \
3028 -C "HTTP/1.0 200 OK" \
3029 -s "too many records with bad MAC" \
3030 -s "Verification of the message MAC failed"
3031
3032run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3033 -p "$P_PXY bad_ad=1" \
3034 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3035 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3036 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003037 -c "discarding invalid record (mac)" \
3038 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003039 -s "Extra-header:" \
3040 -c "HTTP/1.0 200 OK" \
3041 -S "too many records with bad MAC" \
3042 -S "Verification of the message MAC failed"
3043
3044run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3045 -p "$P_PXY bad_ad=1" \
3046 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3047 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3048 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003049 -c "discarding invalid record (mac)" \
3050 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003051 -s "Extra-header:" \
3052 -c "HTTP/1.0 200 OK" \
3053 -s "too many records with bad MAC" \
3054 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003055
3056run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003057 -p "$P_PXY delay_ccs=1" \
3058 "$P_SRV dtls=1 debug_level=1" \
3059 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003060 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003061 -c "record from another epoch" \
3062 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003063 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003064 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003065 -s "Extra-header:" \
3066 -c "HTTP/1.0 200 OK"
3067
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003068# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003069
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003070needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003071run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003072 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003073 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3074 psk=abc123" \
3075 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003076 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3077 0 \
3078 -s "Extra-header:" \
3079 -c "HTTP/1.0 200 OK"
3080
3081needs_more_time 2
3082run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3083 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003084 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3085 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003086 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3087 0 \
3088 -s "Extra-header:" \
3089 -c "HTTP/1.0 200 OK"
3090
3091needs_more_time 2
3092run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3093 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003094 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3095 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003096 0 \
3097 -s "Extra-header:" \
3098 -c "HTTP/1.0 200 OK"
3099
3100needs_more_time 2
3101run_test "DTLS proxy: 3d, FS, client auth" \
3102 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003103 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3104 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003105 0 \
3106 -s "Extra-header:" \
3107 -c "HTTP/1.0 200 OK"
3108
3109needs_more_time 2
3110run_test "DTLS proxy: 3d, FS, ticket" \
3111 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003112 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3113 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003114 0 \
3115 -s "Extra-header:" \
3116 -c "HTTP/1.0 200 OK"
3117
3118needs_more_time 2
3119run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3120 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003121 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3122 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003123 0 \
3124 -s "Extra-header:" \
3125 -c "HTTP/1.0 200 OK"
3126
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003127needs_more_time 2
3128run_test "DTLS proxy: 3d, max handshake, nbio" \
3129 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003130 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3131 auth_mode=required" \
3132 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003133 0 \
3134 -s "Extra-header:" \
3135 -c "HTTP/1.0 200 OK"
3136
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003137needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003138run_test "DTLS proxy: 3d, min handshake, resumption" \
3139 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3140 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3141 psk=abc123 debug_level=3" \
3142 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3143 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3144 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3145 0 \
3146 -s "a session has been resumed" \
3147 -c "a session has been resumed" \
3148 -s "Extra-header:" \
3149 -c "HTTP/1.0 200 OK"
3150
3151needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003152run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3153 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3154 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3155 psk=abc123 debug_level=3 nbio=2" \
3156 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3157 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3158 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3159 0 \
3160 -s "a session has been resumed" \
3161 -c "a session has been resumed" \
3162 -s "Extra-header:" \
3163 -c "HTTP/1.0 200 OK"
3164
3165needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003166run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003167 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003168 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3169 psk=abc123 renegotiation=1 debug_level=2" \
3170 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3171 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003172 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3173 0 \
3174 -c "=> renegotiate" \
3175 -s "=> renegotiate" \
3176 -s "Extra-header:" \
3177 -c "HTTP/1.0 200 OK"
3178
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003179needs_more_time 4
3180run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3181 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003182 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3183 psk=abc123 renegotiation=1 debug_level=2" \
3184 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3185 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003186 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3187 0 \
3188 -c "=> renegotiate" \
3189 -s "=> renegotiate" \
3190 -s "Extra-header:" \
3191 -c "HTTP/1.0 200 OK"
3192
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003193needs_more_time 4
3194run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003195 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003196 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003197 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003198 debug_level=2" \
3199 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003200 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003201 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3202 0 \
3203 -c "=> renegotiate" \
3204 -s "=> renegotiate" \
3205 -s "Extra-header:" \
3206 -c "HTTP/1.0 200 OK"
3207
3208needs_more_time 4
3209run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003210 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003211 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003212 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003213 debug_level=2 nbio=2" \
3214 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003215 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003216 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3217 0 \
3218 -c "=> renegotiate" \
3219 -s "=> renegotiate" \
3220 -s "Extra-header:" \
3221 -c "HTTP/1.0 200 OK"
3222
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003223needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003224run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003225 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3226 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003227 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003228 0 \
3229 -s "Extra-header:" \
3230 -c "HTTP/1.0 200 OK"
3231
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003232needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003233run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3234 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3235 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003236 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003237 0 \
3238 -s "Extra-header:" \
3239 -c "HTTP/1.0 200 OK"
3240
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003241needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003242run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3243 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3244 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003245 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003246 0 \
3247 -s "Extra-header:" \
3248 -c "HTTP/1.0 200 OK"
3249
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003250requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003251needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003252run_test "DTLS proxy: 3d, gnutls server" \
3253 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3254 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003255 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003256 0 \
3257 -s "Extra-header:" \
3258 -c "Extra-header:"
3259
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003260requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003261needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003262run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3263 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3264 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003265 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003266 0 \
3267 -s "Extra-header:" \
3268 -c "Extra-header:"
3269
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003270requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003271needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003272run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3273 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3274 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003275 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003276 0 \
3277 -s "Extra-header:" \
3278 -c "Extra-header:"
3279
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003280# Final report
3281
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003282echo "------------------------------------------------------------------------"
3283
3284if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003285 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003286else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003287 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003288fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003289PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003290echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003291
3292exit $FAILS