blob: fa8e6f124cc7dc46781db02cccadf0ad7886a02f [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010020
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020021O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010022O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020023G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010024G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010025
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010026TESTS=0
27FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020028SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010029
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020031
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010032MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010033FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020034EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010035
36print_usage() {
37 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010038 printf " -h|--help\tPrint this help.\n"
39 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
40 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
41 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010042}
43
44get_options() {
45 while [ $# -gt 0 ]; do
46 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010047 -f|--filter)
48 shift; FILTER=$1
49 ;;
50 -e|--exclude)
51 shift; EXCLUDE=$1
52 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010053 -m|--memcheck)
54 MEMCHECK=1
55 ;;
56 -h|--help)
57 print_usage
58 exit 0
59 ;;
60 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020061 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 print_usage
63 exit 1
64 ;;
65 esac
66 shift
67 done
68}
69
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010070# skip next test if the flag is not enabled in config.h
71requires_config_enabled() {
72 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
73 SKIP_NEXT="YES"
74 fi
75}
76
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020077# skip next test if OpenSSL doesn't support FALLBACK_SCSV
78requires_openssl_with_fallback_scsv() {
79 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
80 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
81 then
82 OPENSSL_HAS_FBSCSV="YES"
83 else
84 OPENSSL_HAS_FBSCSV="NO"
85 fi
86 fi
87 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
88 SKIP_NEXT="YES"
89 fi
90}
91
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020092# skip next test if GnuTLS isn't available
93requires_gnutls() {
94 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +020095 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020096 GNUTLS_AVAILABLE="YES"
97 else
98 GNUTLS_AVAILABLE="NO"
99 fi
100 fi
101 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
102 SKIP_NEXT="YES"
103 fi
104}
105
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200106# skip next test if IPv6 isn't available on this host
107requires_ipv6() {
108 if [ -z "${HAS_IPV6:-}" ]; then
109 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
110 SRV_PID=$!
111 sleep 1
112 kill $SRV_PID >/dev/null 2>&1
113 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
114 HAS_IPV6="NO"
115 else
116 HAS_IPV6="YES"
117 fi
118 rm -r $SRV_OUT
119 fi
120
121 if [ "$HAS_IPV6" = "NO" ]; then
122 SKIP_NEXT="YES"
123 fi
124}
125
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200126# skip the next test if valgrind is in use
127not_with_valgrind() {
128 if [ "$MEMCHECK" -gt 0 ]; then
129 SKIP_NEXT="YES"
130 fi
131}
132
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200133# multiply the client timeout delay by the given factor for the next test
134needs_more_time() {
135 CLI_DELAY_FACTOR=$1
136}
137
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100138# print_name <name>
139print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100140 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200141 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100142 for i in `seq 1 $LEN`; do printf '.'; done
143 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100144
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200145 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100146}
147
148# fail <message>
149fail() {
150 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100151 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100152
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200153 mv $SRV_OUT o-srv-${TESTS}.log
154 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200155 if [ -n "$PXY_CMD" ]; then
156 mv $PXY_OUT o-pxy-${TESTS}.log
157 fi
158 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100159
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200160 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
161 echo " ! server output:"
162 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200163 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200164 echo " ! client output:"
165 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200166 if [ -n "$PXY_CMD" ]; then
167 echo " ! ========================================================"
168 echo " ! proxy output:"
169 cat o-pxy-${TESTS}.log
170 fi
171 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200172 fi
173
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200174 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100175}
176
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100177# is_polar <cmd_line>
178is_polar() {
179 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
180}
181
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200182# openssl s_server doesn't have -www with DTLS
183check_osrv_dtls() {
184 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
185 NEEDS_INPUT=1
186 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
187 else
188 NEEDS_INPUT=0
189 fi
190}
191
192# provide input to commands that need it
193provide_input() {
194 if [ $NEEDS_INPUT -eq 0 ]; then
195 return
196 fi
197
198 while true; do
199 echo "HTTP/1.0 200 OK"
200 sleep 1
201 done
202}
203
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100204# has_mem_err <log_file_name>
205has_mem_err() {
206 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
207 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
208 then
209 return 1 # false: does not have errors
210 else
211 return 0 # true: has errors
212 fi
213}
214
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200215# wait for server to start: two versions depending on lsof availability
216wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200217 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200218 # make sure we don't loop forever
219 ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200220 DOG_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200221
222 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200223 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100224 until lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null;
225 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200226 else
Manuel Pégourié-Gonnarda65d5082015-01-12 14:54:55 +0100227 until lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null;
228 do :; done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200229 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200230
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200231 kill $DOG_PID >/dev/null 2>&1
232 wait $DOG_PID
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200233 else
234 sleep "$START_DELAY"
235 fi
236}
237
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200238# wait for client to terminate and set CLI_EXIT
239# must be called right after starting the client
240wait_client_done() {
241 CLI_PID=$!
242
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200243 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
244 CLI_DELAY_FACTOR=1
245
246 ( sleep $CLI_DELAY; echo "TIMEOUT" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200247 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200248
249 wait $CLI_PID
250 CLI_EXIT=$?
251
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200252 kill $DOG_PID >/dev/null 2>&1
253 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200254
255 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
256}
257
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200258# check if the given command uses dtls and sets global variable DTLS
259detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200260 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200261 DTLS=1
262 else
263 DTLS=0
264 fi
265}
266
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200267# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100268# Options: -s pattern pattern that must be present in server output
269# -c pattern pattern that must be present in client output
270# -S pattern pattern that must be absent in server output
271# -C pattern pattern that must be absent in client output
272run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100273 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200274 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100275
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100276 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
277 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200278 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100279 return
280 fi
281
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100282 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100283
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200284 # should we skip?
285 if [ "X$SKIP_NEXT" = "XYES" ]; then
286 SKIP_NEXT="NO"
287 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200288 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200289 return
290 fi
291
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200292 # does this test use a proxy?
293 if [ "X$1" = "X-p" ]; then
294 PXY_CMD="$2"
295 shift 2
296 else
297 PXY_CMD=""
298 fi
299
300 # get commands and client output
301 SRV_CMD="$1"
302 CLI_CMD="$2"
303 CLI_EXPECT="$3"
304 shift 3
305
306 # fix client port
307 if [ -n "$PXY_CMD" ]; then
308 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
309 else
310 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
311 fi
312
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200313 # update DTLS variable
314 detect_dtls "$SRV_CMD"
315
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100316 # prepend valgrind to our commands if active
317 if [ "$MEMCHECK" -gt 0 ]; then
318 if is_polar "$SRV_CMD"; then
319 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
320 fi
321 if is_polar "$CLI_CMD"; then
322 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
323 fi
324 fi
325
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100326 # run the commands
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200327 if [ -n "$PXY_CMD" ]; then
328 echo "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200329 $PXY_CMD >> $PXY_OUT 2>&1 &
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200330 PXY_PID=$!
331 # assume proxy starts faster than server
332 fi
333
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200334 check_osrv_dtls
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200335 echo "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200336 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100337 SRV_PID=$!
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200338 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200339
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200340 echo "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200341 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
342 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100343
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200344 # terminate the server (and the proxy)
Manuel Pégourié-Gonnard74b11702014-08-14 15:47:33 +0200345 kill $SRV_PID
346 wait $SRV_PID
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200347 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200348 kill $PXY_PID >/dev/null 2>&1
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200349 wait $PXY_PID
350 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100351
352 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200353 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100354 # expected client exit to incorrectly succeed in case of catastrophic
355 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100356 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200357 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100358 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100359 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100360 return
361 fi
362 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100363 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200364 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100365 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100366 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100367 return
368 fi
369 fi
370
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100371 # check server exit code
372 if [ $? != 0 ]; then
373 fail "server fail"
374 return
375 fi
376
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100377 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100378 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
379 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100380 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200381 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100382 return
383 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100385 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200386 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100387 while [ $# -gt 0 ]
388 do
389 case $1 in
390 "-s")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200391 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100392 fail "-s $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100393 return
394 fi
395 ;;
396
397 "-c")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200398 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then :; else
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100399 fail "-c $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100400 return
401 fi
402 ;;
403
404 "-S")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200405 if grep -v '^==' $SRV_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100406 fail "-S $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100407 return
408 fi
409 ;;
410
411 "-C")
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200412 if grep -v '^==' $CLI_OUT | grep "$2" >/dev/null; then
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100413 fail "-C $2"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100414 return
415 fi
416 ;;
417
418 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200419 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420 exit 1
421 esac
422 shift 2
423 done
424
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100425 # check valgrind's results
426 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200427 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100428 fail "Server has memory errors"
429 return
430 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200431 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100432 fail "Client has memory errors"
433 return
434 fi
435 fi
436
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100437 # if we're here, everything is ok
438 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200439 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100440}
441
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100442cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200443 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200444 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
445 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
446 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
447 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100448 exit 1
449}
450
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100451#
452# MAIN
453#
454
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000455if cd $( dirname $0 ); then :; else
456 echo "cd $( dirname $0 ) failed" >&2
457 exit 1
458fi
459
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100460get_options "$@"
461
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100462# sanity checks, avoid an avalanche of errors
463if [ ! -x "$P_SRV" ]; then
464 echo "Command '$P_SRV' is not an executable file"
465 exit 1
466fi
467if [ ! -x "$P_CLI" ]; then
468 echo "Command '$P_CLI' is not an executable file"
469 exit 1
470fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200471if [ ! -x "$P_PXY" ]; then
472 echo "Command '$P_PXY' is not an executable file"
473 exit 1
474fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100475if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
476 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100477 exit 1
478fi
479
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200480# used by watchdog
481MAIN_PID="$$"
482
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200483# be more patient with valgrind
484if [ "$MEMCHECK" -gt 0 ]; then
485 START_DELAY=3
486 DOG_DELAY=30
487else
488 START_DELAY=1
489 DOG_DELAY=10
490fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200491CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200492
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200493# Pick a "unique" server port in the range 10000-19999, and a proxy port
494PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000495PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200496SRV_PORT="1$PORT_BASE"
497PXY_PORT="2$PORT_BASE"
498unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200499
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200500# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000501# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
503P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
504P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200505O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200506O_CLI="$O_CLI -connect localhost:+SRV_PORT"
507G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000508G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200509
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200510# Also pick a unique name for intermediate files
511SRV_OUT="srv_out.$$"
512CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200513PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200514SESSION="session.$$"
515
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200516SKIP_NEXT="NO"
517
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100518trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200520# Basic test
521
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200522# Checks that:
523# - things work with all ciphersuites active (used with config-full in all.sh)
524# - the expected (highest security) parameters are selected
525# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200526run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200527 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200528 "$P_CLI" \
529 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200530 -s "Protocol is TLSv1.2" \
531 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
532 -s "client hello v3, signature_algorithm ext: 6" \
533 -s "ECDHE curve: secp521r1" \
534 -S "error" \
535 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200536
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000537run_test "Default, DTLS" \
538 "$P_SRV dtls=1" \
539 "$P_CLI dtls=1" \
540 0 \
541 -s "Protocol is DTLSv1.2" \
542 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
543
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100544# Tests for rc4 option
545
546run_test "RC4: server disabled, client enabled" \
547 "$P_SRV" \
548 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
549 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100550 -s "SSL - The server has no ciphersuites in common"
551
552run_test "RC4: server half, client enabled" \
553 "$P_SRV arc4=1" \
554 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
555 1 \
556 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100557
558run_test "RC4: server enabled, client disabled" \
559 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
560 "$P_CLI" \
561 1 \
562 -s "SSL - The server has no ciphersuites in common"
563
564run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100565 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100566 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
567 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100568 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100569 -S "SSL - The server has no ciphersuites in common"
570
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100571# Tests for Truncated HMAC extension
572
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100573run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200574 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100575 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100576 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100577 -s "dumping 'computed mac' (20 bytes)" \
578 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100579
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100580run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200581 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100582 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
583 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100584 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100585 -s "dumping 'computed mac' (20 bytes)" \
586 -S "dumping 'computed mac' (10 bytes)"
587
588run_test "Truncated HMAC: client enabled, server default" \
589 "$P_SRV debug_level=4" \
590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
591 trunc_hmac=1" \
592 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100593 -s "dumping 'computed mac' (20 bytes)" \
594 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100595
596run_test "Truncated HMAC: client enabled, server disabled" \
597 "$P_SRV debug_level=4 trunc_hmac=0" \
598 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
599 trunc_hmac=1" \
600 0 \
601 -s "dumping 'computed mac' (20 bytes)" \
602 -S "dumping 'computed mac' (10 bytes)"
603
604run_test "Truncated HMAC: client enabled, server enabled" \
605 "$P_SRV debug_level=4 trunc_hmac=1" \
606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
607 trunc_hmac=1" \
608 0 \
609 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100610 -s "dumping 'computed mac' (10 bytes)"
611
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100612# Tests for Encrypt-then-MAC extension
613
614run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100615 "$P_SRV debug_level=3 \
616 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100617 "$P_CLI debug_level=3" \
618 0 \
619 -c "client hello, adding encrypt_then_mac extension" \
620 -s "found encrypt then mac extension" \
621 -s "server hello, adding encrypt then mac extension" \
622 -c "found encrypt_then_mac extension" \
623 -c "using encrypt then mac" \
624 -s "using encrypt then mac"
625
626run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100627 "$P_SRV debug_level=3 etm=0 \
628 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100629 "$P_CLI debug_level=3 etm=1" \
630 0 \
631 -c "client hello, adding encrypt_then_mac extension" \
632 -s "found encrypt then mac extension" \
633 -S "server hello, adding encrypt then mac extension" \
634 -C "found encrypt_then_mac extension" \
635 -C "using encrypt then mac" \
636 -S "using encrypt then mac"
637
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100638run_test "Encrypt then MAC: client enabled, aead cipher" \
639 "$P_SRV debug_level=3 etm=1 \
640 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
641 "$P_CLI debug_level=3 etm=1" \
642 0 \
643 -c "client hello, adding encrypt_then_mac extension" \
644 -s "found encrypt then mac extension" \
645 -S "server hello, adding encrypt then mac extension" \
646 -C "found encrypt_then_mac extension" \
647 -C "using encrypt then mac" \
648 -S "using encrypt then mac"
649
650run_test "Encrypt then MAC: client enabled, stream cipher" \
651 "$P_SRV debug_level=3 etm=1 \
652 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100653 "$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 +0100654 0 \
655 -c "client hello, adding encrypt_then_mac extension" \
656 -s "found encrypt then mac extension" \
657 -S "server hello, adding encrypt then mac extension" \
658 -C "found encrypt_then_mac extension" \
659 -C "using encrypt then mac" \
660 -S "using encrypt then mac"
661
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100662run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100663 "$P_SRV debug_level=3 etm=1 \
664 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100665 "$P_CLI debug_level=3 etm=0" \
666 0 \
667 -C "client hello, adding encrypt_then_mac extension" \
668 -S "found encrypt then mac extension" \
669 -S "server hello, adding encrypt then mac extension" \
670 -C "found encrypt_then_mac extension" \
671 -C "using encrypt then mac" \
672 -S "using encrypt then mac"
673
674run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100675 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100676 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100677 "$P_CLI debug_level=3 force_version=ssl3" \
678 0 \
679 -C "client hello, adding encrypt_then_mac extension" \
680 -S "found encrypt then mac extension" \
681 -S "server hello, adding encrypt then mac extension" \
682 -C "found encrypt_then_mac extension" \
683 -C "using encrypt then mac" \
684 -S "using encrypt then mac"
685
686run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100687 "$P_SRV debug_level=3 force_version=ssl3 \
688 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100689 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100690 0 \
691 -c "client hello, adding encrypt_then_mac extension" \
692 -s "found encrypt then mac extension" \
693 -S "server hello, adding encrypt then mac extension" \
694 -C "found encrypt_then_mac extension" \
695 -C "using encrypt then mac" \
696 -S "using encrypt then mac"
697
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200698# Tests for Extended Master Secret extension
699
700run_test "Extended Master Secret: default" \
701 "$P_SRV debug_level=3" \
702 "$P_CLI debug_level=3" \
703 0 \
704 -c "client hello, adding extended_master_secret extension" \
705 -s "found extended master secret extension" \
706 -s "server hello, adding extended master secret extension" \
707 -c "found extended_master_secret extension" \
708 -c "using extended master secret" \
709 -s "using extended master secret"
710
711run_test "Extended Master Secret: client enabled, server disabled" \
712 "$P_SRV debug_level=3 extended_ms=0" \
713 "$P_CLI debug_level=3 extended_ms=1" \
714 0 \
715 -c "client hello, adding extended_master_secret extension" \
716 -s "found extended master secret extension" \
717 -S "server hello, adding extended master secret extension" \
718 -C "found extended_master_secret extension" \
719 -C "using extended master secret" \
720 -S "using extended master secret"
721
722run_test "Extended Master Secret: client disabled, server enabled" \
723 "$P_SRV debug_level=3 extended_ms=1" \
724 "$P_CLI debug_level=3 extended_ms=0" \
725 0 \
726 -C "client hello, adding extended_master_secret extension" \
727 -S "found extended master secret extension" \
728 -S "server hello, adding extended master secret extension" \
729 -C "found extended_master_secret extension" \
730 -C "using extended master secret" \
731 -S "using extended master secret"
732
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200733run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100734 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200735 "$P_CLI debug_level=3 force_version=ssl3" \
736 0 \
737 -C "client hello, adding extended_master_secret extension" \
738 -S "found extended master secret extension" \
739 -S "server hello, adding extended master secret extension" \
740 -C "found extended_master_secret extension" \
741 -C "using extended master secret" \
742 -S "using extended master secret"
743
744run_test "Extended Master Secret: client enabled, server SSLv3" \
745 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100746 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200747 0 \
748 -c "client hello, adding extended_master_secret extension" \
749 -s "found extended master secret extension" \
750 -S "server hello, adding extended master secret extension" \
751 -C "found extended_master_secret extension" \
752 -C "using extended master secret" \
753 -S "using extended master secret"
754
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200755# Tests for FALLBACK_SCSV
756
757run_test "Fallback SCSV: default" \
758 "$P_SRV" \
759 "$P_CLI debug_level=3 force_version=tls1_1" \
760 0 \
761 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200762 -S "received FALLBACK_SCSV" \
763 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200764 -C "is a fatal alert message (msg 86)"
765
766run_test "Fallback SCSV: explicitly disabled" \
767 "$P_SRV" \
768 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
769 0 \
770 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200771 -S "received FALLBACK_SCSV" \
772 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200773 -C "is a fatal alert message (msg 86)"
774
775run_test "Fallback SCSV: enabled" \
776 "$P_SRV" \
777 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200778 1 \
779 -c "adding FALLBACK_SCSV" \
780 -s "received FALLBACK_SCSV" \
781 -s "inapropriate fallback" \
782 -c "is a fatal alert message (msg 86)"
783
784run_test "Fallback SCSV: enabled, max version" \
785 "$P_SRV" \
786 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200787 0 \
788 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200789 -s "received FALLBACK_SCSV" \
790 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200791 -C "is a fatal alert message (msg 86)"
792
793requires_openssl_with_fallback_scsv
794run_test "Fallback SCSV: default, openssl server" \
795 "$O_SRV" \
796 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
797 0 \
798 -C "adding FALLBACK_SCSV" \
799 -C "is a fatal alert message (msg 86)"
800
801requires_openssl_with_fallback_scsv
802run_test "Fallback SCSV: enabled, openssl server" \
803 "$O_SRV" \
804 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
805 1 \
806 -c "adding FALLBACK_SCSV" \
807 -c "is a fatal alert message (msg 86)"
808
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200809requires_openssl_with_fallback_scsv
810run_test "Fallback SCSV: disabled, openssl client" \
811 "$P_SRV" \
812 "$O_CLI -tls1_1" \
813 0 \
814 -S "received FALLBACK_SCSV" \
815 -S "inapropriate fallback"
816
817requires_openssl_with_fallback_scsv
818run_test "Fallback SCSV: enabled, openssl client" \
819 "$P_SRV" \
820 "$O_CLI -tls1_1 -fallback_scsv" \
821 1 \
822 -s "received FALLBACK_SCSV" \
823 -s "inapropriate fallback"
824
825requires_openssl_with_fallback_scsv
826run_test "Fallback SCSV: enabled, max version, openssl client" \
827 "$P_SRV" \
828 "$O_CLI -fallback_scsv" \
829 0 \
830 -s "received FALLBACK_SCSV" \
831 -S "inapropriate fallback"
832
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100833# Tests for CBC 1/n-1 record splitting
834
835run_test "CBC Record splitting: TLS 1.2, no splitting" \
836 "$P_SRV" \
837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
838 request_size=123 force_version=tls1_2" \
839 0 \
840 -s "Read from client: 123 bytes read" \
841 -S "Read from client: 1 bytes read" \
842 -S "122 bytes read"
843
844run_test "CBC Record splitting: TLS 1.1, no splitting" \
845 "$P_SRV" \
846 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
847 request_size=123 force_version=tls1_1" \
848 0 \
849 -s "Read from client: 123 bytes read" \
850 -S "Read from client: 1 bytes read" \
851 -S "122 bytes read"
852
853run_test "CBC Record splitting: TLS 1.0, splitting" \
854 "$P_SRV" \
855 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
856 request_size=123 force_version=tls1" \
857 0 \
858 -S "Read from client: 123 bytes read" \
859 -s "Read from client: 1 bytes read" \
860 -s "122 bytes read"
861
862run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100863 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100864 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
865 request_size=123 force_version=ssl3" \
866 0 \
867 -S "Read from client: 123 bytes read" \
868 -s "Read from client: 1 bytes read" \
869 -s "122 bytes read"
870
871run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100872 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100873 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
874 request_size=123 force_version=tls1" \
875 0 \
876 -s "Read from client: 123 bytes read" \
877 -S "Read from client: 1 bytes read" \
878 -S "122 bytes read"
879
880run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
881 "$P_SRV" \
882 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
883 request_size=123 force_version=tls1 recsplit=0" \
884 0 \
885 -s "Read from client: 123 bytes read" \
886 -S "Read from client: 1 bytes read" \
887 -S "122 bytes read"
888
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +0100889run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
890 "$P_SRV nbio=2" \
891 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
892 request_size=123 force_version=tls1" \
893 0 \
894 -S "Read from client: 123 bytes read" \
895 -s "Read from client: 1 bytes read" \
896 -s "122 bytes read"
897
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100898# Tests for Session Tickets
899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200900run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200901 "$P_SRV debug_level=3 tickets=1" \
902 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100903 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100904 -c "client hello, adding session ticket extension" \
905 -s "found session ticket extension" \
906 -s "server hello, adding session ticket extension" \
907 -c "found session_ticket extension" \
908 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100909 -S "session successfully restored from cache" \
910 -s "session successfully restored from ticket" \
911 -s "a session has been resumed" \
912 -c "a session has been resumed"
913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200914run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200915 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
916 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100917 0 \
918 -c "client hello, adding session ticket extension" \
919 -s "found session ticket extension" \
920 -s "server hello, adding session ticket extension" \
921 -c "found session_ticket extension" \
922 -c "parse new session ticket" \
923 -S "session successfully restored from cache" \
924 -s "session successfully restored from ticket" \
925 -s "a session has been resumed" \
926 -c "a session has been resumed"
927
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200928run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200929 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
930 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +0100931 0 \
932 -c "client hello, adding session ticket extension" \
933 -s "found session ticket extension" \
934 -s "server hello, adding session ticket extension" \
935 -c "found session_ticket extension" \
936 -c "parse new session ticket" \
937 -S "session successfully restored from cache" \
938 -S "session successfully restored from ticket" \
939 -S "a session has been resumed" \
940 -C "a session has been resumed"
941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200942run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100943 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200944 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100945 0 \
946 -c "client hello, adding session ticket extension" \
947 -c "found session_ticket extension" \
948 -c "parse new session ticket" \
949 -c "a session has been resumed"
950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200951run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200952 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200953 "( $O_CLI -sess_out $SESSION; \
954 $O_CLI -sess_in $SESSION; \
955 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100956 0 \
957 -s "found session ticket extension" \
958 -s "server hello, adding session ticket extension" \
959 -S "session successfully restored from cache" \
960 -s "session successfully restored from ticket" \
961 -s "a session has been resumed"
962
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100963# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200965run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200966 "$P_SRV debug_level=3 tickets=0" \
967 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100968 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100969 -c "client hello, adding session ticket extension" \
970 -s "found session ticket extension" \
971 -S "server hello, adding session ticket extension" \
972 -C "found session_ticket extension" \
973 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100974 -s "session successfully restored from cache" \
975 -S "session successfully restored from ticket" \
976 -s "a session has been resumed" \
977 -c "a session has been resumed"
978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200979run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200980 "$P_SRV debug_level=3 tickets=1" \
981 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100982 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100983 -C "client hello, adding session ticket extension" \
984 -S "found session ticket extension" \
985 -S "server hello, adding session ticket extension" \
986 -C "found session_ticket extension" \
987 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100988 -s "session successfully restored from cache" \
989 -S "session successfully restored from ticket" \
990 -s "a session has been resumed" \
991 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +0100992
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +0200993run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200994 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
995 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +0100996 0 \
997 -S "session successfully restored from cache" \
998 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +0100999 -S "a session has been resumed" \
1000 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001001
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001002run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001003 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1004 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001005 0 \
1006 -s "session successfully restored from cache" \
1007 -S "session successfully restored from ticket" \
1008 -s "a session has been resumed" \
1009 -c "a session has been resumed"
1010
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001011run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001012 "$P_SRV debug_level=3 tickets=0" \
1013 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001014 0 \
1015 -s "session successfully restored from cache" \
1016 -S "session successfully restored from ticket" \
1017 -s "a session has been resumed" \
1018 -c "a session has been resumed"
1019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001020run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001021 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1022 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001023 0 \
1024 -S "session successfully restored from cache" \
1025 -S "session successfully restored from ticket" \
1026 -S "a session has been resumed" \
1027 -C "a session has been resumed"
1028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001029run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001030 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1031 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001032 0 \
1033 -s "session successfully restored from cache" \
1034 -S "session successfully restored from ticket" \
1035 -s "a session has been resumed" \
1036 -c "a session has been resumed"
1037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001038run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001039 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001040 "( $O_CLI -sess_out $SESSION; \
1041 $O_CLI -sess_in $SESSION; \
1042 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001043 0 \
1044 -s "found session ticket extension" \
1045 -S "server hello, adding session ticket extension" \
1046 -s "session successfully restored from cache" \
1047 -S "session successfully restored from ticket" \
1048 -s "a session has been resumed"
1049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001050run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001051 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001052 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001053 0 \
1054 -C "found session_ticket extension" \
1055 -C "parse new session ticket" \
1056 -c "a session has been resumed"
1057
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001058# Tests for Max Fragment Length extension
1059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001060run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001061 "$P_SRV debug_level=3" \
1062 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001063 0 \
1064 -C "client hello, adding max_fragment_length extension" \
1065 -S "found max fragment length extension" \
1066 -S "server hello, max_fragment_length extension" \
1067 -C "found max_fragment_length extension"
1068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001069run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001070 "$P_SRV debug_level=3" \
1071 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001072 0 \
1073 -c "client hello, adding max_fragment_length extension" \
1074 -s "found max fragment length extension" \
1075 -s "server hello, max_fragment_length extension" \
1076 -c "found max_fragment_length extension"
1077
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001078run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001079 "$P_SRV debug_level=3 max_frag_len=4096" \
1080 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001081 0 \
1082 -C "client hello, adding max_fragment_length extension" \
1083 -S "found max fragment length extension" \
1084 -S "server hello, max_fragment_length extension" \
1085 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001087requires_gnutls
1088run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001089 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001090 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001091 0 \
1092 -c "client hello, adding max_fragment_length extension" \
1093 -c "found max_fragment_length extension"
1094
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001095run_test "Max fragment length: client, message just fits" \
1096 "$P_SRV debug_level=3" \
1097 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1098 0 \
1099 -c "client hello, adding max_fragment_length extension" \
1100 -s "found max fragment length extension" \
1101 -s "server hello, max_fragment_length extension" \
1102 -c "found max_fragment_length extension" \
1103 -c "2048 bytes written in 1 fragments" \
1104 -s "2048 bytes read"
1105
1106run_test "Max fragment length: client, larger message" \
1107 "$P_SRV debug_level=3" \
1108 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1109 0 \
1110 -c "client hello, adding max_fragment_length extension" \
1111 -s "found max fragment length extension" \
1112 -s "server hello, max_fragment_length extension" \
1113 -c "found max_fragment_length extension" \
1114 -c "2345 bytes written in 2 fragments" \
1115 -s "2048 bytes read" \
1116 -s "297 bytes read"
1117
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001118run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001119 "$P_SRV debug_level=3 dtls=1" \
1120 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1121 1 \
1122 -c "client hello, adding max_fragment_length extension" \
1123 -s "found max fragment length extension" \
1124 -s "server hello, max_fragment_length extension" \
1125 -c "found max_fragment_length extension" \
1126 -c "fragment larger than.*maximum"
1127
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001128# Tests for renegotiation
1129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001130run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001131 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001132 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001133 0 \
1134 -C "client hello, adding renegotiation extension" \
1135 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1136 -S "found renegotiation extension" \
1137 -s "server hello, secure renegotiation extension" \
1138 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001139 -C "=> renegotiate" \
1140 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001141 -S "write hello request"
1142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001143run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001144 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001145 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001146 0 \
1147 -c "client hello, adding renegotiation extension" \
1148 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1149 -s "found renegotiation extension" \
1150 -s "server hello, secure renegotiation extension" \
1151 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001152 -c "=> renegotiate" \
1153 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001154 -S "write hello request"
1155
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001156run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001157 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001158 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001159 0 \
1160 -c "client hello, adding renegotiation extension" \
1161 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1162 -s "found renegotiation extension" \
1163 -s "server hello, secure renegotiation extension" \
1164 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001165 -c "=> renegotiate" \
1166 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001167 -s "write hello request"
1168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001169run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001170 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001171 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001172 0 \
1173 -c "client hello, adding renegotiation extension" \
1174 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1175 -s "found renegotiation extension" \
1176 -s "server hello, secure renegotiation extension" \
1177 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001178 -c "=> renegotiate" \
1179 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001180 -s "write hello request"
1181
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001182run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001183 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001184 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001185 1 \
1186 -c "client hello, adding renegotiation extension" \
1187 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1188 -S "found renegotiation extension" \
1189 -s "server hello, secure renegotiation extension" \
1190 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001191 -c "=> renegotiate" \
1192 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001193 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001194 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001195 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001198 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001199 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001200 0 \
1201 -C "client hello, adding renegotiation extension" \
1202 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1203 -S "found renegotiation extension" \
1204 -s "server hello, secure renegotiation extension" \
1205 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001206 -C "=> renegotiate" \
1207 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001208 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001209 -S "SSL - An unexpected message was received from our peer" \
1210 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001211
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001212run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001213 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001214 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001215 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001216 0 \
1217 -C "client hello, adding renegotiation extension" \
1218 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1219 -S "found renegotiation extension" \
1220 -s "server hello, secure renegotiation extension" \
1221 -c "found renegotiation extension" \
1222 -C "=> renegotiate" \
1223 -S "=> renegotiate" \
1224 -s "write hello request" \
1225 -S "SSL - An unexpected message was received from our peer" \
1226 -S "failed"
1227
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001228# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001229run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001230 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001231 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001232 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001233 0 \
1234 -C "client hello, adding renegotiation extension" \
1235 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1236 -S "found renegotiation extension" \
1237 -s "server hello, secure renegotiation extension" \
1238 -c "found renegotiation extension" \
1239 -C "=> renegotiate" \
1240 -S "=> renegotiate" \
1241 -s "write hello request" \
1242 -S "SSL - An unexpected message was received from our peer" \
1243 -S "failed"
1244
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001245run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001246 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001247 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001248 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001249 0 \
1250 -C "client hello, adding renegotiation extension" \
1251 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1252 -S "found renegotiation extension" \
1253 -s "server hello, secure renegotiation extension" \
1254 -c "found renegotiation extension" \
1255 -C "=> renegotiate" \
1256 -S "=> renegotiate" \
1257 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001258 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001260run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001261 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001262 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001263 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001264 0 \
1265 -c "client hello, adding renegotiation extension" \
1266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1267 -s "found renegotiation extension" \
1268 -s "server hello, secure renegotiation extension" \
1269 -c "found renegotiation extension" \
1270 -c "=> renegotiate" \
1271 -s "=> renegotiate" \
1272 -s "write hello request" \
1273 -S "SSL - An unexpected message was received from our peer" \
1274 -S "failed"
1275
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001276run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001277 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001278 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1279 0 \
1280 -C "client hello, adding renegotiation extension" \
1281 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1282 -S "found renegotiation extension" \
1283 -s "server hello, secure renegotiation extension" \
1284 -c "found renegotiation extension" \
1285 -S "record counter limit reached: renegotiate" \
1286 -C "=> renegotiate" \
1287 -S "=> renegotiate" \
1288 -S "write hello request" \
1289 -S "SSL - An unexpected message was received from our peer" \
1290 -S "failed"
1291
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001292# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001293run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001294 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001295 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001296 0 \
1297 -c "client hello, adding renegotiation extension" \
1298 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1299 -s "found renegotiation extension" \
1300 -s "server hello, secure renegotiation extension" \
1301 -c "found renegotiation extension" \
1302 -s "record counter limit reached: renegotiate" \
1303 -c "=> renegotiate" \
1304 -s "=> renegotiate" \
1305 -s "write hello request" \
1306 -S "SSL - An unexpected message was received from our peer" \
1307 -S "failed"
1308
1309run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001310 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001311 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001312 0 \
1313 -c "client hello, adding renegotiation extension" \
1314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1315 -s "found renegotiation extension" \
1316 -s "server hello, secure renegotiation extension" \
1317 -c "found renegotiation extension" \
1318 -s "record counter limit reached: renegotiate" \
1319 -c "=> renegotiate" \
1320 -s "=> renegotiate" \
1321 -s "write hello request" \
1322 -S "SSL - An unexpected message was received from our peer" \
1323 -S "failed"
1324
1325run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001326 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001327 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1328 0 \
1329 -C "client hello, adding renegotiation extension" \
1330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1331 -S "found renegotiation extension" \
1332 -s "server hello, secure renegotiation extension" \
1333 -c "found renegotiation extension" \
1334 -S "record counter limit reached: renegotiate" \
1335 -C "=> renegotiate" \
1336 -S "=> renegotiate" \
1337 -S "write hello request" \
1338 -S "SSL - An unexpected message was received from our peer" \
1339 -S "failed"
1340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001341run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001342 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001344 0 \
1345 -c "client hello, adding renegotiation extension" \
1346 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1347 -s "found renegotiation extension" \
1348 -s "server hello, secure renegotiation extension" \
1349 -c "found renegotiation extension" \
1350 -c "=> renegotiate" \
1351 -s "=> renegotiate" \
1352 -S "write hello request"
1353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001354run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001355 "$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 +02001356 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001357 0 \
1358 -c "client hello, adding renegotiation extension" \
1359 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1360 -s "found renegotiation extension" \
1361 -s "server hello, secure renegotiation extension" \
1362 -c "found renegotiation extension" \
1363 -c "=> renegotiate" \
1364 -s "=> renegotiate" \
1365 -s "write hello request"
1366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001367run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001368 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001369 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001370 0 \
1371 -c "client hello, adding renegotiation extension" \
1372 -c "found renegotiation extension" \
1373 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001374 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001375 -C "error" \
1376 -c "HTTP/1.0 200 [Oo][Kk]"
1377
Paul Bakker539d9722015-02-08 16:18:35 +01001378requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001379run_test "Renegotiation: gnutls server strict, client-initiated" \
1380 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001381 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001382 0 \
1383 -c "client hello, adding renegotiation extension" \
1384 -c "found renegotiation extension" \
1385 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001386 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001387 -C "error" \
1388 -c "HTTP/1.0 200 [Oo][Kk]"
1389
Paul Bakker539d9722015-02-08 16:18:35 +01001390requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001391run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1392 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1393 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1394 1 \
1395 -c "client hello, adding renegotiation extension" \
1396 -C "found renegotiation extension" \
1397 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001398 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001399 -c "error" \
1400 -C "HTTP/1.0 200 [Oo][Kk]"
1401
Paul Bakker539d9722015-02-08 16:18:35 +01001402requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001403run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1404 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1405 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1406 allow_legacy=0" \
1407 1 \
1408 -c "client hello, adding renegotiation extension" \
1409 -C "found renegotiation extension" \
1410 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001411 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001412 -c "error" \
1413 -C "HTTP/1.0 200 [Oo][Kk]"
1414
Paul Bakker539d9722015-02-08 16:18:35 +01001415requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001416run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1417 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1418 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1419 allow_legacy=1" \
1420 0 \
1421 -c "client hello, adding renegotiation extension" \
1422 -C "found renegotiation extension" \
1423 -c "=> renegotiate" \
1424 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001425 -C "error" \
1426 -c "HTTP/1.0 200 [Oo][Kk]"
1427
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001428run_test "Renegotiation: DTLS, client-initiated" \
1429 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1430 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1431 0 \
1432 -c "client hello, adding renegotiation extension" \
1433 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1434 -s "found renegotiation extension" \
1435 -s "server hello, secure renegotiation extension" \
1436 -c "found renegotiation extension" \
1437 -c "=> renegotiate" \
1438 -s "=> renegotiate" \
1439 -S "write hello request"
1440
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001441run_test "Renegotiation: DTLS, server-initiated" \
1442 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001443 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1444 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001445 0 \
1446 -c "client hello, adding renegotiation extension" \
1447 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1448 -s "found renegotiation extension" \
1449 -s "server hello, secure renegotiation extension" \
1450 -c "found renegotiation extension" \
1451 -c "=> renegotiate" \
1452 -s "=> renegotiate" \
1453 -s "write hello request"
1454
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001455requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001456run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1457 "$G_SRV -u --mtu 4096" \
1458 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1459 0 \
1460 -c "client hello, adding renegotiation extension" \
1461 -c "found renegotiation extension" \
1462 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001463 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001464 -C "error" \
1465 -s "Extra-header:"
1466
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001467# Test for the "secure renegotation" extension only (no actual renegotiation)
1468
Paul Bakker539d9722015-02-08 16:18:35 +01001469requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001470run_test "Renego ext: gnutls server strict, client default" \
1471 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1472 "$P_CLI debug_level=3" \
1473 0 \
1474 -c "found renegotiation extension" \
1475 -C "error" \
1476 -c "HTTP/1.0 200 [Oo][Kk]"
1477
Paul Bakker539d9722015-02-08 16:18:35 +01001478requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001479run_test "Renego ext: gnutls server unsafe, client default" \
1480 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1481 "$P_CLI debug_level=3" \
1482 0 \
1483 -C "found renegotiation extension" \
1484 -C "error" \
1485 -c "HTTP/1.0 200 [Oo][Kk]"
1486
Paul Bakker539d9722015-02-08 16:18:35 +01001487requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001488run_test "Renego ext: gnutls server unsafe, client break legacy" \
1489 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1490 "$P_CLI debug_level=3 allow_legacy=-1" \
1491 1 \
1492 -C "found renegotiation extension" \
1493 -c "error" \
1494 -C "HTTP/1.0 200 [Oo][Kk]"
1495
Paul Bakker539d9722015-02-08 16:18:35 +01001496requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001497run_test "Renego ext: gnutls client strict, server default" \
1498 "$P_SRV debug_level=3" \
1499 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1500 0 \
1501 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1502 -s "server hello, secure renegotiation extension"
1503
Paul Bakker539d9722015-02-08 16:18:35 +01001504requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001505run_test "Renego ext: gnutls client unsafe, server default" \
1506 "$P_SRV debug_level=3" \
1507 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1508 0 \
1509 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1510 -S "server hello, secure renegotiation extension"
1511
Paul Bakker539d9722015-02-08 16:18:35 +01001512requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001513run_test "Renego ext: gnutls client unsafe, server break legacy" \
1514 "$P_SRV debug_level=3 allow_legacy=-1" \
1515 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1516 1 \
1517 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1518 -S "server hello, secure renegotiation extension"
1519
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001520# Tests for auth_mode
1521
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001522run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001523 "$P_SRV crt_file=data_files/server5-badsign.crt \
1524 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001525 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001526 1 \
1527 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001528 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001529 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001530 -c "X509 - Certificate verification failed"
1531
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001532run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001533 "$P_SRV crt_file=data_files/server5-badsign.crt \
1534 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001535 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001536 0 \
1537 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001538 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001539 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001540 -C "X509 - Certificate verification failed"
1541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001542run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001543 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001544 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001545 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001546 0 \
1547 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001548 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001549 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001550 -C "X509 - Certificate verification failed"
1551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001552run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001553 "$P_SRV debug_level=3 auth_mode=required" \
1554 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001555 key_file=data_files/server5.key" \
1556 1 \
1557 -S "skip write certificate request" \
1558 -C "skip parse certificate request" \
1559 -c "got a certificate request" \
1560 -C "skip write certificate" \
1561 -C "skip write certificate verify" \
1562 -S "skip parse certificate verify" \
1563 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001564 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001565 -s "! mbedtls_ssl_handshake returned" \
1566 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001567 -s "X509 - Certificate verification failed"
1568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001569run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001570 "$P_SRV debug_level=3 auth_mode=optional" \
1571 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001572 key_file=data_files/server5.key" \
1573 0 \
1574 -S "skip write certificate request" \
1575 -C "skip parse certificate request" \
1576 -c "got a certificate request" \
1577 -C "skip write certificate" \
1578 -C "skip write certificate verify" \
1579 -S "skip parse certificate verify" \
1580 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001581 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001582 -S "! mbedtls_ssl_handshake returned" \
1583 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001584 -S "X509 - Certificate verification failed"
1585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001586run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001587 "$P_SRV debug_level=3 auth_mode=none" \
1588 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001589 key_file=data_files/server5.key" \
1590 0 \
1591 -s "skip write certificate request" \
1592 -C "skip parse certificate request" \
1593 -c "got no certificate request" \
1594 -c "skip write certificate" \
1595 -c "skip write certificate verify" \
1596 -s "skip parse certificate verify" \
1597 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001598 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001599 -S "! mbedtls_ssl_handshake returned" \
1600 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001601 -S "X509 - Certificate verification failed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001604 "$P_SRV debug_level=3 auth_mode=optional" \
1605 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001606 0 \
1607 -S "skip write certificate request" \
1608 -C "skip parse certificate request" \
1609 -c "got a certificate request" \
1610 -C "skip write certificate$" \
1611 -C "got no certificate to send" \
1612 -S "SSLv3 client has no certificate" \
1613 -c "skip write certificate verify" \
1614 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001615 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001616 -S "! mbedtls_ssl_handshake returned" \
1617 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001618 -S "X509 - Certificate verification failed"
1619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001620run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001621 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001622 "$O_CLI" \
1623 0 \
1624 -S "skip write certificate request" \
1625 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001626 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001627 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001628 -S "X509 - Certificate verification failed"
1629
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001630run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001631 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001632 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001633 0 \
1634 -C "skip parse certificate request" \
1635 -c "got a certificate request" \
1636 -C "skip write certificate$" \
1637 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001638 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001639
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001640run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001641 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01001642 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001643 0 \
1644 -S "skip write certificate request" \
1645 -C "skip parse certificate request" \
1646 -c "got a certificate request" \
1647 -C "skip write certificate$" \
1648 -c "skip write certificate verify" \
1649 -c "got no certificate to send" \
1650 -s "SSLv3 client has no certificate" \
1651 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001652 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001653 -S "! mbedtls_ssl_handshake returned" \
1654 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01001655 -S "X509 - Certificate verification failed"
1656
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01001657# Tests for certificate selection based on SHA verson
1658
1659run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
1660 "$P_SRV crt_file=data_files/server5.crt \
1661 key_file=data_files/server5.key \
1662 crt_file2=data_files/server5-sha1.crt \
1663 key_file2=data_files/server5.key" \
1664 "$P_CLI force_version=tls1_2" \
1665 0 \
1666 -c "signed using.*ECDSA with SHA256" \
1667 -C "signed using.*ECDSA with SHA1"
1668
1669run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
1670 "$P_SRV crt_file=data_files/server5.crt \
1671 key_file=data_files/server5.key \
1672 crt_file2=data_files/server5-sha1.crt \
1673 key_file2=data_files/server5.key" \
1674 "$P_CLI force_version=tls1_1" \
1675 0 \
1676 -C "signed using.*ECDSA with SHA256" \
1677 -c "signed using.*ECDSA with SHA1"
1678
1679run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
1680 "$P_SRV crt_file=data_files/server5.crt \
1681 key_file=data_files/server5.key \
1682 crt_file2=data_files/server5-sha1.crt \
1683 key_file2=data_files/server5.key" \
1684 "$P_CLI force_version=tls1" \
1685 0 \
1686 -C "signed using.*ECDSA with SHA256" \
1687 -c "signed using.*ECDSA with SHA1"
1688
1689run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
1690 "$P_SRV crt_file=data_files/server5.crt \
1691 key_file=data_files/server5.key \
1692 crt_file2=data_files/server6.crt \
1693 key_file2=data_files/server6.key" \
1694 "$P_CLI force_version=tls1_1" \
1695 0 \
1696 -c "serial number.*09" \
1697 -c "signed using.*ECDSA with SHA256" \
1698 -C "signed using.*ECDSA with SHA1"
1699
1700run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
1701 "$P_SRV crt_file=data_files/server6.crt \
1702 key_file=data_files/server6.key \
1703 crt_file2=data_files/server5.crt \
1704 key_file2=data_files/server5.key" \
1705 "$P_CLI force_version=tls1_1" \
1706 0 \
1707 -c "serial number.*0A" \
1708 -c "signed using.*ECDSA with SHA256" \
1709 -C "signed using.*ECDSA with SHA1"
1710
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001711# tests for SNI
1712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001713run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001714 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001715 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001716 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001717 0 \
1718 -S "parse ServerName extension" \
1719 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
1720 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001722run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001723 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001724 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001725 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 +02001726 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001727 0 \
1728 -s "parse ServerName extension" \
1729 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1730 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001731
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001732run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001733 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001734 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001735 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 +02001736 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001737 0 \
1738 -s "parse ServerName extension" \
1739 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
1740 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001742run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001743 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001744 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02001745 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 +02001746 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001747 1 \
1748 -s "parse ServerName extension" \
1749 -s "ssl_sni_wrapper() returned" \
1750 -s "mbedtls_ssl_handshake returned" \
1751 -c "mbedtls_ssl_handshake returned" \
1752 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01001753
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001754run_test "SNI: client auth no override: optional" \
1755 "$P_SRV debug_level=3 auth_mode=optional \
1756 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1757 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
1758 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001759 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001760 -S "skip write certificate request" \
1761 -C "skip parse certificate request" \
1762 -c "got a certificate request" \
1763 -C "skip write certificate" \
1764 -C "skip write certificate verify" \
1765 -S "skip parse certificate verify"
1766
1767run_test "SNI: client auth override: none -> optional" \
1768 "$P_SRV debug_level=3 auth_mode=none \
1769 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1770 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
1771 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001772 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001773 -S "skip write certificate request" \
1774 -C "skip parse certificate request" \
1775 -c "got a certificate request" \
1776 -C "skip write certificate" \
1777 -C "skip write certificate verify" \
1778 -S "skip parse certificate verify"
1779
1780run_test "SNI: client auth override: optional -> none" \
1781 "$P_SRV debug_level=3 auth_mode=optional \
1782 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1783 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
1784 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001785 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02001786 -s "skip write certificate request" \
1787 -C "skip parse certificate request" \
1788 -c "got no certificate request" \
1789 -c "skip write certificate" \
1790 -c "skip write certificate verify" \
1791 -s "skip parse certificate verify"
1792
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001793run_test "SNI: CA no override" \
1794 "$P_SRV debug_level=3 auth_mode=optional \
1795 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1796 ca_file=data_files/test-ca.crt \
1797 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
1798 "$P_CLI debug_level=3 server_name=localhost \
1799 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1800 1 \
1801 -S "skip write certificate request" \
1802 -C "skip parse certificate request" \
1803 -c "got a certificate request" \
1804 -C "skip write certificate" \
1805 -C "skip write certificate verify" \
1806 -S "skip parse certificate verify" \
1807 -s "x509_verify_cert() returned" \
1808 -s "! The certificate is not correctly signed by the trusted CA" \
1809 -S "The certificate has been revoked (is on a CRL)"
1810
1811run_test "SNI: CA override" \
1812 "$P_SRV debug_level=3 auth_mode=optional \
1813 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1814 ca_file=data_files/test-ca.crt \
1815 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
1816 "$P_CLI debug_level=3 server_name=localhost \
1817 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1818 0 \
1819 -S "skip write certificate request" \
1820 -C "skip parse certificate request" \
1821 -c "got a certificate request" \
1822 -C "skip write certificate" \
1823 -C "skip write certificate verify" \
1824 -S "skip parse certificate verify" \
1825 -S "x509_verify_cert() returned" \
1826 -S "! The certificate is not correctly signed by the trusted CA" \
1827 -S "The certificate has been revoked (is on a CRL)"
1828
1829run_test "SNI: CA override with CRL" \
1830 "$P_SRV debug_level=3 auth_mode=optional \
1831 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1832 ca_file=data_files/test-ca.crt \
1833 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
1834 "$P_CLI debug_level=3 server_name=localhost \
1835 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
1836 1 \
1837 -S "skip write certificate request" \
1838 -C "skip parse certificate request" \
1839 -c "got a certificate request" \
1840 -C "skip write certificate" \
1841 -C "skip write certificate verify" \
1842 -S "skip parse certificate verify" \
1843 -s "x509_verify_cert() returned" \
1844 -S "! The certificate is not correctly signed by the trusted CA" \
1845 -s "The certificate has been revoked (is on a CRL)"
1846
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001847# Tests for non-blocking I/O: exercise a variety of handshake flows
1848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001849run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001850 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1851 "$P_CLI nbio=2 tickets=0" \
1852 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001853 -S "mbedtls_ssl_handshake returned" \
1854 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001855 -c "Read from server: .* bytes read"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001858 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
1859 "$P_CLI nbio=2 tickets=0" \
1860 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001861 -S "mbedtls_ssl_handshake returned" \
1862 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001863 -c "Read from server: .* bytes read"
1864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001865run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001866 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1867 "$P_CLI nbio=2 tickets=1" \
1868 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001869 -S "mbedtls_ssl_handshake returned" \
1870 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001871 -c "Read from server: .* bytes read"
1872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001873run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001874 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1875 "$P_CLI nbio=2 tickets=1" \
1876 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001877 -S "mbedtls_ssl_handshake returned" \
1878 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001879 -c "Read from server: .* bytes read"
1880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001881run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001882 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
1883 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1884 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001885 -S "mbedtls_ssl_handshake returned" \
1886 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001887 -c "Read from server: .* bytes read"
1888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001889run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001890 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
1891 "$P_CLI nbio=2 tickets=1 reconnect=1" \
1892 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001893 -S "mbedtls_ssl_handshake returned" \
1894 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001895 -c "Read from server: .* bytes read"
1896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001897run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001898 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
1899 "$P_CLI nbio=2 tickets=0 reconnect=1" \
1900 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001901 -S "mbedtls_ssl_handshake returned" \
1902 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01001903 -c "Read from server: .* bytes read"
1904
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001905# Tests for version negotiation
1906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001908 "$P_SRV" \
1909 "$P_CLI" \
1910 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001911 -S "mbedtls_ssl_handshake returned" \
1912 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001913 -s "Protocol is TLSv1.2" \
1914 -c "Protocol is TLSv1.2"
1915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001916run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001917 "$P_SRV" \
1918 "$P_CLI max_version=tls1_1" \
1919 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001920 -S "mbedtls_ssl_handshake returned" \
1921 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001922 -s "Protocol is TLSv1.1" \
1923 -c "Protocol is TLSv1.1"
1924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001925run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001926 "$P_SRV max_version=tls1_1" \
1927 "$P_CLI" \
1928 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001929 -S "mbedtls_ssl_handshake returned" \
1930 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001931 -s "Protocol is TLSv1.1" \
1932 -c "Protocol is TLSv1.1"
1933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001934run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001935 "$P_SRV max_version=tls1_1" \
1936 "$P_CLI max_version=tls1_1" \
1937 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001938 -S "mbedtls_ssl_handshake returned" \
1939 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001940 -s "Protocol is TLSv1.1" \
1941 -c "Protocol is TLSv1.1"
1942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001943run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001944 "$P_SRV min_version=tls1_1" \
1945 "$P_CLI max_version=tls1_1" \
1946 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001947 -S "mbedtls_ssl_handshake returned" \
1948 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001949 -s "Protocol is TLSv1.1" \
1950 -c "Protocol is TLSv1.1"
1951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001952run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001953 "$P_SRV max_version=tls1_1" \
1954 "$P_CLI min_version=tls1_1" \
1955 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001956 -S "mbedtls_ssl_handshake returned" \
1957 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001958 -s "Protocol is TLSv1.1" \
1959 -c "Protocol is TLSv1.1"
1960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001961run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001962 "$P_SRV max_version=tls1_1" \
1963 "$P_CLI min_version=tls1_2" \
1964 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001965 -s "mbedtls_ssl_handshake returned" \
1966 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001967 -c "SSL - Handshake protocol not within min/max boundaries"
1968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001969run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001970 "$P_SRV min_version=tls1_2" \
1971 "$P_CLI max_version=tls1_1" \
1972 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001973 -s "mbedtls_ssl_handshake returned" \
1974 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01001975 -s "SSL - Handshake protocol not within min/max boundaries"
1976
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001977# Tests for ALPN extension
1978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001979run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001980 "$P_SRV debug_level=3" \
1981 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001982 0 \
1983 -C "client hello, adding alpn extension" \
1984 -S "found alpn extension" \
1985 -C "got an alert message, type: \\[2:120]" \
1986 -S "server hello, adding alpn extension" \
1987 -C "found alpn extension " \
1988 -C "Application Layer Protocol is" \
1989 -S "Application Layer Protocol is"
1990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001991run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001992 "$P_SRV debug_level=3" \
1993 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02001994 0 \
1995 -c "client hello, adding alpn extension" \
1996 -s "found alpn extension" \
1997 -C "got an alert message, type: \\[2:120]" \
1998 -S "server hello, adding alpn extension" \
1999 -C "found alpn extension " \
2000 -c "Application Layer Protocol is (none)" \
2001 -S "Application Layer Protocol is"
2002
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002003run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002004 "$P_SRV debug_level=3 alpn=abc,1234" \
2005 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002006 0 \
2007 -C "client hello, adding alpn extension" \
2008 -S "found alpn extension" \
2009 -C "got an alert message, type: \\[2:120]" \
2010 -S "server hello, adding alpn extension" \
2011 -C "found alpn extension " \
2012 -C "Application Layer Protocol is" \
2013 -s "Application Layer Protocol is (none)"
2014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002015run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002016 "$P_SRV debug_level=3 alpn=abc,1234" \
2017 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002018 0 \
2019 -c "client hello, adding alpn extension" \
2020 -s "found alpn extension" \
2021 -C "got an alert message, type: \\[2:120]" \
2022 -s "server hello, adding alpn extension" \
2023 -c "found alpn extension" \
2024 -c "Application Layer Protocol is abc" \
2025 -s "Application Layer Protocol is abc"
2026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002027run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002028 "$P_SRV debug_level=3 alpn=abc,1234" \
2029 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002030 0 \
2031 -c "client hello, adding alpn extension" \
2032 -s "found alpn extension" \
2033 -C "got an alert message, type: \\[2:120]" \
2034 -s "server hello, adding alpn extension" \
2035 -c "found alpn extension" \
2036 -c "Application Layer Protocol is abc" \
2037 -s "Application Layer Protocol is abc"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002040 "$P_SRV debug_level=3 alpn=abc,1234" \
2041 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002042 0 \
2043 -c "client hello, adding alpn extension" \
2044 -s "found alpn extension" \
2045 -C "got an alert message, type: \\[2:120]" \
2046 -s "server hello, adding alpn extension" \
2047 -c "found alpn extension" \
2048 -c "Application Layer Protocol is 1234" \
2049 -s "Application Layer Protocol is 1234"
2050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002052 "$P_SRV debug_level=3 alpn=abc,123" \
2053 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002054 1 \
2055 -c "client hello, adding alpn extension" \
2056 -s "found alpn extension" \
2057 -c "got an alert message, type: \\[2:120]" \
2058 -S "server hello, adding alpn extension" \
2059 -C "found alpn extension" \
2060 -C "Application Layer Protocol is 1234" \
2061 -S "Application Layer Protocol is 1234"
2062
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002063
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002064# Tests for keyUsage in leaf certificates, part 1:
2065# server-side certificate/suite selection
2066
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002067run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002068 "$P_SRV key_file=data_files/server2.key \
2069 crt_file=data_files/server2.ku-ds.crt" \
2070 "$P_CLI" \
2071 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002072 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002073
2074
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002076 "$P_SRV key_file=data_files/server2.key \
2077 crt_file=data_files/server2.ku-ke.crt" \
2078 "$P_CLI" \
2079 0 \
2080 -c "Ciphersuite is TLS-RSA-WITH-"
2081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002082run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002083 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002084 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002085 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002086 1 \
2087 -C "Ciphersuite is "
2088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002089run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002090 "$P_SRV key_file=data_files/server5.key \
2091 crt_file=data_files/server5.ku-ds.crt" \
2092 "$P_CLI" \
2093 0 \
2094 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2095
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002098 "$P_SRV key_file=data_files/server5.key \
2099 crt_file=data_files/server5.ku-ka.crt" \
2100 "$P_CLI" \
2101 0 \
2102 -c "Ciphersuite is TLS-ECDH-"
2103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002104run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002105 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002106 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002107 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002108 1 \
2109 -C "Ciphersuite is "
2110
2111# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002112# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002115 "$O_SRV -key data_files/server2.key \
2116 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002118 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2119 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002120 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002121 -C "Processing of the Certificate handshake message failed" \
2122 -c "Ciphersuite is TLS-"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002125 "$O_SRV -key data_files/server2.key \
2126 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002127 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002128 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2129 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002130 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002131 -C "Processing of the Certificate handshake message failed" \
2132 -c "Ciphersuite is TLS-"
2133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002134run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002135 "$O_SRV -key data_files/server2.key \
2136 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002137 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002138 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2139 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002140 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002141 -C "Processing of the Certificate handshake message failed" \
2142 -c "Ciphersuite is TLS-"
2143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002144run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002145 "$O_SRV -key data_files/server2.key \
2146 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002147 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002148 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2149 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002150 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002151 -c "Processing of the Certificate handshake message failed" \
2152 -C "Ciphersuite is TLS-"
2153
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002154run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2155 "$O_SRV -key data_files/server2.key \
2156 -cert data_files/server2.ku-ke.crt" \
2157 "$P_CLI debug_level=1 auth_mode=optional \
2158 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2159 0 \
2160 -c "bad certificate (usage extensions)" \
2161 -C "Processing of the Certificate handshake message failed" \
2162 -c "Ciphersuite is TLS-" \
2163 -c "! Usage does not match the keyUsage extension"
2164
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002166 "$O_SRV -key data_files/server2.key \
2167 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002168 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002169 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2170 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002171 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002172 -C "Processing of the Certificate handshake message failed" \
2173 -c "Ciphersuite is TLS-"
2174
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002176 "$O_SRV -key data_files/server2.key \
2177 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002178 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002179 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2180 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002181 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002182 -c "Processing of the Certificate handshake message failed" \
2183 -C "Ciphersuite is TLS-"
2184
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002185run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2186 "$O_SRV -key data_files/server2.key \
2187 -cert data_files/server2.ku-ds.crt" \
2188 "$P_CLI debug_level=1 auth_mode=optional \
2189 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2190 0 \
2191 -c "bad certificate (usage extensions)" \
2192 -C "Processing of the Certificate handshake message failed" \
2193 -c "Ciphersuite is TLS-" \
2194 -c "! Usage does not match the keyUsage extension"
2195
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002196# Tests for keyUsage in leaf certificates, part 3:
2197# server-side checking of client cert
2198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002199run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002200 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002201 "$O_CLI -key data_files/server2.key \
2202 -cert data_files/server2.ku-ds.crt" \
2203 0 \
2204 -S "bad certificate (usage extensions)" \
2205 -S "Processing of the Certificate handshake message failed"
2206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002208 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002209 "$O_CLI -key data_files/server2.key \
2210 -cert data_files/server2.ku-ke.crt" \
2211 0 \
2212 -s "bad certificate (usage extensions)" \
2213 -S "Processing of the Certificate handshake message failed"
2214
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002215run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002216 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002217 "$O_CLI -key data_files/server2.key \
2218 -cert data_files/server2.ku-ke.crt" \
2219 1 \
2220 -s "bad certificate (usage extensions)" \
2221 -s "Processing of the Certificate handshake message failed"
2222
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002224 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002225 "$O_CLI -key data_files/server5.key \
2226 -cert data_files/server5.ku-ds.crt" \
2227 0 \
2228 -S "bad certificate (usage extensions)" \
2229 -S "Processing of the Certificate handshake message failed"
2230
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002231run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002232 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002233 "$O_CLI -key data_files/server5.key \
2234 -cert data_files/server5.ku-ka.crt" \
2235 0 \
2236 -s "bad certificate (usage extensions)" \
2237 -S "Processing of the Certificate handshake message failed"
2238
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002239# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2240
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002242 "$P_SRV key_file=data_files/server5.key \
2243 crt_file=data_files/server5.eku-srv.crt" \
2244 "$P_CLI" \
2245 0
2246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002247run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002248 "$P_SRV key_file=data_files/server5.key \
2249 crt_file=data_files/server5.eku-srv.crt" \
2250 "$P_CLI" \
2251 0
2252
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002254 "$P_SRV key_file=data_files/server5.key \
2255 crt_file=data_files/server5.eku-cs_any.crt" \
2256 "$P_CLI" \
2257 0
2258
2259# add psk to leave an option for client to send SERVERQUIT
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002260run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002261 "$P_SRV psk=abc123 key_file=data_files/server5.key \
2262 crt_file=data_files/server5.eku-cli.crt" \
2263 "$P_CLI psk=badbad" \
2264 1
2265
2266# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002268run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002269 "$O_SRV -key data_files/server5.key \
2270 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002271 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002272 0 \
2273 -C "bad certificate (usage extensions)" \
2274 -C "Processing of the Certificate handshake message failed" \
2275 -c "Ciphersuite is TLS-"
2276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002278 "$O_SRV -key data_files/server5.key \
2279 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002280 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002281 0 \
2282 -C "bad certificate (usage extensions)" \
2283 -C "Processing of the Certificate handshake message failed" \
2284 -c "Ciphersuite is TLS-"
2285
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002286run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002287 "$O_SRV -key data_files/server5.key \
2288 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002289 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002290 0 \
2291 -C "bad certificate (usage extensions)" \
2292 -C "Processing of the Certificate handshake message failed" \
2293 -c "Ciphersuite is TLS-"
2294
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002295run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002296 "$O_SRV -key data_files/server5.key \
2297 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002298 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002299 1 \
2300 -c "bad certificate (usage extensions)" \
2301 -c "Processing of the Certificate handshake message failed" \
2302 -C "Ciphersuite is TLS-"
2303
2304# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002307 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002308 "$O_CLI -key data_files/server5.key \
2309 -cert data_files/server5.eku-cli.crt" \
2310 0 \
2311 -S "bad certificate (usage extensions)" \
2312 -S "Processing of the Certificate handshake message failed"
2313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002314run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002315 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002316 "$O_CLI -key data_files/server5.key \
2317 -cert data_files/server5.eku-srv_cli.crt" \
2318 0 \
2319 -S "bad certificate (usage extensions)" \
2320 -S "Processing of the Certificate handshake message failed"
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002323 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002324 "$O_CLI -key data_files/server5.key \
2325 -cert data_files/server5.eku-cs_any.crt" \
2326 0 \
2327 -S "bad certificate (usage extensions)" \
2328 -S "Processing of the Certificate handshake message failed"
2329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002330run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002331 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002332 "$O_CLI -key data_files/server5.key \
2333 -cert data_files/server5.eku-cs.crt" \
2334 0 \
2335 -s "bad certificate (usage extensions)" \
2336 -S "Processing of the Certificate handshake message failed"
2337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002338run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002339 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002340 "$O_CLI -key data_files/server5.key \
2341 -cert data_files/server5.eku-cs.crt" \
2342 1 \
2343 -s "bad certificate (usage extensions)" \
2344 -s "Processing of the Certificate handshake message failed"
2345
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002346# Tests for DHM parameters loading
2347
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002348run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002349 "$P_SRV" \
2350 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2351 debug_level=3" \
2352 0 \
2353 -c "value of 'DHM: P ' (2048 bits)" \
2354 -c "value of 'DHM: G ' (2048 bits)"
2355
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002356run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002357 "$P_SRV dhm_file=data_files/dhparams.pem" \
2358 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2359 debug_level=3" \
2360 0 \
2361 -c "value of 'DHM: P ' (1024 bits)" \
2362 -c "value of 'DHM: G ' (2 bits)"
2363
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002364# Tests for DHM client-side size checking
2365
2366run_test "DHM size: server default, client default, OK" \
2367 "$P_SRV" \
2368 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2369 debug_level=1" \
2370 0 \
2371 -C "DHM prime too short:"
2372
2373run_test "DHM size: server default, client 2048, OK" \
2374 "$P_SRV" \
2375 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2376 debug_level=1 dhmlen=2048" \
2377 0 \
2378 -C "DHM prime too short:"
2379
2380run_test "DHM size: server 1024, client default, OK" \
2381 "$P_SRV dhm_file=data_files/dhparams.pem" \
2382 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2383 debug_level=1" \
2384 0 \
2385 -C "DHM prime too short:"
2386
2387run_test "DHM size: server 1000, client default, rejected" \
2388 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2389 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2390 debug_level=1" \
2391 1 \
2392 -c "DHM prime too short:"
2393
2394run_test "DHM size: server default, client 2049, rejected" \
2395 "$P_SRV" \
2396 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2397 debug_level=1 dhmlen=2049" \
2398 1 \
2399 -c "DHM prime too short:"
2400
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002401# Tests for PSK callback
2402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002403run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002404 "$P_SRV psk=abc123 psk_identity=foo" \
2405 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2406 psk_identity=foo psk=abc123" \
2407 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002408 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002409 -S "SSL - Unknown identity received" \
2410 -S "SSL - Verification of the message MAC failed"
2411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002413 "$P_SRV" \
2414 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2415 psk_identity=foo psk=abc123" \
2416 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002417 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002418 -S "SSL - Unknown identity received" \
2419 -S "SSL - Verification of the message MAC failed"
2420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002421run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002422 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2423 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2424 psk_identity=foo psk=abc123" \
2425 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002426 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002427 -s "SSL - Unknown identity received" \
2428 -S "SSL - Verification of the message MAC failed"
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002431 "$P_SRV psk_list=abc,dead,def,beef" \
2432 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2433 psk_identity=abc psk=dead" \
2434 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002435 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002436 -S "SSL - Unknown identity received" \
2437 -S "SSL - Verification of the message MAC failed"
2438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002439run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002440 "$P_SRV psk_list=abc,dead,def,beef" \
2441 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2442 psk_identity=def psk=beef" \
2443 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002444 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002445 -S "SSL - Unknown identity received" \
2446 -S "SSL - Verification of the message MAC failed"
2447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002448run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002449 "$P_SRV psk_list=abc,dead,def,beef" \
2450 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2451 psk_identity=ghi psk=beef" \
2452 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002453 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002454 -s "SSL - Unknown identity received" \
2455 -S "SSL - Verification of the message MAC failed"
2456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002457run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002458 "$P_SRV psk_list=abc,dead,def,beef" \
2459 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2460 psk_identity=abc psk=beef" \
2461 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002462 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002463 -S "SSL - Unknown identity received" \
2464 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002465
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002466# Tests for ciphersuites per version
2467
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002468run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002469 "$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 +02002470 "$P_CLI force_version=ssl3" \
2471 0 \
2472 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002474run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002475 "$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 +01002476 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002477 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002478 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002479
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002480run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002481 "$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 +02002482 "$P_CLI force_version=tls1_1" \
2483 0 \
2484 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002486run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002487 "$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 +02002488 "$P_CLI force_version=tls1_2" \
2489 0 \
2490 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2491
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002492# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002493
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002494run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002495 "$P_SRV" \
2496 "$P_CLI request_size=100" \
2497 0 \
2498 -s "Read from client: 100 bytes read$"
2499
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002500run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002501 "$P_SRV" \
2502 "$P_CLI request_size=500" \
2503 0 \
2504 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002505
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002506# Tests for small packets
2507
2508run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002509 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002510 "$P_CLI request_size=1 force_version=ssl3 \
2511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2512 0 \
2513 -s "Read from client: 1 bytes read"
2514
2515run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002516 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002517 "$P_CLI request_size=1 force_version=ssl3 \
2518 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2519 0 \
2520 -s "Read from client: 1 bytes read"
2521
2522run_test "Small packet TLS 1.0 BlockCipher" \
2523 "$P_SRV" \
2524 "$P_CLI request_size=1 force_version=tls1 \
2525 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2526 0 \
2527 -s "Read from client: 1 bytes read"
2528
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002529run_test "Small packet TLS 1.0 BlockCipher without EtM" \
2530 "$P_SRV" \
2531 "$P_CLI request_size=1 force_version=tls1 etm=0 \
2532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2533 0 \
2534 -s "Read from client: 1 bytes read"
2535
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002536run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
2537 "$P_SRV" \
2538 "$P_CLI request_size=1 force_version=tls1 \
2539 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2540 trunc_hmac=1" \
2541 0 \
2542 -s "Read from client: 1 bytes read"
2543
2544run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002545 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002546 "$P_CLI request_size=1 force_version=tls1 \
2547 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2548 trunc_hmac=1" \
2549 0 \
2550 -s "Read from client: 1 bytes read"
2551
2552run_test "Small packet TLS 1.1 BlockCipher" \
2553 "$P_SRV" \
2554 "$P_CLI request_size=1 force_version=tls1_1 \
2555 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2556 0 \
2557 -s "Read from client: 1 bytes read"
2558
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002559run_test "Small packet TLS 1.1 BlockCipher without EtM" \
2560 "$P_SRV" \
2561 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
2562 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2563 0 \
2564 -s "Read from client: 1 bytes read"
2565
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002566run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002567 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002568 "$P_CLI request_size=1 force_version=tls1_1 \
2569 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2570 0 \
2571 -s "Read from client: 1 bytes read"
2572
2573run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
2574 "$P_SRV" \
2575 "$P_CLI request_size=1 force_version=tls1_1 \
2576 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2577 trunc_hmac=1" \
2578 0 \
2579 -s "Read from client: 1 bytes read"
2580
2581run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002582 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002583 "$P_CLI request_size=1 force_version=tls1_1 \
2584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2585 trunc_hmac=1" \
2586 0 \
2587 -s "Read from client: 1 bytes read"
2588
2589run_test "Small packet TLS 1.2 BlockCipher" \
2590 "$P_SRV" \
2591 "$P_CLI request_size=1 force_version=tls1_2 \
2592 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2593 0 \
2594 -s "Read from client: 1 bytes read"
2595
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01002596run_test "Small packet TLS 1.2 BlockCipher without EtM" \
2597 "$P_SRV" \
2598 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
2599 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2600 0 \
2601 -s "Read from client: 1 bytes read"
2602
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002603run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
2604 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002605 "$P_CLI request_size=1 force_version=tls1_2 \
2606 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002607 0 \
2608 -s "Read from client: 1 bytes read"
2609
2610run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
2611 "$P_SRV" \
2612 "$P_CLI request_size=1 force_version=tls1_2 \
2613 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2614 trunc_hmac=1" \
2615 0 \
2616 -s "Read from client: 1 bytes read"
2617
2618run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002619 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002620 "$P_CLI request_size=1 force_version=tls1_2 \
2621 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2622 0 \
2623 -s "Read from client: 1 bytes read"
2624
2625run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002626 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02002627 "$P_CLI request_size=1 force_version=tls1_2 \
2628 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2629 trunc_hmac=1" \
2630 0 \
2631 -s "Read from client: 1 bytes read"
2632
2633run_test "Small packet TLS 1.2 AEAD" \
2634 "$P_SRV" \
2635 "$P_CLI request_size=1 force_version=tls1_2 \
2636 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2637 0 \
2638 -s "Read from client: 1 bytes read"
2639
2640run_test "Small packet TLS 1.2 AEAD shorter tag" \
2641 "$P_SRV" \
2642 "$P_CLI request_size=1 force_version=tls1_2 \
2643 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2644 0 \
2645 -s "Read from client: 1 bytes read"
2646
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002647# Test for large packets
2648
2649run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002650 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002651 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002652 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2653 0 \
2654 -s "Read from client: 16384 bytes read"
2655
2656run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002657 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002658 "$P_CLI request_size=16384 force_version=ssl3 \
2659 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2660 0 \
2661 -s "Read from client: 16384 bytes read"
2662
2663run_test "Large packet TLS 1.0 BlockCipher" \
2664 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002665 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002666 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2667 0 \
2668 -s "Read from client: 16384 bytes read"
2669
2670run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
2671 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002672 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002673 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2674 trunc_hmac=1" \
2675 0 \
2676 -s "Read from client: 16384 bytes read"
2677
2678run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002679 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002680 "$P_CLI request_size=16384 force_version=tls1 \
2681 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2682 trunc_hmac=1" \
2683 0 \
2684 -s "Read from client: 16384 bytes read"
2685
2686run_test "Large packet TLS 1.1 BlockCipher" \
2687 "$P_SRV" \
2688 "$P_CLI request_size=16384 force_version=tls1_1 \
2689 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2690 0 \
2691 -s "Read from client: 16384 bytes read"
2692
2693run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002694 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002695 "$P_CLI request_size=16384 force_version=tls1_1 \
2696 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2697 0 \
2698 -s "Read from client: 16384 bytes read"
2699
2700run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
2701 "$P_SRV" \
2702 "$P_CLI request_size=16384 force_version=tls1_1 \
2703 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2704 trunc_hmac=1" \
2705 0 \
2706 -s "Read from client: 16384 bytes read"
2707
2708run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002709 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002710 "$P_CLI request_size=16384 force_version=tls1_1 \
2711 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2712 trunc_hmac=1" \
2713 0 \
2714 -s "Read from client: 16384 bytes read"
2715
2716run_test "Large packet TLS 1.2 BlockCipher" \
2717 "$P_SRV" \
2718 "$P_CLI request_size=16384 force_version=tls1_2 \
2719 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
2720 0 \
2721 -s "Read from client: 16384 bytes read"
2722
2723run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
2724 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01002725 "$P_CLI request_size=16384 force_version=tls1_2 \
2726 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002727 0 \
2728 -s "Read from client: 16384 bytes read"
2729
2730run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
2731 "$P_SRV" \
2732 "$P_CLI request_size=16384 force_version=tls1_2 \
2733 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
2734 trunc_hmac=1" \
2735 0 \
2736 -s "Read from client: 16384 bytes read"
2737
2738run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002739 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002740 "$P_CLI request_size=16384 force_version=tls1_2 \
2741 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
2742 0 \
2743 -s "Read from client: 16384 bytes read"
2744
2745run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002746 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02002747 "$P_CLI request_size=16384 force_version=tls1_2 \
2748 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2749 trunc_hmac=1" \
2750 0 \
2751 -s "Read from client: 16384 bytes read"
2752
2753run_test "Large packet TLS 1.2 AEAD" \
2754 "$P_SRV" \
2755 "$P_CLI request_size=16384 force_version=tls1_2 \
2756 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
2757 0 \
2758 -s "Read from client: 16384 bytes read"
2759
2760run_test "Large packet TLS 1.2 AEAD shorter tag" \
2761 "$P_SRV" \
2762 "$P_CLI request_size=16384 force_version=tls1_2 \
2763 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
2764 0 \
2765 -s "Read from client: 16384 bytes read"
2766
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002767# Tests for DTLS HelloVerifyRequest
2768
2769run_test "DTLS cookie: enabled" \
2770 "$P_SRV dtls=1 debug_level=2" \
2771 "$P_CLI dtls=1 debug_level=2" \
2772 0 \
2773 -s "cookie verification failed" \
2774 -s "cookie verification passed" \
2775 -S "cookie verification skipped" \
2776 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002777 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002778 -S "SSL - The requested feature is not available"
2779
2780run_test "DTLS cookie: disabled" \
2781 "$P_SRV dtls=1 debug_level=2 cookies=0" \
2782 "$P_CLI dtls=1 debug_level=2" \
2783 0 \
2784 -S "cookie verification failed" \
2785 -S "cookie verification passed" \
2786 -s "cookie verification skipped" \
2787 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002788 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002789 -S "SSL - The requested feature is not available"
2790
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002791run_test "DTLS cookie: default (failing)" \
2792 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
2793 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
2794 1 \
2795 -s "cookie verification failed" \
2796 -S "cookie verification passed" \
2797 -S "cookie verification skipped" \
2798 -C "received hello verify request" \
2799 -S "hello verification requested" \
2800 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002801
2802requires_ipv6
2803run_test "DTLS cookie: enabled, IPv6" \
2804 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
2805 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
2806 0 \
2807 -s "cookie verification failed" \
2808 -s "cookie verification passed" \
2809 -S "cookie verification skipped" \
2810 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002811 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002812 -S "SSL - The requested feature is not available"
2813
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002814run_test "DTLS cookie: enabled, nbio" \
2815 "$P_SRV dtls=1 nbio=2 debug_level=2" \
2816 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2817 0 \
2818 -s "cookie verification failed" \
2819 -s "cookie verification passed" \
2820 -S "cookie verification skipped" \
2821 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02002822 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02002823 -S "SSL - The requested feature is not available"
2824
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002825# Tests for various cases of client authentication with DTLS
2826# (focused on handshake flows and message parsing)
2827
2828run_test "DTLS client auth: required" \
2829 "$P_SRV dtls=1 auth_mode=required" \
2830 "$P_CLI dtls=1" \
2831 0 \
2832 -s "Verifying peer X.509 certificate... ok"
2833
2834run_test "DTLS client auth: optional, client has no cert" \
2835 "$P_SRV dtls=1 auth_mode=optional" \
2836 "$P_CLI dtls=1 crt_file=none key_file=none" \
2837 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002838 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002839
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002840run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002841 "$P_SRV dtls=1 auth_mode=none" \
2842 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
2843 0 \
2844 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002845 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02002846
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02002847# Tests for receiving fragmented handshake messages with DTLS
2848
2849requires_gnutls
2850run_test "DTLS reassembly: no fragmentation (gnutls server)" \
2851 "$G_SRV -u --mtu 2048 -a" \
2852 "$P_CLI dtls=1 debug_level=2" \
2853 0 \
2854 -C "found fragmented DTLS handshake message" \
2855 -C "error"
2856
2857requires_gnutls
2858run_test "DTLS reassembly: some fragmentation (gnutls server)" \
2859 "$G_SRV -u --mtu 512" \
2860 "$P_CLI dtls=1 debug_level=2" \
2861 0 \
2862 -c "found fragmented DTLS handshake message" \
2863 -C "error"
2864
2865requires_gnutls
2866run_test "DTLS reassembly: more fragmentation (gnutls server)" \
2867 "$G_SRV -u --mtu 128" \
2868 "$P_CLI dtls=1 debug_level=2" \
2869 0 \
2870 -c "found fragmented DTLS handshake message" \
2871 -C "error"
2872
2873requires_gnutls
2874run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
2875 "$G_SRV -u --mtu 128" \
2876 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2877 0 \
2878 -c "found fragmented DTLS handshake message" \
2879 -C "error"
2880
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002881requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002882run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
2883 "$G_SRV -u --mtu 256" \
2884 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
2885 0 \
2886 -c "found fragmented DTLS handshake message" \
2887 -c "client hello, adding renegotiation extension" \
2888 -c "found renegotiation extension" \
2889 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002890 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002891 -C "error" \
2892 -s "Extra-header:"
2893
2894requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002895run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
2896 "$G_SRV -u --mtu 256" \
2897 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
2898 0 \
2899 -c "found fragmented DTLS handshake message" \
2900 -c "client hello, adding renegotiation extension" \
2901 -c "found renegotiation extension" \
2902 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002903 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02002904 -C "error" \
2905 -s "Extra-header:"
2906
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002907run_test "DTLS reassembly: no fragmentation (openssl server)" \
2908 "$O_SRV -dtls1 -mtu 2048" \
2909 "$P_CLI dtls=1 debug_level=2" \
2910 0 \
2911 -C "found fragmented DTLS handshake message" \
2912 -C "error"
2913
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002914run_test "DTLS reassembly: some fragmentation (openssl server)" \
2915 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002916 "$P_CLI dtls=1 debug_level=2" \
2917 0 \
2918 -c "found fragmented DTLS handshake message" \
2919 -C "error"
2920
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002921run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02002922 "$O_SRV -dtls1 -mtu 256" \
2923 "$P_CLI dtls=1 debug_level=2" \
2924 0 \
2925 -c "found fragmented DTLS handshake message" \
2926 -C "error"
2927
2928run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
2929 "$O_SRV -dtls1 -mtu 256" \
2930 "$P_CLI dtls=1 nbio=2 debug_level=2" \
2931 0 \
2932 -c "found fragmented DTLS handshake message" \
2933 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002934
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02002935# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002936
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002937not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002938run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02002939 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002940 "$P_SRV dtls=1 debug_level=2" \
2941 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002942 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002943 -C "replayed record" \
2944 -S "replayed record" \
2945 -C "record from another epoch" \
2946 -S "record from another epoch" \
2947 -C "discarding invalid record" \
2948 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002949 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002950 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002951 -c "HTTP/1.0 200 OK"
2952
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002953not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002954run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002955 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002956 "$P_SRV dtls=1 debug_level=2" \
2957 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02002958 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02002959 -c "replayed record" \
2960 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002961 -c "discarding invalid record" \
2962 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002963 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002964 -s "Extra-header:" \
2965 -c "HTTP/1.0 200 OK"
2966
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002967run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
2968 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002969 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
2970 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002971 0 \
2972 -c "replayed record" \
2973 -S "replayed record" \
2974 -c "discarding invalid record" \
2975 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02002976 -c "resend" \
2977 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02002978 -s "Extra-header:" \
2979 -c "HTTP/1.0 200 OK"
2980
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002981run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02002982 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02002983 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002984 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002985 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002986 -c "discarding invalid record (mac)" \
2987 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02002988 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02002989 -c "HTTP/1.0 200 OK" \
2990 -S "too many records with bad MAC" \
2991 -S "Verification of the message MAC failed"
2992
2993run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
2994 -p "$P_PXY bad_ad=1" \
2995 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
2996 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
2997 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02002998 -C "discarding invalid record (mac)" \
2999 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003000 -S "Extra-header:" \
3001 -C "HTTP/1.0 200 OK" \
3002 -s "too many records with bad MAC" \
3003 -s "Verification of the message MAC failed"
3004
3005run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3006 -p "$P_PXY bad_ad=1" \
3007 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3008 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3009 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003010 -c "discarding invalid record (mac)" \
3011 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003012 -s "Extra-header:" \
3013 -c "HTTP/1.0 200 OK" \
3014 -S "too many records with bad MAC" \
3015 -S "Verification of the message MAC failed"
3016
3017run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3018 -p "$P_PXY bad_ad=1" \
3019 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3020 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3021 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003022 -c "discarding invalid record (mac)" \
3023 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003024 -s "Extra-header:" \
3025 -c "HTTP/1.0 200 OK" \
3026 -s "too many records with bad MAC" \
3027 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003028
3029run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003030 -p "$P_PXY delay_ccs=1" \
3031 "$P_SRV dtls=1 debug_level=1" \
3032 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003033 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003034 -c "record from another epoch" \
3035 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003036 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003037 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003038 -s "Extra-header:" \
3039 -c "HTTP/1.0 200 OK"
3040
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003041# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003042
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003043needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003044run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003045 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003046 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3047 psk=abc123" \
3048 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003049 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3050 0 \
3051 -s "Extra-header:" \
3052 -c "HTTP/1.0 200 OK"
3053
3054needs_more_time 2
3055run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3056 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003057 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3058 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003059 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3060 0 \
3061 -s "Extra-header:" \
3062 -c "HTTP/1.0 200 OK"
3063
3064needs_more_time 2
3065run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3066 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003067 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3068 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003069 0 \
3070 -s "Extra-header:" \
3071 -c "HTTP/1.0 200 OK"
3072
3073needs_more_time 2
3074run_test "DTLS proxy: 3d, FS, client auth" \
3075 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003076 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3077 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003078 0 \
3079 -s "Extra-header:" \
3080 -c "HTTP/1.0 200 OK"
3081
3082needs_more_time 2
3083run_test "DTLS proxy: 3d, FS, ticket" \
3084 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003085 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3086 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003087 0 \
3088 -s "Extra-header:" \
3089 -c "HTTP/1.0 200 OK"
3090
3091needs_more_time 2
3092run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3093 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003094 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3095 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003096 0 \
3097 -s "Extra-header:" \
3098 -c "HTTP/1.0 200 OK"
3099
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003100needs_more_time 2
3101run_test "DTLS proxy: 3d, max handshake, nbio" \
3102 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003103 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3104 auth_mode=required" \
3105 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003106 0 \
3107 -s "Extra-header:" \
3108 -c "HTTP/1.0 200 OK"
3109
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003110needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003111run_test "DTLS proxy: 3d, min handshake, resumption" \
3112 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3113 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3114 psk=abc123 debug_level=3" \
3115 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3116 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3117 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3118 0 \
3119 -s "a session has been resumed" \
3120 -c "a session has been resumed" \
3121 -s "Extra-header:" \
3122 -c "HTTP/1.0 200 OK"
3123
3124needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003125run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3126 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3127 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3128 psk=abc123 debug_level=3 nbio=2" \
3129 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3130 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3131 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3132 0 \
3133 -s "a session has been resumed" \
3134 -c "a session has been resumed" \
3135 -s "Extra-header:" \
3136 -c "HTTP/1.0 200 OK"
3137
3138needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003139run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003140 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003141 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3142 psk=abc123 renegotiation=1 debug_level=2" \
3143 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3144 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003145 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3146 0 \
3147 -c "=> renegotiate" \
3148 -s "=> renegotiate" \
3149 -s "Extra-header:" \
3150 -c "HTTP/1.0 200 OK"
3151
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003152needs_more_time 4
3153run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3154 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003155 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3156 psk=abc123 renegotiation=1 debug_level=2" \
3157 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3158 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003159 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3160 0 \
3161 -c "=> renegotiate" \
3162 -s "=> renegotiate" \
3163 -s "Extra-header:" \
3164 -c "HTTP/1.0 200 OK"
3165
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003166needs_more_time 4
3167run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003168 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003169 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003170 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003171 debug_level=2" \
3172 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003173 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003174 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3175 0 \
3176 -c "=> renegotiate" \
3177 -s "=> renegotiate" \
3178 -s "Extra-header:" \
3179 -c "HTTP/1.0 200 OK"
3180
3181needs_more_time 4
3182run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003183 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003184 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003185 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003186 debug_level=2 nbio=2" \
3187 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003188 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003189 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3190 0 \
3191 -c "=> renegotiate" \
3192 -s "=> renegotiate" \
3193 -s "Extra-header:" \
3194 -c "HTTP/1.0 200 OK"
3195
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003196needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003197run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003198 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3199 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003200 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003201 0 \
3202 -s "Extra-header:" \
3203 -c "HTTP/1.0 200 OK"
3204
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003205needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003206run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3207 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3208 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003209 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003210 0 \
3211 -s "Extra-header:" \
3212 -c "HTTP/1.0 200 OK"
3213
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003214needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003215run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3216 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3217 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003218 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003219 0 \
3220 -s "Extra-header:" \
3221 -c "HTTP/1.0 200 OK"
3222
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003223requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003224needs_more_time 6
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003225run_test "DTLS proxy: 3d, gnutls server" \
3226 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3227 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003228 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003229 0 \
3230 -s "Extra-header:" \
3231 -c "Extra-header:"
3232
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003233requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003234needs_more_time 8
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003235run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3236 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3237 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003238 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003239 0 \
3240 -s "Extra-header:" \
3241 -c "Extra-header:"
3242
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003243requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003244needs_more_time 8
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003245run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3246 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3247 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003248 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003249 0 \
3250 -s "Extra-header:" \
3251 -c "Extra-header:"
3252
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003253# Final report
3254
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003255echo "------------------------------------------------------------------------"
3256
3257if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003258 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003259else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003260 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003261fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003262PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003263echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003264
3265exit $FAILS