blob: 7fcca685b1a043c3109841924b12760b84b85c4d [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200289# wait for server to start: two versions depending on lsof availability
290wait_server_start() {
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200291 if which lsof >/dev/null 2>&1; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200292 START_TIME=$( date +%s )
293 DONE=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200294
295 # make a tight loop, server usually takes less than 1 sec to start
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200296 if [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200297 while [ $DONE -eq 0 ]; do
298 if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
299 then
300 DONE=1
301 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
302 echo "SERVERSTART TIMEOUT"
303 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
304 DONE=1
305 fi
306 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200307 else
Manuel Pégourié-Gonnard74681fa2015-08-04 20:34:39 +0200308 while [ $DONE -eq 0 ]; do
309 if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
310 then
311 DONE=1
312 elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
313 echo "SERVERSTART TIMEOUT"
314 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
315 DONE=1
316 fi
317 done
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200318 fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200319 else
320 sleep "$START_DELAY"
321 fi
322}
323
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100324# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100325# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100326# acceptable bounds
327check_server_hello_time() {
328 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100329 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100330 # Get the Unix timestamp for now
331 CUR_TIME=$(date +'%s')
332 THRESHOLD_IN_SECS=300
333
334 # Check if the ServerHello time was printed
335 if [ -z "$SERVER_HELLO_TIME" ]; then
336 return 1
337 fi
338
339 # Check the time in ServerHello is within acceptable bounds
340 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
341 # The time in ServerHello is at least 5 minutes before now
342 return 1
343 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100344 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100345 return 1
346 else
347 return 0
348 fi
349}
350
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200351# wait for client to terminate and set CLI_EXIT
352# must be called right after starting the client
353wait_client_done() {
354 CLI_PID=$!
355
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200356 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
357 CLI_DELAY_FACTOR=1
358
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200359 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200360 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200361
362 wait $CLI_PID
363 CLI_EXIT=$?
364
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200365 kill $DOG_PID >/dev/null 2>&1
366 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200367
368 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100369
370 sleep $SRV_DELAY_SECONDS
371 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200372}
373
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200374# check if the given command uses dtls and sets global variable DTLS
375detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200376 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200377 DTLS=1
378 else
379 DTLS=0
380 fi
381}
382
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200383# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384# Options: -s pattern pattern that must be present in server output
385# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100386# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100387# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100388# -S pattern pattern that must be absent in server output
389# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100390# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100391# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100392run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100393 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200394 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100395
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100396 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
397 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200398 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100399 return
400 fi
401
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100402 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100403
Paul Bakkerb7584a52016-05-10 10:50:43 +0100404 # Do we only run numbered tests?
405 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
406 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
407 else
408 SKIP_NEXT="YES"
409 fi
410
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200411 # should we skip?
412 if [ "X$SKIP_NEXT" = "XYES" ]; then
413 SKIP_NEXT="NO"
414 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200415 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200416 return
417 fi
418
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200419 # does this test use a proxy?
420 if [ "X$1" = "X-p" ]; then
421 PXY_CMD="$2"
422 shift 2
423 else
424 PXY_CMD=""
425 fi
426
427 # get commands and client output
428 SRV_CMD="$1"
429 CLI_CMD="$2"
430 CLI_EXPECT="$3"
431 shift 3
432
433 # fix client port
434 if [ -n "$PXY_CMD" ]; then
435 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
436 else
437 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
438 fi
439
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200440 # update DTLS variable
441 detect_dtls "$SRV_CMD"
442
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100443 # prepend valgrind to our commands if active
444 if [ "$MEMCHECK" -gt 0 ]; then
445 if is_polar "$SRV_CMD"; then
446 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
447 fi
448 if is_polar "$CLI_CMD"; then
449 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
450 fi
451 fi
452
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200453 TIMES_LEFT=2
454 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200455 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200456
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200457 # run the commands
458 if [ -n "$PXY_CMD" ]; then
459 echo "$PXY_CMD" > $PXY_OUT
460 $PXY_CMD >> $PXY_OUT 2>&1 &
461 PXY_PID=$!
462 # assume proxy starts faster than server
463 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200465 check_osrv_dtls
466 echo "$SRV_CMD" > $SRV_OUT
467 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
468 SRV_PID=$!
469 wait_server_start
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200470
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200471 echo "$CLI_CMD" > $CLI_OUT
472 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
473 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100474
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200475 # terminate the server (and the proxy)
476 kill $SRV_PID
477 wait $SRV_PID
478 if [ -n "$PXY_CMD" ]; then
479 kill $PXY_PID >/dev/null 2>&1
480 wait $PXY_PID
481 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100482
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200483 # retry only on timeouts
484 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
485 printf "RETRY "
486 else
487 TIMES_LEFT=0
488 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200489 done
490
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100491 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200492 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100493 # expected client exit to incorrectly succeed in case of catastrophic
494 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100495 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200496 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100497 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100498 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100499 return
500 fi
501 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100502 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200503 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100504 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100505 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100506 return
507 fi
508 fi
509
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100510 # check server exit code
511 if [ $? != 0 ]; then
512 fail "server fail"
513 return
514 fi
515
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100516 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100517 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
518 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100519 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200520 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100521 return
522 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100523
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100524 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200525 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100526 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100527 while [ $# -gt 0 ]
528 do
529 case $1 in
530 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100531 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100532 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100533 return
534 fi
535 ;;
536
537 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100538 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100539 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100540 return
541 fi
542 ;;
543
544 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100545 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100546 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100547 return
548 fi
549 ;;
550
551 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100552 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100553 fail "pattern '$2' MUST NOT be present in the Client output"
554 return
555 fi
556 ;;
557
558 # The filtering in the following two options (-u and -U) do the following
559 # - ignore valgrind output
560 # - filter out everything but lines right after the pattern occurances
561 # - keep one of each non-unique line
562 # - count how many lines remain
563 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
564 # if there were no duplicates.
565 "-U")
566 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
567 fail "lines following pattern '$2' must be unique in Server output"
568 return
569 fi
570 ;;
571
572 "-u")
573 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
574 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575 return
576 fi
577 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100578 "-F")
579 if ! $2 "$SRV_OUT"; then
580 fail "function call to '$2' failed on Server output"
581 return
582 fi
583 ;;
584 "-f")
585 if ! $2 "$CLI_OUT"; then
586 fail "function call to '$2' failed on Client output"
587 return
588 fi
589 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100590
591 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200592 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100593 exit 1
594 esac
595 shift 2
596 done
597
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100598 # check valgrind's results
599 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200600 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100601 fail "Server has memory errors"
602 return
603 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200604 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100605 fail "Client has memory errors"
606 return
607 fi
608 fi
609
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610 # if we're here, everything is ok
611 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100612 if [ "$PRESERVE_LOGS" -gt 0 ]; then
613 mv $SRV_OUT o-srv-${TESTS}.log
614 mv $CLI_OUT o-cli-${TESTS}.log
615 fi
616
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200617 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618}
619
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100620cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200621 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200622 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
623 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
624 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
625 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100626 exit 1
627}
628
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100629#
630# MAIN
631#
632
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000633if cd $( dirname $0 ); then :; else
634 echo "cd $( dirname $0 ) failed" >&2
635 exit 1
636fi
637
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100638get_options "$@"
639
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100640# sanity checks, avoid an avalanche of errors
641if [ ! -x "$P_SRV" ]; then
642 echo "Command '$P_SRV' is not an executable file"
643 exit 1
644fi
645if [ ! -x "$P_CLI" ]; then
646 echo "Command '$P_CLI' is not an executable file"
647 exit 1
648fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200649if [ ! -x "$P_PXY" ]; then
650 echo "Command '$P_PXY' is not an executable file"
651 exit 1
652fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100653if [ "$MEMCHECK" -gt 0 ]; then
654 if which valgrind >/dev/null 2>&1; then :; else
655 echo "Memcheck not possible. Valgrind not found"
656 exit 1
657 fi
658fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100659if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
660 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100661 exit 1
662fi
663
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200664# used by watchdog
665MAIN_PID="$$"
666
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200667# be more patient with valgrind
668if [ "$MEMCHECK" -gt 0 ]; then
669 START_DELAY=3
670 DOG_DELAY=30
671else
672 START_DELAY=1
673 DOG_DELAY=10
674fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200675CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100676SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200677
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200678# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000679# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200680P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
681P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100682P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200683O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200684O_CLI="$O_CLI -connect localhost:+SRV_PORT"
685G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000686G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200687
Gilles Peskine62469d92017-05-10 10:13:59 +0200688# Allow SHA-1, because many of our test certificates use it
689P_SRV="$P_SRV allow_sha1=1"
690P_CLI="$P_CLI allow_sha1=1"
691
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200692# Also pick a unique name for intermediate files
693SRV_OUT="srv_out.$$"
694CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200695PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696SESSION="session.$$"
697
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200698SKIP_NEXT="NO"
699
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100700trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100701
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200702# Basic test
703
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200704# Checks that:
705# - things work with all ciphersuites active (used with config-full in all.sh)
706# - the expected (highest security) parameters are selected
707# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200708run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200709 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200710 "$P_CLI" \
711 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200712 -s "Protocol is TLSv1.2" \
713 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
714 -s "client hello v3, signature_algorithm ext: 6" \
715 -s "ECDHE curve: secp521r1" \
716 -S "error" \
717 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200718
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000719run_test "Default, DTLS" \
720 "$P_SRV dtls=1" \
721 "$P_CLI dtls=1" \
722 0 \
723 -s "Protocol is DTLSv1.2" \
724 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
725
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100726# Test current time in ServerHello
727requires_config_enabled MBEDTLS_HAVE_TIME
728run_test "Default, ServerHello contains gmt_unix_time" \
729 "$P_SRV debug_level=3" \
730 "$P_CLI debug_level=3" \
731 0 \
732 -s "Protocol is TLSv1.2" \
733 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
734 -s "client hello v3, signature_algorithm ext: 6" \
735 -s "ECDHE curve: secp521r1" \
736 -S "error" \
737 -C "error" \
738 -f "check_server_hello_time" \
739 -F "check_server_hello_time"
740
Simon Butcher8e004102016-10-14 00:48:33 +0100741# Test for uniqueness of IVs in AEAD ciphersuites
742run_test "Unique IV in GCM" \
743 "$P_SRV exchanges=20 debug_level=4" \
744 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
745 0 \
746 -u "IV used" \
747 -U "IV used"
748
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100749# Tests for rc4 option
750
Simon Butchera410af52016-05-19 22:12:18 +0100751requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100752run_test "RC4: server disabled, client enabled" \
753 "$P_SRV" \
754 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
755 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100756 -s "SSL - The server has no ciphersuites in common"
757
Simon Butchera410af52016-05-19 22:12:18 +0100758requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100759run_test "RC4: server half, client enabled" \
760 "$P_SRV arc4=1" \
761 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
762 1 \
763 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100764
765run_test "RC4: server enabled, client disabled" \
766 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
767 "$P_CLI" \
768 1 \
769 -s "SSL - The server has no ciphersuites in common"
770
771run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100772 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100773 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
774 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100775 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100776 -S "SSL - The server has no ciphersuites in common"
777
Gilles Peskinebc70a182017-05-09 15:59:24 +0200778# Tests for SHA-1 support
779
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200780requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200781run_test "SHA-1 forbidden by default in server certificate" \
782 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
783 "$P_CLI debug_level=2 allow_sha1=0" \
784 1 \
785 -c "The certificate is signed with an unacceptable hash"
786
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200787requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
788run_test "SHA-1 forbidden by default in server certificate" \
789 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
790 "$P_CLI debug_level=2 allow_sha1=0" \
791 0
792
Gilles Peskinebc70a182017-05-09 15:59:24 +0200793run_test "SHA-1 explicitly allowed in server certificate" \
794 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
795 "$P_CLI allow_sha1=1" \
796 0
797
798run_test "SHA-256 allowed by default in server certificate" \
799 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
800 "$P_CLI allow_sha1=0" \
801 0
802
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200803requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200804run_test "SHA-1 forbidden by default in client certificate" \
805 "$P_SRV auth_mode=required allow_sha1=0" \
806 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
807 1 \
808 -s "The certificate is signed with an unacceptable hash"
809
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200810requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
811run_test "SHA-1 forbidden by default in client certificate" \
812 "$P_SRV auth_mode=required allow_sha1=0" \
813 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
814 0
815
Gilles Peskinebc70a182017-05-09 15:59:24 +0200816run_test "SHA-1 explicitly allowed in client certificate" \
817 "$P_SRV auth_mode=required allow_sha1=1" \
818 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
819 0
820
821run_test "SHA-256 allowed by default in client certificate" \
822 "$P_SRV auth_mode=required allow_sha1=0" \
823 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
824 0
825
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100826# Tests for Truncated HMAC extension
827
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100828run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200829 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100830 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100831 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100832 -s "dumping 'computed mac' (20 bytes)" \
833 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100834
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100835run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200836 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
838 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100839 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100840 -s "dumping 'computed mac' (20 bytes)" \
841 -S "dumping 'computed mac' (10 bytes)"
842
843run_test "Truncated HMAC: client enabled, server default" \
844 "$P_SRV debug_level=4" \
845 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
846 trunc_hmac=1" \
847 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100848 -s "dumping 'computed mac' (20 bytes)" \
849 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100850
851run_test "Truncated HMAC: client enabled, server disabled" \
852 "$P_SRV debug_level=4 trunc_hmac=0" \
853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
854 trunc_hmac=1" \
855 0 \
856 -s "dumping 'computed mac' (20 bytes)" \
857 -S "dumping 'computed mac' (10 bytes)"
858
859run_test "Truncated HMAC: client enabled, server enabled" \
860 "$P_SRV debug_level=4 trunc_hmac=1" \
861 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
862 trunc_hmac=1" \
863 0 \
864 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100865 -s "dumping 'computed mac' (10 bytes)"
866
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100867# Tests for Encrypt-then-MAC extension
868
869run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100870 "$P_SRV debug_level=3 \
871 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100872 "$P_CLI debug_level=3" \
873 0 \
874 -c "client hello, adding encrypt_then_mac extension" \
875 -s "found encrypt then mac extension" \
876 -s "server hello, adding encrypt then mac extension" \
877 -c "found encrypt_then_mac extension" \
878 -c "using encrypt then mac" \
879 -s "using encrypt then mac"
880
881run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100882 "$P_SRV debug_level=3 etm=0 \
883 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100884 "$P_CLI debug_level=3 etm=1" \
885 0 \
886 -c "client hello, adding encrypt_then_mac extension" \
887 -s "found encrypt then mac extension" \
888 -S "server hello, adding encrypt then mac extension" \
889 -C "found encrypt_then_mac extension" \
890 -C "using encrypt then mac" \
891 -S "using encrypt then mac"
892
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100893run_test "Encrypt then MAC: client enabled, aead cipher" \
894 "$P_SRV debug_level=3 etm=1 \
895 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
896 "$P_CLI debug_level=3 etm=1" \
897 0 \
898 -c "client hello, adding encrypt_then_mac extension" \
899 -s "found encrypt then mac extension" \
900 -S "server hello, adding encrypt then mac extension" \
901 -C "found encrypt_then_mac extension" \
902 -C "using encrypt then mac" \
903 -S "using encrypt then mac"
904
905run_test "Encrypt then MAC: client enabled, stream cipher" \
906 "$P_SRV debug_level=3 etm=1 \
907 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100908 "$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 +0100909 0 \
910 -c "client hello, adding encrypt_then_mac extension" \
911 -s "found encrypt then mac extension" \
912 -S "server hello, adding encrypt then mac extension" \
913 -C "found encrypt_then_mac extension" \
914 -C "using encrypt then mac" \
915 -S "using encrypt then mac"
916
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100917run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100918 "$P_SRV debug_level=3 etm=1 \
919 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100920 "$P_CLI debug_level=3 etm=0" \
921 0 \
922 -C "client hello, adding encrypt_then_mac extension" \
923 -S "found encrypt then mac extension" \
924 -S "server hello, adding encrypt then mac extension" \
925 -C "found encrypt_then_mac extension" \
926 -C "using encrypt then mac" \
927 -S "using encrypt then mac"
928
Janos Follathe2681a42016-03-07 15:57:05 +0000929requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100930run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100931 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100932 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100933 "$P_CLI debug_level=3 force_version=ssl3" \
934 0 \
935 -C "client hello, adding encrypt_then_mac extension" \
936 -S "found encrypt then mac extension" \
937 -S "server hello, adding encrypt then mac extension" \
938 -C "found encrypt_then_mac extension" \
939 -C "using encrypt then mac" \
940 -S "using encrypt then mac"
941
Janos Follathe2681a42016-03-07 15:57:05 +0000942requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100943run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100944 "$P_SRV debug_level=3 force_version=ssl3 \
945 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100946 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100947 0 \
948 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100949 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100950 -S "server hello, adding encrypt then mac extension" \
951 -C "found encrypt_then_mac extension" \
952 -C "using encrypt then mac" \
953 -S "using encrypt then mac"
954
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200955# Tests for Extended Master Secret extension
956
957run_test "Extended Master Secret: default" \
958 "$P_SRV debug_level=3" \
959 "$P_CLI debug_level=3" \
960 0 \
961 -c "client hello, adding extended_master_secret extension" \
962 -s "found extended master secret extension" \
963 -s "server hello, adding extended master secret extension" \
964 -c "found extended_master_secret extension" \
965 -c "using extended master secret" \
966 -s "using extended master secret"
967
968run_test "Extended Master Secret: client enabled, server disabled" \
969 "$P_SRV debug_level=3 extended_ms=0" \
970 "$P_CLI debug_level=3 extended_ms=1" \
971 0 \
972 -c "client hello, adding extended_master_secret extension" \
973 -s "found extended master secret extension" \
974 -S "server hello, adding extended master secret extension" \
975 -C "found extended_master_secret extension" \
976 -C "using extended master secret" \
977 -S "using extended master secret"
978
979run_test "Extended Master Secret: client disabled, server enabled" \
980 "$P_SRV debug_level=3 extended_ms=1" \
981 "$P_CLI debug_level=3 extended_ms=0" \
982 0 \
983 -C "client hello, adding extended_master_secret extension" \
984 -S "found extended master secret extension" \
985 -S "server hello, adding extended master secret extension" \
986 -C "found extended_master_secret extension" \
987 -C "using extended master secret" \
988 -S "using extended master secret"
989
Janos Follathe2681a42016-03-07 15:57:05 +0000990requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200991run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100992 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200993 "$P_CLI debug_level=3 force_version=ssl3" \
994 0 \
995 -C "client hello, adding extended_master_secret extension" \
996 -S "found extended master secret extension" \
997 -S "server hello, adding extended master secret extension" \
998 -C "found extended_master_secret extension" \
999 -C "using extended master secret" \
1000 -S "using extended master secret"
1001
Janos Follathe2681a42016-03-07 15:57:05 +00001002requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001003run_test "Extended Master Secret: client enabled, server SSLv3" \
1004 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001005 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001006 0 \
1007 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001008 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001009 -S "server hello, adding extended master secret extension" \
1010 -C "found extended_master_secret extension" \
1011 -C "using extended master secret" \
1012 -S "using extended master secret"
1013
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001014# Tests for FALLBACK_SCSV
1015
1016run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001017 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001018 "$P_CLI debug_level=3 force_version=tls1_1" \
1019 0 \
1020 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001021 -S "received FALLBACK_SCSV" \
1022 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001023 -C "is a fatal alert message (msg 86)"
1024
1025run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001026 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001027 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1028 0 \
1029 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001030 -S "received FALLBACK_SCSV" \
1031 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001032 -C "is a fatal alert message (msg 86)"
1033
1034run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001035 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001036 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 1 \
1038 -c "adding FALLBACK_SCSV" \
1039 -s "received FALLBACK_SCSV" \
1040 -s "inapropriate fallback" \
1041 -c "is a fatal alert message (msg 86)"
1042
1043run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001044 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001045 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001046 0 \
1047 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001048 -s "received FALLBACK_SCSV" \
1049 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001050 -C "is a fatal alert message (msg 86)"
1051
1052requires_openssl_with_fallback_scsv
1053run_test "Fallback SCSV: default, openssl server" \
1054 "$O_SRV" \
1055 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1056 0 \
1057 -C "adding FALLBACK_SCSV" \
1058 -C "is a fatal alert message (msg 86)"
1059
1060requires_openssl_with_fallback_scsv
1061run_test "Fallback SCSV: enabled, openssl server" \
1062 "$O_SRV" \
1063 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1064 1 \
1065 -c "adding FALLBACK_SCSV" \
1066 -c "is a fatal alert message (msg 86)"
1067
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001068requires_openssl_with_fallback_scsv
1069run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001070 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001071 "$O_CLI -tls1_1" \
1072 0 \
1073 -S "received FALLBACK_SCSV" \
1074 -S "inapropriate fallback"
1075
1076requires_openssl_with_fallback_scsv
1077run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001078 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001079 "$O_CLI -tls1_1 -fallback_scsv" \
1080 1 \
1081 -s "received FALLBACK_SCSV" \
1082 -s "inapropriate fallback"
1083
1084requires_openssl_with_fallback_scsv
1085run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001086 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001087 "$O_CLI -fallback_scsv" \
1088 0 \
1089 -s "received FALLBACK_SCSV" \
1090 -S "inapropriate fallback"
1091
Gilles Peskined50177f2017-05-16 17:53:03 +02001092## ClientHello generated with
1093## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1094## then manually twiddling the ciphersuite list.
1095## The ClientHello content is spelled out below as a hex string as
1096## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1097## The expected response is an inappropriate_fallback alert.
1098requires_openssl_with_fallback_scsv
1099run_test "Fallback SCSV: beginning of list" \
1100 "$P_SRV debug_level=2" \
1101 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1102 0 \
1103 -s "received FALLBACK_SCSV" \
1104 -s "inapropriate fallback"
1105
1106requires_openssl_with_fallback_scsv
1107run_test "Fallback SCSV: end of list" \
1108 "$P_SRV debug_level=2" \
1109 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1110 0 \
1111 -s "received FALLBACK_SCSV" \
1112 -s "inapropriate fallback"
1113
1114## Here the expected response is a valid ServerHello prefix, up to the random.
1115requires_openssl_with_fallback_scsv
1116run_test "Fallback SCSV: not in list" \
1117 "$P_SRV debug_level=2" \
1118 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1119 0 \
1120 -S "received FALLBACK_SCSV" \
1121 -S "inapropriate fallback"
1122
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001123# Tests for CBC 1/n-1 record splitting
1124
1125run_test "CBC Record splitting: TLS 1.2, no splitting" \
1126 "$P_SRV" \
1127 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1128 request_size=123 force_version=tls1_2" \
1129 0 \
1130 -s "Read from client: 123 bytes read" \
1131 -S "Read from client: 1 bytes read" \
1132 -S "122 bytes read"
1133
1134run_test "CBC Record splitting: TLS 1.1, no splitting" \
1135 "$P_SRV" \
1136 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1137 request_size=123 force_version=tls1_1" \
1138 0 \
1139 -s "Read from client: 123 bytes read" \
1140 -S "Read from client: 1 bytes read" \
1141 -S "122 bytes read"
1142
1143run_test "CBC Record splitting: TLS 1.0, splitting" \
1144 "$P_SRV" \
1145 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1146 request_size=123 force_version=tls1" \
1147 0 \
1148 -S "Read from client: 123 bytes read" \
1149 -s "Read from client: 1 bytes read" \
1150 -s "122 bytes read"
1151
Janos Follathe2681a42016-03-07 15:57:05 +00001152requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001153run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001154 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001155 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1156 request_size=123 force_version=ssl3" \
1157 0 \
1158 -S "Read from client: 123 bytes read" \
1159 -s "Read from client: 1 bytes read" \
1160 -s "122 bytes read"
1161
1162run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001163 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001164 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1165 request_size=123 force_version=tls1" \
1166 0 \
1167 -s "Read from client: 123 bytes read" \
1168 -S "Read from client: 1 bytes read" \
1169 -S "122 bytes read"
1170
1171run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1172 "$P_SRV" \
1173 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1174 request_size=123 force_version=tls1 recsplit=0" \
1175 0 \
1176 -s "Read from client: 123 bytes read" \
1177 -S "Read from client: 1 bytes read" \
1178 -S "122 bytes read"
1179
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001180run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1181 "$P_SRV nbio=2" \
1182 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1183 request_size=123 force_version=tls1" \
1184 0 \
1185 -S "Read from client: 123 bytes read" \
1186 -s "Read from client: 1 bytes read" \
1187 -s "122 bytes read"
1188
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001189# Tests for Session Tickets
1190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001191run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001192 "$P_SRV debug_level=3 tickets=1" \
1193 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001194 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001195 -c "client hello, adding session ticket extension" \
1196 -s "found session ticket extension" \
1197 -s "server hello, adding session ticket extension" \
1198 -c "found session_ticket extension" \
1199 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001200 -S "session successfully restored from cache" \
1201 -s "session successfully restored from ticket" \
1202 -s "a session has been resumed" \
1203 -c "a session has been resumed"
1204
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001205run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001206 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1207 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001208 0 \
1209 -c "client hello, adding session ticket extension" \
1210 -s "found session ticket extension" \
1211 -s "server hello, adding session ticket extension" \
1212 -c "found session_ticket extension" \
1213 -c "parse new session ticket" \
1214 -S "session successfully restored from cache" \
1215 -s "session successfully restored from ticket" \
1216 -s "a session has been resumed" \
1217 -c "a session has been resumed"
1218
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001219run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001220 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1221 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001222 0 \
1223 -c "client hello, adding session ticket extension" \
1224 -s "found session ticket extension" \
1225 -s "server hello, adding session ticket extension" \
1226 -c "found session_ticket extension" \
1227 -c "parse new session ticket" \
1228 -S "session successfully restored from cache" \
1229 -S "session successfully restored from ticket" \
1230 -S "a session has been resumed" \
1231 -C "a session has been resumed"
1232
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001233run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001234 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001236 0 \
1237 -c "client hello, adding session ticket extension" \
1238 -c "found session_ticket extension" \
1239 -c "parse new session ticket" \
1240 -c "a session has been resumed"
1241
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001242run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001243 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001244 "( $O_CLI -sess_out $SESSION; \
1245 $O_CLI -sess_in $SESSION; \
1246 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001247 0 \
1248 -s "found session ticket extension" \
1249 -s "server hello, adding session ticket extension" \
1250 -S "session successfully restored from cache" \
1251 -s "session successfully restored from ticket" \
1252 -s "a session has been resumed"
1253
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001254# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001255
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001256run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001257 "$P_SRV debug_level=3 tickets=0" \
1258 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001259 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001260 -c "client hello, adding session ticket extension" \
1261 -s "found session ticket extension" \
1262 -S "server hello, adding session ticket extension" \
1263 -C "found session_ticket extension" \
1264 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001265 -s "session successfully restored from cache" \
1266 -S "session successfully restored from ticket" \
1267 -s "a session has been resumed" \
1268 -c "a session has been resumed"
1269
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001270run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001271 "$P_SRV debug_level=3 tickets=1" \
1272 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001273 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001274 -C "client hello, adding session ticket extension" \
1275 -S "found session ticket extension" \
1276 -S "server hello, adding session ticket extension" \
1277 -C "found session_ticket extension" \
1278 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001279 -s "session successfully restored from cache" \
1280 -S "session successfully restored from ticket" \
1281 -s "a session has been resumed" \
1282 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001284run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001285 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1286 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001287 0 \
1288 -S "session successfully restored from cache" \
1289 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001290 -S "a session has been resumed" \
1291 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001293run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1295 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001296 0 \
1297 -s "session successfully restored from cache" \
1298 -S "session successfully restored from ticket" \
1299 -s "a session has been resumed" \
1300 -c "a session has been resumed"
1301
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001302run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001303 "$P_SRV debug_level=3 tickets=0" \
1304 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001305 0 \
1306 -s "session successfully restored from cache" \
1307 -S "session successfully restored from ticket" \
1308 -s "a session has been resumed" \
1309 -c "a session has been resumed"
1310
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001311run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001312 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1313 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001314 0 \
1315 -S "session successfully restored from cache" \
1316 -S "session successfully restored from ticket" \
1317 -S "a session has been resumed" \
1318 -C "a session has been resumed"
1319
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001320run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001321 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1322 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001323 0 \
1324 -s "session successfully restored from cache" \
1325 -S "session successfully restored from ticket" \
1326 -s "a session has been resumed" \
1327 -c "a session has been resumed"
1328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001329run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001330 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001331 "( $O_CLI -sess_out $SESSION; \
1332 $O_CLI -sess_in $SESSION; \
1333 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001334 0 \
1335 -s "found session ticket extension" \
1336 -S "server hello, adding session ticket extension" \
1337 -s "session successfully restored from cache" \
1338 -S "session successfully restored from ticket" \
1339 -s "a session has been resumed"
1340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001341run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001342 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001343 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001344 0 \
1345 -C "found session_ticket extension" \
1346 -C "parse new session ticket" \
1347 -c "a session has been resumed"
1348
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001349# Tests for Max Fragment Length extension
1350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001351run_test "Max fragment length: not used, reference" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001352 "$P_SRV debug_level=3" \
1353 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001354 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001355 -c "Maximum fragment length is 16384" \
1356 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001357 -C "client hello, adding max_fragment_length extension" \
1358 -S "found max fragment length extension" \
1359 -S "server hello, max_fragment_length extension" \
1360 -C "found max_fragment_length extension"
1361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001362run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001363 "$P_SRV debug_level=3" \
1364 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001365 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001366 -c "Maximum fragment length is 4096" \
1367 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001368 -c "client hello, adding max_fragment_length extension" \
1369 -s "found max fragment length extension" \
1370 -s "server hello, max_fragment_length extension" \
1371 -c "found max_fragment_length extension"
1372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001373run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001374 "$P_SRV debug_level=3 max_frag_len=4096" \
1375 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001376 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001377 -c "Maximum fragment length is 16384" \
1378 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001379 -C "client hello, adding max_fragment_length extension" \
1380 -S "found max fragment length extension" \
1381 -S "server hello, max_fragment_length extension" \
1382 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001383
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384requires_gnutls
1385run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001386 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001387 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001388 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001389 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001390 -c "client hello, adding max_fragment_length extension" \
1391 -c "found max_fragment_length extension"
1392
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001393run_test "Max fragment length: client, message just fits" \
1394 "$P_SRV debug_level=3" \
1395 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1396 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001397 -c "Maximum fragment length is 2048" \
1398 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001399 -c "client hello, adding max_fragment_length extension" \
1400 -s "found max fragment length extension" \
1401 -s "server hello, max_fragment_length extension" \
1402 -c "found max_fragment_length extension" \
1403 -c "2048 bytes written in 1 fragments" \
1404 -s "2048 bytes read"
1405
1406run_test "Max fragment length: client, larger message" \
1407 "$P_SRV debug_level=3" \
1408 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1409 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001410 -c "Maximum fragment length is 2048" \
1411 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001412 -c "client hello, adding max_fragment_length extension" \
1413 -s "found max fragment length extension" \
1414 -s "server hello, max_fragment_length extension" \
1415 -c "found max_fragment_length extension" \
1416 -c "2345 bytes written in 2 fragments" \
1417 -s "2048 bytes read" \
1418 -s "297 bytes read"
1419
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001420run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001421 "$P_SRV debug_level=3 dtls=1" \
1422 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1423 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001424 -c "Maximum fragment length is 2048" \
1425 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001426 -c "client hello, adding max_fragment_length extension" \
1427 -s "found max fragment length extension" \
1428 -s "server hello, max_fragment_length extension" \
1429 -c "found max_fragment_length extension" \
1430 -c "fragment larger than.*maximum"
1431
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001432# Tests for renegotiation
1433
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001434run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001435 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001436 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001437 0 \
1438 -C "client hello, adding renegotiation extension" \
1439 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1440 -S "found renegotiation extension" \
1441 -s "server hello, secure renegotiation extension" \
1442 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001443 -C "=> renegotiate" \
1444 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001445 -S "write hello request"
1446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001447run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001448 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001449 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001450 0 \
1451 -c "client hello, adding renegotiation extension" \
1452 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1453 -s "found renegotiation extension" \
1454 -s "server hello, secure renegotiation extension" \
1455 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001456 -c "=> renegotiate" \
1457 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001458 -S "write hello request"
1459
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001460run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001461 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001462 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001463 0 \
1464 -c "client hello, adding renegotiation extension" \
1465 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1466 -s "found renegotiation extension" \
1467 -s "server hello, secure renegotiation extension" \
1468 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001469 -c "=> renegotiate" \
1470 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001471 -s "write hello request"
1472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001473run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001474 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001475 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001476 0 \
1477 -c "client hello, adding renegotiation extension" \
1478 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1479 -s "found renegotiation extension" \
1480 -s "server hello, secure renegotiation extension" \
1481 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001482 -c "=> renegotiate" \
1483 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001484 -s "write hello request"
1485
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001486run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001487 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001488 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001489 1 \
1490 -c "client hello, adding renegotiation extension" \
1491 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1492 -S "found renegotiation extension" \
1493 -s "server hello, secure renegotiation extension" \
1494 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001495 -c "=> renegotiate" \
1496 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001497 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001498 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001499 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001501run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001502 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001503 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001504 0 \
1505 -C "client hello, adding renegotiation extension" \
1506 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1507 -S "found renegotiation extension" \
1508 -s "server hello, secure renegotiation extension" \
1509 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001510 -C "=> renegotiate" \
1511 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001512 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001513 -S "SSL - An unexpected message was received from our peer" \
1514 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001516run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001517 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001518 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001519 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001520 0 \
1521 -C "client hello, adding renegotiation extension" \
1522 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1523 -S "found renegotiation extension" \
1524 -s "server hello, secure renegotiation extension" \
1525 -c "found renegotiation extension" \
1526 -C "=> renegotiate" \
1527 -S "=> renegotiate" \
1528 -s "write hello request" \
1529 -S "SSL - An unexpected message was received from our peer" \
1530 -S "failed"
1531
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001532# delay 2 for 1 alert record + 1 application data record
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001533run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001534 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001535 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001536 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001537 0 \
1538 -C "client hello, adding renegotiation extension" \
1539 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1540 -S "found renegotiation extension" \
1541 -s "server hello, secure renegotiation extension" \
1542 -c "found renegotiation extension" \
1543 -C "=> renegotiate" \
1544 -S "=> renegotiate" \
1545 -s "write hello request" \
1546 -S "SSL - An unexpected message was received from our peer" \
1547 -S "failed"
1548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001549run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001550 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001551 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001552 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001553 0 \
1554 -C "client hello, adding renegotiation extension" \
1555 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1556 -S "found renegotiation extension" \
1557 -s "server hello, secure renegotiation extension" \
1558 -c "found renegotiation extension" \
1559 -C "=> renegotiate" \
1560 -S "=> renegotiate" \
1561 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001562 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001564run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001565 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001566 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001567 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001568 0 \
1569 -c "client hello, adding renegotiation extension" \
1570 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1571 -s "found renegotiation extension" \
1572 -s "server hello, secure renegotiation extension" \
1573 -c "found renegotiation extension" \
1574 -c "=> renegotiate" \
1575 -s "=> renegotiate" \
1576 -s "write hello request" \
1577 -S "SSL - An unexpected message was received from our peer" \
1578 -S "failed"
1579
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001580run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001581 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001582 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1583 0 \
1584 -C "client hello, adding renegotiation extension" \
1585 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1586 -S "found renegotiation extension" \
1587 -s "server hello, secure renegotiation extension" \
1588 -c "found renegotiation extension" \
1589 -S "record counter limit reached: renegotiate" \
1590 -C "=> renegotiate" \
1591 -S "=> renegotiate" \
1592 -S "write hello request" \
1593 -S "SSL - An unexpected message was received from our peer" \
1594 -S "failed"
1595
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001596# one extra exchange to be able to complete renego
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001597run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001598 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001599 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001600 0 \
1601 -c "client hello, adding renegotiation extension" \
1602 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1603 -s "found renegotiation extension" \
1604 -s "server hello, secure renegotiation extension" \
1605 -c "found renegotiation extension" \
1606 -s "record counter limit reached: renegotiate" \
1607 -c "=> renegotiate" \
1608 -s "=> renegotiate" \
1609 -s "write hello request" \
1610 -S "SSL - An unexpected message was received from our peer" \
1611 -S "failed"
1612
1613run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001614 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001615 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001616 0 \
1617 -c "client hello, adding renegotiation extension" \
1618 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1619 -s "found renegotiation extension" \
1620 -s "server hello, secure renegotiation extension" \
1621 -c "found renegotiation extension" \
1622 -s "record counter limit reached: renegotiate" \
1623 -c "=> renegotiate" \
1624 -s "=> renegotiate" \
1625 -s "write hello request" \
1626 -S "SSL - An unexpected message was received from our peer" \
1627 -S "failed"
1628
1629run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001630 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001631 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1632 0 \
1633 -C "client hello, adding renegotiation extension" \
1634 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1635 -S "found renegotiation extension" \
1636 -s "server hello, secure renegotiation extension" \
1637 -c "found renegotiation extension" \
1638 -S "record counter limit reached: renegotiate" \
1639 -C "=> renegotiate" \
1640 -S "=> renegotiate" \
1641 -S "write hello request" \
1642 -S "SSL - An unexpected message was received from our peer" \
1643 -S "failed"
1644
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001646 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001648 0 \
1649 -c "client hello, adding renegotiation extension" \
1650 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1651 -s "found renegotiation extension" \
1652 -s "server hello, secure renegotiation extension" \
1653 -c "found renegotiation extension" \
1654 -c "=> renegotiate" \
1655 -s "=> renegotiate" \
1656 -S "write hello request"
1657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001658run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001659 "$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 +02001660 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001661 0 \
1662 -c "client hello, adding renegotiation extension" \
1663 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1664 -s "found renegotiation extension" \
1665 -s "server hello, secure renegotiation extension" \
1666 -c "found renegotiation extension" \
1667 -c "=> renegotiate" \
1668 -s "=> renegotiate" \
1669 -s "write hello request"
1670
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001671run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001672 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001673 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001674 0 \
1675 -c "client hello, adding renegotiation extension" \
1676 -c "found renegotiation extension" \
1677 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001678 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001679 -C "error" \
1680 -c "HTTP/1.0 200 [Oo][Kk]"
1681
Paul Bakker539d9722015-02-08 16:18:35 +01001682requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001683run_test "Renegotiation: gnutls server strict, client-initiated" \
1684 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001685 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001686 0 \
1687 -c "client hello, adding renegotiation extension" \
1688 -c "found renegotiation extension" \
1689 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001690 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001691 -C "error" \
1692 -c "HTTP/1.0 200 [Oo][Kk]"
1693
Paul Bakker539d9722015-02-08 16:18:35 +01001694requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001695run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1696 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1697 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1698 1 \
1699 -c "client hello, adding renegotiation extension" \
1700 -C "found renegotiation extension" \
1701 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001702 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001703 -c "error" \
1704 -C "HTTP/1.0 200 [Oo][Kk]"
1705
Paul Bakker539d9722015-02-08 16:18:35 +01001706requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001707run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1708 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1709 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1710 allow_legacy=0" \
1711 1 \
1712 -c "client hello, adding renegotiation extension" \
1713 -C "found renegotiation extension" \
1714 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001715 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001716 -c "error" \
1717 -C "HTTP/1.0 200 [Oo][Kk]"
1718
Paul Bakker539d9722015-02-08 16:18:35 +01001719requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001720run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1721 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1722 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1723 allow_legacy=1" \
1724 0 \
1725 -c "client hello, adding renegotiation extension" \
1726 -C "found renegotiation extension" \
1727 -c "=> renegotiate" \
1728 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001729 -C "error" \
1730 -c "HTTP/1.0 200 [Oo][Kk]"
1731
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001732run_test "Renegotiation: DTLS, client-initiated" \
1733 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1734 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1735 0 \
1736 -c "client hello, adding renegotiation extension" \
1737 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1738 -s "found renegotiation extension" \
1739 -s "server hello, secure renegotiation extension" \
1740 -c "found renegotiation extension" \
1741 -c "=> renegotiate" \
1742 -s "=> renegotiate" \
1743 -S "write hello request"
1744
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001745run_test "Renegotiation: DTLS, server-initiated" \
1746 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001747 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1748 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001749 0 \
1750 -c "client hello, adding renegotiation extension" \
1751 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1752 -s "found renegotiation extension" \
1753 -s "server hello, secure renegotiation extension" \
1754 -c "found renegotiation extension" \
1755 -c "=> renegotiate" \
1756 -s "=> renegotiate" \
1757 -s "write hello request"
1758
Andres AG692ad842017-01-19 16:30:57 +00001759run_test "Renegotiation: DTLS, renego_period overflow" \
1760 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1761 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1762 0 \
1763 -c "client hello, adding renegotiation extension" \
1764 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1765 -s "found renegotiation extension" \
1766 -s "server hello, secure renegotiation extension" \
1767 -s "record counter limit reached: renegotiate" \
1768 -c "=> renegotiate" \
1769 -s "=> renegotiate" \
1770 -s "write hello request" \
1771
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001772requires_gnutls
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001773run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1774 "$G_SRV -u --mtu 4096" \
1775 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1776 0 \
1777 -c "client hello, adding renegotiation extension" \
1778 -c "found renegotiation extension" \
1779 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001780 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001781 -C "error" \
1782 -s "Extra-header:"
1783
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001784# Test for the "secure renegotation" extension only (no actual renegotiation)
1785
Paul Bakker539d9722015-02-08 16:18:35 +01001786requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001787run_test "Renego ext: gnutls server strict, client default" \
1788 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1789 "$P_CLI debug_level=3" \
1790 0 \
1791 -c "found renegotiation extension" \
1792 -C "error" \
1793 -c "HTTP/1.0 200 [Oo][Kk]"
1794
Paul Bakker539d9722015-02-08 16:18:35 +01001795requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001796run_test "Renego ext: gnutls server unsafe, client default" \
1797 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1798 "$P_CLI debug_level=3" \
1799 0 \
1800 -C "found renegotiation extension" \
1801 -C "error" \
1802 -c "HTTP/1.0 200 [Oo][Kk]"
1803
Paul Bakker539d9722015-02-08 16:18:35 +01001804requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001805run_test "Renego ext: gnutls server unsafe, client break legacy" \
1806 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1807 "$P_CLI debug_level=3 allow_legacy=-1" \
1808 1 \
1809 -C "found renegotiation extension" \
1810 -c "error" \
1811 -C "HTTP/1.0 200 [Oo][Kk]"
1812
Paul Bakker539d9722015-02-08 16:18:35 +01001813requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001814run_test "Renego ext: gnutls client strict, server default" \
1815 "$P_SRV debug_level=3" \
1816 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1817 0 \
1818 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1819 -s "server hello, secure renegotiation extension"
1820
Paul Bakker539d9722015-02-08 16:18:35 +01001821requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001822run_test "Renego ext: gnutls client unsafe, server default" \
1823 "$P_SRV debug_level=3" \
1824 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1825 0 \
1826 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1827 -S "server hello, secure renegotiation extension"
1828
Paul Bakker539d9722015-02-08 16:18:35 +01001829requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001830run_test "Renego ext: gnutls client unsafe, server break legacy" \
1831 "$P_SRV debug_level=3 allow_legacy=-1" \
1832 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1833 1 \
1834 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1835 -S "server hello, secure renegotiation extension"
1836
Janos Follath0b242342016-02-17 10:11:21 +00001837# Tests for silently dropping trailing extra bytes in .der certificates
1838
1839requires_gnutls
1840run_test "DER format: no trailing bytes" \
1841 "$P_SRV crt_file=data_files/server5-der0.crt \
1842 key_file=data_files/server5.key" \
1843 "$G_CLI " \
1844 0 \
1845 -c "Handshake was completed" \
1846
1847requires_gnutls
1848run_test "DER format: with a trailing zero byte" \
1849 "$P_SRV crt_file=data_files/server5-der1a.crt \
1850 key_file=data_files/server5.key" \
1851 "$G_CLI " \
1852 0 \
1853 -c "Handshake was completed" \
1854
1855requires_gnutls
1856run_test "DER format: with a trailing random byte" \
1857 "$P_SRV crt_file=data_files/server5-der1b.crt \
1858 key_file=data_files/server5.key" \
1859 "$G_CLI " \
1860 0 \
1861 -c "Handshake was completed" \
1862
1863requires_gnutls
1864run_test "DER format: with 2 trailing random bytes" \
1865 "$P_SRV crt_file=data_files/server5-der2.crt \
1866 key_file=data_files/server5.key" \
1867 "$G_CLI " \
1868 0 \
1869 -c "Handshake was completed" \
1870
1871requires_gnutls
1872run_test "DER format: with 4 trailing random bytes" \
1873 "$P_SRV crt_file=data_files/server5-der4.crt \
1874 key_file=data_files/server5.key" \
1875 "$G_CLI " \
1876 0 \
1877 -c "Handshake was completed" \
1878
1879requires_gnutls
1880run_test "DER format: with 8 trailing random bytes" \
1881 "$P_SRV crt_file=data_files/server5-der8.crt \
1882 key_file=data_files/server5.key" \
1883 "$G_CLI " \
1884 0 \
1885 -c "Handshake was completed" \
1886
1887requires_gnutls
1888run_test "DER format: with 9 trailing random bytes" \
1889 "$P_SRV crt_file=data_files/server5-der9.crt \
1890 key_file=data_files/server5.key" \
1891 "$G_CLI " \
1892 0 \
1893 -c "Handshake was completed" \
1894
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001895# Tests for auth_mode
1896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001897run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001898 "$P_SRV crt_file=data_files/server5-badsign.crt \
1899 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001900 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001901 1 \
1902 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001903 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001904 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001905 -c "X509 - Certificate verification failed"
1906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001907run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001908 "$P_SRV crt_file=data_files/server5-badsign.crt \
1909 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001910 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001911 0 \
1912 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001913 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001914 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001915 -C "X509 - Certificate verification failed"
1916
Hanno Beckere6706e62017-05-15 16:05:15 +01001917run_test "Authentication: server goodcert, client optional, no trusted CA" \
1918 "$P_SRV" \
1919 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1920 0 \
1921 -c "x509_verify_cert() returned" \
1922 -c "! The certificate is not correctly signed by the trusted CA" \
1923 -c "! Certificate verification flags"\
1924 -C "! mbedtls_ssl_handshake returned" \
1925 -C "X509 - Certificate verification failed" \
1926 -C "SSL - No CA Chain is set, but required to operate"
1927
1928run_test "Authentication: server goodcert, client required, no trusted CA" \
1929 "$P_SRV" \
1930 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1931 1 \
1932 -c "x509_verify_cert() returned" \
1933 -c "! The certificate is not correctly signed by the trusted CA" \
1934 -c "! Certificate verification flags"\
1935 -c "! mbedtls_ssl_handshake returned" \
1936 -c "SSL - No CA Chain is set, but required to operate"
1937
1938# The purpose of the next two tests is to test the client's behaviour when receiving a server
1939# certificate with an unsupported elliptic curve. This should usually not happen because
1940# the client informs the server about the supported curves - it does, though, in the
1941# corner case of a static ECDH suite, because the server doesn't check the curve on that
1942# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1943# different means to have the server ignoring the client's supported curve list.
1944
1945requires_config_enabled MBEDTLS_ECP_C
1946run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1947 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1948 crt_file=data_files/server5.ku-ka.crt" \
1949 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1950 1 \
1951 -c "bad certificate (EC key curve)"\
1952 -c "! Certificate verification flags"\
1953 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1954
1955requires_config_enabled MBEDTLS_ECP_C
1956run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1957 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1958 crt_file=data_files/server5.ku-ka.crt" \
1959 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1960 1 \
1961 -c "bad certificate (EC key curve)"\
1962 -c "! Certificate verification flags"\
1963 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001965run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001966 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001967 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001968 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001969 0 \
1970 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001971 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001972 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001973 -C "X509 - Certificate verification failed"
1974
Simon Butcher99000142016-10-13 17:21:01 +01001975run_test "Authentication: client SHA256, server required" \
1976 "$P_SRV auth_mode=required" \
1977 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1978 key_file=data_files/server6.key \
1979 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1980 0 \
1981 -c "Supported Signature Algorithm found: 4," \
1982 -c "Supported Signature Algorithm found: 5,"
1983
1984run_test "Authentication: client SHA384, server required" \
1985 "$P_SRV auth_mode=required" \
1986 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
1987 key_file=data_files/server6.key \
1988 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
1989 0 \
1990 -c "Supported Signature Algorithm found: 4," \
1991 -c "Supported Signature Algorithm found: 5,"
1992
Gilles Peskinefd8332e2017-05-03 16:25:07 +02001993requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
1994run_test "Authentication: client has no cert, server required (SSLv3)" \
1995 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
1996 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
1997 key_file=data_files/server5.key" \
1998 1 \
1999 -S "skip write certificate request" \
2000 -C "skip parse certificate request" \
2001 -c "got a certificate request" \
2002 -c "got no certificate to send" \
2003 -S "x509_verify_cert() returned" \
2004 -s "client has no certificate" \
2005 -s "! mbedtls_ssl_handshake returned" \
2006 -c "! mbedtls_ssl_handshake returned" \
2007 -s "No client certification received from the client, but required by the authentication mode"
2008
2009run_test "Authentication: client has no cert, server required (TLS)" \
2010 "$P_SRV debug_level=3 auth_mode=required" \
2011 "$P_CLI debug_level=3 crt_file=none \
2012 key_file=data_files/server5.key" \
2013 1 \
2014 -S "skip write certificate request" \
2015 -C "skip parse certificate request" \
2016 -c "got a certificate request" \
2017 -c "= write certificate$" \
2018 -C "skip write certificate$" \
2019 -S "x509_verify_cert() returned" \
2020 -s "client has no certificate" \
2021 -s "! mbedtls_ssl_handshake returned" \
2022 -c "! mbedtls_ssl_handshake returned" \
2023 -s "No client certification received from the client, but required by the authentication mode"
2024
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002025run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002026 "$P_SRV debug_level=3 auth_mode=required" \
2027 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002028 key_file=data_files/server5.key" \
2029 1 \
2030 -S "skip write certificate request" \
2031 -C "skip parse certificate request" \
2032 -c "got a certificate request" \
2033 -C "skip write certificate" \
2034 -C "skip write certificate verify" \
2035 -S "skip parse certificate verify" \
2036 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002037 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002038 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002039 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002040 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002041 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002042# We don't check that the client receives the alert because it might
2043# detect that its write end of the connection is closed and abort
2044# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002045
Janos Follath89baba22017-04-10 14:34:35 +01002046run_test "Authentication: client cert not trusted, server required" \
2047 "$P_SRV debug_level=3 auth_mode=required" \
2048 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2049 key_file=data_files/server5.key" \
2050 1 \
2051 -S "skip write certificate request" \
2052 -C "skip parse certificate request" \
2053 -c "got a certificate request" \
2054 -C "skip write certificate" \
2055 -C "skip write certificate verify" \
2056 -S "skip parse certificate verify" \
2057 -s "x509_verify_cert() returned" \
2058 -s "! The certificate is not correctly signed by the trusted CA" \
2059 -s "! mbedtls_ssl_handshake returned" \
2060 -c "! mbedtls_ssl_handshake returned" \
2061 -s "X509 - Certificate verification failed"
2062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002064 "$P_SRV debug_level=3 auth_mode=optional" \
2065 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002066 key_file=data_files/server5.key" \
2067 0 \
2068 -S "skip write certificate request" \
2069 -C "skip parse certificate request" \
2070 -c "got a certificate request" \
2071 -C "skip write certificate" \
2072 -C "skip write certificate verify" \
2073 -S "skip parse certificate verify" \
2074 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002075 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002076 -S "! mbedtls_ssl_handshake returned" \
2077 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002078 -S "X509 - Certificate verification failed"
2079
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002080run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002081 "$P_SRV debug_level=3 auth_mode=none" \
2082 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002083 key_file=data_files/server5.key" \
2084 0 \
2085 -s "skip write certificate request" \
2086 -C "skip parse certificate request" \
2087 -c "got no certificate request" \
2088 -c "skip write certificate" \
2089 -c "skip write certificate verify" \
2090 -s "skip parse certificate verify" \
2091 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002092 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002093 -S "! mbedtls_ssl_handshake returned" \
2094 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002095 -S "X509 - Certificate verification failed"
2096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002097run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002098 "$P_SRV debug_level=3 auth_mode=optional" \
2099 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002100 0 \
2101 -S "skip write certificate request" \
2102 -C "skip parse certificate request" \
2103 -c "got a certificate request" \
2104 -C "skip write certificate$" \
2105 -C "got no certificate to send" \
2106 -S "SSLv3 client has no certificate" \
2107 -c "skip write certificate verify" \
2108 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002109 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002110 -S "! mbedtls_ssl_handshake returned" \
2111 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002112 -S "X509 - Certificate verification failed"
2113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002115 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002116 "$O_CLI" \
2117 0 \
2118 -S "skip write certificate request" \
2119 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002120 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002121 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002122 -S "X509 - Certificate verification failed"
2123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002125 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002126 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002127 0 \
2128 -C "skip parse certificate request" \
2129 -c "got a certificate request" \
2130 -C "skip write certificate$" \
2131 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002132 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002133
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002134run_test "Authentication: client no cert, openssl server required" \
2135 "$O_SRV -Verify 10" \
2136 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2137 1 \
2138 -C "skip parse certificate request" \
2139 -c "got a certificate request" \
2140 -C "skip write certificate$" \
2141 -c "skip write certificate verify" \
2142 -c "! mbedtls_ssl_handshake returned"
2143
Janos Follathe2681a42016-03-07 15:57:05 +00002144requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002146 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002147 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002148 0 \
2149 -S "skip write certificate request" \
2150 -C "skip parse certificate request" \
2151 -c "got a certificate request" \
2152 -C "skip write certificate$" \
2153 -c "skip write certificate verify" \
2154 -c "got no certificate to send" \
2155 -s "SSLv3 client has no certificate" \
2156 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002157 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002158 -S "! mbedtls_ssl_handshake returned" \
2159 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002160 -S "X509 - Certificate verification failed"
2161
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002162# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2163# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002164
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002165MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002166MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002167
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002168if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002169 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002170 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002171 printf "test value of ${MAX_IM_CA}. \n"
2172 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002173 printf "The tests assume this value and if it changes, the tests in this\n"
2174 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002175 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002176
2177 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002178fi
2179
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002180run_test "Authentication: server max_int chain, client default" \
2181 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2182 key_file=data_files/dir-maxpath/09.key" \
2183 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2184 0 \
2185 -C "X509 - A fatal error occured"
2186
2187run_test "Authentication: server max_int+1 chain, client default" \
2188 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2189 key_file=data_files/dir-maxpath/10.key" \
2190 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2191 1 \
2192 -c "X509 - A fatal error occured"
2193
2194run_test "Authentication: server max_int+1 chain, client optional" \
2195 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2196 key_file=data_files/dir-maxpath/10.key" \
2197 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2198 auth_mode=optional" \
2199 1 \
2200 -c "X509 - A fatal error occured"
2201
2202run_test "Authentication: server max_int+1 chain, client none" \
2203 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2204 key_file=data_files/dir-maxpath/10.key" \
2205 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2206 auth_mode=none" \
2207 0 \
2208 -C "X509 - A fatal error occured"
2209
2210run_test "Authentication: client max_int+1 chain, server default" \
2211 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2212 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2213 key_file=data_files/dir-maxpath/10.key" \
2214 0 \
2215 -S "X509 - A fatal error occured"
2216
2217run_test "Authentication: client max_int+1 chain, server optional" \
2218 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2219 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2220 key_file=data_files/dir-maxpath/10.key" \
2221 1 \
2222 -s "X509 - A fatal error occured"
2223
2224run_test "Authentication: client max_int+1 chain, server required" \
2225 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2226 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2227 key_file=data_files/dir-maxpath/10.key" \
2228 1 \
2229 -s "X509 - A fatal error occured"
2230
2231run_test "Authentication: client max_int chain, server required" \
2232 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2233 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2234 key_file=data_files/dir-maxpath/09.key" \
2235 0 \
2236 -S "X509 - A fatal error occured"
2237
Janos Follath89baba22017-04-10 14:34:35 +01002238# Tests for CA list in CertificateRequest messages
2239
2240run_test "Authentication: send CA list in CertificateRequest (default)" \
2241 "$P_SRV debug_level=3 auth_mode=required" \
2242 "$P_CLI crt_file=data_files/server6.crt \
2243 key_file=data_files/server6.key" \
2244 0 \
2245 -s "requested DN"
2246
2247run_test "Authentication: do not send CA list in CertificateRequest" \
2248 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2249 "$P_CLI crt_file=data_files/server6.crt \
2250 key_file=data_files/server6.key" \
2251 0 \
2252 -S "requested DN"
2253
2254run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2255 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2256 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2257 key_file=data_files/server5.key" \
2258 1 \
2259 -S "requested DN" \
2260 -s "x509_verify_cert() returned" \
2261 -s "! The certificate is not correctly signed by the trusted CA" \
2262 -s "! mbedtls_ssl_handshake returned" \
2263 -c "! mbedtls_ssl_handshake returned" \
2264 -s "X509 - Certificate verification failed"
2265
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002266# Tests for certificate selection based on SHA verson
2267
2268run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2269 "$P_SRV crt_file=data_files/server5.crt \
2270 key_file=data_files/server5.key \
2271 crt_file2=data_files/server5-sha1.crt \
2272 key_file2=data_files/server5.key" \
2273 "$P_CLI force_version=tls1_2" \
2274 0 \
2275 -c "signed using.*ECDSA with SHA256" \
2276 -C "signed using.*ECDSA with SHA1"
2277
2278run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2279 "$P_SRV crt_file=data_files/server5.crt \
2280 key_file=data_files/server5.key \
2281 crt_file2=data_files/server5-sha1.crt \
2282 key_file2=data_files/server5.key" \
2283 "$P_CLI force_version=tls1_1" \
2284 0 \
2285 -C "signed using.*ECDSA with SHA256" \
2286 -c "signed using.*ECDSA with SHA1"
2287
2288run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2289 "$P_SRV crt_file=data_files/server5.crt \
2290 key_file=data_files/server5.key \
2291 crt_file2=data_files/server5-sha1.crt \
2292 key_file2=data_files/server5.key" \
2293 "$P_CLI force_version=tls1" \
2294 0 \
2295 -C "signed using.*ECDSA with SHA256" \
2296 -c "signed using.*ECDSA with SHA1"
2297
2298run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2299 "$P_SRV crt_file=data_files/server5.crt \
2300 key_file=data_files/server5.key \
2301 crt_file2=data_files/server6.crt \
2302 key_file2=data_files/server6.key" \
2303 "$P_CLI force_version=tls1_1" \
2304 0 \
2305 -c "serial number.*09" \
2306 -c "signed using.*ECDSA with SHA256" \
2307 -C "signed using.*ECDSA with SHA1"
2308
2309run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2310 "$P_SRV crt_file=data_files/server6.crt \
2311 key_file=data_files/server6.key \
2312 crt_file2=data_files/server5.crt \
2313 key_file2=data_files/server5.key" \
2314 "$P_CLI force_version=tls1_1" \
2315 0 \
2316 -c "serial number.*0A" \
2317 -c "signed using.*ECDSA with SHA256" \
2318 -C "signed using.*ECDSA with SHA1"
2319
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002320# tests for SNI
2321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002323 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002324 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002325 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002326 0 \
2327 -S "parse ServerName extension" \
2328 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2329 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002330
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002331run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002332 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002333 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002334 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 +02002335 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002336 0 \
2337 -s "parse ServerName extension" \
2338 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2339 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002340
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002341run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002342 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002343 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002344 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 +02002345 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002346 0 \
2347 -s "parse ServerName extension" \
2348 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2349 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002351run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002352 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002353 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002354 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 +02002355 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002356 1 \
2357 -s "parse ServerName extension" \
2358 -s "ssl_sni_wrapper() returned" \
2359 -s "mbedtls_ssl_handshake returned" \
2360 -c "mbedtls_ssl_handshake returned" \
2361 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002362
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002363run_test "SNI: client auth no override: optional" \
2364 "$P_SRV debug_level=3 auth_mode=optional \
2365 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2366 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2367 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002368 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002369 -S "skip write certificate request" \
2370 -C "skip parse certificate request" \
2371 -c "got a certificate request" \
2372 -C "skip write certificate" \
2373 -C "skip write certificate verify" \
2374 -S "skip parse certificate verify"
2375
2376run_test "SNI: client auth override: none -> optional" \
2377 "$P_SRV debug_level=3 auth_mode=none \
2378 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2379 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2380 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002381 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002382 -S "skip write certificate request" \
2383 -C "skip parse certificate request" \
2384 -c "got a certificate request" \
2385 -C "skip write certificate" \
2386 -C "skip write certificate verify" \
2387 -S "skip parse certificate verify"
2388
2389run_test "SNI: client auth override: optional -> none" \
2390 "$P_SRV debug_level=3 auth_mode=optional \
2391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2392 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2393 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002394 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002395 -s "skip write certificate request" \
2396 -C "skip parse certificate request" \
2397 -c "got no certificate request" \
2398 -c "skip write certificate" \
2399 -c "skip write certificate verify" \
2400 -s "skip parse certificate verify"
2401
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002402run_test "SNI: CA no override" \
2403 "$P_SRV debug_level=3 auth_mode=optional \
2404 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2405 ca_file=data_files/test-ca.crt \
2406 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2407 "$P_CLI debug_level=3 server_name=localhost \
2408 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2409 1 \
2410 -S "skip write certificate request" \
2411 -C "skip parse certificate request" \
2412 -c "got a certificate request" \
2413 -C "skip write certificate" \
2414 -C "skip write certificate verify" \
2415 -S "skip parse certificate verify" \
2416 -s "x509_verify_cert() returned" \
2417 -s "! The certificate is not correctly signed by the trusted CA" \
2418 -S "The certificate has been revoked (is on a CRL)"
2419
2420run_test "SNI: CA override" \
2421 "$P_SRV debug_level=3 auth_mode=optional \
2422 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2423 ca_file=data_files/test-ca.crt \
2424 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2425 "$P_CLI debug_level=3 server_name=localhost \
2426 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2427 0 \
2428 -S "skip write certificate request" \
2429 -C "skip parse certificate request" \
2430 -c "got a certificate request" \
2431 -C "skip write certificate" \
2432 -C "skip write certificate verify" \
2433 -S "skip parse certificate verify" \
2434 -S "x509_verify_cert() returned" \
2435 -S "! The certificate is not correctly signed by the trusted CA" \
2436 -S "The certificate has been revoked (is on a CRL)"
2437
2438run_test "SNI: CA override with CRL" \
2439 "$P_SRV debug_level=3 auth_mode=optional \
2440 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2441 ca_file=data_files/test-ca.crt \
2442 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2443 "$P_CLI debug_level=3 server_name=localhost \
2444 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2445 1 \
2446 -S "skip write certificate request" \
2447 -C "skip parse certificate request" \
2448 -c "got a certificate request" \
2449 -C "skip write certificate" \
2450 -C "skip write certificate verify" \
2451 -S "skip parse certificate verify" \
2452 -s "x509_verify_cert() returned" \
2453 -S "! The certificate is not correctly signed by the trusted CA" \
2454 -s "The certificate has been revoked (is on a CRL)"
2455
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002456# Tests for non-blocking I/O: exercise a variety of handshake flows
2457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002458run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002459 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2460 "$P_CLI nbio=2 tickets=0" \
2461 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002462 -S "mbedtls_ssl_handshake returned" \
2463 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002464 -c "Read from server: .* bytes read"
2465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002466run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002467 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2468 "$P_CLI nbio=2 tickets=0" \
2469 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002470 -S "mbedtls_ssl_handshake returned" \
2471 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002472 -c "Read from server: .* bytes read"
2473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002474run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002475 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2476 "$P_CLI nbio=2 tickets=1" \
2477 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002478 -S "mbedtls_ssl_handshake returned" \
2479 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002480 -c "Read from server: .* bytes read"
2481
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002482run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002483 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2484 "$P_CLI nbio=2 tickets=1" \
2485 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002486 -S "mbedtls_ssl_handshake returned" \
2487 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002488 -c "Read from server: .* bytes read"
2489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002490run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002491 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2492 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2493 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002494 -S "mbedtls_ssl_handshake returned" \
2495 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002496 -c "Read from server: .* bytes read"
2497
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002498run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002499 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2500 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2501 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002502 -S "mbedtls_ssl_handshake returned" \
2503 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002504 -c "Read from server: .* bytes read"
2505
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002506run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002507 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2508 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2509 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002510 -S "mbedtls_ssl_handshake returned" \
2511 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002512 -c "Read from server: .* bytes read"
2513
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002514# Tests for version negotiation
2515
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002516run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002517 "$P_SRV" \
2518 "$P_CLI" \
2519 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002520 -S "mbedtls_ssl_handshake returned" \
2521 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002522 -s "Protocol is TLSv1.2" \
2523 -c "Protocol is TLSv1.2"
2524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002525run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002526 "$P_SRV" \
2527 "$P_CLI max_version=tls1_1" \
2528 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002529 -S "mbedtls_ssl_handshake returned" \
2530 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002531 -s "Protocol is TLSv1.1" \
2532 -c "Protocol is TLSv1.1"
2533
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002534run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002535 "$P_SRV max_version=tls1_1" \
2536 "$P_CLI" \
2537 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002538 -S "mbedtls_ssl_handshake returned" \
2539 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002540 -s "Protocol is TLSv1.1" \
2541 -c "Protocol is TLSv1.1"
2542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002543run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002544 "$P_SRV max_version=tls1_1" \
2545 "$P_CLI max_version=tls1_1" \
2546 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002547 -S "mbedtls_ssl_handshake returned" \
2548 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002549 -s "Protocol is TLSv1.1" \
2550 -c "Protocol is TLSv1.1"
2551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002552run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002553 "$P_SRV min_version=tls1_1" \
2554 "$P_CLI max_version=tls1_1" \
2555 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002556 -S "mbedtls_ssl_handshake returned" \
2557 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002558 -s "Protocol is TLSv1.1" \
2559 -c "Protocol is TLSv1.1"
2560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002561run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002562 "$P_SRV max_version=tls1_1" \
2563 "$P_CLI min_version=tls1_1" \
2564 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002565 -S "mbedtls_ssl_handshake returned" \
2566 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002567 -s "Protocol is TLSv1.1" \
2568 -c "Protocol is TLSv1.1"
2569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002570run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002571 "$P_SRV max_version=tls1_1" \
2572 "$P_CLI min_version=tls1_2" \
2573 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002574 -s "mbedtls_ssl_handshake returned" \
2575 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002576 -c "SSL - Handshake protocol not within min/max boundaries"
2577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002578run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002579 "$P_SRV min_version=tls1_2" \
2580 "$P_CLI max_version=tls1_1" \
2581 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002582 -s "mbedtls_ssl_handshake returned" \
2583 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002584 -s "SSL - Handshake protocol not within min/max boundaries"
2585
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002586# Tests for ALPN extension
2587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002588run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002589 "$P_SRV debug_level=3" \
2590 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002591 0 \
2592 -C "client hello, adding alpn extension" \
2593 -S "found alpn extension" \
2594 -C "got an alert message, type: \\[2:120]" \
2595 -S "server hello, adding alpn extension" \
2596 -C "found alpn extension " \
2597 -C "Application Layer Protocol is" \
2598 -S "Application Layer Protocol is"
2599
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002600run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002601 "$P_SRV debug_level=3" \
2602 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002603 0 \
2604 -c "client hello, adding alpn extension" \
2605 -s "found alpn extension" \
2606 -C "got an alert message, type: \\[2:120]" \
2607 -S "server hello, adding alpn extension" \
2608 -C "found alpn extension " \
2609 -c "Application Layer Protocol is (none)" \
2610 -S "Application Layer Protocol is"
2611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002612run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002613 "$P_SRV debug_level=3 alpn=abc,1234" \
2614 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002615 0 \
2616 -C "client hello, adding alpn extension" \
2617 -S "found alpn extension" \
2618 -C "got an alert message, type: \\[2:120]" \
2619 -S "server hello, adding alpn extension" \
2620 -C "found alpn extension " \
2621 -C "Application Layer Protocol is" \
2622 -s "Application Layer Protocol is (none)"
2623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002624run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002625 "$P_SRV debug_level=3 alpn=abc,1234" \
2626 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002627 0 \
2628 -c "client hello, adding alpn extension" \
2629 -s "found alpn extension" \
2630 -C "got an alert message, type: \\[2:120]" \
2631 -s "server hello, adding alpn extension" \
2632 -c "found alpn extension" \
2633 -c "Application Layer Protocol is abc" \
2634 -s "Application Layer Protocol is abc"
2635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002636run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002637 "$P_SRV debug_level=3 alpn=abc,1234" \
2638 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002639 0 \
2640 -c "client hello, adding alpn extension" \
2641 -s "found alpn extension" \
2642 -C "got an alert message, type: \\[2:120]" \
2643 -s "server hello, adding alpn extension" \
2644 -c "found alpn extension" \
2645 -c "Application Layer Protocol is abc" \
2646 -s "Application Layer Protocol is abc"
2647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002649 "$P_SRV debug_level=3 alpn=abc,1234" \
2650 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002651 0 \
2652 -c "client hello, adding alpn extension" \
2653 -s "found alpn extension" \
2654 -C "got an alert message, type: \\[2:120]" \
2655 -s "server hello, adding alpn extension" \
2656 -c "found alpn extension" \
2657 -c "Application Layer Protocol is 1234" \
2658 -s "Application Layer Protocol is 1234"
2659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002660run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002661 "$P_SRV debug_level=3 alpn=abc,123" \
2662 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002663 1 \
2664 -c "client hello, adding alpn extension" \
2665 -s "found alpn extension" \
2666 -c "got an alert message, type: \\[2:120]" \
2667 -S "server hello, adding alpn extension" \
2668 -C "found alpn extension" \
2669 -C "Application Layer Protocol is 1234" \
2670 -S "Application Layer Protocol is 1234"
2671
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002672
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002673# Tests for keyUsage in leaf certificates, part 1:
2674# server-side certificate/suite selection
2675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002676run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002677 "$P_SRV key_file=data_files/server2.key \
2678 crt_file=data_files/server2.ku-ds.crt" \
2679 "$P_CLI" \
2680 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002681 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002682
2683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002684run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002685 "$P_SRV key_file=data_files/server2.key \
2686 crt_file=data_files/server2.ku-ke.crt" \
2687 "$P_CLI" \
2688 0 \
2689 -c "Ciphersuite is TLS-RSA-WITH-"
2690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002691run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002692 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002693 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002694 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002695 1 \
2696 -C "Ciphersuite is "
2697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002698run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002699 "$P_SRV key_file=data_files/server5.key \
2700 crt_file=data_files/server5.ku-ds.crt" \
2701 "$P_CLI" \
2702 0 \
2703 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2704
2705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002706run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002707 "$P_SRV key_file=data_files/server5.key \
2708 crt_file=data_files/server5.ku-ka.crt" \
2709 "$P_CLI" \
2710 0 \
2711 -c "Ciphersuite is TLS-ECDH-"
2712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002713run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002714 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002715 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002716 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002717 1 \
2718 -C "Ciphersuite is "
2719
2720# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002721# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002724 "$O_SRV -key data_files/server2.key \
2725 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002726 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002727 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2728 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002729 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002730 -C "Processing of the Certificate handshake message failed" \
2731 -c "Ciphersuite is TLS-"
2732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002733run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002734 "$O_SRV -key data_files/server2.key \
2735 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002736 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002737 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2738 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002739 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002740 -C "Processing of the Certificate handshake message failed" \
2741 -c "Ciphersuite is TLS-"
2742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002743run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002744 "$O_SRV -key data_files/server2.key \
2745 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002746 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002747 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2748 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002749 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002750 -C "Processing of the Certificate handshake message failed" \
2751 -c "Ciphersuite is TLS-"
2752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002753run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002754 "$O_SRV -key data_files/server2.key \
2755 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002756 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002757 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2758 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002759 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002760 -c "Processing of the Certificate handshake message failed" \
2761 -C "Ciphersuite is TLS-"
2762
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002763run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2764 "$O_SRV -key data_files/server2.key \
2765 -cert data_files/server2.ku-ke.crt" \
2766 "$P_CLI debug_level=1 auth_mode=optional \
2767 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2768 0 \
2769 -c "bad certificate (usage extensions)" \
2770 -C "Processing of the Certificate handshake message failed" \
2771 -c "Ciphersuite is TLS-" \
2772 -c "! Usage does not match the keyUsage extension"
2773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002774run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002775 "$O_SRV -key data_files/server2.key \
2776 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002777 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002778 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2779 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002780 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002781 -C "Processing of the Certificate handshake message failed" \
2782 -c "Ciphersuite is TLS-"
2783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002785 "$O_SRV -key data_files/server2.key \
2786 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002787 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002788 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2789 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002790 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002791 -c "Processing of the Certificate handshake message failed" \
2792 -C "Ciphersuite is TLS-"
2793
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002794run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2795 "$O_SRV -key data_files/server2.key \
2796 -cert data_files/server2.ku-ds.crt" \
2797 "$P_CLI debug_level=1 auth_mode=optional \
2798 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2799 0 \
2800 -c "bad certificate (usage extensions)" \
2801 -C "Processing of the Certificate handshake message failed" \
2802 -c "Ciphersuite is TLS-" \
2803 -c "! Usage does not match the keyUsage extension"
2804
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002805# Tests for keyUsage in leaf certificates, part 3:
2806# server-side checking of client cert
2807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002808run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002809 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002810 "$O_CLI -key data_files/server2.key \
2811 -cert data_files/server2.ku-ds.crt" \
2812 0 \
2813 -S "bad certificate (usage extensions)" \
2814 -S "Processing of the Certificate handshake message failed"
2815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002816run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002817 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002818 "$O_CLI -key data_files/server2.key \
2819 -cert data_files/server2.ku-ke.crt" \
2820 0 \
2821 -s "bad certificate (usage extensions)" \
2822 -S "Processing of the Certificate handshake message failed"
2823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002824run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002825 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002826 "$O_CLI -key data_files/server2.key \
2827 -cert data_files/server2.ku-ke.crt" \
2828 1 \
2829 -s "bad certificate (usage extensions)" \
2830 -s "Processing of the Certificate handshake message failed"
2831
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002832run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002833 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002834 "$O_CLI -key data_files/server5.key \
2835 -cert data_files/server5.ku-ds.crt" \
2836 0 \
2837 -S "bad certificate (usage extensions)" \
2838 -S "Processing of the Certificate handshake message failed"
2839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002840run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002841 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002842 "$O_CLI -key data_files/server5.key \
2843 -cert data_files/server5.ku-ka.crt" \
2844 0 \
2845 -s "bad certificate (usage extensions)" \
2846 -S "Processing of the Certificate handshake message failed"
2847
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002848# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002851 "$P_SRV key_file=data_files/server5.key \
2852 crt_file=data_files/server5.eku-srv.crt" \
2853 "$P_CLI" \
2854 0
2855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002856run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002857 "$P_SRV key_file=data_files/server5.key \
2858 crt_file=data_files/server5.eku-srv.crt" \
2859 "$P_CLI" \
2860 0
2861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002862run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002863 "$P_SRV key_file=data_files/server5.key \
2864 crt_file=data_files/server5.eku-cs_any.crt" \
2865 "$P_CLI" \
2866 0
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002869 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002870 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002871 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002872 1
2873
2874# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002876run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002877 "$O_SRV -key data_files/server5.key \
2878 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002879 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002880 0 \
2881 -C "bad certificate (usage extensions)" \
2882 -C "Processing of the Certificate handshake message failed" \
2883 -c "Ciphersuite is TLS-"
2884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002886 "$O_SRV -key data_files/server5.key \
2887 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002888 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002889 0 \
2890 -C "bad certificate (usage extensions)" \
2891 -C "Processing of the Certificate handshake message failed" \
2892 -c "Ciphersuite is TLS-"
2893
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002894run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002895 "$O_SRV -key data_files/server5.key \
2896 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002897 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002898 0 \
2899 -C "bad certificate (usage extensions)" \
2900 -C "Processing of the Certificate handshake message failed" \
2901 -c "Ciphersuite is TLS-"
2902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002903run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002904 "$O_SRV -key data_files/server5.key \
2905 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002906 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002907 1 \
2908 -c "bad certificate (usage extensions)" \
2909 -c "Processing of the Certificate handshake message failed" \
2910 -C "Ciphersuite is TLS-"
2911
2912# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002914run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002915 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002916 "$O_CLI -key data_files/server5.key \
2917 -cert data_files/server5.eku-cli.crt" \
2918 0 \
2919 -S "bad certificate (usage extensions)" \
2920 -S "Processing of the Certificate handshake message failed"
2921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002922run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002923 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002924 "$O_CLI -key data_files/server5.key \
2925 -cert data_files/server5.eku-srv_cli.crt" \
2926 0 \
2927 -S "bad certificate (usage extensions)" \
2928 -S "Processing of the Certificate handshake message failed"
2929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002930run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002931 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002932 "$O_CLI -key data_files/server5.key \
2933 -cert data_files/server5.eku-cs_any.crt" \
2934 0 \
2935 -S "bad certificate (usage extensions)" \
2936 -S "Processing of the Certificate handshake message failed"
2937
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002938run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002939 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002940 "$O_CLI -key data_files/server5.key \
2941 -cert data_files/server5.eku-cs.crt" \
2942 0 \
2943 -s "bad certificate (usage extensions)" \
2944 -S "Processing of the Certificate handshake message failed"
2945
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002946run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002947 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002948 "$O_CLI -key data_files/server5.key \
2949 -cert data_files/server5.eku-cs.crt" \
2950 1 \
2951 -s "bad certificate (usage extensions)" \
2952 -s "Processing of the Certificate handshake message failed"
2953
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002954# Tests for DHM parameters loading
2955
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002956run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002957 "$P_SRV" \
2958 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2959 debug_level=3" \
2960 0 \
2961 -c "value of 'DHM: P ' (2048 bits)" \
2962 -c "value of 'DHM: G ' (2048 bits)"
2963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002964run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002965 "$P_SRV dhm_file=data_files/dhparams.pem" \
2966 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2967 debug_level=3" \
2968 0 \
2969 -c "value of 'DHM: P ' (1024 bits)" \
2970 -c "value of 'DHM: G ' (2 bits)"
2971
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002972# Tests for DHM client-side size checking
2973
2974run_test "DHM size: server default, client default, OK" \
2975 "$P_SRV" \
2976 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2977 debug_level=1" \
2978 0 \
2979 -C "DHM prime too short:"
2980
2981run_test "DHM size: server default, client 2048, OK" \
2982 "$P_SRV" \
2983 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2984 debug_level=1 dhmlen=2048" \
2985 0 \
2986 -C "DHM prime too short:"
2987
2988run_test "DHM size: server 1024, client default, OK" \
2989 "$P_SRV dhm_file=data_files/dhparams.pem" \
2990 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2991 debug_level=1" \
2992 0 \
2993 -C "DHM prime too short:"
2994
2995run_test "DHM size: server 1000, client default, rejected" \
2996 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2997 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2998 debug_level=1" \
2999 1 \
3000 -c "DHM prime too short:"
3001
3002run_test "DHM size: server default, client 2049, rejected" \
3003 "$P_SRV" \
3004 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3005 debug_level=1 dhmlen=2049" \
3006 1 \
3007 -c "DHM prime too short:"
3008
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003009# Tests for PSK callback
3010
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003011run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003012 "$P_SRV psk=abc123 psk_identity=foo" \
3013 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3014 psk_identity=foo psk=abc123" \
3015 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003016 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003017 -S "SSL - Unknown identity received" \
3018 -S "SSL - Verification of the message MAC failed"
3019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003020run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003021 "$P_SRV" \
3022 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3023 psk_identity=foo psk=abc123" \
3024 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003025 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003026 -S "SSL - Unknown identity received" \
3027 -S "SSL - Verification of the message MAC failed"
3028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003029run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003030 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3031 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3032 psk_identity=foo psk=abc123" \
3033 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003034 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003035 -s "SSL - Unknown identity received" \
3036 -S "SSL - Verification of the message MAC failed"
3037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003038run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003039 "$P_SRV psk_list=abc,dead,def,beef" \
3040 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3041 psk_identity=abc psk=dead" \
3042 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003043 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003044 -S "SSL - Unknown identity received" \
3045 -S "SSL - Verification of the message MAC failed"
3046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003047run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003048 "$P_SRV psk_list=abc,dead,def,beef" \
3049 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3050 psk_identity=def psk=beef" \
3051 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003052 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003053 -S "SSL - Unknown identity received" \
3054 -S "SSL - Verification of the message MAC failed"
3055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003056run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003057 "$P_SRV psk_list=abc,dead,def,beef" \
3058 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3059 psk_identity=ghi psk=beef" \
3060 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003061 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003062 -s "SSL - Unknown identity received" \
3063 -S "SSL - Verification of the message MAC failed"
3064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003065run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003066 "$P_SRV psk_list=abc,dead,def,beef" \
3067 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3068 psk_identity=abc psk=beef" \
3069 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003070 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003071 -S "SSL - Unknown identity received" \
3072 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003073
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003074# Tests for EC J-PAKE
3075
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003076requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003077run_test "ECJPAKE: client not configured" \
3078 "$P_SRV debug_level=3" \
3079 "$P_CLI debug_level=3" \
3080 0 \
3081 -C "add ciphersuite: c0ff" \
3082 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003083 -S "found ecjpake kkpp extension" \
3084 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003085 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003086 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003087 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003088 -S "None of the common ciphersuites is usable"
3089
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003090requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003091run_test "ECJPAKE: server not configured" \
3092 "$P_SRV debug_level=3" \
3093 "$P_CLI debug_level=3 ecjpake_pw=bla \
3094 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3095 1 \
3096 -c "add ciphersuite: c0ff" \
3097 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003098 -s "found ecjpake kkpp extension" \
3099 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003100 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003101 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003102 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003103 -s "None of the common ciphersuites is usable"
3104
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003105requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003106run_test "ECJPAKE: working, TLS" \
3107 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3108 "$P_CLI debug_level=3 ecjpake_pw=bla \
3109 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003110 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003111 -c "add ciphersuite: c0ff" \
3112 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003113 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003114 -s "found ecjpake kkpp extension" \
3115 -S "skip ecjpake kkpp extension" \
3116 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003117 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003118 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003119 -S "None of the common ciphersuites is usable" \
3120 -S "SSL - Verification of the message MAC failed"
3121
Janos Follath74537a62016-09-02 13:45:28 +01003122server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003123requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003124run_test "ECJPAKE: password mismatch, TLS" \
3125 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3126 "$P_CLI debug_level=3 ecjpake_pw=bad \
3127 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3128 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003129 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003130 -s "SSL - Verification of the message MAC failed"
3131
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003132requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003133run_test "ECJPAKE: working, DTLS" \
3134 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3135 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3136 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3137 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003138 -c "re-using cached ecjpake parameters" \
3139 -S "SSL - Verification of the message MAC failed"
3140
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003141requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003142run_test "ECJPAKE: working, DTLS, no cookie" \
3143 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3144 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3145 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3146 0 \
3147 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003148 -S "SSL - Verification of the message MAC failed"
3149
Janos Follath74537a62016-09-02 13:45:28 +01003150server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003151requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003152run_test "ECJPAKE: password mismatch, DTLS" \
3153 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3154 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3155 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3156 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003157 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003158 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003159
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003160# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003161requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003162run_test "ECJPAKE: working, DTLS, nolog" \
3163 "$P_SRV dtls=1 ecjpake_pw=bla" \
3164 "$P_CLI dtls=1 ecjpake_pw=bla \
3165 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3166 0
3167
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003168# Tests for ciphersuites per version
3169
Janos Follathe2681a42016-03-07 15:57:05 +00003170requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003171run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003172 "$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 +02003173 "$P_CLI force_version=ssl3" \
3174 0 \
3175 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003177run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003178 "$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 +01003179 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003180 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003181 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003183run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003184 "$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 +02003185 "$P_CLI force_version=tls1_1" \
3186 0 \
3187 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3188
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003189run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003190 "$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 +02003191 "$P_CLI force_version=tls1_2" \
3192 0 \
3193 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3194
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003195# Test for ClientHello without extensions
3196
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003197requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003198run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003199 "$P_SRV debug_level=3" \
3200 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3201 0 \
3202 -s "dumping 'client hello extensions' (0 bytes)"
3203
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003204requires_gnutls
3205run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3206 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3207 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3208 0 \
3209 -s "dumping 'client hello extensions' (0 bytes)"
3210
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003211# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003212
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003213run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003214 "$P_SRV" \
3215 "$P_CLI request_size=100" \
3216 0 \
3217 -s "Read from client: 100 bytes read$"
3218
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003219run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003220 "$P_SRV" \
3221 "$P_CLI request_size=500" \
3222 0 \
3223 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003224
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003225# Tests for small packets
3226
Janos Follathe2681a42016-03-07 15:57:05 +00003227requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003228run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003229 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003230 "$P_CLI request_size=1 force_version=ssl3 \
3231 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3232 0 \
3233 -s "Read from client: 1 bytes read"
3234
Janos Follathe2681a42016-03-07 15:57:05 +00003235requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003236run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003237 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003238 "$P_CLI request_size=1 force_version=ssl3 \
3239 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3240 0 \
3241 -s "Read from client: 1 bytes read"
3242
3243run_test "Small packet TLS 1.0 BlockCipher" \
3244 "$P_SRV" \
3245 "$P_CLI request_size=1 force_version=tls1 \
3246 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3247 0 \
3248 -s "Read from client: 1 bytes read"
3249
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003250run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3251 "$P_SRV" \
3252 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3253 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3254 0 \
3255 -s "Read from client: 1 bytes read"
3256
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003257run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3258 "$P_SRV" \
3259 "$P_CLI request_size=1 force_version=tls1 \
3260 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3261 trunc_hmac=1" \
3262 0 \
3263 -s "Read from client: 1 bytes read"
3264
3265run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003266 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003267 "$P_CLI request_size=1 force_version=tls1 \
3268 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3269 trunc_hmac=1" \
3270 0 \
3271 -s "Read from client: 1 bytes read"
3272
3273run_test "Small packet TLS 1.1 BlockCipher" \
3274 "$P_SRV" \
3275 "$P_CLI request_size=1 force_version=tls1_1 \
3276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3277 0 \
3278 -s "Read from client: 1 bytes read"
3279
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003280run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3281 "$P_SRV" \
3282 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3284 0 \
3285 -s "Read from client: 1 bytes read"
3286
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003287run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003288 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003289 "$P_CLI request_size=1 force_version=tls1_1 \
3290 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3291 0 \
3292 -s "Read from client: 1 bytes read"
3293
3294run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3295 "$P_SRV" \
3296 "$P_CLI request_size=1 force_version=tls1_1 \
3297 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3298 trunc_hmac=1" \
3299 0 \
3300 -s "Read from client: 1 bytes read"
3301
3302run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003303 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003304 "$P_CLI request_size=1 force_version=tls1_1 \
3305 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3306 trunc_hmac=1" \
3307 0 \
3308 -s "Read from client: 1 bytes read"
3309
3310run_test "Small packet TLS 1.2 BlockCipher" \
3311 "$P_SRV" \
3312 "$P_CLI request_size=1 force_version=tls1_2 \
3313 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3314 0 \
3315 -s "Read from client: 1 bytes read"
3316
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003317run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3318 "$P_SRV" \
3319 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3321 0 \
3322 -s "Read from client: 1 bytes read"
3323
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003324run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3325 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003326 "$P_CLI request_size=1 force_version=tls1_2 \
3327 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003328 0 \
3329 -s "Read from client: 1 bytes read"
3330
3331run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3332 "$P_SRV" \
3333 "$P_CLI request_size=1 force_version=tls1_2 \
3334 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3335 trunc_hmac=1" \
3336 0 \
3337 -s "Read from client: 1 bytes read"
3338
3339run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003340 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003341 "$P_CLI request_size=1 force_version=tls1_2 \
3342 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3343 0 \
3344 -s "Read from client: 1 bytes read"
3345
3346run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003347 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003348 "$P_CLI request_size=1 force_version=tls1_2 \
3349 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3350 trunc_hmac=1" \
3351 0 \
3352 -s "Read from client: 1 bytes read"
3353
3354run_test "Small packet TLS 1.2 AEAD" \
3355 "$P_SRV" \
3356 "$P_CLI request_size=1 force_version=tls1_2 \
3357 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3358 0 \
3359 -s "Read from client: 1 bytes read"
3360
3361run_test "Small packet TLS 1.2 AEAD shorter tag" \
3362 "$P_SRV" \
3363 "$P_CLI request_size=1 force_version=tls1_2 \
3364 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3365 0 \
3366 -s "Read from client: 1 bytes read"
3367
Janos Follath00efff72016-05-06 13:48:23 +01003368# A test for extensions in SSLv3
3369
3370requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3371run_test "SSLv3 with extensions, server side" \
3372 "$P_SRV min_version=ssl3 debug_level=3" \
3373 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3374 0 \
3375 -S "dumping 'client hello extensions'" \
3376 -S "server hello, total extension length:"
3377
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003378# Test for large packets
3379
Janos Follathe2681a42016-03-07 15:57:05 +00003380requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003381run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003382 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003383 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003384 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3385 0 \
3386 -s "Read from client: 16384 bytes read"
3387
Janos Follathe2681a42016-03-07 15:57:05 +00003388requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003389run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003390 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003391 "$P_CLI request_size=16384 force_version=ssl3 \
3392 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3393 0 \
3394 -s "Read from client: 16384 bytes read"
3395
3396run_test "Large packet TLS 1.0 BlockCipher" \
3397 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003398 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3400 0 \
3401 -s "Read from client: 16384 bytes read"
3402
3403run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3404 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003405 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003406 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3407 trunc_hmac=1" \
3408 0 \
3409 -s "Read from client: 16384 bytes read"
3410
3411run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003412 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003413 "$P_CLI request_size=16384 force_version=tls1 \
3414 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3415 trunc_hmac=1" \
3416 0 \
3417 -s "Read from client: 16384 bytes read"
3418
3419run_test "Large packet TLS 1.1 BlockCipher" \
3420 "$P_SRV" \
3421 "$P_CLI request_size=16384 force_version=tls1_1 \
3422 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3423 0 \
3424 -s "Read from client: 16384 bytes read"
3425
3426run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003427 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003428 "$P_CLI request_size=16384 force_version=tls1_1 \
3429 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3430 0 \
3431 -s "Read from client: 16384 bytes read"
3432
3433run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3434 "$P_SRV" \
3435 "$P_CLI request_size=16384 force_version=tls1_1 \
3436 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3437 trunc_hmac=1" \
3438 0 \
3439 -s "Read from client: 16384 bytes read"
3440
3441run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003442 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003443 "$P_CLI request_size=16384 force_version=tls1_1 \
3444 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3445 trunc_hmac=1" \
3446 0 \
3447 -s "Read from client: 16384 bytes read"
3448
3449run_test "Large packet TLS 1.2 BlockCipher" \
3450 "$P_SRV" \
3451 "$P_CLI request_size=16384 force_version=tls1_2 \
3452 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3453 0 \
3454 -s "Read from client: 16384 bytes read"
3455
3456run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3457 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003458 "$P_CLI request_size=16384 force_version=tls1_2 \
3459 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003460 0 \
3461 -s "Read from client: 16384 bytes read"
3462
3463run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3464 "$P_SRV" \
3465 "$P_CLI request_size=16384 force_version=tls1_2 \
3466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3467 trunc_hmac=1" \
3468 0 \
3469 -s "Read from client: 16384 bytes read"
3470
3471run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003472 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003473 "$P_CLI request_size=16384 force_version=tls1_2 \
3474 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3475 0 \
3476 -s "Read from client: 16384 bytes read"
3477
3478run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003479 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003480 "$P_CLI request_size=16384 force_version=tls1_2 \
3481 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3482 trunc_hmac=1" \
3483 0 \
3484 -s "Read from client: 16384 bytes read"
3485
3486run_test "Large packet TLS 1.2 AEAD" \
3487 "$P_SRV" \
3488 "$P_CLI request_size=16384 force_version=tls1_2 \
3489 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3490 0 \
3491 -s "Read from client: 16384 bytes read"
3492
3493run_test "Large packet TLS 1.2 AEAD shorter tag" \
3494 "$P_SRV" \
3495 "$P_CLI request_size=16384 force_version=tls1_2 \
3496 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3497 0 \
3498 -s "Read from client: 16384 bytes read"
3499
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003500# Tests for DTLS HelloVerifyRequest
3501
3502run_test "DTLS cookie: enabled" \
3503 "$P_SRV dtls=1 debug_level=2" \
3504 "$P_CLI dtls=1 debug_level=2" \
3505 0 \
3506 -s "cookie verification failed" \
3507 -s "cookie verification passed" \
3508 -S "cookie verification skipped" \
3509 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003510 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003511 -S "SSL - The requested feature is not available"
3512
3513run_test "DTLS cookie: disabled" \
3514 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3515 "$P_CLI dtls=1 debug_level=2" \
3516 0 \
3517 -S "cookie verification failed" \
3518 -S "cookie verification passed" \
3519 -s "cookie verification skipped" \
3520 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003521 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003522 -S "SSL - The requested feature is not available"
3523
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003524run_test "DTLS cookie: default (failing)" \
3525 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3526 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3527 1 \
3528 -s "cookie verification failed" \
3529 -S "cookie verification passed" \
3530 -S "cookie verification skipped" \
3531 -C "received hello verify request" \
3532 -S "hello verification requested" \
3533 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003534
3535requires_ipv6
3536run_test "DTLS cookie: enabled, IPv6" \
3537 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3538 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3539 0 \
3540 -s "cookie verification failed" \
3541 -s "cookie verification passed" \
3542 -S "cookie verification skipped" \
3543 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003544 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003545 -S "SSL - The requested feature is not available"
3546
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003547run_test "DTLS cookie: enabled, nbio" \
3548 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3549 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3550 0 \
3551 -s "cookie verification failed" \
3552 -s "cookie verification passed" \
3553 -S "cookie verification skipped" \
3554 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003555 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003556 -S "SSL - The requested feature is not available"
3557
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003558# Tests for client reconnecting from the same port with DTLS
3559
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003560not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003561run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003562 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3563 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003564 0 \
3565 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003566 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003567 -S "Client initiated reconnection from same port"
3568
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003569not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003570run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003571 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3572 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003573 0 \
3574 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003575 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003576 -s "Client initiated reconnection from same port"
3577
Paul Bakker362689d2016-05-13 10:33:25 +01003578not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3579run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003580 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3581 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003582 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003583 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003584 -s "Client initiated reconnection from same port"
3585
Paul Bakker362689d2016-05-13 10:33:25 +01003586only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3587run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3588 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3589 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3590 0 \
3591 -S "The operation timed out" \
3592 -s "Client initiated reconnection from same port"
3593
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003594run_test "DTLS client reconnect from same port: no cookies" \
3595 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003596 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3597 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003598 -s "The operation timed out" \
3599 -S "Client initiated reconnection from same port"
3600
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003601# Tests for various cases of client authentication with DTLS
3602# (focused on handshake flows and message parsing)
3603
3604run_test "DTLS client auth: required" \
3605 "$P_SRV dtls=1 auth_mode=required" \
3606 "$P_CLI dtls=1" \
3607 0 \
3608 -s "Verifying peer X.509 certificate... ok"
3609
3610run_test "DTLS client auth: optional, client has no cert" \
3611 "$P_SRV dtls=1 auth_mode=optional" \
3612 "$P_CLI dtls=1 crt_file=none key_file=none" \
3613 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003614 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003615
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003616run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003617 "$P_SRV dtls=1 auth_mode=none" \
3618 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3619 0 \
3620 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003621 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003622
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003623run_test "DTLS wrong PSK: badmac alert" \
3624 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3625 "$P_CLI dtls=1 psk=abc124" \
3626 1 \
3627 -s "SSL - Verification of the message MAC failed" \
3628 -c "SSL - A fatal alert message was received from our peer"
3629
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003630# Tests for receiving fragmented handshake messages with DTLS
3631
3632requires_gnutls
3633run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3634 "$G_SRV -u --mtu 2048 -a" \
3635 "$P_CLI dtls=1 debug_level=2" \
3636 0 \
3637 -C "found fragmented DTLS handshake message" \
3638 -C "error"
3639
3640requires_gnutls
3641run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3642 "$G_SRV -u --mtu 512" \
3643 "$P_CLI dtls=1 debug_level=2" \
3644 0 \
3645 -c "found fragmented DTLS handshake message" \
3646 -C "error"
3647
3648requires_gnutls
3649run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3650 "$G_SRV -u --mtu 128" \
3651 "$P_CLI dtls=1 debug_level=2" \
3652 0 \
3653 -c "found fragmented DTLS handshake message" \
3654 -C "error"
3655
3656requires_gnutls
3657run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3658 "$G_SRV -u --mtu 128" \
3659 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3660 0 \
3661 -c "found fragmented DTLS handshake message" \
3662 -C "error"
3663
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003664requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003665run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3666 "$G_SRV -u --mtu 256" \
3667 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3668 0 \
3669 -c "found fragmented DTLS handshake message" \
3670 -c "client hello, adding renegotiation extension" \
3671 -c "found renegotiation extension" \
3672 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003673 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003674 -C "error" \
3675 -s "Extra-header:"
3676
3677requires_gnutls
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003678run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3679 "$G_SRV -u --mtu 256" \
3680 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3681 0 \
3682 -c "found fragmented DTLS handshake message" \
3683 -c "client hello, adding renegotiation extension" \
3684 -c "found renegotiation extension" \
3685 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003686 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003687 -C "error" \
3688 -s "Extra-header:"
3689
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003690run_test "DTLS reassembly: no fragmentation (openssl server)" \
3691 "$O_SRV -dtls1 -mtu 2048" \
3692 "$P_CLI dtls=1 debug_level=2" \
3693 0 \
3694 -C "found fragmented DTLS handshake message" \
3695 -C "error"
3696
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003697run_test "DTLS reassembly: some fragmentation (openssl server)" \
3698 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003699 "$P_CLI dtls=1 debug_level=2" \
3700 0 \
3701 -c "found fragmented DTLS handshake message" \
3702 -C "error"
3703
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003704run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003705 "$O_SRV -dtls1 -mtu 256" \
3706 "$P_CLI dtls=1 debug_level=2" \
3707 0 \
3708 -c "found fragmented DTLS handshake message" \
3709 -C "error"
3710
3711run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3712 "$O_SRV -dtls1 -mtu 256" \
3713 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3714 0 \
3715 -c "found fragmented DTLS handshake message" \
3716 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003717
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003718# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003719
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003720not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003721run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003722 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003723 "$P_SRV dtls=1 debug_level=2" \
3724 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003725 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003726 -C "replayed record" \
3727 -S "replayed record" \
3728 -C "record from another epoch" \
3729 -S "record from another epoch" \
3730 -C "discarding invalid record" \
3731 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003732 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003733 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003734 -c "HTTP/1.0 200 OK"
3735
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003736not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003737run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003738 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003739 "$P_SRV dtls=1 debug_level=2" \
3740 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003741 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003742 -c "replayed record" \
3743 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003744 -c "discarding invalid record" \
3745 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003746 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003747 -s "Extra-header:" \
3748 -c "HTTP/1.0 200 OK"
3749
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003750run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3751 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003752 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3753 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003754 0 \
3755 -c "replayed record" \
3756 -S "replayed record" \
3757 -c "discarding invalid record" \
3758 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003759 -c "resend" \
3760 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003761 -s "Extra-header:" \
3762 -c "HTTP/1.0 200 OK"
3763
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003764run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003765 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003766 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003767 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003768 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003769 -c "discarding invalid record (mac)" \
3770 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003771 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003772 -c "HTTP/1.0 200 OK" \
3773 -S "too many records with bad MAC" \
3774 -S "Verification of the message MAC failed"
3775
3776run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3777 -p "$P_PXY bad_ad=1" \
3778 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3779 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3780 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003781 -C "discarding invalid record (mac)" \
3782 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003783 -S "Extra-header:" \
3784 -C "HTTP/1.0 200 OK" \
3785 -s "too many records with bad MAC" \
3786 -s "Verification of the message MAC failed"
3787
3788run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3789 -p "$P_PXY bad_ad=1" \
3790 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3791 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3792 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003793 -c "discarding invalid record (mac)" \
3794 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003795 -s "Extra-header:" \
3796 -c "HTTP/1.0 200 OK" \
3797 -S "too many records with bad MAC" \
3798 -S "Verification of the message MAC failed"
3799
3800run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3801 -p "$P_PXY bad_ad=1" \
3802 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3803 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3804 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003805 -c "discarding invalid record (mac)" \
3806 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003807 -s "Extra-header:" \
3808 -c "HTTP/1.0 200 OK" \
3809 -s "too many records with bad MAC" \
3810 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003811
3812run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003813 -p "$P_PXY delay_ccs=1" \
3814 "$P_SRV dtls=1 debug_level=1" \
3815 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003816 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003817 -c "record from another epoch" \
3818 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003819 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003820 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003821 -s "Extra-header:" \
3822 -c "HTTP/1.0 200 OK"
3823
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003824# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003825
Janos Follath74537a62016-09-02 13:45:28 +01003826client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003827run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003828 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003829 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3830 psk=abc123" \
3831 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003832 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3833 0 \
3834 -s "Extra-header:" \
3835 -c "HTTP/1.0 200 OK"
3836
Janos Follath74537a62016-09-02 13:45:28 +01003837client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003838run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3839 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003840 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3841 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003842 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3843 0 \
3844 -s "Extra-header:" \
3845 -c "HTTP/1.0 200 OK"
3846
Janos Follath74537a62016-09-02 13:45:28 +01003847client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003848run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3849 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003850 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3851 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003852 0 \
3853 -s "Extra-header:" \
3854 -c "HTTP/1.0 200 OK"
3855
Janos Follath74537a62016-09-02 13:45:28 +01003856client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003857run_test "DTLS proxy: 3d, FS, client auth" \
3858 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003859 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3860 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003861 0 \
3862 -s "Extra-header:" \
3863 -c "HTTP/1.0 200 OK"
3864
Janos Follath74537a62016-09-02 13:45:28 +01003865client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003866run_test "DTLS proxy: 3d, FS, ticket" \
3867 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003868 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3869 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003870 0 \
3871 -s "Extra-header:" \
3872 -c "HTTP/1.0 200 OK"
3873
Janos Follath74537a62016-09-02 13:45:28 +01003874client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003875run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3876 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003877 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3878 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003879 0 \
3880 -s "Extra-header:" \
3881 -c "HTTP/1.0 200 OK"
3882
Janos Follath74537a62016-09-02 13:45:28 +01003883client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003884run_test "DTLS proxy: 3d, max handshake, nbio" \
3885 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003886 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3887 auth_mode=required" \
3888 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003889 0 \
3890 -s "Extra-header:" \
3891 -c "HTTP/1.0 200 OK"
3892
Janos Follath74537a62016-09-02 13:45:28 +01003893client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003894run_test "DTLS proxy: 3d, min handshake, resumption" \
3895 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3896 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3897 psk=abc123 debug_level=3" \
3898 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3899 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3900 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3901 0 \
3902 -s "a session has been resumed" \
3903 -c "a session has been resumed" \
3904 -s "Extra-header:" \
3905 -c "HTTP/1.0 200 OK"
3906
Janos Follath74537a62016-09-02 13:45:28 +01003907client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003908run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3909 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3910 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3911 psk=abc123 debug_level=3 nbio=2" \
3912 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3913 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3914 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3915 0 \
3916 -s "a session has been resumed" \
3917 -c "a session has been resumed" \
3918 -s "Extra-header:" \
3919 -c "HTTP/1.0 200 OK"
3920
Janos Follath74537a62016-09-02 13:45:28 +01003921client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003922run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003923 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003924 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3925 psk=abc123 renegotiation=1 debug_level=2" \
3926 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3927 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003928 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3929 0 \
3930 -c "=> renegotiate" \
3931 -s "=> renegotiate" \
3932 -s "Extra-header:" \
3933 -c "HTTP/1.0 200 OK"
3934
Janos Follath74537a62016-09-02 13:45:28 +01003935client_needs_more_time 4
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003936run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3937 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003938 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3939 psk=abc123 renegotiation=1 debug_level=2" \
3940 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3941 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003942 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3943 0 \
3944 -c "=> renegotiate" \
3945 -s "=> renegotiate" \
3946 -s "Extra-header:" \
3947 -c "HTTP/1.0 200 OK"
3948
Janos Follath74537a62016-09-02 13:45:28 +01003949client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003950run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003951 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003952 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003953 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003954 debug_level=2" \
3955 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003956 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003957 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3958 0 \
3959 -c "=> renegotiate" \
3960 -s "=> renegotiate" \
3961 -s "Extra-header:" \
3962 -c "HTTP/1.0 200 OK"
3963
Janos Follath74537a62016-09-02 13:45:28 +01003964client_needs_more_time 4
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003965run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003966 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003967 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003968 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003969 debug_level=2 nbio=2" \
3970 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003971 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003972 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3973 0 \
3974 -c "=> renegotiate" \
3975 -s "=> renegotiate" \
3976 -s "Extra-header:" \
3977 -c "HTTP/1.0 200 OK"
3978
Janos Follath74537a62016-09-02 13:45:28 +01003979client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003980not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003981run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003982 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3983 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003984 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003985 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003986 -c "HTTP/1.0 200 OK"
3987
Janos Follath74537a62016-09-02 13:45:28 +01003988client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003989not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003990run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3991 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3992 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003993 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003994 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003995 -c "HTTP/1.0 200 OK"
3996
Janos Follath74537a62016-09-02 13:45:28 +01003997client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003998not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003999run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4000 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4001 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004002 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004003 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004004 -c "HTTP/1.0 200 OK"
4005
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004006requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004007client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004008not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004009run_test "DTLS proxy: 3d, gnutls server" \
4010 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4011 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004012 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004013 0 \
4014 -s "Extra-header:" \
4015 -c "Extra-header:"
4016
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004017requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004018client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004019not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004020run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4021 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4022 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004023 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004024 0 \
4025 -s "Extra-header:" \
4026 -c "Extra-header:"
4027
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004028requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004029client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004030not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004031run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4032 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4033 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004034 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004035 0 \
4036 -s "Extra-header:" \
4037 -c "Extra-header:"
4038
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004039# Final report
4040
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004041echo "------------------------------------------------------------------------"
4042
4043if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004044 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004045else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004046 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004047fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004048PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004049echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004050
4051exit $FAILS