blob: b57edd7fe1d07aca047832ce2e3721b133761ff4 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_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 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200125# skip next test if OpenSSL doesn't support FALLBACK_SCSV
126requires_openssl_with_fallback_scsv() {
127 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
128 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
129 then
130 OPENSSL_HAS_FBSCSV="YES"
131 else
132 OPENSSL_HAS_FBSCSV="NO"
133 fi
134 fi
135 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
136 SKIP_NEXT="YES"
137 fi
138}
139
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200140# skip next test if GnuTLS isn't available
141requires_gnutls() {
142 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200143 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200144 GNUTLS_AVAILABLE="YES"
145 else
146 GNUTLS_AVAILABLE="NO"
147 fi
148 fi
149 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
150 SKIP_NEXT="YES"
151 fi
152}
153
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200154# skip next test if IPv6 isn't available on this host
155requires_ipv6() {
156 if [ -z "${HAS_IPV6:-}" ]; then
157 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
158 SRV_PID=$!
159 sleep 1
160 kill $SRV_PID >/dev/null 2>&1
161 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
162 HAS_IPV6="NO"
163 else
164 HAS_IPV6="YES"
165 fi
166 rm -r $SRV_OUT
167 fi
168
169 if [ "$HAS_IPV6" = "NO" ]; then
170 SKIP_NEXT="YES"
171 fi
172}
173
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200174# skip the next test if valgrind is in use
175not_with_valgrind() {
176 if [ "$MEMCHECK" -gt 0 ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Paul Bakker362689d2016-05-13 10:33:25 +0100181# skip the next test if valgrind is NOT in use
182only_with_valgrind() {
183 if [ "$MEMCHECK" -eq 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200188# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100189client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200190 CLI_DELAY_FACTOR=$1
191}
192
Janos Follath74537a62016-09-02 13:45:28 +0100193# wait for the given seconds after the client finished in the next test
194server_needs_more_time() {
195 SRV_DELAY_SECONDS=$1
196}
197
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100198# print_name <name>
199print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100200 TESTS=$(( $TESTS + 1 ))
201 LINE=""
202
203 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
204 LINE="$TESTS "
205 fi
206
207 LINE="$LINE$1"
208 printf "$LINE "
209 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100210 for i in `seq 1 $LEN`; do printf '.'; done
211 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100212
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100213}
214
215# fail <message>
216fail() {
217 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100218 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200220 mv $SRV_OUT o-srv-${TESTS}.log
221 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200222 if [ -n "$PXY_CMD" ]; then
223 mv $PXY_OUT o-pxy-${TESTS}.log
224 fi
225 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200227 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
228 echo " ! server output:"
229 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200230 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200231 echo " ! client output:"
232 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200233 if [ -n "$PXY_CMD" ]; then
234 echo " ! ========================================================"
235 echo " ! proxy output:"
236 cat o-pxy-${TESTS}.log
237 fi
238 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200239 fi
240
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200241 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100242}
243
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100244# is_polar <cmd_line>
245is_polar() {
246 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
247}
248
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200249# openssl s_server doesn't have -www with DTLS
250check_osrv_dtls() {
251 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
252 NEEDS_INPUT=1
253 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
254 else
255 NEEDS_INPUT=0
256 fi
257}
258
259# provide input to commands that need it
260provide_input() {
261 if [ $NEEDS_INPUT -eq 0 ]; then
262 return
263 fi
264
265 while true; do
266 echo "HTTP/1.0 200 OK"
267 sleep 1
268 done
269}
270
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100271# has_mem_err <log_file_name>
272has_mem_err() {
273 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
274 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
275 then
276 return 1 # false: does not have errors
277 else
278 return 0 # true: has errors
279 fi
280}
281
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200282# wait for server to start: two versions depending on lsof availability
283wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200284 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200285 START_TIME=$( date +%s )
286 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200287
288 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200289 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200290 while [ $DONE -eq 0 ]; do
291 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
292 then
293 DONE=1
294 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
295 echo "SERVERSTART TIMEOUT"
296 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
297 DONE=1
298 fi
299 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200300 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200301 while [ $DONE -eq 0 ]; do
302 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
303 then
304 DONE=1
305 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
306 echo "SERVERSTART TIMEOUT"
307 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
308 DONE=1
309 fi
310 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200311 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200312 else
313 sleep "$START_DELAY"
314 fi
315}
316
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200317# wait for client to terminate and set CLI_EXIT
318# must be called right after starting the client
319wait_client_done() {
320 CLI_PID=$!
321
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200322 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
323 CLI_DELAY_FACTOR=1
324
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200325 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200326 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200327
328 wait $CLI_PID
329 CLI_EXIT=$?
330
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200331 kill $DOG_PID >/dev/null 2>&1
332 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200333
334 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100335
336 sleep $SRV_DELAY_SECONDS
337 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200338}
339
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200340# check if the given command uses dtls and sets global variable DTLS
341detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200342 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200343 DTLS=1
344 else
345 DTLS=0
346 fi
347}
348
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100350# Options: -s pattern pattern that must be present in server output
351# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100352# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100353# -S pattern pattern that must be absent in server output
354# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100355# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100356run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100357 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200358 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100359
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100360 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
361 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200362 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100363 return
364 fi
365
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100366 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100367
Paul Bakkerb7584a52016-05-10 10:50:43 +0100368 # Do we only run numbered tests?
369 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
370 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
371 else
372 SKIP_NEXT="YES"
373 fi
374
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200375 # should we skip?
376 if [ "X$SKIP_NEXT" = "XYES" ]; then
377 SKIP_NEXT="NO"
378 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200379 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200380 return
381 fi
382
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383 # does this test use a proxy?
384 if [ "X$1" = "X-p" ]; then
385 PXY_CMD="$2"
386 shift 2
387 else
388 PXY_CMD=""
389 fi
390
391 # get commands and client output
392 SRV_CMD="$1"
393 CLI_CMD="$2"
394 CLI_EXPECT="$3"
395 shift 3
396
397 # fix client port
398 if [ -n "$PXY_CMD" ]; then
399 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
400 else
401 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
402 fi
403
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200404 # update DTLS variable
405 detect_dtls "$SRV_CMD"
406
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100407 # prepend valgrind to our commands if active
408 if [ "$MEMCHECK" -gt 0 ]; then
409 if is_polar "$SRV_CMD"; then
410 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
411 fi
412 if is_polar "$CLI_CMD"; then
413 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
414 fi
415 fi
416
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200417 TIMES_LEFT=2
418 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200419 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200420
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200421 # run the commands
422 if [ -n "$PXY_CMD" ]; then
423 echo "$PXY_CMD" > $PXY_OUT
424 $PXY_CMD >> $PXY_OUT 2>&1 &
425 PXY_PID=$!
426 # assume proxy starts faster than server
427 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200428
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200429 check_osrv_dtls
430 echo "$SRV_CMD" > $SRV_OUT
431 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
432 SRV_PID=$!
433 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200434
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200435 echo "$CLI_CMD" > $CLI_OUT
436 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
437 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100438
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200439 # terminate the server (and the proxy)
440 kill $SRV_PID
441 wait $SRV_PID
442 if [ -n "$PXY_CMD" ]; then
443 kill $PXY_PID >/dev/null 2>&1
444 wait $PXY_PID
445 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100446
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200447 # retry only on timeouts
448 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
449 printf "RETRY "
450 else
451 TIMES_LEFT=0
452 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453 done
454
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100455 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200456 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100457 # expected client exit to incorrectly succeed in case of catastrophic
458 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100459 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200460 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100461 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100462 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100463 return
464 fi
465 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100466 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200467 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100468 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100469 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100470 return
471 fi
472 fi
473
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100474 # check server exit code
475 if [ $? != 0 ]; then
476 fail "server fail"
477 return
478 fi
479
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100480 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100481 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
482 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100483 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200484 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100485 return
486 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100487
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100488 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200489 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100490 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100491 while [ $# -gt 0 ]
492 do
493 case $1 in
494 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100495 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100496 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100497 return
498 fi
499 ;;
500
501 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100502 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100503 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100504 return
505 fi
506 ;;
507
508 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100509 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100510 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100511 return
512 fi
513 ;;
514
515 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100516 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100517 fail "pattern '$2' MUST NOT be present in the Client output"
518 return
519 fi
520 ;;
521
522 # The filtering in the following two options (-u and -U) do the following
523 # - ignore valgrind output
524 # - filter out everything but lines right after the pattern occurances
525 # - keep one of each non-unique line
526 # - count how many lines remain
527 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
528 # if there were no duplicates.
529 "-U")
530 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
531 fail "lines following pattern '$2' must be unique in Server output"
532 return
533 fi
534 ;;
535
536 "-u")
537 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
538 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100539 return
540 fi
541 ;;
542
543 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200544 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100545 exit 1
546 esac
547 shift 2
548 done
549
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100550 # check valgrind's results
551 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200552 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100553 fail "Server has memory errors"
554 return
555 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200556 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100557 fail "Client has memory errors"
558 return
559 fi
560 fi
561
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100562 # if we're here, everything is ok
563 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100564 if [ "$PRESERVE_LOGS" -gt 0 ]; then
565 mv $SRV_OUT o-srv-${TESTS}.log
566 mv $CLI_OUT o-cli-${TESTS}.log
567 fi
568
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100570}
571
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100572cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200573 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200574 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
575 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
576 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
577 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100578 exit 1
579}
580
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100581#
582# MAIN
583#
584
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000585if cd $( dirname $0 ); then :; else
586 echo "cd $( dirname $0 ) failed" >&2
587 exit 1
588fi
589
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100590get_options "$@"
591
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100592# sanity checks, avoid an avalanche of errors
593if [ ! -x "$P_SRV" ]; then
594 echo "Command '$P_SRV' is not an executable file"
595 exit 1
596fi
597if [ ! -x "$P_CLI" ]; then
598 echo "Command '$P_CLI' is not an executable file"
599 exit 1
600fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200601if [ ! -x "$P_PXY" ]; then
602 echo "Command '$P_PXY' is not an executable file"
603 exit 1
604fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100605if [ "$MEMCHECK" -gt 0 ]; then
606 if which valgrind >/dev/null 2>&1; then :; else
607 echo "Memcheck not possible. Valgrind not found"
608 exit 1
609 fi
610fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100611if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
612 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100613 exit 1
614fi
615
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200616# used by watchdog
617MAIN_PID="$$"
618
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200619# be more patient with valgrind
620if [ "$MEMCHECK" -gt 0 ]; then
621 START_DELAY=3
622 DOG_DELAY=30
623else
624 START_DELAY=1
625 DOG_DELAY=10
626fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200627CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100628SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200629
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200630# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000631# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200632P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
633P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100634P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200635O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200636O_CLI="$O_CLI -connect localhost:+SRV_PORT"
637G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000638G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200639
Gilles Peskine62469d92017-05-10 10:13:59 +0200640# Allow SHA-1, because many of our test certificates use it
641P_SRV="$P_SRV allow_sha1=1"
642P_CLI="$P_CLI allow_sha1=1"
643
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200644# Also pick a unique name for intermediate files
645SRV_OUT="srv_out.$$"
646CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200647PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200648SESSION="session.$$"
649
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200650SKIP_NEXT="NO"
651
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100652trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100653
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200654# Basic test
655
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200656# Checks that:
657# - things work with all ciphersuites active (used with config-full in all.sh)
658# - the expected (highest security) parameters are selected
659# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200660run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200661 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200662 "$P_CLI" \
663 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200664 -s "Protocol is TLSv1.2" \
665 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
666 -s "client hello v3, signature_algorithm ext: 6" \
667 -s "ECDHE curve: secp521r1" \
668 -S "error" \
669 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200670
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000671run_test "Default, DTLS" \
672 "$P_SRV dtls=1" \
673 "$P_CLI dtls=1" \
674 0 \
675 -s "Protocol is DTLSv1.2" \
676 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
677
Simon Butcher8e004102016-10-14 00:48:33 +0100678# Test for uniqueness of IVs in AEAD ciphersuites
679run_test "Unique IV in GCM" \
680 "$P_SRV exchanges=20 debug_level=4" \
681 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
682 0 \
683 -u "IV used" \
684 -U "IV used"
685
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100686# Tests for rc4 option
687
Simon Butchera410af52016-05-19 22:12:18 +0100688requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100689run_test "RC4: server disabled, client enabled" \
690 "$P_SRV" \
691 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
692 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100693 -s "SSL - The server has no ciphersuites in common"
694
Simon Butchera410af52016-05-19 22:12:18 +0100695requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100696run_test "RC4: server half, client enabled" \
697 "$P_SRV arc4=1" \
698 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
699 1 \
700 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100701
702run_test "RC4: server enabled, client disabled" \
703 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
704 "$P_CLI" \
705 1 \
706 -s "SSL - The server has no ciphersuites in common"
707
708run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100709 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100710 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
711 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100712 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100713 -S "SSL - The server has no ciphersuites in common"
714
Gilles Peskinebc70a182017-05-09 15:59:24 +0200715# Tests for SHA-1 support
716
717run_test "SHA-1 forbidden by default in server certificate" \
718 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
719 "$P_CLI debug_level=2 allow_sha1=0" \
720 1 \
721 -c "The certificate is signed with an unacceptable hash"
722
723run_test "SHA-1 explicitly allowed in server certificate" \
724 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
725 "$P_CLI allow_sha1=1" \
726 0
727
728run_test "SHA-256 allowed by default in server certificate" \
729 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
730 "$P_CLI allow_sha1=0" \
731 0
732
733run_test "SHA-1 forbidden by default in client certificate" \
734 "$P_SRV auth_mode=required allow_sha1=0" \
735 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
736 1 \
737 -s "The certificate is signed with an unacceptable hash"
738
739run_test "SHA-1 explicitly allowed in client certificate" \
740 "$P_SRV auth_mode=required allow_sha1=1" \
741 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
742 0
743
744run_test "SHA-256 allowed by default in client certificate" \
745 "$P_SRV auth_mode=required allow_sha1=0" \
746 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
747 0
748
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100749# Tests for Truncated HMAC extension
750
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100751run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200752 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100753 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100754 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100755 -s "dumping 'computed mac' (20 bytes)" \
756 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100757
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100758run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200759 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100760 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
761 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100762 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100763 -s "dumping 'computed mac' (20 bytes)" \
764 -S "dumping 'computed mac' (10 bytes)"
765
766run_test "Truncated HMAC: client enabled, server default" \
767 "$P_SRV debug_level=4" \
768 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
769 trunc_hmac=1" \
770 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100771 -s "dumping 'computed mac' (20 bytes)" \
772 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100773
774run_test "Truncated HMAC: client enabled, server disabled" \
775 "$P_SRV debug_level=4 trunc_hmac=0" \
776 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
777 trunc_hmac=1" \
778 0 \
779 -s "dumping 'computed mac' (20 bytes)" \
780 -S "dumping 'computed mac' (10 bytes)"
781
782run_test "Truncated HMAC: client enabled, server enabled" \
783 "$P_SRV debug_level=4 trunc_hmac=1" \
784 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
785 trunc_hmac=1" \
786 0 \
787 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100788 -s "dumping 'computed mac' (10 bytes)"
789
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100790# Tests for Encrypt-then-MAC extension
791
792run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100793 "$P_SRV debug_level=3 \
794 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100795 "$P_CLI debug_level=3" \
796 0 \
797 -c "client hello, adding encrypt_then_mac extension" \
798 -s "found encrypt then mac extension" \
799 -s "server hello, adding encrypt then mac extension" \
800 -c "found encrypt_then_mac extension" \
801 -c "using encrypt then mac" \
802 -s "using encrypt then mac"
803
804run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100805 "$P_SRV debug_level=3 etm=0 \
806 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100807 "$P_CLI debug_level=3 etm=1" \
808 0 \
809 -c "client hello, adding encrypt_then_mac extension" \
810 -s "found encrypt then mac extension" \
811 -S "server hello, adding encrypt then mac extension" \
812 -C "found encrypt_then_mac extension" \
813 -C "using encrypt then mac" \
814 -S "using encrypt then mac"
815
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100816run_test "Encrypt then MAC: client enabled, aead cipher" \
817 "$P_SRV debug_level=3 etm=1 \
818 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
819 "$P_CLI debug_level=3 etm=1" \
820 0 \
821 -c "client hello, adding encrypt_then_mac extension" \
822 -s "found encrypt then mac extension" \
823 -S "server hello, adding encrypt then mac extension" \
824 -C "found encrypt_then_mac extension" \
825 -C "using encrypt then mac" \
826 -S "using encrypt then mac"
827
828run_test "Encrypt then MAC: client enabled, stream cipher" \
829 "$P_SRV debug_level=3 etm=1 \
830 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100831 "$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 +0100832 0 \
833 -c "client hello, adding encrypt_then_mac extension" \
834 -s "found encrypt then mac extension" \
835 -S "server hello, adding encrypt then mac extension" \
836 -C "found encrypt_then_mac extension" \
837 -C "using encrypt then mac" \
838 -S "using encrypt then mac"
839
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100840run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100841 "$P_SRV debug_level=3 etm=1 \
842 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100843 "$P_CLI debug_level=3 etm=0" \
844 0 \
845 -C "client hello, adding encrypt_then_mac extension" \
846 -S "found encrypt then mac extension" \
847 -S "server hello, adding encrypt then mac extension" \
848 -C "found encrypt_then_mac extension" \
849 -C "using encrypt then mac" \
850 -S "using encrypt then mac"
851
Janos Follathe2681a42016-03-07 15:57:05 +0000852requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100853run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100854 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100855 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100856 "$P_CLI debug_level=3 force_version=ssl3" \
857 0 \
858 -C "client hello, adding encrypt_then_mac extension" \
859 -S "found encrypt then mac extension" \
860 -S "server hello, adding encrypt then mac extension" \
861 -C "found encrypt_then_mac extension" \
862 -C "using encrypt then mac" \
863 -S "using encrypt then mac"
864
Janos Follathe2681a42016-03-07 15:57:05 +0000865requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100866run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100867 "$P_SRV debug_level=3 force_version=ssl3 \
868 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100869 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100870 0 \
871 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100872 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100873 -S "server hello, adding encrypt then mac extension" \
874 -C "found encrypt_then_mac extension" \
875 -C "using encrypt then mac" \
876 -S "using encrypt then mac"
877
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200878# Tests for Extended Master Secret extension
879
880run_test "Extended Master Secret: default" \
881 "$P_SRV debug_level=3" \
882 "$P_CLI debug_level=3" \
883 0 \
884 -c "client hello, adding extended_master_secret extension" \
885 -s "found extended master secret extension" \
886 -s "server hello, adding extended master secret extension" \
887 -c "found extended_master_secret extension" \
888 -c "using extended master secret" \
889 -s "using extended master secret"
890
891run_test "Extended Master Secret: client enabled, server disabled" \
892 "$P_SRV debug_level=3 extended_ms=0" \
893 "$P_CLI debug_level=3 extended_ms=1" \
894 0 \
895 -c "client hello, adding extended_master_secret extension" \
896 -s "found extended master secret extension" \
897 -S "server hello, adding extended master secret extension" \
898 -C "found extended_master_secret extension" \
899 -C "using extended master secret" \
900 -S "using extended master secret"
901
902run_test "Extended Master Secret: client disabled, server enabled" \
903 "$P_SRV debug_level=3 extended_ms=1" \
904 "$P_CLI debug_level=3 extended_ms=0" \
905 0 \
906 -C "client hello, adding extended_master_secret extension" \
907 -S "found extended master secret extension" \
908 -S "server hello, adding extended master secret extension" \
909 -C "found extended_master_secret extension" \
910 -C "using extended master secret" \
911 -S "using extended master secret"
912
Janos Follathe2681a42016-03-07 15:57:05 +0000913requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200914run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100915 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200916 "$P_CLI debug_level=3 force_version=ssl3" \
917 0 \
918 -C "client hello, adding extended_master_secret extension" \
919 -S "found extended master secret extension" \
920 -S "server hello, adding extended master secret extension" \
921 -C "found extended_master_secret extension" \
922 -C "using extended master secret" \
923 -S "using extended master secret"
924
Janos Follathe2681a42016-03-07 15:57:05 +0000925requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200926run_test "Extended Master Secret: client enabled, server SSLv3" \
927 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100928 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200929 0 \
930 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100931 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200932 -S "server hello, adding extended master secret extension" \
933 -C "found extended_master_secret extension" \
934 -C "using extended master secret" \
935 -S "using extended master secret"
936
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200937# Tests for FALLBACK_SCSV
938
939run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200940 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200941 "$P_CLI debug_level=3 force_version=tls1_1" \
942 0 \
943 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200944 -S "received FALLBACK_SCSV" \
945 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200946 -C "is a fatal alert message (msg 86)"
947
948run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200949 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200950 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
951 0 \
952 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200953 -S "received FALLBACK_SCSV" \
954 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200955 -C "is a fatal alert message (msg 86)"
956
957run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200958 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200959 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200960 1 \
961 -c "adding FALLBACK_SCSV" \
962 -s "received FALLBACK_SCSV" \
963 -s "inapropriate fallback" \
964 -c "is a fatal alert message (msg 86)"
965
966run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200967 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200968 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200969 0 \
970 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200971 -s "received FALLBACK_SCSV" \
972 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200973 -C "is a fatal alert message (msg 86)"
974
975requires_openssl_with_fallback_scsv
976run_test "Fallback SCSV: default, openssl server" \
977 "$O_SRV" \
978 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
979 0 \
980 -C "adding FALLBACK_SCSV" \
981 -C "is a fatal alert message (msg 86)"
982
983requires_openssl_with_fallback_scsv
984run_test "Fallback SCSV: enabled, openssl server" \
985 "$O_SRV" \
986 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
987 1 \
988 -c "adding FALLBACK_SCSV" \
989 -c "is a fatal alert message (msg 86)"
990
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200991requires_openssl_with_fallback_scsv
992run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200993 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200994 "$O_CLI -tls1_1" \
995 0 \
996 -S "received FALLBACK_SCSV" \
997 -S "inapropriate fallback"
998
999requires_openssl_with_fallback_scsv
1000run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001001 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001002 "$O_CLI -tls1_1 -fallback_scsv" \
1003 1 \
1004 -s "received FALLBACK_SCSV" \
1005 -s "inapropriate fallback"
1006
1007requires_openssl_with_fallback_scsv
1008run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001009 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001010 "$O_CLI -fallback_scsv" \
1011 0 \
1012 -s "received FALLBACK_SCSV" \
1013 -S "inapropriate fallback"
1014
Gilles Peskined50177f2017-05-16 17:53:03 +02001015## ClientHello generated with
1016## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1017## then manually twiddling the ciphersuite list.
1018## The ClientHello content is spelled out below as a hex string as
1019## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1020## The expected response is an inappropriate_fallback alert.
1021requires_openssl_with_fallback_scsv
1022run_test "Fallback SCSV: beginning of list" \
1023 "$P_SRV debug_level=2" \
1024 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1025 0 \
1026 -s "received FALLBACK_SCSV" \
1027 -s "inapropriate fallback"
1028
1029requires_openssl_with_fallback_scsv
1030run_test "Fallback SCSV: end of list" \
1031 "$P_SRV debug_level=2" \
1032 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1033 0 \
1034 -s "received FALLBACK_SCSV" \
1035 -s "inapropriate fallback"
1036
1037## Here the expected response is a valid ServerHello prefix, up to the random.
1038requires_openssl_with_fallback_scsv
1039run_test "Fallback SCSV: not in list" \
1040 "$P_SRV debug_level=2" \
1041 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1042 0 \
1043 -S "received FALLBACK_SCSV" \
1044 -S "inapropriate fallback"
1045
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001046# Tests for CBC 1/n-1 record splitting
1047
1048run_test "CBC Record splitting: TLS 1.2, no splitting" \
1049 "$P_SRV" \
1050 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1051 request_size=123 force_version=tls1_2" \
1052 0 \
1053 -s "Read from client: 123 bytes read" \
1054 -S "Read from client: 1 bytes read" \
1055 -S "122 bytes read"
1056
1057run_test "CBC Record splitting: TLS 1.1, no splitting" \
1058 "$P_SRV" \
1059 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1060 request_size=123 force_version=tls1_1" \
1061 0 \
1062 -s "Read from client: 123 bytes read" \
1063 -S "Read from client: 1 bytes read" \
1064 -S "122 bytes read"
1065
1066run_test "CBC Record splitting: TLS 1.0, splitting" \
1067 "$P_SRV" \
1068 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1069 request_size=123 force_version=tls1" \
1070 0 \
1071 -S "Read from client: 123 bytes read" \
1072 -s "Read from client: 1 bytes read" \
1073 -s "122 bytes read"
1074
Janos Follathe2681a42016-03-07 15:57:05 +00001075requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001076run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001077 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001078 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1079 request_size=123 force_version=ssl3" \
1080 0 \
1081 -S "Read from client: 123 bytes read" \
1082 -s "Read from client: 1 bytes read" \
1083 -s "122 bytes read"
1084
1085run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001086 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001087 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1088 request_size=123 force_version=tls1" \
1089 0 \
1090 -s "Read from client: 123 bytes read" \
1091 -S "Read from client: 1 bytes read" \
1092 -S "122 bytes read"
1093
1094run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1095 "$P_SRV" \
1096 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1097 request_size=123 force_version=tls1 recsplit=0" \
1098 0 \
1099 -s "Read from client: 123 bytes read" \
1100 -S "Read from client: 1 bytes read" \
1101 -S "122 bytes read"
1102
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001103run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1104 "$P_SRV nbio=2" \
1105 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1106 request_size=123 force_version=tls1" \
1107 0 \
1108 -S "Read from client: 123 bytes read" \
1109 -s "Read from client: 1 bytes read" \
1110 -s "122 bytes read"
1111
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001112# Tests for Session Tickets
1113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001114run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001115 "$P_SRV debug_level=3 tickets=1" \
1116 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001117 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001118 -c "client hello, adding session ticket extension" \
1119 -s "found session ticket extension" \
1120 -s "server hello, adding session ticket extension" \
1121 -c "found session_ticket extension" \
1122 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001123 -S "session successfully restored from cache" \
1124 -s "session successfully restored from ticket" \
1125 -s "a session has been resumed" \
1126 -c "a session has been resumed"
1127
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001128run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001129 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1130 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001131 0 \
1132 -c "client hello, adding session ticket extension" \
1133 -s "found session ticket extension" \
1134 -s "server hello, adding session ticket extension" \
1135 -c "found session_ticket extension" \
1136 -c "parse new session ticket" \
1137 -S "session successfully restored from cache" \
1138 -s "session successfully restored from ticket" \
1139 -s "a session has been resumed" \
1140 -c "a session has been resumed"
1141
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001142run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001143 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1144 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001145 0 \
1146 -c "client hello, adding session ticket extension" \
1147 -s "found session ticket extension" \
1148 -s "server hello, adding session ticket extension" \
1149 -c "found session_ticket extension" \
1150 -c "parse new session ticket" \
1151 -S "session successfully restored from cache" \
1152 -S "session successfully restored from ticket" \
1153 -S "a session has been resumed" \
1154 -C "a session has been resumed"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001157 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001159 0 \
1160 -c "client hello, adding session ticket extension" \
1161 -c "found session_ticket extension" \
1162 -c "parse new session ticket" \
1163 -c "a session has been resumed"
1164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001165run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001166 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001167 "( $O_CLI -sess_out $SESSION; \
1168 $O_CLI -sess_in $SESSION; \
1169 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001170 0 \
1171 -s "found session ticket extension" \
1172 -s "server hello, adding session ticket extension" \
1173 -S "session successfully restored from cache" \
1174 -s "session successfully restored from ticket" \
1175 -s "a session has been resumed"
1176
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001177# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001179run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001180 "$P_SRV debug_level=3 tickets=0" \
1181 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001182 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001183 -c "client hello, adding session ticket extension" \
1184 -s "found session ticket extension" \
1185 -S "server hello, adding session ticket extension" \
1186 -C "found session_ticket extension" \
1187 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001188 -s "session successfully restored from cache" \
1189 -S "session successfully restored from ticket" \
1190 -s "a session has been resumed" \
1191 -c "a session has been resumed"
1192
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001193run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001194 "$P_SRV debug_level=3 tickets=1" \
1195 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001196 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001197 -C "client hello, adding session ticket extension" \
1198 -S "found session ticket extension" \
1199 -S "server hello, adding session ticket extension" \
1200 -C "found session_ticket extension" \
1201 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001202 -s "session successfully restored from cache" \
1203 -S "session successfully restored from ticket" \
1204 -s "a session has been resumed" \
1205 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001207run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001208 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1209 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001210 0 \
1211 -S "session successfully restored from cache" \
1212 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001213 -S "a session has been resumed" \
1214 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001216run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001217 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1218 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001219 0 \
1220 -s "session successfully restored from cache" \
1221 -S "session successfully restored from ticket" \
1222 -s "a session has been resumed" \
1223 -c "a session has been resumed"
1224
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001225run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001226 "$P_SRV debug_level=3 tickets=0" \
1227 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001228 0 \
1229 -s "session successfully restored from cache" \
1230 -S "session successfully restored from ticket" \
1231 -s "a session has been resumed" \
1232 -c "a session has been resumed"
1233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1236 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001237 0 \
1238 -S "session successfully restored from cache" \
1239 -S "session successfully restored from ticket" \
1240 -S "a session has been resumed" \
1241 -C "a session has been resumed"
1242
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001243run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001244 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1245 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001246 0 \
1247 -s "session successfully restored from cache" \
1248 -S "session successfully restored from ticket" \
1249 -s "a session has been resumed" \
1250 -c "a session has been resumed"
1251
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001252run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001253 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001254 "( $O_CLI -sess_out $SESSION; \
1255 $O_CLI -sess_in $SESSION; \
1256 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001257 0 \
1258 -s "found session ticket extension" \
1259 -S "server hello, adding session ticket extension" \
1260 -s "session successfully restored from cache" \
1261 -S "session successfully restored from ticket" \
1262 -s "a session has been resumed"
1263
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001264run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001265 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001266 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001267 0 \
1268 -C "found session_ticket extension" \
1269 -C "parse new session ticket" \
1270 -c "a session has been resumed"
1271
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001272# Tests for Max Fragment Length extension
1273
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001274run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001275 "$P_SRV debug_level=3" \
1276 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001277 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001278 -c "Maximum fragment length is 16384" \
1279 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001280 -C "client hello, adding max_fragment_length extension" \
1281 -S "found max fragment length extension" \
1282 -S "server hello, max_fragment_length extension" \
1283 -C "found max_fragment_length extension"
1284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001286 "$P_SRV debug_level=3" \
1287 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001288 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001289 -c "Maximum fragment length is 4096" \
1290 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001291 -c "client hello, adding max_fragment_length extension" \
1292 -s "found max fragment length extension" \
1293 -s "server hello, max_fragment_length extension" \
1294 -c "found max_fragment_length extension"
1295
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001296run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001297 "$P_SRV debug_level=3 max_frag_len=4096" \
1298 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001299 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001300 -c "Maximum fragment length is 16384" \
1301 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001302 -C "client hello, adding max_fragment_length extension" \
1303 -S "found max fragment length extension" \
1304 -S "server hello, max_fragment_length extension" \
1305 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001307requires_gnutls
1308run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001309 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001310 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001311 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001312 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001313 -c "client hello, adding max_fragment_length extension" \
1314 -c "found max_fragment_length extension"
1315
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001316run_test "Max fragment length: client, message just fits" \
1317 "$P_SRV debug_level=3" \
1318 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1319 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001320 -c "Maximum fragment length is 2048" \
1321 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001322 -c "client hello, adding max_fragment_length extension" \
1323 -s "found max fragment length extension" \
1324 -s "server hello, max_fragment_length extension" \
1325 -c "found max_fragment_length extension" \
1326 -c "2048 bytes written in 1 fragments" \
1327 -s "2048 bytes read"
1328
1329run_test "Max fragment length: client, larger message" \
1330 "$P_SRV debug_level=3" \
1331 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1332 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001333 -c "Maximum fragment length is 2048" \
1334 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001335 -c "client hello, adding max_fragment_length extension" \
1336 -s "found max fragment length extension" \
1337 -s "server hello, max_fragment_length extension" \
1338 -c "found max_fragment_length extension" \
1339 -c "2345 bytes written in 2 fragments" \
1340 -s "2048 bytes read" \
1341 -s "297 bytes read"
1342
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001343run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001344 "$P_SRV debug_level=3 dtls=1" \
1345 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1346 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001347 -c "Maximum fragment length is 2048" \
1348 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001349 -c "client hello, adding max_fragment_length extension" \
1350 -s "found max fragment length extension" \
1351 -s "server hello, max_fragment_length extension" \
1352 -c "found max_fragment_length extension" \
1353 -c "fragment larger than.*maximum"
1354
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001355# Tests for renegotiation
1356
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001357run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001358 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001359 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001360 0 \
1361 -C "client hello, adding renegotiation extension" \
1362 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1363 -S "found renegotiation extension" \
1364 -s "server hello, secure renegotiation extension" \
1365 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001366 -C "=> renegotiate" \
1367 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001368 -S "write hello request"
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001371 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001373 0 \
1374 -c "client hello, adding renegotiation extension" \
1375 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1376 -s "found renegotiation extension" \
1377 -s "server hello, secure renegotiation extension" \
1378 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001379 -c "=> renegotiate" \
1380 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001381 -S "write hello request"
1382
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001383run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001384 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001385 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001386 0 \
1387 -c "client hello, adding renegotiation extension" \
1388 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1389 -s "found renegotiation extension" \
1390 -s "server hello, secure renegotiation extension" \
1391 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001392 -c "=> renegotiate" \
1393 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001394 -s "write hello request"
1395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001396run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001397 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001398 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001399 0 \
1400 -c "client hello, adding renegotiation extension" \
1401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1402 -s "found renegotiation extension" \
1403 -s "server hello, secure renegotiation extension" \
1404 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001405 -c "=> renegotiate" \
1406 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001407 -s "write hello request"
1408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001409run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001410 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001411 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001412 1 \
1413 -c "client hello, adding renegotiation extension" \
1414 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1415 -S "found renegotiation extension" \
1416 -s "server hello, secure renegotiation extension" \
1417 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001418 -c "=> renegotiate" \
1419 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001420 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001421 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001422 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001423
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001424run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001425 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001426 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001427 0 \
1428 -C "client hello, adding renegotiation extension" \
1429 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1430 -S "found renegotiation extension" \
1431 -s "server hello, secure renegotiation extension" \
1432 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001433 -C "=> renegotiate" \
1434 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001435 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001436 -S "SSL - An unexpected message was received from our peer" \
1437 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001439run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001441 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001442 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001443 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 -S "SSL - An unexpected message was received from our peer" \
1453 -S "failed"
1454
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001455# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001456run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001457 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001458 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001459 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001460 0 \
1461 -C "client hello, adding renegotiation extension" \
1462 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1463 -S "found renegotiation extension" \
1464 -s "server hello, secure renegotiation extension" \
1465 -c "found renegotiation extension" \
1466 -C "=> renegotiate" \
1467 -S "=> renegotiate" \
1468 -s "write hello request" \
1469 -S "SSL - An unexpected message was received from our peer" \
1470 -S "failed"
1471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001472run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001473 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001474 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001476 0 \
1477 -C "client hello, adding renegotiation extension" \
1478 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1479 -S "found renegotiation extension" \
1480 -s "server hello, secure renegotiation extension" \
1481 -c "found renegotiation extension" \
1482 -C "=> renegotiate" \
1483 -S "=> renegotiate" \
1484 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001485 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001487run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001489 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001490 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001491 0 \
1492 -c "client hello, adding renegotiation extension" \
1493 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1494 -s "found renegotiation extension" \
1495 -s "server hello, secure renegotiation extension" \
1496 -c "found renegotiation extension" \
1497 -c "=> renegotiate" \
1498 -s "=> renegotiate" \
1499 -s "write hello request" \
1500 -S "SSL - An unexpected message was received from our peer" \
1501 -S "failed"
1502
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001503run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001504 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001505 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1506 0 \
1507 -C "client hello, adding renegotiation extension" \
1508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1509 -S "found renegotiation extension" \
1510 -s "server hello, secure renegotiation extension" \
1511 -c "found renegotiation extension" \
1512 -S "record counter limit reached: renegotiate" \
1513 -C "=> renegotiate" \
1514 -S "=> renegotiate" \
1515 -S "write hello request" \
1516 -S "SSL - An unexpected message was received from our peer" \
1517 -S "failed"
1518
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001519# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001520run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001521 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001522 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001523 0 \
1524 -c "client hello, adding renegotiation extension" \
1525 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1526 -s "found renegotiation extension" \
1527 -s "server hello, secure renegotiation extension" \
1528 -c "found renegotiation extension" \
1529 -s "record counter limit reached: renegotiate" \
1530 -c "=> renegotiate" \
1531 -s "=> renegotiate" \
1532 -s "write hello request" \
1533 -S "SSL - An unexpected message was received from our peer" \
1534 -S "failed"
1535
1536run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001537 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001538 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001539 0 \
1540 -c "client hello, adding renegotiation extension" \
1541 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1542 -s "found renegotiation extension" \
1543 -s "server hello, secure renegotiation extension" \
1544 -c "found renegotiation extension" \
1545 -s "record counter limit reached: renegotiate" \
1546 -c "=> renegotiate" \
1547 -s "=> renegotiate" \
1548 -s "write hello request" \
1549 -S "SSL - An unexpected message was received from our peer" \
1550 -S "failed"
1551
1552run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001553 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001554 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1555 0 \
1556 -C "client hello, adding renegotiation extension" \
1557 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1558 -S "found renegotiation extension" \
1559 -s "server hello, secure renegotiation extension" \
1560 -c "found renegotiation extension" \
1561 -S "record counter limit reached: renegotiate" \
1562 -C "=> renegotiate" \
1563 -S "=> renegotiate" \
1564 -S "write hello request" \
1565 -S "SSL - An unexpected message was received from our peer" \
1566 -S "failed"
1567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001568run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001569 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001570 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001571 0 \
1572 -c "client hello, adding renegotiation extension" \
1573 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1574 -s "found renegotiation extension" \
1575 -s "server hello, secure renegotiation extension" \
1576 -c "found renegotiation extension" \
1577 -c "=> renegotiate" \
1578 -s "=> renegotiate" \
1579 -S "write hello request"
1580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001581run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001582 "$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 +02001583 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001584 0 \
1585 -c "client hello, adding renegotiation extension" \
1586 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1587 -s "found renegotiation extension" \
1588 -s "server hello, secure renegotiation extension" \
1589 -c "found renegotiation extension" \
1590 -c "=> renegotiate" \
1591 -s "=> renegotiate" \
1592 -s "write hello request"
1593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001594run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001595 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001596 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001597 0 \
1598 -c "client hello, adding renegotiation extension" \
1599 -c "found renegotiation extension" \
1600 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001601 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001602 -C "error" \
1603 -c "HTTP/1.0 200 [Oo][Kk]"
1604
Paul Bakker539d9722015-02-08 16:18:35 +01001605requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001606run_test "Renegotiation: gnutls server strict, client-initiated" \
1607 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001608 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001609 0 \
1610 -c "client hello, adding renegotiation extension" \
1611 -c "found renegotiation extension" \
1612 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001613 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001614 -C "error" \
1615 -c "HTTP/1.0 200 [Oo][Kk]"
1616
Paul Bakker539d9722015-02-08 16:18:35 +01001617requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001618run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1619 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1620 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1621 1 \
1622 -c "client hello, adding renegotiation extension" \
1623 -C "found renegotiation extension" \
1624 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001625 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001626 -c "error" \
1627 -C "HTTP/1.0 200 [Oo][Kk]"
1628
Paul Bakker539d9722015-02-08 16:18:35 +01001629requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001630run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1631 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1632 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1633 allow_legacy=0" \
1634 1 \
1635 -c "client hello, adding renegotiation extension" \
1636 -C "found renegotiation extension" \
1637 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001638 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001639 -c "error" \
1640 -C "HTTP/1.0 200 [Oo][Kk]"
1641
Paul Bakker539d9722015-02-08 16:18:35 +01001642requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001643run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1644 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1645 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1646 allow_legacy=1" \
1647 0 \
1648 -c "client hello, adding renegotiation extension" \
1649 -C "found renegotiation extension" \
1650 -c "=> renegotiate" \
1651 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001652 -C "error" \
1653 -c "HTTP/1.0 200 [Oo][Kk]"
1654
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001655run_test "Renegotiation: DTLS, client-initiated" \
1656 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1657 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1658 0 \
1659 -c "client hello, adding renegotiation extension" \
1660 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1661 -s "found renegotiation extension" \
1662 -s "server hello, secure renegotiation extension" \
1663 -c "found renegotiation extension" \
1664 -c "=> renegotiate" \
1665 -s "=> renegotiate" \
1666 -S "write hello request"
1667
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001668run_test "Renegotiation: DTLS, server-initiated" \
1669 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001670 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1671 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001672 0 \
1673 -c "client hello, adding renegotiation extension" \
1674 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1675 -s "found renegotiation extension" \
1676 -s "server hello, secure renegotiation extension" \
1677 -c "found renegotiation extension" \
1678 -c "=> renegotiate" \
1679 -s "=> renegotiate" \
1680 -s "write hello request"
1681
Andres AG692ad842017-01-19 16:30:57 +00001682run_test "Renegotiation: DTLS, renego_period overflow" \
1683 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1684 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1685 0 \
1686 -c "client hello, adding renegotiation extension" \
1687 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1688 -s "found renegotiation extension" \
1689 -s "server hello, secure renegotiation extension" \
1690 -s "record counter limit reached: renegotiate" \
1691 -c "=> renegotiate" \
1692 -s "=> renegotiate" \
1693 -s "write hello request" \
1694
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001695requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001696run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1697 "$G_SRV -u --mtu 4096" \
1698 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1699 0 \
1700 -c "client hello, adding renegotiation extension" \
1701 -c "found renegotiation extension" \
1702 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001703 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001704 -C "error" \
1705 -s "Extra-header:"
1706
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001707# Test for the "secure renegotation" extension only (no actual renegotiation)
1708
Paul Bakker539d9722015-02-08 16:18:35 +01001709requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001710run_test "Renego ext: gnutls server strict, client default" \
1711 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1712 "$P_CLI debug_level=3" \
1713 0 \
1714 -c "found renegotiation extension" \
1715 -C "error" \
1716 -c "HTTP/1.0 200 [Oo][Kk]"
1717
Paul Bakker539d9722015-02-08 16:18:35 +01001718requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001719run_test "Renego ext: gnutls server unsafe, client default" \
1720 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1721 "$P_CLI debug_level=3" \
1722 0 \
1723 -C "found renegotiation extension" \
1724 -C "error" \
1725 -c "HTTP/1.0 200 [Oo][Kk]"
1726
Paul Bakker539d9722015-02-08 16:18:35 +01001727requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001728run_test "Renego ext: gnutls server unsafe, client break legacy" \
1729 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1730 "$P_CLI debug_level=3 allow_legacy=-1" \
1731 1 \
1732 -C "found renegotiation extension" \
1733 -c "error" \
1734 -C "HTTP/1.0 200 [Oo][Kk]"
1735
Paul Bakker539d9722015-02-08 16:18:35 +01001736requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001737run_test "Renego ext: gnutls client strict, server default" \
1738 "$P_SRV debug_level=3" \
1739 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1740 0 \
1741 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1742 -s "server hello, secure renegotiation extension"
1743
Paul Bakker539d9722015-02-08 16:18:35 +01001744requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001745run_test "Renego ext: gnutls client unsafe, server default" \
1746 "$P_SRV debug_level=3" \
1747 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1748 0 \
1749 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1750 -S "server hello, secure renegotiation extension"
1751
Paul Bakker539d9722015-02-08 16:18:35 +01001752requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001753run_test "Renego ext: gnutls client unsafe, server break legacy" \
1754 "$P_SRV debug_level=3 allow_legacy=-1" \
1755 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1756 1 \
1757 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1758 -S "server hello, secure renegotiation extension"
1759
Janos Follath0b242342016-02-17 10:11:21 +00001760# Tests for silently dropping trailing extra bytes in .der certificates
1761
1762requires_gnutls
1763run_test "DER format: no trailing bytes" \
1764 "$P_SRV crt_file=data_files/server5-der0.crt \
1765 key_file=data_files/server5.key" \
1766 "$G_CLI " \
1767 0 \
1768 -c "Handshake was completed" \
1769
1770requires_gnutls
1771run_test "DER format: with a trailing zero byte" \
1772 "$P_SRV crt_file=data_files/server5-der1a.crt \
1773 key_file=data_files/server5.key" \
1774 "$G_CLI " \
1775 0 \
1776 -c "Handshake was completed" \
1777
1778requires_gnutls
1779run_test "DER format: with a trailing random byte" \
1780 "$P_SRV crt_file=data_files/server5-der1b.crt \
1781 key_file=data_files/server5.key" \
1782 "$G_CLI " \
1783 0 \
1784 -c "Handshake was completed" \
1785
1786requires_gnutls
1787run_test "DER format: with 2 trailing random bytes" \
1788 "$P_SRV crt_file=data_files/server5-der2.crt \
1789 key_file=data_files/server5.key" \
1790 "$G_CLI " \
1791 0 \
1792 -c "Handshake was completed" \
1793
1794requires_gnutls
1795run_test "DER format: with 4 trailing random bytes" \
1796 "$P_SRV crt_file=data_files/server5-der4.crt \
1797 key_file=data_files/server5.key" \
1798 "$G_CLI " \
1799 0 \
1800 -c "Handshake was completed" \
1801
1802requires_gnutls
1803run_test "DER format: with 8 trailing random bytes" \
1804 "$P_SRV crt_file=data_files/server5-der8.crt \
1805 key_file=data_files/server5.key" \
1806 "$G_CLI " \
1807 0 \
1808 -c "Handshake was completed" \
1809
1810requires_gnutls
1811run_test "DER format: with 9 trailing random bytes" \
1812 "$P_SRV crt_file=data_files/server5-der9.crt \
1813 key_file=data_files/server5.key" \
1814 "$G_CLI " \
1815 0 \
1816 -c "Handshake was completed" \
1817
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001818# Tests for auth_mode
1819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001820run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001821 "$P_SRV crt_file=data_files/server5-badsign.crt \
1822 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001823 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001824 1 \
1825 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001826 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001827 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001828 -c "X509 - Certificate verification failed"
1829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001830run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001831 "$P_SRV crt_file=data_files/server5-badsign.crt \
1832 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001833 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001834 0 \
1835 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001836 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001837 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001838 -C "X509 - Certificate verification failed"
1839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001840run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001841 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001842 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001843 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001844 0 \
1845 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001846 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001847 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001848 -C "X509 - Certificate verification failed"
1849
Simon Butcher99000142016-10-13 17:21:01 +01001850run_test "Authentication: client SHA256, server required" \
1851 "$P_SRV auth_mode=required" \
1852 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1853 key_file=data_files/server6.key \
1854 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1855 0 \
1856 -c "Supported Signature Algorithm found: 4," \
1857 -c "Supported Signature Algorithm found: 5,"
1858
1859run_test "Authentication: client SHA384, server required" \
1860 "$P_SRV auth_mode=required" \
1861 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1862 key_file=data_files/server6.key \
1863 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1864 0 \
1865 -c "Supported Signature Algorithm found: 4," \
1866 -c "Supported Signature Algorithm found: 5,"
1867
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001868requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1869run_test "Authentication: client has no cert, server required (SSLv3)" \
1870 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1871 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1872 key_file=data_files/server5.key" \
1873 1 \
1874 -S "skip write certificate request" \
1875 -C "skip parse certificate request" \
1876 -c "got a certificate request" \
1877 -c "got no certificate to send" \
1878 -S "x509_verify_cert() returned" \
1879 -s "client has no certificate" \
1880 -s "! mbedtls_ssl_handshake returned" \
1881 -c "! mbedtls_ssl_handshake returned" \
1882 -s "No client certification received from the client, but required by the authentication mode"
1883
1884run_test "Authentication: client has no cert, server required (TLS)" \
1885 "$P_SRV debug_level=3 auth_mode=required" \
1886 "$P_CLI debug_level=3 crt_file=none \
1887 key_file=data_files/server5.key" \
1888 1 \
1889 -S "skip write certificate request" \
1890 -C "skip parse certificate request" \
1891 -c "got a certificate request" \
1892 -c "= write certificate$" \
1893 -C "skip write certificate$" \
1894 -S "x509_verify_cert() returned" \
1895 -s "client has no certificate" \
1896 -s "! mbedtls_ssl_handshake returned" \
1897 -c "! mbedtls_ssl_handshake returned" \
1898 -s "No client certification received from the client, but required by the authentication mode"
1899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001900run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001901 "$P_SRV debug_level=3 auth_mode=required" \
1902 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001903 key_file=data_files/server5.key" \
1904 1 \
1905 -S "skip write certificate request" \
1906 -C "skip parse certificate request" \
1907 -c "got a certificate request" \
1908 -C "skip write certificate" \
1909 -C "skip write certificate verify" \
1910 -S "skip parse certificate verify" \
1911 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001912 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001913 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001914 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001915 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001916 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02001917# We don't check that the client receives the alert because it might
1918# detect that its write end of the connection is closed and abort
1919# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001920
Janos Follath89baba22017-04-10 14:34:35 +01001921run_test "Authentication: client cert not trusted, server required" \
1922 "$P_SRV debug_level=3 auth_mode=required" \
1923 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
1924 key_file=data_files/server5.key" \
1925 1 \
1926 -S "skip write certificate request" \
1927 -C "skip parse certificate request" \
1928 -c "got a certificate request" \
1929 -C "skip write certificate" \
1930 -C "skip write certificate verify" \
1931 -S "skip parse certificate verify" \
1932 -s "x509_verify_cert() returned" \
1933 -s "! The certificate is not correctly signed by the trusted CA" \
1934 -s "! mbedtls_ssl_handshake returned" \
1935 -c "! mbedtls_ssl_handshake returned" \
1936 -s "X509 - Certificate verification failed"
1937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001938run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001939 "$P_SRV debug_level=3 auth_mode=optional" \
1940 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001941 key_file=data_files/server5.key" \
1942 0 \
1943 -S "skip write certificate request" \
1944 -C "skip parse certificate request" \
1945 -c "got a certificate request" \
1946 -C "skip write certificate" \
1947 -C "skip write certificate verify" \
1948 -S "skip parse certificate verify" \
1949 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001950 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001951 -S "! mbedtls_ssl_handshake returned" \
1952 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001953 -S "X509 - Certificate verification failed"
1954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001955run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001956 "$P_SRV debug_level=3 auth_mode=none" \
1957 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001958 key_file=data_files/server5.key" \
1959 0 \
1960 -s "skip write certificate request" \
1961 -C "skip parse certificate request" \
1962 -c "got no certificate request" \
1963 -c "skip write certificate" \
1964 -c "skip write certificate verify" \
1965 -s "skip parse certificate verify" \
1966 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001967 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001968 -S "! mbedtls_ssl_handshake returned" \
1969 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001970 -S "X509 - Certificate verification failed"
1971
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001972run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001973 "$P_SRV debug_level=3 auth_mode=optional" \
1974 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001975 0 \
1976 -S "skip write certificate request" \
1977 -C "skip parse certificate request" \
1978 -c "got a certificate request" \
1979 -C "skip write certificate$" \
1980 -C "got no certificate to send" \
1981 -S "SSLv3 client has no certificate" \
1982 -c "skip write certificate verify" \
1983 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001984 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001985 -S "! mbedtls_ssl_handshake returned" \
1986 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001987 -S "X509 - Certificate verification failed"
1988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001989run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001990 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001991 "$O_CLI" \
1992 0 \
1993 -S "skip write certificate request" \
1994 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001995 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001996 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001997 -S "X509 - Certificate verification failed"
1998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001999run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002000 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002001 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002002 0 \
2003 -C "skip parse certificate request" \
2004 -c "got a certificate request" \
2005 -C "skip write certificate$" \
2006 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002007 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002008
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002009run_test "Authentication: client no cert, openssl server required" \
2010 "$O_SRV -Verify 10" \
2011 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2012 1 \
2013 -C "skip parse certificate request" \
2014 -c "got a certificate request" \
2015 -C "skip write certificate$" \
2016 -c "skip write certificate verify" \
2017 -c "! mbedtls_ssl_handshake returned"
2018
Janos Follathe2681a42016-03-07 15:57:05 +00002019requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002021 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002022 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002023 0 \
2024 -S "skip write certificate request" \
2025 -C "skip parse certificate request" \
2026 -c "got a certificate request" \
2027 -C "skip write certificate$" \
2028 -c "skip write certificate verify" \
2029 -c "got no certificate to send" \
2030 -s "SSLv3 client has no certificate" \
2031 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002032 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002033 -S "! mbedtls_ssl_handshake returned" \
2034 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002035 -S "X509 - Certificate verification failed"
2036
Janos Follath89baba22017-04-10 14:34:35 +01002037# Tests for CA list in CertificateRequest messages
2038
2039run_test "Authentication: send CA list in CertificateRequest (default)" \
2040 "$P_SRV debug_level=3 auth_mode=required" \
2041 "$P_CLI crt_file=data_files/server6.crt \
2042 key_file=data_files/server6.key" \
2043 0 \
2044 -s "requested DN"
2045
2046run_test "Authentication: do not send CA list in CertificateRequest" \
2047 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2048 "$P_CLI crt_file=data_files/server6.crt \
2049 key_file=data_files/server6.key" \
2050 0 \
2051 -S "requested DN"
2052
2053run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2054 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2055 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2056 key_file=data_files/server5.key" \
2057 1 \
2058 -S "requested DN" \
2059 -s "x509_verify_cert() returned" \
2060 -s "! The certificate is not correctly signed by the trusted CA" \
2061 -s "! mbedtls_ssl_handshake returned" \
2062 -c "! mbedtls_ssl_handshake returned" \
2063 -s "X509 - Certificate verification failed"
2064
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002065# Tests for certificate selection based on SHA verson
2066
2067run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2068 "$P_SRV crt_file=data_files/server5.crt \
2069 key_file=data_files/server5.key \
2070 crt_file2=data_files/server5-sha1.crt \
2071 key_file2=data_files/server5.key" \
2072 "$P_CLI force_version=tls1_2" \
2073 0 \
2074 -c "signed using.*ECDSA with SHA256" \
2075 -C "signed using.*ECDSA with SHA1"
2076
2077run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2078 "$P_SRV crt_file=data_files/server5.crt \
2079 key_file=data_files/server5.key \
2080 crt_file2=data_files/server5-sha1.crt \
2081 key_file2=data_files/server5.key" \
2082 "$P_CLI force_version=tls1_1" \
2083 0 \
2084 -C "signed using.*ECDSA with SHA256" \
2085 -c "signed using.*ECDSA with SHA1"
2086
2087run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2088 "$P_SRV crt_file=data_files/server5.crt \
2089 key_file=data_files/server5.key \
2090 crt_file2=data_files/server5-sha1.crt \
2091 key_file2=data_files/server5.key" \
2092 "$P_CLI force_version=tls1" \
2093 0 \
2094 -C "signed using.*ECDSA with SHA256" \
2095 -c "signed using.*ECDSA with SHA1"
2096
2097run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2098 "$P_SRV crt_file=data_files/server5.crt \
2099 key_file=data_files/server5.key \
2100 crt_file2=data_files/server6.crt \
2101 key_file2=data_files/server6.key" \
2102 "$P_CLI force_version=tls1_1" \
2103 0 \
2104 -c "serial number.*09" \
2105 -c "signed using.*ECDSA with SHA256" \
2106 -C "signed using.*ECDSA with SHA1"
2107
2108run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2109 "$P_SRV crt_file=data_files/server6.crt \
2110 key_file=data_files/server6.key \
2111 crt_file2=data_files/server5.crt \
2112 key_file2=data_files/server5.key" \
2113 "$P_CLI force_version=tls1_1" \
2114 0 \
2115 -c "serial number.*0A" \
2116 -c "signed using.*ECDSA with SHA256" \
2117 -C "signed using.*ECDSA with SHA1"
2118
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002119# tests for SNI
2120
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002121run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002122 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002123 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002124 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002125 0 \
2126 -S "parse ServerName extension" \
2127 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2128 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002130run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002131 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002132 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002133 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 +02002134 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002135 0 \
2136 -s "parse ServerName extension" \
2137 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2138 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002139
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002141 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002142 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002143 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 +02002144 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002145 0 \
2146 -s "parse ServerName extension" \
2147 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2148 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002150run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002151 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002152 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002153 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 +02002154 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002155 1 \
2156 -s "parse ServerName extension" \
2157 -s "ssl_sni_wrapper() returned" \
2158 -s "mbedtls_ssl_handshake returned" \
2159 -c "mbedtls_ssl_handshake returned" \
2160 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002161
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002162run_test "SNI: client auth no override: optional" \
2163 "$P_SRV debug_level=3 auth_mode=optional \
2164 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2165 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2166 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002167 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002168 -S "skip write certificate request" \
2169 -C "skip parse certificate request" \
2170 -c "got a certificate request" \
2171 -C "skip write certificate" \
2172 -C "skip write certificate verify" \
2173 -S "skip parse certificate verify"
2174
2175run_test "SNI: client auth override: none -> optional" \
2176 "$P_SRV debug_level=3 auth_mode=none \
2177 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2178 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2179 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002180 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002181 -S "skip write certificate request" \
2182 -C "skip parse certificate request" \
2183 -c "got a certificate request" \
2184 -C "skip write certificate" \
2185 -C "skip write certificate verify" \
2186 -S "skip parse certificate verify"
2187
2188run_test "SNI: client auth override: optional -> none" \
2189 "$P_SRV debug_level=3 auth_mode=optional \
2190 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2191 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2192 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002193 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002194 -s "skip write certificate request" \
2195 -C "skip parse certificate request" \
2196 -c "got no certificate request" \
2197 -c "skip write certificate" \
2198 -c "skip write certificate verify" \
2199 -s "skip parse certificate verify"
2200
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002201run_test "SNI: CA no override" \
2202 "$P_SRV debug_level=3 auth_mode=optional \
2203 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2204 ca_file=data_files/test-ca.crt \
2205 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2206 "$P_CLI debug_level=3 server_name=localhost \
2207 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2208 1 \
2209 -S "skip write certificate request" \
2210 -C "skip parse certificate request" \
2211 -c "got a certificate request" \
2212 -C "skip write certificate" \
2213 -C "skip write certificate verify" \
2214 -S "skip parse certificate verify" \
2215 -s "x509_verify_cert() returned" \
2216 -s "! The certificate is not correctly signed by the trusted CA" \
2217 -S "The certificate has been revoked (is on a CRL)"
2218
2219run_test "SNI: CA override" \
2220 "$P_SRV debug_level=3 auth_mode=optional \
2221 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2222 ca_file=data_files/test-ca.crt \
2223 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2224 "$P_CLI debug_level=3 server_name=localhost \
2225 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2226 0 \
2227 -S "skip write certificate request" \
2228 -C "skip parse certificate request" \
2229 -c "got a certificate request" \
2230 -C "skip write certificate" \
2231 -C "skip write certificate verify" \
2232 -S "skip parse certificate verify" \
2233 -S "x509_verify_cert() returned" \
2234 -S "! The certificate is not correctly signed by the trusted CA" \
2235 -S "The certificate has been revoked (is on a CRL)"
2236
2237run_test "SNI: CA override with CRL" \
2238 "$P_SRV debug_level=3 auth_mode=optional \
2239 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2240 ca_file=data_files/test-ca.crt \
2241 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2242 "$P_CLI debug_level=3 server_name=localhost \
2243 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2244 1 \
2245 -S "skip write certificate request" \
2246 -C "skip parse certificate request" \
2247 -c "got a certificate request" \
2248 -C "skip write certificate" \
2249 -C "skip write certificate verify" \
2250 -S "skip parse certificate verify" \
2251 -s "x509_verify_cert() returned" \
2252 -S "! The certificate is not correctly signed by the trusted CA" \
2253 -s "The certificate has been revoked (is on a CRL)"
2254
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002255# Tests for non-blocking I/O: exercise a variety of handshake flows
2256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002257run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002258 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2259 "$P_CLI nbio=2 tickets=0" \
2260 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002261 -S "mbedtls_ssl_handshake returned" \
2262 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002263 -c "Read from server: .* bytes read"
2264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002265run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002266 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2267 "$P_CLI nbio=2 tickets=0" \
2268 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002269 -S "mbedtls_ssl_handshake returned" \
2270 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002271 -c "Read from server: .* bytes read"
2272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002273run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002274 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2275 "$P_CLI nbio=2 tickets=1" \
2276 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002277 -S "mbedtls_ssl_handshake returned" \
2278 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002279 -c "Read from server: .* bytes read"
2280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002281run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002282 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2283 "$P_CLI nbio=2 tickets=1" \
2284 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002285 -S "mbedtls_ssl_handshake returned" \
2286 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002287 -c "Read from server: .* bytes read"
2288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002289run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002290 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2291 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2292 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002293 -S "mbedtls_ssl_handshake returned" \
2294 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002295 -c "Read from server: .* bytes read"
2296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002297run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002298 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2299 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2300 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002301 -S "mbedtls_ssl_handshake returned" \
2302 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002303 -c "Read from server: .* bytes read"
2304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002305run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002306 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2307 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2308 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002309 -S "mbedtls_ssl_handshake returned" \
2310 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002311 -c "Read from server: .* bytes read"
2312
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002313# Tests for version negotiation
2314
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002315run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002316 "$P_SRV" \
2317 "$P_CLI" \
2318 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002319 -S "mbedtls_ssl_handshake returned" \
2320 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002321 -s "Protocol is TLSv1.2" \
2322 -c "Protocol is TLSv1.2"
2323
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002325 "$P_SRV" \
2326 "$P_CLI max_version=tls1_1" \
2327 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002328 -S "mbedtls_ssl_handshake returned" \
2329 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002330 -s "Protocol is TLSv1.1" \
2331 -c "Protocol is TLSv1.1"
2332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002333run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002334 "$P_SRV max_version=tls1_1" \
2335 "$P_CLI" \
2336 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002337 -S "mbedtls_ssl_handshake returned" \
2338 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002339 -s "Protocol is TLSv1.1" \
2340 -c "Protocol is TLSv1.1"
2341
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002342run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002343 "$P_SRV max_version=tls1_1" \
2344 "$P_CLI max_version=tls1_1" \
2345 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002346 -S "mbedtls_ssl_handshake returned" \
2347 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002348 -s "Protocol is TLSv1.1" \
2349 -c "Protocol is TLSv1.1"
2350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002351run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002352 "$P_SRV min_version=tls1_1" \
2353 "$P_CLI max_version=tls1_1" \
2354 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002355 -S "mbedtls_ssl_handshake returned" \
2356 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002357 -s "Protocol is TLSv1.1" \
2358 -c "Protocol is TLSv1.1"
2359
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002360run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002361 "$P_SRV max_version=tls1_1" \
2362 "$P_CLI min_version=tls1_1" \
2363 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002364 -S "mbedtls_ssl_handshake returned" \
2365 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002366 -s "Protocol is TLSv1.1" \
2367 -c "Protocol is TLSv1.1"
2368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002369run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002370 "$P_SRV max_version=tls1_1" \
2371 "$P_CLI min_version=tls1_2" \
2372 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002373 -s "mbedtls_ssl_handshake returned" \
2374 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002375 -c "SSL - Handshake protocol not within min/max boundaries"
2376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002377run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002378 "$P_SRV min_version=tls1_2" \
2379 "$P_CLI max_version=tls1_1" \
2380 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002381 -s "mbedtls_ssl_handshake returned" \
2382 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002383 -s "SSL - Handshake protocol not within min/max boundaries"
2384
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002385# Tests for ALPN extension
2386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002387run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002388 "$P_SRV debug_level=3" \
2389 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002390 0 \
2391 -C "client hello, adding alpn extension" \
2392 -S "found alpn extension" \
2393 -C "got an alert message, type: \\[2:120]" \
2394 -S "server hello, adding alpn extension" \
2395 -C "found alpn extension " \
2396 -C "Application Layer Protocol is" \
2397 -S "Application Layer Protocol is"
2398
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002399run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002400 "$P_SRV debug_level=3" \
2401 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002402 0 \
2403 -c "client hello, adding alpn extension" \
2404 -s "found alpn extension" \
2405 -C "got an alert message, type: \\[2:120]" \
2406 -S "server hello, adding alpn extension" \
2407 -C "found alpn extension " \
2408 -c "Application Layer Protocol is (none)" \
2409 -S "Application Layer Protocol is"
2410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002411run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002412 "$P_SRV debug_level=3 alpn=abc,1234" \
2413 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002414 0 \
2415 -C "client hello, adding alpn extension" \
2416 -S "found alpn extension" \
2417 -C "got an alert message, type: \\[2:120]" \
2418 -S "server hello, adding alpn extension" \
2419 -C "found alpn extension " \
2420 -C "Application Layer Protocol is" \
2421 -s "Application Layer Protocol is (none)"
2422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002423run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002424 "$P_SRV debug_level=3 alpn=abc,1234" \
2425 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002426 0 \
2427 -c "client hello, adding alpn extension" \
2428 -s "found alpn extension" \
2429 -C "got an alert message, type: \\[2:120]" \
2430 -s "server hello, adding alpn extension" \
2431 -c "found alpn extension" \
2432 -c "Application Layer Protocol is abc" \
2433 -s "Application Layer Protocol is abc"
2434
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002435run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002436 "$P_SRV debug_level=3 alpn=abc,1234" \
2437 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002438 0 \
2439 -c "client hello, adding alpn extension" \
2440 -s "found alpn extension" \
2441 -C "got an alert message, type: \\[2:120]" \
2442 -s "server hello, adding alpn extension" \
2443 -c "found alpn extension" \
2444 -c "Application Layer Protocol is abc" \
2445 -s "Application Layer Protocol is abc"
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002448 "$P_SRV debug_level=3 alpn=abc,1234" \
2449 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002450 0 \
2451 -c "client hello, adding alpn extension" \
2452 -s "found alpn extension" \
2453 -C "got an alert message, type: \\[2:120]" \
2454 -s "server hello, adding alpn extension" \
2455 -c "found alpn extension" \
2456 -c "Application Layer Protocol is 1234" \
2457 -s "Application Layer Protocol is 1234"
2458
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002459run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002460 "$P_SRV debug_level=3 alpn=abc,123" \
2461 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002462 1 \
2463 -c "client hello, adding alpn extension" \
2464 -s "found alpn extension" \
2465 -c "got an alert message, type: \\[2:120]" \
2466 -S "server hello, adding alpn extension" \
2467 -C "found alpn extension" \
2468 -C "Application Layer Protocol is 1234" \
2469 -S "Application Layer Protocol is 1234"
2470
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002471
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002472# Tests for keyUsage in leaf certificates, part 1:
2473# server-side certificate/suite selection
2474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002475run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002476 "$P_SRV key_file=data_files/server2.key \
2477 crt_file=data_files/server2.ku-ds.crt" \
2478 "$P_CLI" \
2479 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002480 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002481
2482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002483run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002484 "$P_SRV key_file=data_files/server2.key \
2485 crt_file=data_files/server2.ku-ke.crt" \
2486 "$P_CLI" \
2487 0 \
2488 -c "Ciphersuite is TLS-RSA-WITH-"
2489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002490run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002491 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002492 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002493 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002494 1 \
2495 -C "Ciphersuite is "
2496
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002497run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002498 "$P_SRV key_file=data_files/server5.key \
2499 crt_file=data_files/server5.ku-ds.crt" \
2500 "$P_CLI" \
2501 0 \
2502 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2503
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002506 "$P_SRV key_file=data_files/server5.key \
2507 crt_file=data_files/server5.ku-ka.crt" \
2508 "$P_CLI" \
2509 0 \
2510 -c "Ciphersuite is TLS-ECDH-"
2511
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002512run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002513 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002514 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002515 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002516 1 \
2517 -C "Ciphersuite is "
2518
2519# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002520# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002522run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002523 "$O_SRV -key data_files/server2.key \
2524 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002525 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002526 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2527 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002528 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002529 -C "Processing of the Certificate handshake message failed" \
2530 -c "Ciphersuite is TLS-"
2531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002532run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002533 "$O_SRV -key data_files/server2.key \
2534 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002535 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002536 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2537 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002538 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002539 -C "Processing of the Certificate handshake message failed" \
2540 -c "Ciphersuite is TLS-"
2541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002542run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002543 "$O_SRV -key data_files/server2.key \
2544 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002545 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002546 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2547 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002548 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002549 -C "Processing of the Certificate handshake message failed" \
2550 -c "Ciphersuite is TLS-"
2551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002552run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002553 "$O_SRV -key data_files/server2.key \
2554 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002555 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002556 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2557 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002558 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002559 -c "Processing of the Certificate handshake message failed" \
2560 -C "Ciphersuite is TLS-"
2561
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002562run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2563 "$O_SRV -key data_files/server2.key \
2564 -cert data_files/server2.ku-ke.crt" \
2565 "$P_CLI debug_level=1 auth_mode=optional \
2566 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2567 0 \
2568 -c "bad certificate (usage extensions)" \
2569 -C "Processing of the Certificate handshake message failed" \
2570 -c "Ciphersuite is TLS-" \
2571 -c "! Usage does not match the keyUsage extension"
2572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002573run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002574 "$O_SRV -key data_files/server2.key \
2575 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002576 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002577 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2578 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002579 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002580 -C "Processing of the Certificate handshake message failed" \
2581 -c "Ciphersuite is TLS-"
2582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002583run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002584 "$O_SRV -key data_files/server2.key \
2585 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002586 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002587 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2588 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002589 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002590 -c "Processing of the Certificate handshake message failed" \
2591 -C "Ciphersuite is TLS-"
2592
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002593run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2594 "$O_SRV -key data_files/server2.key \
2595 -cert data_files/server2.ku-ds.crt" \
2596 "$P_CLI debug_level=1 auth_mode=optional \
2597 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2598 0 \
2599 -c "bad certificate (usage extensions)" \
2600 -C "Processing of the Certificate handshake message failed" \
2601 -c "Ciphersuite is TLS-" \
2602 -c "! Usage does not match the keyUsage extension"
2603
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002604# Tests for keyUsage in leaf certificates, part 3:
2605# server-side checking of client cert
2606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002607run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002608 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002609 "$O_CLI -key data_files/server2.key \
2610 -cert data_files/server2.ku-ds.crt" \
2611 0 \
2612 -S "bad certificate (usage extensions)" \
2613 -S "Processing of the Certificate handshake message failed"
2614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002615run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002616 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002617 "$O_CLI -key data_files/server2.key \
2618 -cert data_files/server2.ku-ke.crt" \
2619 0 \
2620 -s "bad certificate (usage extensions)" \
2621 -S "Processing of the Certificate handshake message failed"
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002624 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002625 "$O_CLI -key data_files/server2.key \
2626 -cert data_files/server2.ku-ke.crt" \
2627 1 \
2628 -s "bad certificate (usage extensions)" \
2629 -s "Processing of the Certificate handshake message failed"
2630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002631run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002632 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002633 "$O_CLI -key data_files/server5.key \
2634 -cert data_files/server5.ku-ds.crt" \
2635 0 \
2636 -S "bad certificate (usage extensions)" \
2637 -S "Processing of the Certificate handshake message failed"
2638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002639run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002640 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002641 "$O_CLI -key data_files/server5.key \
2642 -cert data_files/server5.ku-ka.crt" \
2643 0 \
2644 -s "bad certificate (usage extensions)" \
2645 -S "Processing of the Certificate handshake message failed"
2646
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002647# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2648
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002649run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002650 "$P_SRV key_file=data_files/server5.key \
2651 crt_file=data_files/server5.eku-srv.crt" \
2652 "$P_CLI" \
2653 0
2654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002655run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002656 "$P_SRV key_file=data_files/server5.key \
2657 crt_file=data_files/server5.eku-srv.crt" \
2658 "$P_CLI" \
2659 0
2660
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002661run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002662 "$P_SRV key_file=data_files/server5.key \
2663 crt_file=data_files/server5.eku-cs_any.crt" \
2664 "$P_CLI" \
2665 0
2666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002667run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002668 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002669 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002670 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002671 1
2672
2673# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002675run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002676 "$O_SRV -key data_files/server5.key \
2677 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002678 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002679 0 \
2680 -C "bad certificate (usage extensions)" \
2681 -C "Processing of the Certificate handshake message failed" \
2682 -c "Ciphersuite is TLS-"
2683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002684run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002685 "$O_SRV -key data_files/server5.key \
2686 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002687 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002688 0 \
2689 -C "bad certificate (usage extensions)" \
2690 -C "Processing of the Certificate handshake message failed" \
2691 -c "Ciphersuite is TLS-"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002694 "$O_SRV -key data_files/server5.key \
2695 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002696 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002697 0 \
2698 -C "bad certificate (usage extensions)" \
2699 -C "Processing of the Certificate handshake message failed" \
2700 -c "Ciphersuite is TLS-"
2701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002702run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002703 "$O_SRV -key data_files/server5.key \
2704 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002705 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002706 1 \
2707 -c "bad certificate (usage extensions)" \
2708 -c "Processing of the Certificate handshake message failed" \
2709 -C "Ciphersuite is TLS-"
2710
2711# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002713run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002714 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002715 "$O_CLI -key data_files/server5.key \
2716 -cert data_files/server5.eku-cli.crt" \
2717 0 \
2718 -S "bad certificate (usage extensions)" \
2719 -S "Processing of the Certificate handshake message failed"
2720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002721run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002722 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002723 "$O_CLI -key data_files/server5.key \
2724 -cert data_files/server5.eku-srv_cli.crt" \
2725 0 \
2726 -S "bad certificate (usage extensions)" \
2727 -S "Processing of the Certificate handshake message failed"
2728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002729run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002730 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002731 "$O_CLI -key data_files/server5.key \
2732 -cert data_files/server5.eku-cs_any.crt" \
2733 0 \
2734 -S "bad certificate (usage extensions)" \
2735 -S "Processing of the Certificate handshake message failed"
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002738 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002739 "$O_CLI -key data_files/server5.key \
2740 -cert data_files/server5.eku-cs.crt" \
2741 0 \
2742 -s "bad certificate (usage extensions)" \
2743 -S "Processing of the Certificate handshake message failed"
2744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002746 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002747 "$O_CLI -key data_files/server5.key \
2748 -cert data_files/server5.eku-cs.crt" \
2749 1 \
2750 -s "bad certificate (usage extensions)" \
2751 -s "Processing of the Certificate handshake message failed"
2752
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002753# Tests for DHM parameters loading
2754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002755run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002756 "$P_SRV" \
2757 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2758 debug_level=3" \
2759 0 \
2760 -c "value of 'DHM: P ' (2048 bits)" \
2761 -c "value of 'DHM: G ' (2048 bits)"
2762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002763run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002764 "$P_SRV dhm_file=data_files/dhparams.pem" \
2765 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2766 debug_level=3" \
2767 0 \
2768 -c "value of 'DHM: P ' (1024 bits)" \
2769 -c "value of 'DHM: G ' (2 bits)"
2770
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002771# Tests for DHM client-side size checking
2772
2773run_test "DHM size: server default, client default, OK" \
2774 "$P_SRV" \
2775 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2776 debug_level=1" \
2777 0 \
2778 -C "DHM prime too short:"
2779
2780run_test "DHM size: server default, client 2048, OK" \
2781 "$P_SRV" \
2782 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2783 debug_level=1 dhmlen=2048" \
2784 0 \
2785 -C "DHM prime too short:"
2786
2787run_test "DHM size: server 1024, client default, OK" \
2788 "$P_SRV dhm_file=data_files/dhparams.pem" \
2789 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2790 debug_level=1" \
2791 0 \
2792 -C "DHM prime too short:"
2793
2794run_test "DHM size: server 1000, client default, rejected" \
2795 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2796 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2797 debug_level=1" \
2798 1 \
2799 -c "DHM prime too short:"
2800
2801run_test "DHM size: server default, client 2049, rejected" \
2802 "$P_SRV" \
2803 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2804 debug_level=1 dhmlen=2049" \
2805 1 \
2806 -c "DHM prime too short:"
2807
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002808# Tests for PSK callback
2809
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002810run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002811 "$P_SRV psk=abc123 psk_identity=foo" \
2812 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2813 psk_identity=foo psk=abc123" \
2814 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002815 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002816 -S "SSL - Unknown identity received" \
2817 -S "SSL - Verification of the message MAC failed"
2818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002819run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002820 "$P_SRV" \
2821 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2822 psk_identity=foo psk=abc123" \
2823 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002824 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002825 -S "SSL - Unknown identity received" \
2826 -S "SSL - Verification of the message MAC failed"
2827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002828run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002829 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2830 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2831 psk_identity=foo psk=abc123" \
2832 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002833 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002834 -s "SSL - Unknown identity received" \
2835 -S "SSL - Verification of the message MAC failed"
2836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002837run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002838 "$P_SRV psk_list=abc,dead,def,beef" \
2839 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2840 psk_identity=abc psk=dead" \
2841 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002842 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002843 -S "SSL - Unknown identity received" \
2844 -S "SSL - Verification of the message MAC failed"
2845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002847 "$P_SRV psk_list=abc,dead,def,beef" \
2848 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2849 psk_identity=def psk=beef" \
2850 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002851 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002852 -S "SSL - Unknown identity received" \
2853 -S "SSL - Verification of the message MAC failed"
2854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002855run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002856 "$P_SRV psk_list=abc,dead,def,beef" \
2857 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2858 psk_identity=ghi psk=beef" \
2859 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002860 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002861 -s "SSL - Unknown identity received" \
2862 -S "SSL - Verification of the message MAC failed"
2863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002864run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002865 "$P_SRV psk_list=abc,dead,def,beef" \
2866 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2867 psk_identity=abc psk=beef" \
2868 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002869 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002870 -S "SSL - Unknown identity received" \
2871 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002872
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002873# Tests for EC J-PAKE
2874
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002875requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002876run_test "ECJPAKE: client not configured" \
2877 "$P_SRV debug_level=3" \
2878 "$P_CLI debug_level=3" \
2879 0 \
2880 -C "add ciphersuite: c0ff" \
2881 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002882 -S "found ecjpake kkpp extension" \
2883 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002884 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002885 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002886 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002887 -S "None of the common ciphersuites is usable"
2888
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002889requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002890run_test "ECJPAKE: server not configured" \
2891 "$P_SRV debug_level=3" \
2892 "$P_CLI debug_level=3 ecjpake_pw=bla \
2893 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2894 1 \
2895 -c "add ciphersuite: c0ff" \
2896 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002897 -s "found ecjpake kkpp extension" \
2898 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002899 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002900 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002901 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02002902 -s "None of the common ciphersuites is usable"
2903
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002904requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002905run_test "ECJPAKE: working, TLS" \
2906 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2907 "$P_CLI debug_level=3 ecjpake_pw=bla \
2908 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02002909 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002910 -c "add ciphersuite: c0ff" \
2911 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002912 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002913 -s "found ecjpake kkpp extension" \
2914 -S "skip ecjpake kkpp extension" \
2915 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02002916 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02002917 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002918 -S "None of the common ciphersuites is usable" \
2919 -S "SSL - Verification of the message MAC failed"
2920
Janos Follath74537a62016-09-02 13:45:28 +01002921server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002922requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002923run_test "ECJPAKE: password mismatch, TLS" \
2924 "$P_SRV debug_level=3 ecjpake_pw=bla" \
2925 "$P_CLI debug_level=3 ecjpake_pw=bad \
2926 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2927 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002928 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002929 -s "SSL - Verification of the message MAC failed"
2930
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002931requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002932run_test "ECJPAKE: working, DTLS" \
2933 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2934 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2935 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2936 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002937 -c "re-using cached ecjpake parameters" \
2938 -S "SSL - Verification of the message MAC failed"
2939
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002940requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002941run_test "ECJPAKE: working, DTLS, no cookie" \
2942 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
2943 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
2944 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2945 0 \
2946 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002947 -S "SSL - Verification of the message MAC failed"
2948
Janos Follath74537a62016-09-02 13:45:28 +01002949server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002950requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002951run_test "ECJPAKE: password mismatch, DTLS" \
2952 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
2953 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
2954 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2955 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02002956 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02002957 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02002958
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002959# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02002960requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02002961run_test "ECJPAKE: working, DTLS, nolog" \
2962 "$P_SRV dtls=1 ecjpake_pw=bla" \
2963 "$P_CLI dtls=1 ecjpake_pw=bla \
2964 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
2965 0
2966
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002967# Tests for ciphersuites per version
2968
Janos Follathe2681a42016-03-07 15:57:05 +00002969requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002970run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002971 "$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 +02002972 "$P_CLI force_version=ssl3" \
2973 0 \
2974 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002976run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002977 "$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 +01002978 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002979 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002980 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002981
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002982run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002983 "$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 +02002984 "$P_CLI force_version=tls1_1" \
2985 0 \
2986 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002988run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002989 "$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 +02002990 "$P_CLI force_version=tls1_2" \
2991 0 \
2992 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2993
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002994# Test for ClientHello without extensions
2995
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002996requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02002997run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002998 "$P_SRV debug_level=3" \
2999 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3000 0 \
3001 -s "dumping 'client hello extensions' (0 bytes)"
3002
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003003requires_gnutls
3004run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3005 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3006 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3007 0 \
3008 -s "dumping 'client hello extensions' (0 bytes)"
3009
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003010# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003011
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003012run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003013 "$P_SRV" \
3014 "$P_CLI request_size=100" \
3015 0 \
3016 -s "Read from client: 100 bytes read$"
3017
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003018run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003019 "$P_SRV" \
3020 "$P_CLI request_size=500" \
3021 0 \
3022 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003023
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003024# Tests for small packets
3025
Janos Follathe2681a42016-03-07 15:57:05 +00003026requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003027run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003028 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003029 "$P_CLI request_size=1 force_version=ssl3 \
3030 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3031 0 \
3032 -s "Read from client: 1 bytes read"
3033
Janos Follathe2681a42016-03-07 15:57:05 +00003034requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003035run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003036 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003037 "$P_CLI request_size=1 force_version=ssl3 \
3038 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3039 0 \
3040 -s "Read from client: 1 bytes read"
3041
3042run_test "Small packet TLS 1.0 BlockCipher" \
3043 "$P_SRV" \
3044 "$P_CLI request_size=1 force_version=tls1 \
3045 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3046 0 \
3047 -s "Read from client: 1 bytes read"
3048
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003049run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3050 "$P_SRV" \
3051 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3053 0 \
3054 -s "Read from client: 1 bytes read"
3055
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003056run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3057 "$P_SRV" \
3058 "$P_CLI request_size=1 force_version=tls1 \
3059 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3060 trunc_hmac=1" \
3061 0 \
3062 -s "Read from client: 1 bytes read"
3063
3064run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003065 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003066 "$P_CLI request_size=1 force_version=tls1 \
3067 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3068 trunc_hmac=1" \
3069 0 \
3070 -s "Read from client: 1 bytes read"
3071
3072run_test "Small packet TLS 1.1 BlockCipher" \
3073 "$P_SRV" \
3074 "$P_CLI request_size=1 force_version=tls1_1 \
3075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3076 0 \
3077 -s "Read from client: 1 bytes read"
3078
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003079run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3080 "$P_SRV" \
3081 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3083 0 \
3084 -s "Read from client: 1 bytes read"
3085
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003086run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003087 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003088 "$P_CLI request_size=1 force_version=tls1_1 \
3089 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3090 0 \
3091 -s "Read from client: 1 bytes read"
3092
3093run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3094 "$P_SRV" \
3095 "$P_CLI request_size=1 force_version=tls1_1 \
3096 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3097 trunc_hmac=1" \
3098 0 \
3099 -s "Read from client: 1 bytes read"
3100
3101run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003102 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003103 "$P_CLI request_size=1 force_version=tls1_1 \
3104 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3105 trunc_hmac=1" \
3106 0 \
3107 -s "Read from client: 1 bytes read"
3108
3109run_test "Small packet TLS 1.2 BlockCipher" \
3110 "$P_SRV" \
3111 "$P_CLI request_size=1 force_version=tls1_2 \
3112 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3113 0 \
3114 -s "Read from client: 1 bytes read"
3115
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003116run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3117 "$P_SRV" \
3118 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3119 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3120 0 \
3121 -s "Read from client: 1 bytes read"
3122
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003123run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3124 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003125 "$P_CLI request_size=1 force_version=tls1_2 \
3126 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003127 0 \
3128 -s "Read from client: 1 bytes read"
3129
3130run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3131 "$P_SRV" \
3132 "$P_CLI request_size=1 force_version=tls1_2 \
3133 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3134 trunc_hmac=1" \
3135 0 \
3136 -s "Read from client: 1 bytes read"
3137
3138run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003139 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003140 "$P_CLI request_size=1 force_version=tls1_2 \
3141 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3142 0 \
3143 -s "Read from client: 1 bytes read"
3144
3145run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003146 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003147 "$P_CLI request_size=1 force_version=tls1_2 \
3148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3149 trunc_hmac=1" \
3150 0 \
3151 -s "Read from client: 1 bytes read"
3152
3153run_test "Small packet TLS 1.2 AEAD" \
3154 "$P_SRV" \
3155 "$P_CLI request_size=1 force_version=tls1_2 \
3156 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3157 0 \
3158 -s "Read from client: 1 bytes read"
3159
3160run_test "Small packet TLS 1.2 AEAD shorter tag" \
3161 "$P_SRV" \
3162 "$P_CLI request_size=1 force_version=tls1_2 \
3163 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3164 0 \
3165 -s "Read from client: 1 bytes read"
3166
Janos Follath00efff72016-05-06 13:48:23 +01003167# A test for extensions in SSLv3
3168
3169requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3170run_test "SSLv3 with extensions, server side" \
3171 "$P_SRV min_version=ssl3 debug_level=3" \
3172 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3173 0 \
3174 -S "dumping 'client hello extensions'" \
3175 -S "server hello, total extension length:"
3176
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003177# Test for large packets
3178
Janos Follathe2681a42016-03-07 15:57:05 +00003179requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003180run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003181 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003182 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003183 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3184 0 \
3185 -s "Read from client: 16384 bytes read"
3186
Janos Follathe2681a42016-03-07 15:57:05 +00003187requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003188run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003189 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003190 "$P_CLI request_size=16384 force_version=ssl3 \
3191 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3192 0 \
3193 -s "Read from client: 16384 bytes read"
3194
3195run_test "Large packet TLS 1.0 BlockCipher" \
3196 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003197 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003198 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3199 0 \
3200 -s "Read from client: 16384 bytes read"
3201
3202run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3203 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003204 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003205 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3206 trunc_hmac=1" \
3207 0 \
3208 -s "Read from client: 16384 bytes read"
3209
3210run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003211 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003212 "$P_CLI request_size=16384 force_version=tls1 \
3213 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3214 trunc_hmac=1" \
3215 0 \
3216 -s "Read from client: 16384 bytes read"
3217
3218run_test "Large packet TLS 1.1 BlockCipher" \
3219 "$P_SRV" \
3220 "$P_CLI request_size=16384 force_version=tls1_1 \
3221 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3222 0 \
3223 -s "Read from client: 16384 bytes read"
3224
3225run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003226 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003227 "$P_CLI request_size=16384 force_version=tls1_1 \
3228 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3229 0 \
3230 -s "Read from client: 16384 bytes read"
3231
3232run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3233 "$P_SRV" \
3234 "$P_CLI request_size=16384 force_version=tls1_1 \
3235 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3236 trunc_hmac=1" \
3237 0 \
3238 -s "Read from client: 16384 bytes read"
3239
3240run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003241 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003242 "$P_CLI request_size=16384 force_version=tls1_1 \
3243 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3244 trunc_hmac=1" \
3245 0 \
3246 -s "Read from client: 16384 bytes read"
3247
3248run_test "Large packet TLS 1.2 BlockCipher" \
3249 "$P_SRV" \
3250 "$P_CLI request_size=16384 force_version=tls1_2 \
3251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3252 0 \
3253 -s "Read from client: 16384 bytes read"
3254
3255run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3256 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003257 "$P_CLI request_size=16384 force_version=tls1_2 \
3258 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003259 0 \
3260 -s "Read from client: 16384 bytes read"
3261
3262run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3263 "$P_SRV" \
3264 "$P_CLI request_size=16384 force_version=tls1_2 \
3265 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3266 trunc_hmac=1" \
3267 0 \
3268 -s "Read from client: 16384 bytes read"
3269
3270run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003271 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003272 "$P_CLI request_size=16384 force_version=tls1_2 \
3273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3274 0 \
3275 -s "Read from client: 16384 bytes read"
3276
3277run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003278 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003279 "$P_CLI request_size=16384 force_version=tls1_2 \
3280 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3281 trunc_hmac=1" \
3282 0 \
3283 -s "Read from client: 16384 bytes read"
3284
3285run_test "Large packet TLS 1.2 AEAD" \
3286 "$P_SRV" \
3287 "$P_CLI request_size=16384 force_version=tls1_2 \
3288 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3289 0 \
3290 -s "Read from client: 16384 bytes read"
3291
3292run_test "Large packet TLS 1.2 AEAD shorter tag" \
3293 "$P_SRV" \
3294 "$P_CLI request_size=16384 force_version=tls1_2 \
3295 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3296 0 \
3297 -s "Read from client: 16384 bytes read"
3298
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003299# Tests for DTLS HelloVerifyRequest
3300
3301run_test "DTLS cookie: enabled" \
3302 "$P_SRV dtls=1 debug_level=2" \
3303 "$P_CLI dtls=1 debug_level=2" \
3304 0 \
3305 -s "cookie verification failed" \
3306 -s "cookie verification passed" \
3307 -S "cookie verification skipped" \
3308 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003309 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003310 -S "SSL - The requested feature is not available"
3311
3312run_test "DTLS cookie: disabled" \
3313 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3314 "$P_CLI dtls=1 debug_level=2" \
3315 0 \
3316 -S "cookie verification failed" \
3317 -S "cookie verification passed" \
3318 -s "cookie verification skipped" \
3319 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003320 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003321 -S "SSL - The requested feature is not available"
3322
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003323run_test "DTLS cookie: default (failing)" \
3324 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3325 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3326 1 \
3327 -s "cookie verification failed" \
3328 -S "cookie verification passed" \
3329 -S "cookie verification skipped" \
3330 -C "received hello verify request" \
3331 -S "hello verification requested" \
3332 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003333
3334requires_ipv6
3335run_test "DTLS cookie: enabled, IPv6" \
3336 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3337 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3338 0 \
3339 -s "cookie verification failed" \
3340 -s "cookie verification passed" \
3341 -S "cookie verification skipped" \
3342 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003343 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003344 -S "SSL - The requested feature is not available"
3345
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003346run_test "DTLS cookie: enabled, nbio" \
3347 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3348 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3349 0 \
3350 -s "cookie verification failed" \
3351 -s "cookie verification passed" \
3352 -S "cookie verification skipped" \
3353 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003354 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003355 -S "SSL - The requested feature is not available"
3356
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003357# Tests for client reconnecting from the same port with DTLS
3358
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003359not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003360run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003361 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3362 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003363 0 \
3364 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003365 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003366 -S "Client initiated reconnection from same port"
3367
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003368not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003369run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003370 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3371 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003372 0 \
3373 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003374 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003375 -s "Client initiated reconnection from same port"
3376
Paul Bakker362689d2016-05-13 10:33:25 +01003377not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3378run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003379 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3380 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003381 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003382 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003383 -s "Client initiated reconnection from same port"
3384
Paul Bakker362689d2016-05-13 10:33:25 +01003385only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3386run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3387 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3388 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3389 0 \
3390 -S "The operation timed out" \
3391 -s "Client initiated reconnection from same port"
3392
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003393run_test "DTLS client reconnect from same port: no cookies" \
3394 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003395 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3396 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003397 -s "The operation timed out" \
3398 -S "Client initiated reconnection from same port"
3399
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003400# Tests for various cases of client authentication with DTLS
3401# (focused on handshake flows and message parsing)
3402
3403run_test "DTLS client auth: required" \
3404 "$P_SRV dtls=1 auth_mode=required" \
3405 "$P_CLI dtls=1" \
3406 0 \
3407 -s "Verifying peer X.509 certificate... ok"
3408
3409run_test "DTLS client auth: optional, client has no cert" \
3410 "$P_SRV dtls=1 auth_mode=optional" \
3411 "$P_CLI dtls=1 crt_file=none key_file=none" \
3412 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003413 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003414
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003415run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003416 "$P_SRV dtls=1 auth_mode=none" \
3417 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3418 0 \
3419 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003420 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003421
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003422run_test "DTLS wrong PSK: badmac alert" \
3423 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3424 "$P_CLI dtls=1 psk=abc124" \
3425 1 \
3426 -s "SSL - Verification of the message MAC failed" \
3427 -c "SSL - A fatal alert message was received from our peer"
3428
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003429# Tests for receiving fragmented handshake messages with DTLS
3430
3431requires_gnutls
3432run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3433 "$G_SRV -u --mtu 2048 -a" \
3434 "$P_CLI dtls=1 debug_level=2" \
3435 0 \
3436 -C "found fragmented DTLS handshake message" \
3437 -C "error"
3438
3439requires_gnutls
3440run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3441 "$G_SRV -u --mtu 512" \
3442 "$P_CLI dtls=1 debug_level=2" \
3443 0 \
3444 -c "found fragmented DTLS handshake message" \
3445 -C "error"
3446
3447requires_gnutls
3448run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3449 "$G_SRV -u --mtu 128" \
3450 "$P_CLI dtls=1 debug_level=2" \
3451 0 \
3452 -c "found fragmented DTLS handshake message" \
3453 -C "error"
3454
3455requires_gnutls
3456run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3457 "$G_SRV -u --mtu 128" \
3458 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3459 0 \
3460 -c "found fragmented DTLS handshake message" \
3461 -C "error"
3462
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003463requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003464run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3465 "$G_SRV -u --mtu 256" \
3466 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3467 0 \
3468 -c "found fragmented DTLS handshake message" \
3469 -c "client hello, adding renegotiation extension" \
3470 -c "found renegotiation extension" \
3471 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003472 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003473 -C "error" \
3474 -s "Extra-header:"
3475
3476requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003477run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3478 "$G_SRV -u --mtu 256" \
3479 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3480 0 \
3481 -c "found fragmented DTLS handshake message" \
3482 -c "client hello, adding renegotiation extension" \
3483 -c "found renegotiation extension" \
3484 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003485 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003486 -C "error" \
3487 -s "Extra-header:"
3488
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003489run_test "DTLS reassembly: no fragmentation (openssl server)" \
3490 "$O_SRV -dtls1 -mtu 2048" \
3491 "$P_CLI dtls=1 debug_level=2" \
3492 0 \
3493 -C "found fragmented DTLS handshake message" \
3494 -C "error"
3495
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003496run_test "DTLS reassembly: some fragmentation (openssl server)" \
3497 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003498 "$P_CLI dtls=1 debug_level=2" \
3499 0 \
3500 -c "found fragmented DTLS handshake message" \
3501 -C "error"
3502
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003503run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003504 "$O_SRV -dtls1 -mtu 256" \
3505 "$P_CLI dtls=1 debug_level=2" \
3506 0 \
3507 -c "found fragmented DTLS handshake message" \
3508 -C "error"
3509
3510run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3511 "$O_SRV -dtls1 -mtu 256" \
3512 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3513 0 \
3514 -c "found fragmented DTLS handshake message" \
3515 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003516
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003517# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003518
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003519not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003520run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003521 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003522 "$P_SRV dtls=1 debug_level=2" \
3523 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003524 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003525 -C "replayed record" \
3526 -S "replayed record" \
3527 -C "record from another epoch" \
3528 -S "record from another epoch" \
3529 -C "discarding invalid record" \
3530 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003531 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003532 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003533 -c "HTTP/1.0 200 OK"
3534
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003535not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003536run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003537 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003538 "$P_SRV dtls=1 debug_level=2" \
3539 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003540 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003541 -c "replayed record" \
3542 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003543 -c "discarding invalid record" \
3544 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003545 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003546 -s "Extra-header:" \
3547 -c "HTTP/1.0 200 OK"
3548
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003549run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3550 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003551 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3552 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003553 0 \
3554 -c "replayed record" \
3555 -S "replayed record" \
3556 -c "discarding invalid record" \
3557 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003558 -c "resend" \
3559 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003560 -s "Extra-header:" \
3561 -c "HTTP/1.0 200 OK"
3562
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003563run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003564 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003565 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003566 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003567 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003568 -c "discarding invalid record (mac)" \
3569 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003570 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003571 -c "HTTP/1.0 200 OK" \
3572 -S "too many records with bad MAC" \
3573 -S "Verification of the message MAC failed"
3574
3575run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3576 -p "$P_PXY bad_ad=1" \
3577 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3578 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3579 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003580 -C "discarding invalid record (mac)" \
3581 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003582 -S "Extra-header:" \
3583 -C "HTTP/1.0 200 OK" \
3584 -s "too many records with bad MAC" \
3585 -s "Verification of the message MAC failed"
3586
3587run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3588 -p "$P_PXY bad_ad=1" \
3589 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3590 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3591 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003592 -c "discarding invalid record (mac)" \
3593 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003594 -s "Extra-header:" \
3595 -c "HTTP/1.0 200 OK" \
3596 -S "too many records with bad MAC" \
3597 -S "Verification of the message MAC failed"
3598
3599run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3600 -p "$P_PXY bad_ad=1" \
3601 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3602 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3603 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003604 -c "discarding invalid record (mac)" \
3605 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003606 -s "Extra-header:" \
3607 -c "HTTP/1.0 200 OK" \
3608 -s "too many records with bad MAC" \
3609 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003610
3611run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003612 -p "$P_PXY delay_ccs=1" \
3613 "$P_SRV dtls=1 debug_level=1" \
3614 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003615 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003616 -c "record from another epoch" \
3617 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003618 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003619 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003620 -s "Extra-header:" \
3621 -c "HTTP/1.0 200 OK"
3622
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003623# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003624
Janos Follath74537a62016-09-02 13:45:28 +01003625client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003626run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003627 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003628 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3629 psk=abc123" \
3630 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003631 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3632 0 \
3633 -s "Extra-header:" \
3634 -c "HTTP/1.0 200 OK"
3635
Janos Follath74537a62016-09-02 13:45:28 +01003636client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003637run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3638 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003639 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3640 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003641 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3642 0 \
3643 -s "Extra-header:" \
3644 -c "HTTP/1.0 200 OK"
3645
Janos Follath74537a62016-09-02 13:45:28 +01003646client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003647run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3648 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003649 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3650 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003651 0 \
3652 -s "Extra-header:" \
3653 -c "HTTP/1.0 200 OK"
3654
Janos Follath74537a62016-09-02 13:45:28 +01003655client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003656run_test "DTLS proxy: 3d, FS, client auth" \
3657 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003658 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3659 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003660 0 \
3661 -s "Extra-header:" \
3662 -c "HTTP/1.0 200 OK"
3663
Janos Follath74537a62016-09-02 13:45:28 +01003664client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003665run_test "DTLS proxy: 3d, FS, ticket" \
3666 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003667 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3668 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003669 0 \
3670 -s "Extra-header:" \
3671 -c "HTTP/1.0 200 OK"
3672
Janos Follath74537a62016-09-02 13:45:28 +01003673client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003674run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3675 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003676 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3677 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003678 0 \
3679 -s "Extra-header:" \
3680 -c "HTTP/1.0 200 OK"
3681
Janos Follath74537a62016-09-02 13:45:28 +01003682client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003683run_test "DTLS proxy: 3d, max handshake, nbio" \
3684 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003685 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3686 auth_mode=required" \
3687 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003688 0 \
3689 -s "Extra-header:" \
3690 -c "HTTP/1.0 200 OK"
3691
Janos Follath74537a62016-09-02 13:45:28 +01003692client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003693run_test "DTLS proxy: 3d, min handshake, resumption" \
3694 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3695 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3696 psk=abc123 debug_level=3" \
3697 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3698 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3699 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3700 0 \
3701 -s "a session has been resumed" \
3702 -c "a session has been resumed" \
3703 -s "Extra-header:" \
3704 -c "HTTP/1.0 200 OK"
3705
Janos Follath74537a62016-09-02 13:45:28 +01003706client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003707run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3708 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3709 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3710 psk=abc123 debug_level=3 nbio=2" \
3711 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3712 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3713 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3714 0 \
3715 -s "a session has been resumed" \
3716 -c "a session has been resumed" \
3717 -s "Extra-header:" \
3718 -c "HTTP/1.0 200 OK"
3719
Janos Follath74537a62016-09-02 13:45:28 +01003720client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003721run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003722 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003723 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3724 psk=abc123 renegotiation=1 debug_level=2" \
3725 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3726 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003727 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3728 0 \
3729 -c "=> renegotiate" \
3730 -s "=> renegotiate" \
3731 -s "Extra-header:" \
3732 -c "HTTP/1.0 200 OK"
3733
Janos Follath74537a62016-09-02 13:45:28 +01003734client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003735run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3736 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003737 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3738 psk=abc123 renegotiation=1 debug_level=2" \
3739 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3740 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003741 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3742 0 \
3743 -c "=> renegotiate" \
3744 -s "=> renegotiate" \
3745 -s "Extra-header:" \
3746 -c "HTTP/1.0 200 OK"
3747
Janos Follath74537a62016-09-02 13:45:28 +01003748client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003749run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003750 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003751 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003752 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003753 debug_level=2" \
3754 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003755 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003756 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3757 0 \
3758 -c "=> renegotiate" \
3759 -s "=> renegotiate" \
3760 -s "Extra-header:" \
3761 -c "HTTP/1.0 200 OK"
3762
Janos Follath74537a62016-09-02 13:45:28 +01003763client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003764run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003765 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003766 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003767 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003768 debug_level=2 nbio=2" \
3769 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003770 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003771 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3772 0 \
3773 -c "=> renegotiate" \
3774 -s "=> renegotiate" \
3775 -s "Extra-header:" \
3776 -c "HTTP/1.0 200 OK"
3777
Janos Follath74537a62016-09-02 13:45:28 +01003778client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003779not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003780run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003781 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3782 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003783 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003784 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003785 -c "HTTP/1.0 200 OK"
3786
Janos Follath74537a62016-09-02 13:45:28 +01003787client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003788not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003789run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3790 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3791 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003792 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003793 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003794 -c "HTTP/1.0 200 OK"
3795
Janos Follath74537a62016-09-02 13:45:28 +01003796client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003797not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003798run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3799 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3800 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003801 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003802 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003803 -c "HTTP/1.0 200 OK"
3804
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003805requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003806client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003807not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003808run_test "DTLS proxy: 3d, gnutls server" \
3809 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3810 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003811 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003812 0 \
3813 -s "Extra-header:" \
3814 -c "Extra-header:"
3815
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003816requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003817client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003818not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003819run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3820 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3821 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003822 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003823 0 \
3824 -s "Extra-header:" \
3825 -c "Extra-header:"
3826
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003827requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01003828client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003829not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003830run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3831 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3832 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003833 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003834 0 \
3835 -s "Extra-header:" \
3836 -c "Extra-header:"
3837
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003838# Final report
3839
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003840echo "------------------------------------------------------------------------"
3841
3842if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003843 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003844else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003845 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003846fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003847PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003848echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003849
3850exit $FAILS