blob: 9dc75e1e044834ff06114b5565eab8877e56a7f2 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
3# Test various options that are not covered by compat.sh
4#
5# Here the goal is not to cover every ciphersuite/version, but
6# rather specific options (max fragment length, truncated hmac, etc)
7# or procedures (session resumption from cache or ticket, renego, etc).
8#
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02009# Assumes a build with default options.
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010010
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010011set -u
12
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010013# default values, can be overriden by the environment
14: ${P_SRV:=../programs/ssl/ssl_server2}
15: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020016: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010017: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020018: ${GNUTLS_CLI:=gnutls-cli}
19: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskine39e29812017-05-16 17:53:03 +020020: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020022O_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 +010023O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020024G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010025G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskine39e29812017-05-16 17:53:03 +020026TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010027
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010028TESTS=0
29FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020030SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010031
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000032CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020033
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010034MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010035FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020036EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010037
38print_usage() {
39 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010040 printf " -h|--help\tPrint this help.\n"
41 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
42 printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
43 printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010044 printf " --seed\tInteger seed value to use for this test run (default: random)\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045}
46
47get_options() {
48 while [ $# -gt 0 ]; do
49 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010050 -f|--filter)
51 shift; FILTER=$1
52 ;;
53 -e|--exclude)
54 shift; EXCLUDE=$1
55 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010056 -m|--memcheck)
57 MEMCHECK=1
58 ;;
Gilles Peskinebb4aaf12017-11-30 15:56:20 +010059 --seed)
60 shift; SEED="$1"
61 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010062 -h|--help)
63 print_usage
64 exit 0
65 ;;
66 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +020067 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010068 print_usage
69 exit 1
70 ;;
71 esac
72 shift
73 done
74}
75
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +010076# skip next test if the flag is not enabled in config.h
77requires_config_enabled() {
78 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
79 SKIP_NEXT="YES"
80 fi
81}
82
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +020083# skip next test if the flag is enabled in config.h
84requires_config_disabled() {
85 if grep "^#define $1" $CONFIG_H > /dev/null; then
86 SKIP_NEXT="YES"
87 fi
88}
89
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +020090# skip next test if OpenSSL doesn't support FALLBACK_SCSV
91requires_openssl_with_fallback_scsv() {
92 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
93 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
94 then
95 OPENSSL_HAS_FBSCSV="YES"
96 else
97 OPENSSL_HAS_FBSCSV="NO"
98 fi
99 fi
100 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
101 SKIP_NEXT="YES"
102 fi
103}
104
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200105# skip next test if GnuTLS isn't available
106requires_gnutls() {
107 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200108 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200109 GNUTLS_AVAILABLE="YES"
110 else
111 GNUTLS_AVAILABLE="NO"
112 fi
113 fi
114 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
115 SKIP_NEXT="YES"
116 fi
117}
118
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200119# skip next test if IPv6 isn't available on this host
120requires_ipv6() {
121 if [ -z "${HAS_IPV6:-}" ]; then
122 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
123 SRV_PID=$!
124 sleep 1
125 kill $SRV_PID >/dev/null 2>&1
126 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
127 HAS_IPV6="NO"
128 else
129 HAS_IPV6="YES"
130 fi
131 rm -r $SRV_OUT
132 fi
133
134 if [ "$HAS_IPV6" = "NO" ]; then
135 SKIP_NEXT="YES"
136 fi
137}
138
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200139# skip the next test if valgrind is in use
140not_with_valgrind() {
141 if [ "$MEMCHECK" -gt 0 ]; then
142 SKIP_NEXT="YES"
143 fi
144}
145
Paul Bakker3b224ff2016-05-13 10:33:25 +0100146# skip the next test if valgrind is NOT in use
147only_with_valgrind() {
148 if [ "$MEMCHECK" -eq 0 ]; then
149 SKIP_NEXT="YES"
150 fi
151}
152
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200153# multiply the client timeout delay by the given factor for the next test
154needs_more_time() {
155 CLI_DELAY_FACTOR=$1
156}
157
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100158# print_name <name>
159print_name() {
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100160 printf "$1 "
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200161 LEN=$(( 72 - `echo "$1" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100162 for i in `seq 1 $LEN`; do printf '.'; done
163 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100164
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200165 TESTS=$(( $TESTS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100166}
167
168# fail <message>
169fail() {
170 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100171 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100172
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200173 mv $SRV_OUT o-srv-${TESTS}.log
174 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200175 if [ -n "$PXY_CMD" ]; then
176 mv $PXY_OUT o-pxy-${TESTS}.log
177 fi
178 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100179
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200180 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
181 echo " ! server output:"
182 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200183 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200184 echo " ! client output:"
185 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200186 if [ -n "$PXY_CMD" ]; then
187 echo " ! ========================================================"
188 echo " ! proxy output:"
189 cat o-pxy-${TESTS}.log
190 fi
191 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200192 fi
193
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200194 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100195}
196
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100197# is_polar <cmd_line>
198is_polar() {
199 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
200}
201
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200202# openssl s_server doesn't have -www with DTLS
203check_osrv_dtls() {
204 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
205 NEEDS_INPUT=1
206 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
207 else
208 NEEDS_INPUT=0
209 fi
210}
211
212# provide input to commands that need it
213provide_input() {
214 if [ $NEEDS_INPUT -eq 0 ]; then
215 return
216 fi
217
218 while true; do
219 echo "HTTP/1.0 200 OK"
220 sleep 1
221 done
222}
223
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100224# has_mem_err <log_file_name>
225has_mem_err() {
226 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
227 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
228 then
229 return 1 # false: does not have errors
230 else
231 return 0 # true: has errors
232 fi
233}
234
Gilles Peskine684a5172017-12-14 18:58:42 +0100235# Wait for process $2 to be listening on port $1
236if type lsof >/dev/null 2>/dev/null; then
237 wait_server_start() {
238 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200239 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine684a5172017-12-14 18:58:42 +0100240 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200241 else
Gilles Peskine684a5172017-12-14 18:58:42 +0100242 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200243 fi
Gilles Peskine684a5172017-12-14 18:58:42 +0100244 # Make a tight loop, server normally takes less than 1s to start.
245 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
246 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
247 echo "SERVERSTART TIMEOUT"
248 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
249 break
250 fi
251 # Linux and *BSD support decimal arguments to sleep. On other
252 # OSes this may be a tight loop.
253 sleep 0.1 2>/dev/null || true
254 done
255 }
256else
257 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200258 sleep "$START_DELAY"
Gilles Peskine684a5172017-12-14 18:58:42 +0100259 }
260fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200261
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200262# wait for client to terminate and set CLI_EXIT
263# must be called right after starting the client
264wait_client_done() {
265 CLI_PID=$!
266
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200267 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
268 CLI_DELAY_FACTOR=1
269
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200270 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200271 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200272
273 wait $CLI_PID
274 CLI_EXIT=$?
275
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200276 kill $DOG_PID >/dev/null 2>&1
277 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200278
279 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
280}
281
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200282# check if the given command uses dtls and sets global variable DTLS
283detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200284 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200285 DTLS=1
286 else
287 DTLS=0
288 fi
289}
290
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200291# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100292# Options: -s pattern pattern that must be present in server output
293# -c pattern pattern that must be present in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100294# -u pattern lines after pattern must be unique in client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100295# -S pattern pattern that must be absent in server output
296# -C pattern pattern that must be absent in client output
Janos Follath6d3e3382016-09-07 15:48:48 +0100297# -U pattern lines after pattern must be unique in server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100298run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100299 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200300 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100301
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100302 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
303 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200304 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100305 return
306 fi
307
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100308 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100309
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200310 # should we skip?
311 if [ "X$SKIP_NEXT" = "XYES" ]; then
312 SKIP_NEXT="NO"
313 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200314 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200315 return
316 fi
317
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200318 # does this test use a proxy?
319 if [ "X$1" = "X-p" ]; then
320 PXY_CMD="$2"
321 shift 2
322 else
323 PXY_CMD=""
324 fi
325
326 # get commands and client output
327 SRV_CMD="$1"
328 CLI_CMD="$2"
329 CLI_EXPECT="$3"
330 shift 3
331
332 # fix client port
333 if [ -n "$PXY_CMD" ]; then
334 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
335 else
336 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
337 fi
338
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200339 # update DTLS variable
340 detect_dtls "$SRV_CMD"
341
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100342 # prepend valgrind to our commands if active
343 if [ "$MEMCHECK" -gt 0 ]; then
344 if is_polar "$SRV_CMD"; then
345 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
346 fi
347 if is_polar "$CLI_CMD"; then
348 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
349 fi
350 fi
351
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200352 TIMES_LEFT=2
353 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200354 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200355
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200356 # run the commands
357 if [ -n "$PXY_CMD" ]; then
358 echo "$PXY_CMD" > $PXY_OUT
359 $PXY_CMD >> $PXY_OUT 2>&1 &
360 PXY_PID=$!
361 # assume proxy starts faster than server
362 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200363
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200364 check_osrv_dtls
365 echo "$SRV_CMD" > $SRV_OUT
366 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
367 SRV_PID=$!
Gilles Peskine684a5172017-12-14 18:58:42 +0100368 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200369
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200370 echo "$CLI_CMD" > $CLI_OUT
371 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
372 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100373
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200374 # terminate the server (and the proxy)
375 kill $SRV_PID
376 wait $SRV_PID
377 if [ -n "$PXY_CMD" ]; then
378 kill $PXY_PID >/dev/null 2>&1
379 wait $PXY_PID
380 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100381
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200382 # retry only on timeouts
383 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
384 printf "RETRY "
385 else
386 TIMES_LEFT=0
387 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200388 done
389
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100390 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200391 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100392 # expected client exit to incorrectly succeed in case of catastrophic
393 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100394 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200395 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100396 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100397 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100398 return
399 fi
400 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100401 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200402 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100403 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100404 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100405 return
406 fi
407 fi
408
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100409 # check server exit code
410 if [ $? != 0 ]; then
411 fail "server fail"
412 return
413 fi
414
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100415 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100416 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
417 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100418 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200419 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100420 return
421 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100422
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100423 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200424 # lines beginning with == are added by valgrind, ignore them
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100425 while [ $# -gt 0 ]
426 do
427 case $1 in
428 "-s")
Janos Follath6d3e3382016-09-07 15:48:48 +0100429 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
430 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100431 return
432 fi
433 ;;
434
435 "-c")
Janos Follath6d3e3382016-09-07 15:48:48 +0100436 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
437 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100438 return
439 fi
440 ;;
441
442 "-S")
Janos Follath6d3e3382016-09-07 15:48:48 +0100443 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
444 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100445 return
446 fi
447 ;;
448
449 "-C")
Janos Follath6d3e3382016-09-07 15:48:48 +0100450 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
451 fail "pattern '$2' MUST NOT be present in the Client output"
452 return
453 fi
454 ;;
455
456 # The filtering in the following two options (-u and -U) do the following
457 # - ignore valgrind output
458 # - filter out everything but lines right after the pattern occurances
459 # - keep one of each non-unique line
460 # - count how many lines remain
461 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
462 # if there were no duplicates.
463 "-U")
464 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
465 fail "lines following pattern '$2' must be unique in Server output"
466 return
467 fi
468 ;;
469
470 "-u")
471 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
472 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100473 return
474 fi
475 ;;
476
477 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200478 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100479 exit 1
480 esac
481 shift 2
482 done
483
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100484 # check valgrind's results
485 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200486 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100487 fail "Server has memory errors"
488 return
489 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200490 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100491 fail "Client has memory errors"
492 return
493 fi
494 fi
495
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100496 # if we're here, everything is ok
497 echo "PASS"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200498 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100499}
500
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100501cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200502 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200503 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
504 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
505 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
506 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100507 exit 1
508}
509
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100510#
511# MAIN
512#
513
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000514if cd $( dirname $0 ); then :; else
515 echo "cd $( dirname $0 ) failed" >&2
516 exit 1
517fi
518
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100519get_options "$@"
520
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100521# sanity checks, avoid an avalanche of errors
522if [ ! -x "$P_SRV" ]; then
523 echo "Command '$P_SRV' is not an executable file"
524 exit 1
525fi
526if [ ! -x "$P_CLI" ]; then
527 echo "Command '$P_CLI' is not an executable file"
528 exit 1
529fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200530if [ ! -x "$P_PXY" ]; then
531 echo "Command '$P_PXY' is not an executable file"
532 exit 1
533fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100534if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
535 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100536 exit 1
537fi
538
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200539# used by watchdog
540MAIN_PID="$$"
541
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200542# be more patient with valgrind
543if [ "$MEMCHECK" -gt 0 ]; then
544 START_DELAY=3
545 DOG_DELAY=30
546else
547 START_DELAY=1
548 DOG_DELAY=10
549fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200550CLI_DELAY_FACTOR=1
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200551
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200552# Pick a "unique" server port in the range 10000-19999, and a proxy port
553PORT_BASE="0000$$"
Manuel Pégourié-Gonnard3a173f42015-01-22 13:30:33 +0000554PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200555SRV_PORT="1$PORT_BASE"
556PXY_PORT="2$PORT_BASE"
557unset PORT_BASE
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200558
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200559# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000560# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200561P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
562P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Gilles Peskinebb4aaf12017-11-30 15:56:20 +0100563P_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 +0200564O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200565O_CLI="$O_CLI -connect localhost:+SRV_PORT"
566G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000567G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200568
Gilles Peskine35db5ba2017-05-10 10:13:59 +0200569# Allow SHA-1, because many of our test certificates use it
570P_SRV="$P_SRV allow_sha1=1"
571P_CLI="$P_CLI allow_sha1=1"
572
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200573# Also pick a unique name for intermediate files
574SRV_OUT="srv_out.$$"
575CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200576PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200577SESSION="session.$$"
578
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200579SKIP_NEXT="NO"
580
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100581trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100582
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200583# Basic test
584
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200585# Checks that:
586# - things work with all ciphersuites active (used with config-full in all.sh)
587# - the expected (highest security) parameters are selected
588# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200589run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200590 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200591 "$P_CLI" \
592 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200593 -s "Protocol is TLSv1.2" \
594 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
595 -s "client hello v3, signature_algorithm ext: 6" \
596 -s "ECDHE curve: secp521r1" \
597 -S "error" \
598 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200599
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000600run_test "Default, DTLS" \
601 "$P_SRV dtls=1" \
602 "$P_CLI dtls=1" \
603 0 \
604 -s "Protocol is DTLSv1.2" \
605 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
606
Janos Follath6d3e3382016-09-07 15:48:48 +0100607# Test for uniqueness of IVs in AEAD ciphersuites
608run_test "Unique IV in GCM" \
609 "$P_SRV exchanges=20 debug_level=4" \
610 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
611 0 \
612 -u "IV used" \
613 -U "IV used"
614
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100615# Tests for rc4 option
616
Simon Butcher6eb066e2016-05-19 22:12:18 +0100617requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100618run_test "RC4: server disabled, client enabled" \
619 "$P_SRV" \
620 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
621 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100622 -s "SSL - The server has no ciphersuites in common"
623
Simon Butcher6eb066e2016-05-19 22:12:18 +0100624requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100625run_test "RC4: server half, client enabled" \
626 "$P_SRV arc4=1" \
627 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
628 1 \
629 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100630
631run_test "RC4: server enabled, client disabled" \
632 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
633 "$P_CLI" \
634 1 \
635 -s "SSL - The server has no ciphersuites in common"
636
637run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100638 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100639 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
640 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100641 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100642 -S "SSL - The server has no ciphersuites in common"
643
Gilles Peskineae765992017-05-09 15:59:24 +0200644# Tests for SHA-1 support
645
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200646requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200647run_test "SHA-1 forbidden by default in server certificate" \
648 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
649 "$P_CLI debug_level=2 allow_sha1=0" \
650 1 \
651 -c "The certificate is signed with an unacceptable hash"
652
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200653requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
654run_test "SHA-1 forbidden by default in server certificate" \
655 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
656 "$P_CLI debug_level=2 allow_sha1=0" \
657 0
658
Gilles Peskineae765992017-05-09 15:59:24 +0200659run_test "SHA-1 explicitly allowed in server certificate" \
660 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
661 "$P_CLI allow_sha1=1" \
662 0
663
664run_test "SHA-256 allowed by default in server certificate" \
665 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
666 "$P_CLI allow_sha1=0" \
667 0
668
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200669requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskineae765992017-05-09 15:59:24 +0200670run_test "SHA-1 forbidden by default in client certificate" \
671 "$P_SRV auth_mode=required allow_sha1=0" \
672 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
673 1 \
674 -s "The certificate is signed with an unacceptable hash"
675
Manuel Pégourié-Gonnard55393662017-06-08 17:51:08 +0200676requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
677run_test "SHA-1 forbidden by default in client certificate" \
678 "$P_SRV auth_mode=required allow_sha1=0" \
679 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
680 0
681
Gilles Peskineae765992017-05-09 15:59:24 +0200682run_test "SHA-1 explicitly allowed in client certificate" \
683 "$P_SRV auth_mode=required allow_sha1=1" \
684 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
685 0
686
687run_test "SHA-256 allowed by default in client certificate" \
688 "$P_SRV auth_mode=required allow_sha1=0" \
689 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
690 0
691
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100692# Tests for Truncated HMAC extension
693
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100694run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200695 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100696 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100697 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100698 -s "dumping 'computed mac' (20 bytes)" \
699 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100700
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100701run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200702 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100703 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
704 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100705 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100706 -s "dumping 'computed mac' (20 bytes)" \
707 -S "dumping 'computed mac' (10 bytes)"
708
709run_test "Truncated HMAC: client enabled, server default" \
710 "$P_SRV debug_level=4" \
711 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
712 trunc_hmac=1" \
713 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100714 -s "dumping 'computed mac' (20 bytes)" \
715 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100716
717run_test "Truncated HMAC: client enabled, server disabled" \
718 "$P_SRV debug_level=4 trunc_hmac=0" \
719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
720 trunc_hmac=1" \
721 0 \
722 -s "dumping 'computed mac' (20 bytes)" \
723 -S "dumping 'computed mac' (10 bytes)"
724
725run_test "Truncated HMAC: client enabled, server enabled" \
726 "$P_SRV debug_level=4 trunc_hmac=1" \
727 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
728 trunc_hmac=1" \
729 0 \
730 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100731 -s "dumping 'computed mac' (10 bytes)"
732
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100733# Tests for Encrypt-then-MAC extension
734
735run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100736 "$P_SRV debug_level=3 \
737 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100738 "$P_CLI debug_level=3" \
739 0 \
740 -c "client hello, adding encrypt_then_mac extension" \
741 -s "found encrypt then mac extension" \
742 -s "server hello, adding encrypt then mac extension" \
743 -c "found encrypt_then_mac extension" \
744 -c "using encrypt then mac" \
745 -s "using encrypt then mac"
746
747run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100748 "$P_SRV debug_level=3 etm=0 \
749 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100750 "$P_CLI debug_level=3 etm=1" \
751 0 \
752 -c "client hello, adding encrypt_then_mac extension" \
753 -s "found encrypt then mac extension" \
754 -S "server hello, adding encrypt then mac extension" \
755 -C "found encrypt_then_mac extension" \
756 -C "using encrypt then mac" \
757 -S "using encrypt then mac"
758
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100759run_test "Encrypt then MAC: client enabled, aead cipher" \
760 "$P_SRV debug_level=3 etm=1 \
761 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
762 "$P_CLI debug_level=3 etm=1" \
763 0 \
764 -c "client hello, adding encrypt_then_mac extension" \
765 -s "found encrypt then mac extension" \
766 -S "server hello, adding encrypt then mac extension" \
767 -C "found encrypt_then_mac extension" \
768 -C "using encrypt then mac" \
769 -S "using encrypt then mac"
770
771run_test "Encrypt then MAC: client enabled, stream cipher" \
772 "$P_SRV debug_level=3 etm=1 \
773 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100774 "$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 +0100775 0 \
776 -c "client hello, adding encrypt_then_mac extension" \
777 -s "found encrypt then mac extension" \
778 -S "server hello, adding encrypt then mac extension" \
779 -C "found encrypt_then_mac extension" \
780 -C "using encrypt then mac" \
781 -S "using encrypt then mac"
782
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100783run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100784 "$P_SRV debug_level=3 etm=1 \
785 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100786 "$P_CLI debug_level=3 etm=0" \
787 0 \
788 -C "client hello, adding encrypt_then_mac extension" \
789 -S "found encrypt then mac extension" \
790 -S "server hello, adding encrypt then mac extension" \
791 -C "found encrypt_then_mac extension" \
792 -C "using encrypt then mac" \
793 -S "using encrypt then mac"
794
Janos Follath542ee5d2016-03-07 15:57:05 +0000795requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100796run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100797 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100798 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100799 "$P_CLI debug_level=3 force_version=ssl3" \
800 0 \
801 -C "client hello, adding encrypt_then_mac extension" \
802 -S "found encrypt then mac extension" \
803 -S "server hello, adding encrypt then mac extension" \
804 -C "found encrypt_then_mac extension" \
805 -C "using encrypt then mac" \
806 -S "using encrypt then mac"
807
Janos Follath542ee5d2016-03-07 15:57:05 +0000808requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100809run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100810 "$P_SRV debug_level=3 force_version=ssl3 \
811 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100812 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100813 0 \
814 -c "client hello, adding encrypt_then_mac extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100815 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100816 -S "server hello, adding encrypt then mac extension" \
817 -C "found encrypt_then_mac extension" \
818 -C "using encrypt then mac" \
819 -S "using encrypt then mac"
820
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200821# Tests for Extended Master Secret extension
822
823run_test "Extended Master Secret: default" \
824 "$P_SRV debug_level=3" \
825 "$P_CLI debug_level=3" \
826 0 \
827 -c "client hello, adding extended_master_secret extension" \
828 -s "found extended master secret extension" \
829 -s "server hello, adding extended master secret extension" \
830 -c "found extended_master_secret extension" \
831 -c "using extended master secret" \
832 -s "using extended master secret"
833
834run_test "Extended Master Secret: client enabled, server disabled" \
835 "$P_SRV debug_level=3 extended_ms=0" \
836 "$P_CLI debug_level=3 extended_ms=1" \
837 0 \
838 -c "client hello, adding extended_master_secret extension" \
839 -s "found extended master secret extension" \
840 -S "server hello, adding extended master secret extension" \
841 -C "found extended_master_secret extension" \
842 -C "using extended master secret" \
843 -S "using extended master secret"
844
845run_test "Extended Master Secret: client disabled, server enabled" \
846 "$P_SRV debug_level=3 extended_ms=1" \
847 "$P_CLI debug_level=3 extended_ms=0" \
848 0 \
849 -C "client hello, adding extended_master_secret extension" \
850 -S "found extended master secret extension" \
851 -S "server hello, adding extended master secret extension" \
852 -C "found extended_master_secret extension" \
853 -C "using extended master secret" \
854 -S "using extended master secret"
855
Janos Follath542ee5d2016-03-07 15:57:05 +0000856requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200857run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100858 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200859 "$P_CLI debug_level=3 force_version=ssl3" \
860 0 \
861 -C "client hello, adding extended_master_secret extension" \
862 -S "found extended master secret extension" \
863 -S "server hello, adding extended master secret extension" \
864 -C "found extended_master_secret extension" \
865 -C "using extended master secret" \
866 -S "using extended master secret"
867
Janos Follath542ee5d2016-03-07 15:57:05 +0000868requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200869run_test "Extended Master Secret: client enabled, server SSLv3" \
870 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100871 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200872 0 \
873 -c "client hello, adding extended_master_secret extension" \
Janos Follathb700c462016-05-06 13:48:23 +0100874 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200875 -S "server hello, adding extended master secret extension" \
876 -C "found extended_master_secret extension" \
877 -C "using extended master secret" \
878 -S "using extended master secret"
879
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200880# Tests for FALLBACK_SCSV
881
882run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200883 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200884 "$P_CLI debug_level=3 force_version=tls1_1" \
885 0 \
886 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200887 -S "received FALLBACK_SCSV" \
888 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200889 -C "is a fatal alert message (msg 86)"
890
891run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200892 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200893 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
894 0 \
895 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200896 -S "received FALLBACK_SCSV" \
897 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200898 -C "is a fatal alert message (msg 86)"
899
900run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200901 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200902 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200903 1 \
904 -c "adding FALLBACK_SCSV" \
905 -s "received FALLBACK_SCSV" \
906 -s "inapropriate fallback" \
907 -c "is a fatal alert message (msg 86)"
908
909run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200910 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200911 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200912 0 \
913 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200914 -s "received FALLBACK_SCSV" \
915 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200916 -C "is a fatal alert message (msg 86)"
917
918requires_openssl_with_fallback_scsv
919run_test "Fallback SCSV: default, openssl server" \
920 "$O_SRV" \
921 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
922 0 \
923 -C "adding FALLBACK_SCSV" \
924 -C "is a fatal alert message (msg 86)"
925
926requires_openssl_with_fallback_scsv
927run_test "Fallback SCSV: enabled, openssl server" \
928 "$O_SRV" \
929 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
930 1 \
931 -c "adding FALLBACK_SCSV" \
932 -c "is a fatal alert message (msg 86)"
933
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200934requires_openssl_with_fallback_scsv
935run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200936 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200937 "$O_CLI -tls1_1" \
938 0 \
939 -S "received FALLBACK_SCSV" \
940 -S "inapropriate fallback"
941
942requires_openssl_with_fallback_scsv
943run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200944 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200945 "$O_CLI -tls1_1 -fallback_scsv" \
946 1 \
947 -s "received FALLBACK_SCSV" \
948 -s "inapropriate fallback"
949
950requires_openssl_with_fallback_scsv
951run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +0200952 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +0200953 "$O_CLI -fallback_scsv" \
954 0 \
955 -s "received FALLBACK_SCSV" \
956 -S "inapropriate fallback"
957
Gilles Peskine39e29812017-05-16 17:53:03 +0200958## ClientHello generated with
959## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
960## then manually twiddling the ciphersuite list.
961## The ClientHello content is spelled out below as a hex string as
962## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
963## The expected response is an inappropriate_fallback alert.
964requires_openssl_with_fallback_scsv
965run_test "Fallback SCSV: beginning of list" \
966 "$P_SRV debug_level=2" \
967 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
968 0 \
969 -s "received FALLBACK_SCSV" \
970 -s "inapropriate fallback"
971
972requires_openssl_with_fallback_scsv
973run_test "Fallback SCSV: end of list" \
974 "$P_SRV debug_level=2" \
975 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
976 0 \
977 -s "received FALLBACK_SCSV" \
978 -s "inapropriate fallback"
979
980## Here the expected response is a valid ServerHello prefix, up to the random.
981requires_openssl_with_fallback_scsv
982run_test "Fallback SCSV: not in list" \
983 "$P_SRV debug_level=2" \
984 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
985 0 \
986 -S "received FALLBACK_SCSV" \
987 -S "inapropriate fallback"
988
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +0100989# Tests for CBC 1/n-1 record splitting
990
991run_test "CBC Record splitting: TLS 1.2, no splitting" \
992 "$P_SRV" \
993 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
994 request_size=123 force_version=tls1_2" \
995 0 \
996 -s "Read from client: 123 bytes read" \
997 -S "Read from client: 1 bytes read" \
998 -S "122 bytes read"
999
1000run_test "CBC Record splitting: TLS 1.1, no splitting" \
1001 "$P_SRV" \
1002 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1003 request_size=123 force_version=tls1_1" \
1004 0 \
1005 -s "Read from client: 123 bytes read" \
1006 -S "Read from client: 1 bytes read" \
1007 -S "122 bytes read"
1008
1009run_test "CBC Record splitting: TLS 1.0, splitting" \
1010 "$P_SRV" \
1011 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1012 request_size=123 force_version=tls1" \
1013 0 \
1014 -S "Read from client: 123 bytes read" \
1015 -s "Read from client: 1 bytes read" \
1016 -s "122 bytes read"
1017
Janos Follath542ee5d2016-03-07 15:57:05 +00001018requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001019run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001020 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001021 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1022 request_size=123 force_version=ssl3" \
1023 0 \
1024 -S "Read from client: 123 bytes read" \
1025 -s "Read from client: 1 bytes read" \
1026 -s "122 bytes read"
1027
1028run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001029 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001030 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1031 request_size=123 force_version=tls1" \
1032 0 \
1033 -s "Read from client: 123 bytes read" \
1034 -S "Read from client: 1 bytes read" \
1035 -S "122 bytes read"
1036
1037run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1038 "$P_SRV" \
1039 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1040 request_size=123 force_version=tls1 recsplit=0" \
1041 0 \
1042 -s "Read from client: 123 bytes read" \
1043 -S "Read from client: 1 bytes read" \
1044 -S "122 bytes read"
1045
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001046run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1047 "$P_SRV nbio=2" \
1048 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1049 request_size=123 force_version=tls1" \
1050 0 \
1051 -S "Read from client: 123 bytes read" \
1052 -s "Read from client: 1 bytes read" \
1053 -s "122 bytes read"
1054
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001055# Tests for Session Tickets
1056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001057run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001058 "$P_SRV debug_level=3 tickets=1" \
1059 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001060 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001061 -c "client hello, adding session ticket extension" \
1062 -s "found session ticket extension" \
1063 -s "server hello, adding session ticket extension" \
1064 -c "found session_ticket extension" \
1065 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001066 -S "session successfully restored from cache" \
1067 -s "session successfully restored from ticket" \
1068 -s "a session has been resumed" \
1069 -c "a session has been resumed"
1070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001071run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001072 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1073 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001074 0 \
1075 -c "client hello, adding session ticket extension" \
1076 -s "found session ticket extension" \
1077 -s "server hello, adding session ticket extension" \
1078 -c "found session_ticket extension" \
1079 -c "parse new session ticket" \
1080 -S "session successfully restored from cache" \
1081 -s "session successfully restored from ticket" \
1082 -s "a session has been resumed" \
1083 -c "a session has been resumed"
1084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001085run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001086 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1087 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001088 0 \
1089 -c "client hello, adding session ticket extension" \
1090 -s "found session ticket extension" \
1091 -s "server hello, adding session ticket extension" \
1092 -c "found session_ticket extension" \
1093 -c "parse new session ticket" \
1094 -S "session successfully restored from cache" \
1095 -S "session successfully restored from ticket" \
1096 -S "a session has been resumed" \
1097 -C "a session has been resumed"
1098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001099run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001100 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001101 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001102 0 \
1103 -c "client hello, adding session ticket extension" \
1104 -c "found session_ticket extension" \
1105 -c "parse new session ticket" \
1106 -c "a session has been resumed"
1107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001108run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001109 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001110 "( $O_CLI -sess_out $SESSION; \
1111 $O_CLI -sess_in $SESSION; \
1112 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001113 0 \
1114 -s "found session ticket extension" \
1115 -s "server hello, adding session ticket extension" \
1116 -S "session successfully restored from cache" \
1117 -s "session successfully restored from ticket" \
1118 -s "a session has been resumed"
1119
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001120# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001122run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001123 "$P_SRV debug_level=3 tickets=0" \
1124 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001125 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001126 -c "client hello, adding session ticket extension" \
1127 -s "found session ticket extension" \
1128 -S "server hello, adding session ticket extension" \
1129 -C "found session_ticket extension" \
1130 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001131 -s "session successfully restored from cache" \
1132 -S "session successfully restored from ticket" \
1133 -s "a session has been resumed" \
1134 -c "a session has been resumed"
1135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001136run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001137 "$P_SRV debug_level=3 tickets=1" \
1138 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001139 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001140 -C "client hello, adding session ticket extension" \
1141 -S "found session ticket extension" \
1142 -S "server hello, adding session ticket extension" \
1143 -C "found session_ticket extension" \
1144 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001145 -s "session successfully restored from cache" \
1146 -S "session successfully restored from ticket" \
1147 -s "a session has been resumed" \
1148 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001149
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001150run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001151 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1152 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001153 0 \
1154 -S "session successfully restored from cache" \
1155 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001156 -S "a session has been resumed" \
1157 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001159run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001160 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1161 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001162 0 \
1163 -s "session successfully restored from cache" \
1164 -S "session successfully restored from ticket" \
1165 -s "a session has been resumed" \
1166 -c "a session has been resumed"
1167
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001168run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001169 "$P_SRV debug_level=3 tickets=0" \
1170 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001171 0 \
1172 -s "session successfully restored from cache" \
1173 -S "session successfully restored from ticket" \
1174 -s "a session has been resumed" \
1175 -c "a session has been resumed"
1176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001177run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001178 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1179 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001180 0 \
1181 -S "session successfully restored from cache" \
1182 -S "session successfully restored from ticket" \
1183 -S "a session has been resumed" \
1184 -C "a session has been resumed"
1185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001186run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001187 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1188 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001189 0 \
1190 -s "session successfully restored from cache" \
1191 -S "session successfully restored from ticket" \
1192 -s "a session has been resumed" \
1193 -c "a session has been resumed"
1194
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001195run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001196 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001197 "( $O_CLI -sess_out $SESSION; \
1198 $O_CLI -sess_in $SESSION; \
1199 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001200 0 \
1201 -s "found session ticket extension" \
1202 -S "server hello, adding session ticket extension" \
1203 -s "session successfully restored from cache" \
1204 -S "session successfully restored from ticket" \
1205 -s "a session has been resumed"
1206
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001207run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001208 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001210 0 \
1211 -C "found session_ticket extension" \
1212 -C "parse new session ticket" \
1213 -c "a session has been resumed"
1214
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001215# Tests for Max Fragment Length extension
1216
Hanno Becker64691dc2017-09-22 16:58:50 +01001217MAX_CONTENT_LEN_EXPECT='16384'
1218MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1219
1220if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1221 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1222 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1223 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1224 printf "\n"
1225 printf "The tests assume this value and if it changes, the tests in this\n"
1226 printf "script should also be adjusted.\n"
1227 printf "\n"
1228
1229 exit 1
1230fi
1231
Hanno Becker05607782017-09-18 15:00:34 +01001232requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001233run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001234 "$P_SRV debug_level=3" \
1235 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001236 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001237 -c "Maximum fragment length is 16384" \
1238 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001239 -C "client hello, adding max_fragment_length extension" \
1240 -S "found max fragment length extension" \
1241 -S "server hello, max_fragment_length extension" \
1242 -C "found max_fragment_length extension"
1243
Hanno Becker05607782017-09-18 15:00:34 +01001244requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001245run_test "Max fragment length: enabled, default, larger message" \
1246 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001247 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001248 0 \
1249 -c "Maximum fragment length is 16384" \
1250 -s "Maximum fragment length is 16384" \
1251 -C "client hello, adding max_fragment_length extension" \
1252 -S "found max fragment length extension" \
1253 -S "server hello, max_fragment_length extension" \
1254 -C "found max_fragment_length extension" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001255 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001256 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001257 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001258
1259requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1260run_test "Max fragment length, DTLS: enabled, default, larger message" \
1261 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001262 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001263 1 \
1264 -c "Maximum fragment length is 16384" \
1265 -s "Maximum fragment length is 16384" \
1266 -C "client hello, adding max_fragment_length extension" \
1267 -S "found max fragment length extension" \
1268 -S "server hello, max_fragment_length extension" \
1269 -C "found max_fragment_length extension" \
1270 -c "fragment larger than.*maximum "
1271
1272requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1273run_test "Max fragment length: disabled, larger message" \
1274 "$P_SRV debug_level=3" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001275 "$P_CLI debug_level=3 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001276 0 \
1277 -C "Maximum fragment length is 16384" \
1278 -S "Maximum fragment length is 16384" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001279 -c "16385 bytes written in 2 fragments" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001280 -s "16384 bytes read" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001281 -s "1 bytes read"
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001282
1283requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1284run_test "Max fragment length DTLS: disabled, larger message" \
1285 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker6ed76f72017-10-18 14:42:01 +01001286 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Becker2fabe5f2017-09-18 15:01:50 +01001287 1 \
1288 -C "Maximum fragment length is 16384" \
1289 -S "Maximum fragment length is 16384" \
1290 -c "fragment larger than.*maximum "
1291
1292requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001293run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001294 "$P_SRV debug_level=3" \
1295 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001296 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001297 -c "Maximum fragment length is 4096" \
1298 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001299 -c "client hello, adding max_fragment_length extension" \
1300 -s "found max fragment length extension" \
1301 -s "server hello, max_fragment_length extension" \
1302 -c "found max_fragment_length extension"
1303
Hanno Becker05607782017-09-18 15:00:34 +01001304requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001305run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001306 "$P_SRV debug_level=3 max_frag_len=4096" \
1307 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001308 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001309 -c "Maximum fragment length is 16384" \
1310 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001311 -C "client hello, adding max_fragment_length extension" \
1312 -S "found max fragment length extension" \
1313 -S "server hello, max_fragment_length extension" \
1314 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001315
Hanno Becker05607782017-09-18 15:00:34 +01001316requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001317requires_gnutls
1318run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001319 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001320 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001321 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001322 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001323 -c "client hello, adding max_fragment_length extension" \
1324 -c "found max_fragment_length extension"
1325
Hanno Becker05607782017-09-18 15:00:34 +01001326requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001327run_test "Max fragment length: client, message just fits" \
1328 "$P_SRV debug_level=3" \
1329 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1330 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001331 -c "Maximum fragment length is 2048" \
1332 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001333 -c "client hello, adding max_fragment_length extension" \
1334 -s "found max fragment length extension" \
1335 -s "server hello, max_fragment_length extension" \
1336 -c "found max_fragment_length extension" \
1337 -c "2048 bytes written in 1 fragments" \
1338 -s "2048 bytes read"
1339
Hanno Becker05607782017-09-18 15:00:34 +01001340requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001341run_test "Max fragment length: client, larger message" \
1342 "$P_SRV debug_level=3" \
1343 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1344 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001345 -c "Maximum fragment length is 2048" \
1346 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001347 -c "client hello, adding max_fragment_length extension" \
1348 -s "found max fragment length extension" \
1349 -s "server hello, max_fragment_length extension" \
1350 -c "found max_fragment_length extension" \
1351 -c "2345 bytes written in 2 fragments" \
1352 -s "2048 bytes read" \
1353 -s "297 bytes read"
1354
Hanno Becker05607782017-09-18 15:00:34 +01001355requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001356run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001357 "$P_SRV debug_level=3 dtls=1" \
1358 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1359 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001360 -c "Maximum fragment length is 2048" \
1361 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001362 -c "client hello, adding max_fragment_length extension" \
1363 -s "found max fragment length extension" \
1364 -s "server hello, max_fragment_length extension" \
1365 -c "found max_fragment_length extension" \
1366 -c "fragment larger than.*maximum"
1367
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001368# Tests for renegotiation
1369
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001370run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001371 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001372 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001373 0 \
1374 -C "client hello, adding renegotiation extension" \
1375 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1376 -S "found renegotiation extension" \
1377 -s "server hello, secure renegotiation extension" \
1378 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001379 -C "=> renegotiate" \
1380 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001381 -S "write hello request"
1382
Hanno Becker78891132017-10-24 11:54:55 +01001383requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001384run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001385 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001386 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001387 0 \
1388 -c "client hello, adding renegotiation extension" \
1389 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1390 -s "found renegotiation extension" \
1391 -s "server hello, secure renegotiation extension" \
1392 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001393 -c "=> renegotiate" \
1394 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001395 -S "write hello request"
1396
Hanno Becker78891132017-10-24 11:54:55 +01001397requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001398run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001399 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001400 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001401 0 \
1402 -c "client hello, adding renegotiation extension" \
1403 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1404 -s "found renegotiation extension" \
1405 -s "server hello, secure renegotiation extension" \
1406 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001407 -c "=> renegotiate" \
1408 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001409 -s "write hello request"
1410
Janos Follath5f1dd802017-10-05 12:29:42 +01001411# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1412# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1413# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001414requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001415run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1416 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1417 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1418 0 \
1419 -c "client hello, adding renegotiation extension" \
1420 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1421 -s "found renegotiation extension" \
1422 -s "server hello, secure renegotiation extension" \
1423 -c "found renegotiation extension" \
1424 -c "=> renegotiate" \
1425 -s "=> renegotiate" \
1426 -S "write hello request" \
1427 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1428
1429# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1430# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1431# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker78891132017-10-24 11:54:55 +01001432requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follath5f1dd802017-10-05 12:29:42 +01001433run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1434 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1435 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1436 0 \
1437 -c "client hello, adding renegotiation extension" \
1438 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1439 -s "found renegotiation extension" \
1440 -s "server hello, secure renegotiation extension" \
1441 -c "found renegotiation extension" \
1442 -c "=> renegotiate" \
1443 -s "=> renegotiate" \
1444 -s "write hello request" \
1445 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1446
Hanno Becker78891132017-10-24 11:54:55 +01001447requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001448run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001449 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001450 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001451 0 \
1452 -c "client hello, adding renegotiation extension" \
1453 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1454 -s "found renegotiation extension" \
1455 -s "server hello, secure renegotiation extension" \
1456 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001457 -c "=> renegotiate" \
1458 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001459 -s "write hello request"
1460
Hanno Becker78891132017-10-24 11:54:55 +01001461requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001462run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001463 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001464 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001465 1 \
1466 -c "client hello, adding renegotiation extension" \
1467 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1468 -S "found renegotiation extension" \
1469 -s "server hello, secure renegotiation extension" \
1470 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001471 -c "=> renegotiate" \
1472 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001473 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001474 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001475 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001476
Hanno Becker78891132017-10-24 11:54:55 +01001477requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001478run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001479 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001480 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001481 0 \
1482 -C "client hello, adding renegotiation extension" \
1483 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1484 -S "found renegotiation extension" \
1485 -s "server hello, secure renegotiation extension" \
1486 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001487 -C "=> renegotiate" \
1488 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001489 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001490 -S "SSL - An unexpected message was received from our peer" \
1491 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001492
Hanno Becker78891132017-10-24 11:54:55 +01001493requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001494run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001495 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001496 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001497 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001498 0 \
1499 -C "client hello, adding renegotiation extension" \
1500 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1501 -S "found renegotiation extension" \
1502 -s "server hello, secure renegotiation extension" \
1503 -c "found renegotiation extension" \
1504 -C "=> renegotiate" \
1505 -S "=> renegotiate" \
1506 -s "write hello request" \
1507 -S "SSL - An unexpected message was received from our peer" \
1508 -S "failed"
1509
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001510# delay 2 for 1 alert record + 1 application data record
Hanno Becker78891132017-10-24 11:54:55 +01001511requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001512run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001514 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001515 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001516 0 \
1517 -C "client hello, adding renegotiation extension" \
1518 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1519 -S "found renegotiation extension" \
1520 -s "server hello, secure renegotiation extension" \
1521 -c "found renegotiation extension" \
1522 -C "=> renegotiate" \
1523 -S "=> renegotiate" \
1524 -s "write hello request" \
1525 -S "SSL - An unexpected message was received from our peer" \
1526 -S "failed"
1527
Hanno Becker78891132017-10-24 11:54:55 +01001528requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001529run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001530 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001531 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001532 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001533 0 \
1534 -C "client hello, adding renegotiation extension" \
1535 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1536 -S "found renegotiation extension" \
1537 -s "server hello, secure renegotiation extension" \
1538 -c "found renegotiation extension" \
1539 -C "=> renegotiate" \
1540 -S "=> renegotiate" \
1541 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001542 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001543
Hanno Becker78891132017-10-24 11:54:55 +01001544requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001545run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001546 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001547 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001548 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001549 0 \
1550 -c "client hello, adding renegotiation extension" \
1551 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1552 -s "found renegotiation extension" \
1553 -s "server hello, secure renegotiation extension" \
1554 -c "found renegotiation extension" \
1555 -c "=> renegotiate" \
1556 -s "=> renegotiate" \
1557 -s "write hello request" \
1558 -S "SSL - An unexpected message was received from our peer" \
1559 -S "failed"
1560
Hanno Becker78891132017-10-24 11:54:55 +01001561requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001562run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001563 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001564 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1565 0 \
1566 -C "client hello, adding renegotiation extension" \
1567 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1568 -S "found renegotiation extension" \
1569 -s "server hello, secure renegotiation extension" \
1570 -c "found renegotiation extension" \
1571 -S "record counter limit reached: renegotiate" \
1572 -C "=> renegotiate" \
1573 -S "=> renegotiate" \
1574 -S "write hello request" \
1575 -S "SSL - An unexpected message was received from our peer" \
1576 -S "failed"
1577
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001578# one extra exchange to be able to complete renego
Hanno Becker78891132017-10-24 11:54:55 +01001579requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001580run_test "Renegotiation: periodic, just above 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é-Gonnard9835bc02015-01-14 14:41:58 +01001582 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001583 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
Hanno Becker78891132017-10-24 11:54:55 +01001596requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001597run_test "Renegotiation: periodic, two times 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=7 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
Hanno Becker78891132017-10-24 11:54:55 +01001613requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001614run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001615 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001616 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1617 0 \
1618 -C "client hello, adding renegotiation extension" \
1619 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1620 -S "found renegotiation extension" \
1621 -s "server hello, secure renegotiation extension" \
1622 -c "found renegotiation extension" \
1623 -S "record counter limit reached: renegotiate" \
1624 -C "=> renegotiate" \
1625 -S "=> renegotiate" \
1626 -S "write hello request" \
1627 -S "SSL - An unexpected message was received from our peer" \
1628 -S "failed"
1629
Hanno Becker78891132017-10-24 11:54:55 +01001630requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001631run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001632 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001633 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001634 0 \
1635 -c "client hello, adding renegotiation extension" \
1636 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1637 -s "found renegotiation extension" \
1638 -s "server hello, secure renegotiation extension" \
1639 -c "found renegotiation extension" \
1640 -c "=> renegotiate" \
1641 -s "=> renegotiate" \
1642 -S "write hello request"
1643
Hanno Becker78891132017-10-24 11:54:55 +01001644requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001645run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001646 "$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 +02001647 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=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
Hanno Becker78891132017-10-24 11:54:55 +01001658requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001659run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001660 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001662 0 \
1663 -c "client hello, adding renegotiation extension" \
1664 -c "found renegotiation extension" \
1665 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001666 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001667 -C "error" \
1668 -c "HTTP/1.0 200 [Oo][Kk]"
1669
Paul Bakker539d9722015-02-08 16:18:35 +01001670requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001671requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001672run_test "Renegotiation: gnutls server strict, client-initiated" \
1673 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001674 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001675 0 \
1676 -c "client hello, adding renegotiation extension" \
1677 -c "found renegotiation extension" \
1678 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001679 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001680 -C "error" \
1681 -c "HTTP/1.0 200 [Oo][Kk]"
1682
Paul Bakker539d9722015-02-08 16:18:35 +01001683requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001684requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001685run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1686 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1687 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1688 1 \
1689 -c "client hello, adding renegotiation extension" \
1690 -C "found renegotiation extension" \
1691 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001692 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001693 -c "error" \
1694 -C "HTTP/1.0 200 [Oo][Kk]"
1695
Paul Bakker539d9722015-02-08 16:18:35 +01001696requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001697requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001698run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1699 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1700 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1701 allow_legacy=0" \
1702 1 \
1703 -c "client hello, adding renegotiation extension" \
1704 -C "found renegotiation extension" \
1705 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001706 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001707 -c "error" \
1708 -C "HTTP/1.0 200 [Oo][Kk]"
1709
Paul Bakker539d9722015-02-08 16:18:35 +01001710requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001711requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001712run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1713 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1714 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1715 allow_legacy=1" \
1716 0 \
1717 -c "client hello, adding renegotiation extension" \
1718 -C "found renegotiation extension" \
1719 -c "=> renegotiate" \
1720 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001721 -C "error" \
1722 -c "HTTP/1.0 200 [Oo][Kk]"
1723
Hanno Becker78891132017-10-24 11:54:55 +01001724requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001725run_test "Renegotiation: DTLS, client-initiated" \
1726 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1727 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1728 0 \
1729 -c "client hello, adding renegotiation extension" \
1730 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1731 -s "found renegotiation extension" \
1732 -s "server hello, secure renegotiation extension" \
1733 -c "found renegotiation extension" \
1734 -c "=> renegotiate" \
1735 -s "=> renegotiate" \
1736 -S "write hello request"
1737
Hanno Becker78891132017-10-24 11:54:55 +01001738requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001739run_test "Renegotiation: DTLS, server-initiated" \
1740 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001741 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1742 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001743 0 \
1744 -c "client hello, adding renegotiation extension" \
1745 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1746 -s "found renegotiation extension" \
1747 -s "server hello, secure renegotiation extension" \
1748 -c "found renegotiation extension" \
1749 -c "=> renegotiate" \
1750 -s "=> renegotiate" \
1751 -s "write hello request"
1752
Hanno Becker78891132017-10-24 11:54:55 +01001753requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG9b1927b2017-01-19 16:30:57 +00001754run_test "Renegotiation: DTLS, renego_period overflow" \
1755 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1756 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1757 0 \
1758 -c "client hello, adding renegotiation extension" \
1759 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1760 -s "found renegotiation extension" \
1761 -s "server hello, secure renegotiation extension" \
1762 -s "record counter limit reached: renegotiate" \
1763 -c "=> renegotiate" \
1764 -s "=> renegotiate" \
Hanno Becker78891132017-10-24 11:54:55 +01001765 -s "write hello request"
Andres AG9b1927b2017-01-19 16:30:57 +00001766
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001767requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01001768requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001769run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1770 "$G_SRV -u --mtu 4096" \
1771 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1772 0 \
1773 -c "client hello, adding renegotiation extension" \
1774 -c "found renegotiation extension" \
1775 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001776 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001777 -C "error" \
1778 -s "Extra-header:"
1779
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001780# Test for the "secure renegotation" extension only (no actual renegotiation)
1781
Paul Bakker539d9722015-02-08 16:18:35 +01001782requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001783run_test "Renego ext: gnutls server strict, client default" \
1784 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1785 "$P_CLI debug_level=3" \
1786 0 \
1787 -c "found renegotiation extension" \
1788 -C "error" \
1789 -c "HTTP/1.0 200 [Oo][Kk]"
1790
Paul Bakker539d9722015-02-08 16:18:35 +01001791requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001792run_test "Renego ext: gnutls server unsafe, client default" \
1793 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1794 "$P_CLI debug_level=3" \
1795 0 \
1796 -C "found renegotiation extension" \
1797 -C "error" \
1798 -c "HTTP/1.0 200 [Oo][Kk]"
1799
Paul Bakker539d9722015-02-08 16:18:35 +01001800requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001801run_test "Renego ext: gnutls server unsafe, client break legacy" \
1802 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1803 "$P_CLI debug_level=3 allow_legacy=-1" \
1804 1 \
1805 -C "found renegotiation extension" \
1806 -c "error" \
1807 -C "HTTP/1.0 200 [Oo][Kk]"
1808
Paul Bakker539d9722015-02-08 16:18:35 +01001809requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001810run_test "Renego ext: gnutls client strict, server default" \
1811 "$P_SRV debug_level=3" \
1812 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1813 0 \
1814 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1815 -s "server hello, secure renegotiation extension"
1816
Paul Bakker539d9722015-02-08 16:18:35 +01001817requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001818run_test "Renego ext: gnutls client unsafe, server default" \
1819 "$P_SRV debug_level=3" \
1820 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1821 0 \
1822 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1823 -S "server hello, secure renegotiation extension"
1824
Paul Bakker539d9722015-02-08 16:18:35 +01001825requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001826run_test "Renego ext: gnutls client unsafe, server break legacy" \
1827 "$P_SRV debug_level=3 allow_legacy=-1" \
1828 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1829 1 \
1830 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1831 -S "server hello, secure renegotiation extension"
1832
Janos Follath365b2262016-02-17 10:11:21 +00001833# Tests for silently dropping trailing extra bytes in .der certificates
1834
1835requires_gnutls
1836run_test "DER format: no trailing bytes" \
1837 "$P_SRV crt_file=data_files/server5-der0.crt \
1838 key_file=data_files/server5.key" \
1839 "$G_CLI " \
1840 0 \
1841 -c "Handshake was completed" \
1842
1843requires_gnutls
1844run_test "DER format: with a trailing zero byte" \
1845 "$P_SRV crt_file=data_files/server5-der1a.crt \
1846 key_file=data_files/server5.key" \
1847 "$G_CLI " \
1848 0 \
1849 -c "Handshake was completed" \
1850
1851requires_gnutls
1852run_test "DER format: with a trailing random byte" \
1853 "$P_SRV crt_file=data_files/server5-der1b.crt \
1854 key_file=data_files/server5.key" \
1855 "$G_CLI " \
1856 0 \
1857 -c "Handshake was completed" \
1858
1859requires_gnutls
1860run_test "DER format: with 2 trailing random bytes" \
1861 "$P_SRV crt_file=data_files/server5-der2.crt \
1862 key_file=data_files/server5.key" \
1863 "$G_CLI " \
1864 0 \
1865 -c "Handshake was completed" \
1866
1867requires_gnutls
1868run_test "DER format: with 4 trailing random bytes" \
1869 "$P_SRV crt_file=data_files/server5-der4.crt \
1870 key_file=data_files/server5.key" \
1871 "$G_CLI " \
1872 0 \
1873 -c "Handshake was completed" \
1874
1875requires_gnutls
1876run_test "DER format: with 8 trailing random bytes" \
1877 "$P_SRV crt_file=data_files/server5-der8.crt \
1878 key_file=data_files/server5.key" \
1879 "$G_CLI " \
1880 0 \
1881 -c "Handshake was completed" \
1882
1883requires_gnutls
1884run_test "DER format: with 9 trailing random bytes" \
1885 "$P_SRV crt_file=data_files/server5-der9.crt \
1886 key_file=data_files/server5.key" \
1887 "$G_CLI " \
1888 0 \
1889 -c "Handshake was completed" \
1890
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001891# Tests for auth_mode
1892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001893run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001894 "$P_SRV crt_file=data_files/server5-badsign.crt \
1895 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001896 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001897 1 \
1898 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001899 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001900 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001901 -c "X509 - Certificate verification failed"
1902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001903run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001904 "$P_SRV crt_file=data_files/server5-badsign.crt \
1905 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001906 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001907 0 \
1908 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001909 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001910 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001911 -C "X509 - Certificate verification failed"
1912
Hanno Becker61c0c702017-05-15 16:05:15 +01001913run_test "Authentication: server goodcert, client optional, no trusted CA" \
1914 "$P_SRV" \
1915 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
1916 0 \
1917 -c "x509_verify_cert() returned" \
1918 -c "! The certificate is not correctly signed by the trusted CA" \
1919 -c "! Certificate verification flags"\
1920 -C "! mbedtls_ssl_handshake returned" \
1921 -C "X509 - Certificate verification failed" \
1922 -C "SSL - No CA Chain is set, but required to operate"
1923
1924run_test "Authentication: server goodcert, client required, no trusted CA" \
1925 "$P_SRV" \
1926 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
1927 1 \
1928 -c "x509_verify_cert() returned" \
1929 -c "! The certificate is not correctly signed by the trusted CA" \
1930 -c "! Certificate verification flags"\
1931 -c "! mbedtls_ssl_handshake returned" \
1932 -c "SSL - No CA Chain is set, but required to operate"
1933
1934# The purpose of the next two tests is to test the client's behaviour when receiving a server
1935# certificate with an unsupported elliptic curve. This should usually not happen because
1936# the client informs the server about the supported curves - it does, though, in the
1937# corner case of a static ECDH suite, because the server doesn't check the curve on that
1938# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
1939# different means to have the server ignoring the client's supported curve list.
1940
1941requires_config_enabled MBEDTLS_ECP_C
1942run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
1943 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1944 crt_file=data_files/server5.ku-ka.crt" \
1945 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
1946 1 \
1947 -c "bad certificate (EC key curve)"\
1948 -c "! Certificate verification flags"\
1949 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
1950
1951requires_config_enabled MBEDTLS_ECP_C
1952run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
1953 "$P_SRV debug_level=1 key_file=data_files/server5.key \
1954 crt_file=data_files/server5.ku-ka.crt" \
1955 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
1956 1 \
1957 -c "bad certificate (EC key curve)"\
1958 -c "! Certificate verification flags"\
1959 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
1960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001961run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001962 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001963 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001964 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001965 0 \
1966 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01001967 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001968 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001969 -C "X509 - Certificate verification failed"
1970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001971run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001972 "$P_SRV debug_level=3 auth_mode=required" \
1973 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001974 key_file=data_files/server5.key" \
1975 1 \
1976 -S "skip write certificate request" \
1977 -C "skip parse certificate request" \
1978 -c "got a certificate request" \
1979 -C "skip write certificate" \
1980 -C "skip write certificate verify" \
1981 -S "skip parse certificate verify" \
1982 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02001983 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001984 -s "! mbedtls_ssl_handshake returned" \
1985 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001986 -s "X509 - Certificate verification failed"
1987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001988run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001989 "$P_SRV debug_level=3 auth_mode=optional" \
1990 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001991 key_file=data_files/server5.key" \
1992 0 \
1993 -S "skip write certificate request" \
1994 -C "skip parse certificate request" \
1995 -c "got a certificate request" \
1996 -C "skip write certificate" \
1997 -C "skip write certificate verify" \
1998 -S "skip parse certificate verify" \
1999 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002000 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002001 -S "! mbedtls_ssl_handshake returned" \
2002 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002003 -S "X509 - Certificate verification failed"
2004
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002005run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002006 "$P_SRV debug_level=3 auth_mode=none" \
2007 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002008 key_file=data_files/server5.key" \
2009 0 \
2010 -s "skip write certificate request" \
2011 -C "skip parse certificate request" \
2012 -c "got no certificate request" \
2013 -c "skip write certificate" \
2014 -c "skip write certificate verify" \
2015 -s "skip parse certificate verify" \
2016 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002017 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002018 -S "! mbedtls_ssl_handshake returned" \
2019 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002020 -S "X509 - Certificate verification failed"
2021
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002022run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002023 "$P_SRV debug_level=3 auth_mode=optional" \
2024 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002025 0 \
2026 -S "skip write certificate request" \
2027 -C "skip parse certificate request" \
2028 -c "got a certificate request" \
2029 -C "skip write certificate$" \
2030 -C "got no certificate to send" \
2031 -S "SSLv3 client has no certificate" \
2032 -c "skip write certificate verify" \
2033 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002034 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002035 -S "! mbedtls_ssl_handshake returned" \
2036 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002037 -S "X509 - Certificate verification failed"
2038
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002039run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002040 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002041 "$O_CLI" \
2042 0 \
2043 -S "skip write certificate request" \
2044 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002045 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002046 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002047 -S "X509 - Certificate verification failed"
2048
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002049run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002050 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002051 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002052 0 \
2053 -C "skip parse certificate request" \
2054 -c "got a certificate request" \
2055 -C "skip write certificate$" \
2056 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002057 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002058
Janos Follath542ee5d2016-03-07 15:57:05 +00002059requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002060run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002061 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002062 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002063 0 \
2064 -S "skip write certificate request" \
2065 -C "skip parse certificate request" \
2066 -c "got a certificate request" \
2067 -C "skip write certificate$" \
2068 -c "skip write certificate verify" \
2069 -c "got no certificate to send" \
2070 -s "SSLv3 client has no certificate" \
2071 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002072 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002073 -S "! mbedtls_ssl_handshake returned" \
2074 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002075 -S "X509 - Certificate verification failed"
2076
Manuel Pégourié-Gonnard591035d2017-06-26 10:45:33 +02002077run_test "Authentication: server max_int chain, client default" \
2078 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2079 key_file=data_files/dir-maxpath/09.key" \
2080 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2081 0 \
2082 -C "X509 - A fatal error occured"
2083
2084run_test "Authentication: server max_int+1 chain, client default" \
2085 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2086 key_file=data_files/dir-maxpath/10.key" \
2087 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2088 1 \
2089 -c "X509 - A fatal error occured"
2090
2091run_test "Authentication: server max_int+1 chain, client optional" \
2092 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2093 key_file=data_files/dir-maxpath/10.key" \
2094 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2095 auth_mode=optional" \
2096 1 \
2097 -c "X509 - A fatal error occured"
2098
2099run_test "Authentication: server max_int+1 chain, client none" \
2100 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2101 key_file=data_files/dir-maxpath/10.key" \
2102 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2103 auth_mode=none" \
2104 0 \
2105 -C "X509 - A fatal error occured"
2106
2107run_test "Authentication: client max_int+1 chain, server default" \
2108 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2109 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2110 key_file=data_files/dir-maxpath/10.key" \
2111 0 \
2112 -S "X509 - A fatal error occured"
2113
2114run_test "Authentication: client max_int+1 chain, server optional" \
2115 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2116 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2117 key_file=data_files/dir-maxpath/10.key" \
2118 1 \
2119 -s "X509 - A fatal error occured"
2120
2121run_test "Authentication: client max_int+1 chain, server required" \
2122 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2123 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2124 key_file=data_files/dir-maxpath/10.key" \
2125 1 \
2126 -s "X509 - A fatal error occured"
2127
2128run_test "Authentication: client max_int chain, server required" \
2129 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2130 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2131 key_file=data_files/dir-maxpath/09.key" \
2132 0 \
2133 -S "X509 - A fatal error occured"
2134
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002135# Tests for certificate selection based on SHA verson
2136
2137run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2138 "$P_SRV crt_file=data_files/server5.crt \
2139 key_file=data_files/server5.key \
2140 crt_file2=data_files/server5-sha1.crt \
2141 key_file2=data_files/server5.key" \
2142 "$P_CLI force_version=tls1_2" \
2143 0 \
2144 -c "signed using.*ECDSA with SHA256" \
2145 -C "signed using.*ECDSA with SHA1"
2146
2147run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2148 "$P_SRV crt_file=data_files/server5.crt \
2149 key_file=data_files/server5.key \
2150 crt_file2=data_files/server5-sha1.crt \
2151 key_file2=data_files/server5.key" \
2152 "$P_CLI force_version=tls1_1" \
2153 0 \
2154 -C "signed using.*ECDSA with SHA256" \
2155 -c "signed using.*ECDSA with SHA1"
2156
2157run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2158 "$P_SRV crt_file=data_files/server5.crt \
2159 key_file=data_files/server5.key \
2160 crt_file2=data_files/server5-sha1.crt \
2161 key_file2=data_files/server5.key" \
2162 "$P_CLI force_version=tls1" \
2163 0 \
2164 -C "signed using.*ECDSA with SHA256" \
2165 -c "signed using.*ECDSA with SHA1"
2166
2167run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2168 "$P_SRV crt_file=data_files/server5.crt \
2169 key_file=data_files/server5.key \
2170 crt_file2=data_files/server6.crt \
2171 key_file2=data_files/server6.key" \
2172 "$P_CLI force_version=tls1_1" \
2173 0 \
2174 -c "serial number.*09" \
2175 -c "signed using.*ECDSA with SHA256" \
2176 -C "signed using.*ECDSA with SHA1"
2177
2178run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2179 "$P_SRV crt_file=data_files/server6.crt \
2180 key_file=data_files/server6.key \
2181 crt_file2=data_files/server5.crt \
2182 key_file2=data_files/server5.key" \
2183 "$P_CLI force_version=tls1_1" \
2184 0 \
2185 -c "serial number.*0A" \
2186 -c "signed using.*ECDSA with SHA256" \
2187 -C "signed using.*ECDSA with SHA1"
2188
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002189# tests for SNI
2190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002191run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002192 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002193 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002194 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002195 0 \
2196 -S "parse ServerName extension" \
2197 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2198 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002199
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002200run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002201 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002202 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002203 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 +02002204 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002205 0 \
2206 -s "parse ServerName extension" \
2207 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2208 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002209
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002210run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002211 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002212 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002213 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 +02002214 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002215 0 \
2216 -s "parse ServerName extension" \
2217 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2218 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002220run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002221 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002222 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002223 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 +02002224 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002225 1 \
2226 -s "parse ServerName extension" \
2227 -s "ssl_sni_wrapper() returned" \
2228 -s "mbedtls_ssl_handshake returned" \
2229 -c "mbedtls_ssl_handshake returned" \
2230 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002231
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002232run_test "SNI: client auth no override: optional" \
2233 "$P_SRV debug_level=3 auth_mode=optional \
2234 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2235 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2236 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002237 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002238 -S "skip write certificate request" \
2239 -C "skip parse certificate request" \
2240 -c "got a certificate request" \
2241 -C "skip write certificate" \
2242 -C "skip write certificate verify" \
2243 -S "skip parse certificate verify"
2244
2245run_test "SNI: client auth override: none -> optional" \
2246 "$P_SRV debug_level=3 auth_mode=none \
2247 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2248 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2249 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002250 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002251 -S "skip write certificate request" \
2252 -C "skip parse certificate request" \
2253 -c "got a certificate request" \
2254 -C "skip write certificate" \
2255 -C "skip write certificate verify" \
2256 -S "skip parse certificate verify"
2257
2258run_test "SNI: client auth override: optional -> none" \
2259 "$P_SRV debug_level=3 auth_mode=optional \
2260 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2261 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2262 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002263 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002264 -s "skip write certificate request" \
2265 -C "skip parse certificate request" \
2266 -c "got no certificate request" \
2267 -c "skip write certificate" \
2268 -c "skip write certificate verify" \
2269 -s "skip parse certificate verify"
2270
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002271run_test "SNI: CA no override" \
2272 "$P_SRV debug_level=3 auth_mode=optional \
2273 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2274 ca_file=data_files/test-ca.crt \
2275 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2276 "$P_CLI debug_level=3 server_name=localhost \
2277 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2278 1 \
2279 -S "skip write certificate request" \
2280 -C "skip parse certificate request" \
2281 -c "got a certificate request" \
2282 -C "skip write certificate" \
2283 -C "skip write certificate verify" \
2284 -S "skip parse certificate verify" \
2285 -s "x509_verify_cert() returned" \
2286 -s "! The certificate is not correctly signed by the trusted CA" \
2287 -S "The certificate has been revoked (is on a CRL)"
2288
2289run_test "SNI: CA override" \
2290 "$P_SRV debug_level=3 auth_mode=optional \
2291 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2292 ca_file=data_files/test-ca.crt \
2293 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2294 "$P_CLI debug_level=3 server_name=localhost \
2295 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2296 0 \
2297 -S "skip write certificate request" \
2298 -C "skip parse certificate request" \
2299 -c "got a certificate request" \
2300 -C "skip write certificate" \
2301 -C "skip write certificate verify" \
2302 -S "skip parse certificate verify" \
2303 -S "x509_verify_cert() returned" \
2304 -S "! The certificate is not correctly signed by the trusted CA" \
2305 -S "The certificate has been revoked (is on a CRL)"
2306
2307run_test "SNI: CA override with CRL" \
2308 "$P_SRV debug_level=3 auth_mode=optional \
2309 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2310 ca_file=data_files/test-ca.crt \
2311 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2312 "$P_CLI debug_level=3 server_name=localhost \
2313 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2314 1 \
2315 -S "skip write certificate request" \
2316 -C "skip parse certificate request" \
2317 -c "got a certificate request" \
2318 -C "skip write certificate" \
2319 -C "skip write certificate verify" \
2320 -S "skip parse certificate verify" \
2321 -s "x509_verify_cert() returned" \
2322 -S "! The certificate is not correctly signed by the trusted CA" \
2323 -s "The certificate has been revoked (is on a CRL)"
2324
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002325# Tests for non-blocking I/O: exercise a variety of handshake flows
2326
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002327run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002328 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2329 "$P_CLI nbio=2 tickets=0" \
2330 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002331 -S "mbedtls_ssl_handshake returned" \
2332 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002333 -c "Read from server: .* bytes read"
2334
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002335run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002336 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2337 "$P_CLI nbio=2 tickets=0" \
2338 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002339 -S "mbedtls_ssl_handshake returned" \
2340 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002341 -c "Read from server: .* bytes read"
2342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002343run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002344 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2345 "$P_CLI nbio=2 tickets=1" \
2346 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002347 -S "mbedtls_ssl_handshake returned" \
2348 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002349 -c "Read from server: .* bytes read"
2350
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002351run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002352 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2353 "$P_CLI nbio=2 tickets=1" \
2354 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002355 -S "mbedtls_ssl_handshake returned" \
2356 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002357 -c "Read from server: .* bytes read"
2358
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002359run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002360 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2361 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2362 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002363 -S "mbedtls_ssl_handshake returned" \
2364 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002365 -c "Read from server: .* bytes read"
2366
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002367run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002368 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2369 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2370 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002371 -S "mbedtls_ssl_handshake returned" \
2372 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002373 -c "Read from server: .* bytes read"
2374
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002375run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002376 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2377 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2378 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002379 -S "mbedtls_ssl_handshake returned" \
2380 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002381 -c "Read from server: .* bytes read"
2382
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002383# Tests for version negotiation
2384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002385run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002386 "$P_SRV" \
2387 "$P_CLI" \
2388 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002389 -S "mbedtls_ssl_handshake returned" \
2390 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002391 -s "Protocol is TLSv1.2" \
2392 -c "Protocol is TLSv1.2"
2393
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002394run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002395 "$P_SRV" \
2396 "$P_CLI max_version=tls1_1" \
2397 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002398 -S "mbedtls_ssl_handshake returned" \
2399 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002400 -s "Protocol is TLSv1.1" \
2401 -c "Protocol is TLSv1.1"
2402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002403run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002404 "$P_SRV max_version=tls1_1" \
2405 "$P_CLI" \
2406 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002407 -S "mbedtls_ssl_handshake returned" \
2408 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002409 -s "Protocol is TLSv1.1" \
2410 -c "Protocol is TLSv1.1"
2411
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002412run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002413 "$P_SRV max_version=tls1_1" \
2414 "$P_CLI max_version=tls1_1" \
2415 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002416 -S "mbedtls_ssl_handshake returned" \
2417 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002418 -s "Protocol is TLSv1.1" \
2419 -c "Protocol is TLSv1.1"
2420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002421run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002422 "$P_SRV min_version=tls1_1" \
2423 "$P_CLI max_version=tls1_1" \
2424 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002425 -S "mbedtls_ssl_handshake returned" \
2426 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002427 -s "Protocol is TLSv1.1" \
2428 -c "Protocol is TLSv1.1"
2429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002430run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002431 "$P_SRV max_version=tls1_1" \
2432 "$P_CLI min_version=tls1_1" \
2433 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002434 -S "mbedtls_ssl_handshake returned" \
2435 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002436 -s "Protocol is TLSv1.1" \
2437 -c "Protocol is TLSv1.1"
2438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002439run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002440 "$P_SRV max_version=tls1_1" \
2441 "$P_CLI min_version=tls1_2" \
2442 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002443 -s "mbedtls_ssl_handshake returned" \
2444 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002445 -c "SSL - Handshake protocol not within min/max boundaries"
2446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002447run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002448 "$P_SRV min_version=tls1_2" \
2449 "$P_CLI max_version=tls1_1" \
2450 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002451 -s "mbedtls_ssl_handshake returned" \
2452 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002453 -s "SSL - Handshake protocol not within min/max boundaries"
2454
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002455# Tests for ALPN extension
2456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002457run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002458 "$P_SRV debug_level=3" \
2459 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002460 0 \
2461 -C "client hello, adding alpn extension" \
2462 -S "found alpn extension" \
2463 -C "got an alert message, type: \\[2:120]" \
2464 -S "server hello, adding alpn extension" \
2465 -C "found alpn extension " \
2466 -C "Application Layer Protocol is" \
2467 -S "Application Layer Protocol is"
2468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002469run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002470 "$P_SRV debug_level=3" \
2471 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002472 0 \
2473 -c "client hello, adding alpn extension" \
2474 -s "found alpn extension" \
2475 -C "got an alert message, type: \\[2:120]" \
2476 -S "server hello, adding alpn extension" \
2477 -C "found alpn extension " \
2478 -c "Application Layer Protocol is (none)" \
2479 -S "Application Layer Protocol is"
2480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002481run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002482 "$P_SRV debug_level=3 alpn=abc,1234" \
2483 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002484 0 \
2485 -C "client hello, adding alpn extension" \
2486 -S "found alpn extension" \
2487 -C "got an alert message, type: \\[2:120]" \
2488 -S "server hello, adding alpn extension" \
2489 -C "found alpn extension " \
2490 -C "Application Layer Protocol is" \
2491 -s "Application Layer Protocol is (none)"
2492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002493run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002494 "$P_SRV debug_level=3 alpn=abc,1234" \
2495 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002496 0 \
2497 -c "client hello, adding alpn extension" \
2498 -s "found alpn extension" \
2499 -C "got an alert message, type: \\[2:120]" \
2500 -s "server hello, adding alpn extension" \
2501 -c "found alpn extension" \
2502 -c "Application Layer Protocol is abc" \
2503 -s "Application Layer Protocol is abc"
2504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002505run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002506 "$P_SRV debug_level=3 alpn=abc,1234" \
2507 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002508 0 \
2509 -c "client hello, adding alpn extension" \
2510 -s "found alpn extension" \
2511 -C "got an alert message, type: \\[2:120]" \
2512 -s "server hello, adding alpn extension" \
2513 -c "found alpn extension" \
2514 -c "Application Layer Protocol is abc" \
2515 -s "Application Layer Protocol is abc"
2516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002517run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002518 "$P_SRV debug_level=3 alpn=abc,1234" \
2519 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002520 0 \
2521 -c "client hello, adding alpn extension" \
2522 -s "found alpn extension" \
2523 -C "got an alert message, type: \\[2:120]" \
2524 -s "server hello, adding alpn extension" \
2525 -c "found alpn extension" \
2526 -c "Application Layer Protocol is 1234" \
2527 -s "Application Layer Protocol is 1234"
2528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002529run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002530 "$P_SRV debug_level=3 alpn=abc,123" \
2531 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002532 1 \
2533 -c "client hello, adding alpn extension" \
2534 -s "found alpn extension" \
2535 -c "got an alert message, type: \\[2:120]" \
2536 -S "server hello, adding alpn extension" \
2537 -C "found alpn extension" \
2538 -C "Application Layer Protocol is 1234" \
2539 -S "Application Layer Protocol is 1234"
2540
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002541
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002542# Tests for keyUsage in leaf certificates, part 1:
2543# server-side certificate/suite selection
2544
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002545run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002546 "$P_SRV key_file=data_files/server2.key \
2547 crt_file=data_files/server2.ku-ds.crt" \
2548 "$P_CLI" \
2549 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002550 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002551
2552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002553run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002554 "$P_SRV key_file=data_files/server2.key \
2555 crt_file=data_files/server2.ku-ke.crt" \
2556 "$P_CLI" \
2557 0 \
2558 -c "Ciphersuite is TLS-RSA-WITH-"
2559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002560run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002561 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002562 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002563 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002564 1 \
2565 -C "Ciphersuite is "
2566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002567run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002568 "$P_SRV key_file=data_files/server5.key \
2569 crt_file=data_files/server5.ku-ds.crt" \
2570 "$P_CLI" \
2571 0 \
2572 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2573
2574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002575run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002576 "$P_SRV key_file=data_files/server5.key \
2577 crt_file=data_files/server5.ku-ka.crt" \
2578 "$P_CLI" \
2579 0 \
2580 -c "Ciphersuite is TLS-ECDH-"
2581
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002582run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002583 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002584 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002585 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002586 1 \
2587 -C "Ciphersuite is "
2588
2589# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002590# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002592run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002593 "$O_SRV -key data_files/server2.key \
2594 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002595 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002596 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2597 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002598 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002599 -C "Processing of the Certificate handshake message failed" \
2600 -c "Ciphersuite is TLS-"
2601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002602run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002603 "$O_SRV -key data_files/server2.key \
2604 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002605 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002606 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2607 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002608 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002609 -C "Processing of the Certificate handshake message failed" \
2610 -c "Ciphersuite is TLS-"
2611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002612run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002613 "$O_SRV -key data_files/server2.key \
2614 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002615 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002616 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2617 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002618 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002619 -C "Processing of the Certificate handshake message failed" \
2620 -c "Ciphersuite is TLS-"
2621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002622run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002623 "$O_SRV -key data_files/server2.key \
2624 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002625 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002626 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2627 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002628 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002629 -c "Processing of the Certificate handshake message failed" \
2630 -C "Ciphersuite is TLS-"
2631
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002632run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2633 "$O_SRV -key data_files/server2.key \
2634 -cert data_files/server2.ku-ke.crt" \
2635 "$P_CLI debug_level=1 auth_mode=optional \
2636 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2637 0 \
2638 -c "bad certificate (usage extensions)" \
2639 -C "Processing of the Certificate handshake message failed" \
2640 -c "Ciphersuite is TLS-" \
2641 -c "! Usage does not match the keyUsage extension"
2642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002643run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002644 "$O_SRV -key data_files/server2.key \
2645 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002646 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002647 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2648 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002649 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002650 -C "Processing of the Certificate handshake message failed" \
2651 -c "Ciphersuite is TLS-"
2652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002653run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002654 "$O_SRV -key data_files/server2.key \
2655 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002656 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002657 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2658 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002659 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002660 -c "Processing of the Certificate handshake message failed" \
2661 -C "Ciphersuite is TLS-"
2662
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002663run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2664 "$O_SRV -key data_files/server2.key \
2665 -cert data_files/server2.ku-ds.crt" \
2666 "$P_CLI debug_level=1 auth_mode=optional \
2667 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2668 0 \
2669 -c "bad certificate (usage extensions)" \
2670 -C "Processing of the Certificate handshake message failed" \
2671 -c "Ciphersuite is TLS-" \
2672 -c "! Usage does not match the keyUsage extension"
2673
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002674# Tests for keyUsage in leaf certificates, part 3:
2675# server-side checking of client cert
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002678 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002679 "$O_CLI -key data_files/server2.key \
2680 -cert data_files/server2.ku-ds.crt" \
2681 0 \
2682 -S "bad certificate (usage extensions)" \
2683 -S "Processing of the Certificate handshake message failed"
2684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002685run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002686 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002687 "$O_CLI -key data_files/server2.key \
2688 -cert data_files/server2.ku-ke.crt" \
2689 0 \
2690 -s "bad certificate (usage extensions)" \
2691 -S "Processing of the Certificate handshake message failed"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002694 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002695 "$O_CLI -key data_files/server2.key \
2696 -cert data_files/server2.ku-ke.crt" \
2697 1 \
2698 -s "bad certificate (usage extensions)" \
2699 -s "Processing of the Certificate handshake message failed"
2700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002701run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002702 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002703 "$O_CLI -key data_files/server5.key \
2704 -cert data_files/server5.ku-ds.crt" \
2705 0 \
2706 -S "bad certificate (usage extensions)" \
2707 -S "Processing of the Certificate handshake message failed"
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002710 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002711 "$O_CLI -key data_files/server5.key \
2712 -cert data_files/server5.ku-ka.crt" \
2713 0 \
2714 -s "bad certificate (usage extensions)" \
2715 -S "Processing of the Certificate handshake message failed"
2716
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002717# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002719run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002720 "$P_SRV key_file=data_files/server5.key \
2721 crt_file=data_files/server5.eku-srv.crt" \
2722 "$P_CLI" \
2723 0
2724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002725run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002726 "$P_SRV key_file=data_files/server5.key \
2727 crt_file=data_files/server5.eku-srv.crt" \
2728 "$P_CLI" \
2729 0
2730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002731run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002732 "$P_SRV key_file=data_files/server5.key \
2733 crt_file=data_files/server5.eku-cs_any.crt" \
2734 "$P_CLI" \
2735 0
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002738 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002739 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002740 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002741 1
2742
2743# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002745run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002746 "$O_SRV -key data_files/server5.key \
2747 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002748 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002749 0 \
2750 -C "bad certificate (usage extensions)" \
2751 -C "Processing of the Certificate handshake message failed" \
2752 -c "Ciphersuite is TLS-"
2753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002754run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002755 "$O_SRV -key data_files/server5.key \
2756 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002757 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002758 0 \
2759 -C "bad certificate (usage extensions)" \
2760 -C "Processing of the Certificate handshake message failed" \
2761 -c "Ciphersuite is TLS-"
2762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002763run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002764 "$O_SRV -key data_files/server5.key \
2765 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002766 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002767 0 \
2768 -C "bad certificate (usage extensions)" \
2769 -C "Processing of the Certificate handshake message failed" \
2770 -c "Ciphersuite is TLS-"
2771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002772run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002773 "$O_SRV -key data_files/server5.key \
2774 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002775 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002776 1 \
2777 -c "bad certificate (usage extensions)" \
2778 -c "Processing of the Certificate handshake message failed" \
2779 -C "Ciphersuite is TLS-"
2780
2781# Tests for extendedKeyUsage, part 3: server-side checking of client cert
2782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002783run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002784 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002785 "$O_CLI -key data_files/server5.key \
2786 -cert data_files/server5.eku-cli.crt" \
2787 0 \
2788 -S "bad certificate (usage extensions)" \
2789 -S "Processing of the Certificate handshake message failed"
2790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002791run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002792 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002793 "$O_CLI -key data_files/server5.key \
2794 -cert data_files/server5.eku-srv_cli.crt" \
2795 0 \
2796 -S "bad certificate (usage extensions)" \
2797 -S "Processing of the Certificate handshake message failed"
2798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002799run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002800 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002801 "$O_CLI -key data_files/server5.key \
2802 -cert data_files/server5.eku-cs_any.crt" \
2803 0 \
2804 -S "bad certificate (usage extensions)" \
2805 -S "Processing of the Certificate handshake message failed"
2806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002807run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002808 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002809 "$O_CLI -key data_files/server5.key \
2810 -cert data_files/server5.eku-cs.crt" \
2811 0 \
2812 -s "bad certificate (usage extensions)" \
2813 -S "Processing of the Certificate handshake message failed"
2814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002815run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002816 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002817 "$O_CLI -key data_files/server5.key \
2818 -cert data_files/server5.eku-cs.crt" \
2819 1 \
2820 -s "bad certificate (usage extensions)" \
2821 -s "Processing of the Certificate handshake message failed"
2822
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002823# Tests for DHM parameters loading
2824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002825run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002826 "$P_SRV" \
2827 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2828 debug_level=3" \
2829 0 \
2830 -c "value of 'DHM: P ' (2048 bits)" \
2831 -c "value of 'DHM: G ' (2048 bits)"
2832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002833run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002834 "$P_SRV dhm_file=data_files/dhparams.pem" \
2835 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2836 debug_level=3" \
2837 0 \
2838 -c "value of 'DHM: P ' (1024 bits)" \
2839 -c "value of 'DHM: G ' (2 bits)"
2840
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02002841# Tests for DHM client-side size checking
2842
2843run_test "DHM size: server default, client default, OK" \
2844 "$P_SRV" \
2845 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2846 debug_level=1" \
2847 0 \
2848 -C "DHM prime too short:"
2849
2850run_test "DHM size: server default, client 2048, OK" \
2851 "$P_SRV" \
2852 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2853 debug_level=1 dhmlen=2048" \
2854 0 \
2855 -C "DHM prime too short:"
2856
2857run_test "DHM size: server 1024, client default, OK" \
2858 "$P_SRV dhm_file=data_files/dhparams.pem" \
2859 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2860 debug_level=1" \
2861 0 \
2862 -C "DHM prime too short:"
2863
2864run_test "DHM size: server 1000, client default, rejected" \
2865 "$P_SRV dhm_file=data_files/dh.1000.pem" \
2866 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2867 debug_level=1" \
2868 1 \
2869 -c "DHM prime too short:"
2870
2871run_test "DHM size: server default, client 2049, rejected" \
2872 "$P_SRV" \
2873 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
2874 debug_level=1 dhmlen=2049" \
2875 1 \
2876 -c "DHM prime too short:"
2877
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002878# Tests for PSK callback
2879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002880run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002881 "$P_SRV psk=abc123 psk_identity=foo" \
2882 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2883 psk_identity=foo psk=abc123" \
2884 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002885 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002886 -S "SSL - Unknown identity received" \
2887 -S "SSL - Verification of the message MAC failed"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02002890 "$P_SRV" \
2891 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2892 psk_identity=foo psk=abc123" \
2893 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002894 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002895 -S "SSL - Unknown identity received" \
2896 -S "SSL - Verification of the message MAC failed"
2897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002898run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002899 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
2900 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2901 psk_identity=foo psk=abc123" \
2902 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002903 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002904 -s "SSL - Unknown identity received" \
2905 -S "SSL - Verification of the message MAC failed"
2906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002907run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002908 "$P_SRV psk_list=abc,dead,def,beef" \
2909 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2910 psk_identity=abc psk=dead" \
2911 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002912 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002913 -S "SSL - Unknown identity received" \
2914 -S "SSL - Verification of the message MAC failed"
2915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002916run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002917 "$P_SRV psk_list=abc,dead,def,beef" \
2918 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2919 psk_identity=def psk=beef" \
2920 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002921 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002922 -S "SSL - Unknown identity received" \
2923 -S "SSL - Verification of the message MAC failed"
2924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002925run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002926 "$P_SRV psk_list=abc,dead,def,beef" \
2927 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2928 psk_identity=ghi psk=beef" \
2929 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002930 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002931 -s "SSL - Unknown identity received" \
2932 -S "SSL - Verification of the message MAC failed"
2933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002934run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002935 "$P_SRV psk_list=abc,dead,def,beef" \
2936 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
2937 psk_identity=abc psk=beef" \
2938 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01002939 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02002940 -S "SSL - Unknown identity received" \
2941 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02002942
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002943# Tests for ciphersuites per version
2944
Janos Follath542ee5d2016-03-07 15:57:05 +00002945requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002946run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002947 "$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 +02002948 "$P_CLI force_version=ssl3" \
2949 0 \
2950 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
2951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002952run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002953 "$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 +01002954 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002955 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002956 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002958run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002959 "$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 +02002960 "$P_CLI force_version=tls1_1" \
2961 0 \
2962 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
2963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002964run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002965 "$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 +02002966 "$P_CLI force_version=tls1_2" \
2967 0 \
2968 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
2969
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002970# Test for ClientHello without extensions
2971
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02002972requires_gnutls
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002973run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02002974 "$P_SRV debug_level=3" \
2975 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2976 0 \
2977 -s "dumping 'client hello extensions' (0 bytes)"
2978
Gilles Peskine7344e1b2017-05-12 13:16:40 +02002979requires_gnutls
2980run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
2981 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
2982 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
2983 0 \
2984 -s "dumping 'client hello extensions' (0 bytes)"
2985
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002986# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002987
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002988run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002989 "$P_SRV" \
2990 "$P_CLI request_size=100" \
2991 0 \
2992 -s "Read from client: 100 bytes read$"
2993
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002994run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02002995 "$P_SRV" \
2996 "$P_CLI request_size=500" \
2997 0 \
2998 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02002999
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003000# Tests for small packets
3001
Janos Follath542ee5d2016-03-07 15:57:05 +00003002requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003003run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003004 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003005 "$P_CLI request_size=1 force_version=ssl3 \
3006 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3007 0 \
3008 -s "Read from client: 1 bytes read"
3009
Janos Follath542ee5d2016-03-07 15:57:05 +00003010requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003011run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003012 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003013 "$P_CLI request_size=1 force_version=ssl3 \
3014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3015 0 \
3016 -s "Read from client: 1 bytes read"
3017
3018run_test "Small packet TLS 1.0 BlockCipher" \
3019 "$P_SRV" \
3020 "$P_CLI request_size=1 force_version=tls1 \
3021 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3022 0 \
3023 -s "Read from client: 1 bytes read"
3024
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003025run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3026 "$P_SRV" \
3027 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3028 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3029 0 \
3030 -s "Read from client: 1 bytes read"
3031
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003032run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3033 "$P_SRV" \
3034 "$P_CLI request_size=1 force_version=tls1 \
3035 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3036 trunc_hmac=1" \
3037 0 \
3038 -s "Read from client: 1 bytes read"
3039
3040run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003041 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003042 "$P_CLI request_size=1 force_version=tls1 \
3043 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3044 trunc_hmac=1" \
3045 0 \
3046 -s "Read from client: 1 bytes read"
3047
3048run_test "Small packet TLS 1.1 BlockCipher" \
3049 "$P_SRV" \
3050 "$P_CLI request_size=1 force_version=tls1_1 \
3051 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3052 0 \
3053 -s "Read from client: 1 bytes read"
3054
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003055run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3056 "$P_SRV" \
3057 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3058 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3059 0 \
3060 -s "Read from client: 1 bytes read"
3061
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003062run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003063 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003064 "$P_CLI request_size=1 force_version=tls1_1 \
3065 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3066 0 \
3067 -s "Read from client: 1 bytes read"
3068
3069run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3070 "$P_SRV" \
3071 "$P_CLI request_size=1 force_version=tls1_1 \
3072 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3073 trunc_hmac=1" \
3074 0 \
3075 -s "Read from client: 1 bytes read"
3076
3077run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003078 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003079 "$P_CLI request_size=1 force_version=tls1_1 \
3080 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3081 trunc_hmac=1" \
3082 0 \
3083 -s "Read from client: 1 bytes read"
3084
3085run_test "Small packet TLS 1.2 BlockCipher" \
3086 "$P_SRV" \
3087 "$P_CLI request_size=1 force_version=tls1_2 \
3088 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3089 0 \
3090 -s "Read from client: 1 bytes read"
3091
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003092run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3093 "$P_SRV" \
3094 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3095 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3096 0 \
3097 -s "Read from client: 1 bytes read"
3098
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003099run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3100 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003101 "$P_CLI request_size=1 force_version=tls1_2 \
3102 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003103 0 \
3104 -s "Read from client: 1 bytes read"
3105
3106run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3107 "$P_SRV" \
3108 "$P_CLI request_size=1 force_version=tls1_2 \
3109 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3110 trunc_hmac=1" \
3111 0 \
3112 -s "Read from client: 1 bytes read"
3113
3114run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003115 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003116 "$P_CLI request_size=1 force_version=tls1_2 \
3117 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3118 0 \
3119 -s "Read from client: 1 bytes read"
3120
3121run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003122 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003123 "$P_CLI request_size=1 force_version=tls1_2 \
3124 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3125 trunc_hmac=1" \
3126 0 \
3127 -s "Read from client: 1 bytes read"
3128
3129run_test "Small packet TLS 1.2 AEAD" \
3130 "$P_SRV" \
3131 "$P_CLI request_size=1 force_version=tls1_2 \
3132 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3133 0 \
3134 -s "Read from client: 1 bytes read"
3135
3136run_test "Small packet TLS 1.2 AEAD shorter tag" \
3137 "$P_SRV" \
3138 "$P_CLI request_size=1 force_version=tls1_2 \
3139 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3140 0 \
3141 -s "Read from client: 1 bytes read"
3142
Janos Follathb700c462016-05-06 13:48:23 +01003143# A test for extensions in SSLv3
3144
3145requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3146run_test "SSLv3 with extensions, server side" \
3147 "$P_SRV min_version=ssl3 debug_level=3" \
3148 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3149 0 \
3150 -S "dumping 'client hello extensions'" \
3151 -S "server hello, total extension length:"
3152
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003153# Test for large packets
3154
Janos Follath542ee5d2016-03-07 15:57:05 +00003155requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003156run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003157 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003158 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003159 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3160 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003161 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003162 -s "Read from client: 16384 bytes read"
3163
Janos Follath542ee5d2016-03-07 15:57:05 +00003164requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003165run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003166 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003167 "$P_CLI request_size=16384 force_version=ssl3 \
3168 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3169 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003170 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003171 -s "Read from client: 16384 bytes read"
3172
3173run_test "Large packet TLS 1.0 BlockCipher" \
3174 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003175 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003176 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3177 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003178 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003179 -s "Read from client: 16384 bytes read"
3180
3181run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3182 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003183 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003184 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3185 trunc_hmac=1" \
3186 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003187 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003188 -s "Read from client: 16384 bytes read"
3189
3190run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003191 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003192 "$P_CLI request_size=16384 force_version=tls1 \
3193 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3194 trunc_hmac=1" \
3195 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003196 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003197 -s "Read from client: 16384 bytes read"
3198
3199run_test "Large packet TLS 1.1 BlockCipher" \
3200 "$P_SRV" \
3201 "$P_CLI request_size=16384 force_version=tls1_1 \
3202 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3203 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003204 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003205 -s "Read from client: 16384 bytes read"
3206
3207run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003208 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003209 "$P_CLI request_size=16384 force_version=tls1_1 \
3210 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3211 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003212 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003213 -s "Read from client: 16384 bytes read"
3214
3215run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3216 "$P_SRV" \
3217 "$P_CLI request_size=16384 force_version=tls1_1 \
3218 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3219 trunc_hmac=1" \
3220 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003221 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003222 -s "Read from client: 16384 bytes read"
3223
3224run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003225 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003226 "$P_CLI request_size=16384 force_version=tls1_1 \
3227 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3228 trunc_hmac=1" \
3229 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003230 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003231 -s "Read from client: 16384 bytes read"
3232
3233run_test "Large packet TLS 1.2 BlockCipher" \
3234 "$P_SRV" \
3235 "$P_CLI request_size=16384 force_version=tls1_2 \
3236 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3237 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003238 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003239 -s "Read from client: 16384 bytes read"
3240
3241run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3242 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003243 "$P_CLI request_size=16384 force_version=tls1_2 \
3244 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003245 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003246 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003247 -s "Read from client: 16384 bytes read"
3248
3249run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3250 "$P_SRV" \
3251 "$P_CLI request_size=16384 force_version=tls1_2 \
3252 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3253 trunc_hmac=1" \
3254 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003255 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003256 -s "Read from client: 16384 bytes read"
3257
3258run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003259 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003260 "$P_CLI request_size=16384 force_version=tls1_2 \
3261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3262 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003263 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003264 -s "Read from client: 16384 bytes read"
3265
3266run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003267 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003268 "$P_CLI request_size=16384 force_version=tls1_2 \
3269 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3270 trunc_hmac=1" \
3271 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003272 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003273 -s "Read from client: 16384 bytes read"
3274
3275run_test "Large packet TLS 1.2 AEAD" \
3276 "$P_SRV" \
3277 "$P_CLI request_size=16384 force_version=tls1_2 \
3278 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3279 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003280 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003281 -s "Read from client: 16384 bytes read"
3282
3283run_test "Large packet TLS 1.2 AEAD shorter tag" \
3284 "$P_SRV" \
3285 "$P_CLI request_size=16384 force_version=tls1_2 \
3286 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3287 0 \
Hanno Becker0d885d32017-09-18 15:04:19 +01003288 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003289 -s "Read from client: 16384 bytes read"
3290
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003291# Tests for DTLS HelloVerifyRequest
3292
3293run_test "DTLS cookie: enabled" \
3294 "$P_SRV dtls=1 debug_level=2" \
3295 "$P_CLI dtls=1 debug_level=2" \
3296 0 \
3297 -s "cookie verification failed" \
3298 -s "cookie verification passed" \
3299 -S "cookie verification skipped" \
3300 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003301 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003302 -S "SSL - The requested feature is not available"
3303
3304run_test "DTLS cookie: disabled" \
3305 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3306 "$P_CLI dtls=1 debug_level=2" \
3307 0 \
3308 -S "cookie verification failed" \
3309 -S "cookie verification passed" \
3310 -s "cookie verification skipped" \
3311 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003312 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003313 -S "SSL - The requested feature is not available"
3314
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003315run_test "DTLS cookie: default (failing)" \
3316 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3317 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3318 1 \
3319 -s "cookie verification failed" \
3320 -S "cookie verification passed" \
3321 -S "cookie verification skipped" \
3322 -C "received hello verify request" \
3323 -S "hello verification requested" \
3324 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003325
3326requires_ipv6
3327run_test "DTLS cookie: enabled, IPv6" \
3328 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3329 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3330 0 \
3331 -s "cookie verification failed" \
3332 -s "cookie verification passed" \
3333 -S "cookie verification skipped" \
3334 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003335 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003336 -S "SSL - The requested feature is not available"
3337
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003338run_test "DTLS cookie: enabled, nbio" \
3339 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3340 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3341 0 \
3342 -s "cookie verification failed" \
3343 -s "cookie verification passed" \
3344 -S "cookie verification skipped" \
3345 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003346 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003347 -S "SSL - The requested feature is not available"
3348
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003349# Tests for client reconnecting from the same port with DTLS
3350
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003351not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003352run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003353 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3354 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003355 0 \
3356 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003357 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003358 -S "Client initiated reconnection from same port"
3359
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003360not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003361run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003362 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3363 "$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 +02003364 0 \
3365 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003366 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003367 -s "Client initiated reconnection from same port"
3368
Paul Bakker3b224ff2016-05-13 10:33:25 +01003369not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3370run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003371 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3372 "$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 +02003373 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003374 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003375 -s "Client initiated reconnection from same port"
3376
Paul Bakker3b224ff2016-05-13 10:33:25 +01003377only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3378run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3379 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3380 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3381 0 \
3382 -S "The operation timed out" \
3383 -s "Client initiated reconnection from same port"
3384
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003385run_test "DTLS client reconnect from same port: no cookies" \
3386 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003387 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3388 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003389 -s "The operation timed out" \
3390 -S "Client initiated reconnection from same port"
3391
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003392# Tests for various cases of client authentication with DTLS
3393# (focused on handshake flows and message parsing)
3394
3395run_test "DTLS client auth: required" \
3396 "$P_SRV dtls=1 auth_mode=required" \
3397 "$P_CLI dtls=1" \
3398 0 \
3399 -s "Verifying peer X.509 certificate... ok"
3400
3401run_test "DTLS client auth: optional, client has no cert" \
3402 "$P_SRV dtls=1 auth_mode=optional" \
3403 "$P_CLI dtls=1 crt_file=none key_file=none" \
3404 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003405 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003406
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003407run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003408 "$P_SRV dtls=1 auth_mode=none" \
3409 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3410 0 \
3411 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003412 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003413
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003414run_test "DTLS wrong PSK: badmac alert" \
3415 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3416 "$P_CLI dtls=1 psk=abc124" \
3417 1 \
3418 -s "SSL - Verification of the message MAC failed" \
3419 -c "SSL - A fatal alert message was received from our peer"
3420
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003421# Tests for receiving fragmented handshake messages with DTLS
3422
3423requires_gnutls
3424run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3425 "$G_SRV -u --mtu 2048 -a" \
3426 "$P_CLI dtls=1 debug_level=2" \
3427 0 \
3428 -C "found fragmented DTLS handshake message" \
3429 -C "error"
3430
3431requires_gnutls
3432run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3433 "$G_SRV -u --mtu 512" \
3434 "$P_CLI dtls=1 debug_level=2" \
3435 0 \
3436 -c "found fragmented DTLS handshake message" \
3437 -C "error"
3438
3439requires_gnutls
3440run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3441 "$G_SRV -u --mtu 128" \
3442 "$P_CLI dtls=1 debug_level=2" \
3443 0 \
3444 -c "found fragmented DTLS handshake message" \
3445 -C "error"
3446
3447requires_gnutls
3448run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3449 "$G_SRV -u --mtu 128" \
3450 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3451 0 \
3452 -c "found fragmented DTLS handshake message" \
3453 -C "error"
3454
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003455requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003456requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003457run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3458 "$G_SRV -u --mtu 256" \
3459 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3460 0 \
3461 -c "found fragmented DTLS handshake message" \
3462 -c "client hello, adding renegotiation extension" \
3463 -c "found renegotiation extension" \
3464 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003465 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003466 -C "error" \
3467 -s "Extra-header:"
3468
3469requires_gnutls
Hanno Becker78891132017-10-24 11:54:55 +01003470requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003471run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3472 "$G_SRV -u --mtu 256" \
3473 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3474 0 \
3475 -c "found fragmented DTLS handshake message" \
3476 -c "client hello, adding renegotiation extension" \
3477 -c "found renegotiation extension" \
3478 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003479 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003480 -C "error" \
3481 -s "Extra-header:"
3482
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003483run_test "DTLS reassembly: no fragmentation (openssl server)" \
3484 "$O_SRV -dtls1 -mtu 2048" \
3485 "$P_CLI dtls=1 debug_level=2" \
3486 0 \
3487 -C "found fragmented DTLS handshake message" \
3488 -C "error"
3489
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003490run_test "DTLS reassembly: some fragmentation (openssl server)" \
3491 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003492 "$P_CLI dtls=1 debug_level=2" \
3493 0 \
3494 -c "found fragmented DTLS handshake message" \
3495 -C "error"
3496
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003497run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003498 "$O_SRV -dtls1 -mtu 256" \
3499 "$P_CLI dtls=1 debug_level=2" \
3500 0 \
3501 -c "found fragmented DTLS handshake message" \
3502 -C "error"
3503
3504run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3505 "$O_SRV -dtls1 -mtu 256" \
3506 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3507 0 \
3508 -c "found fragmented DTLS handshake message" \
3509 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003510
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003511# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003512
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003513not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003514run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003515 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003516 "$P_SRV dtls=1 debug_level=2" \
3517 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003518 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003519 -C "replayed record" \
3520 -S "replayed record" \
3521 -C "record from another epoch" \
3522 -S "record from another epoch" \
3523 -C "discarding invalid record" \
3524 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003525 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003526 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003527 -c "HTTP/1.0 200 OK"
3528
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003529not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003530run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003531 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003532 "$P_SRV dtls=1 debug_level=2" \
3533 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003534 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003535 -c "replayed record" \
3536 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003537 -c "discarding invalid record" \
3538 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003539 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003540 -s "Extra-header:" \
3541 -c "HTTP/1.0 200 OK"
3542
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003543run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3544 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003545 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3546 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003547 0 \
3548 -c "replayed record" \
3549 -S "replayed record" \
3550 -c "discarding invalid record" \
3551 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003552 -c "resend" \
3553 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003554 -s "Extra-header:" \
3555 -c "HTTP/1.0 200 OK"
3556
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003557run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003558 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003559 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003560 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003561 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003562 -c "discarding invalid record (mac)" \
3563 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003564 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003565 -c "HTTP/1.0 200 OK" \
3566 -S "too many records with bad MAC" \
3567 -S "Verification of the message MAC failed"
3568
3569run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3570 -p "$P_PXY bad_ad=1" \
3571 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3572 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3573 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003574 -C "discarding invalid record (mac)" \
3575 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003576 -S "Extra-header:" \
3577 -C "HTTP/1.0 200 OK" \
3578 -s "too many records with bad MAC" \
3579 -s "Verification of the message MAC failed"
3580
3581run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3582 -p "$P_PXY bad_ad=1" \
3583 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3584 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3585 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003586 -c "discarding invalid record (mac)" \
3587 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003588 -s "Extra-header:" \
3589 -c "HTTP/1.0 200 OK" \
3590 -S "too many records with bad MAC" \
3591 -S "Verification of the message MAC failed"
3592
3593run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3594 -p "$P_PXY bad_ad=1" \
3595 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3596 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3597 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003598 -c "discarding invalid record (mac)" \
3599 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003600 -s "Extra-header:" \
3601 -c "HTTP/1.0 200 OK" \
3602 -s "too many records with bad MAC" \
3603 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003604
3605run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003606 -p "$P_PXY delay_ccs=1" \
3607 "$P_SRV dtls=1 debug_level=1" \
3608 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003609 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003610 -c "record from another epoch" \
3611 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003612 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003613 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003614 -s "Extra-header:" \
3615 -c "HTTP/1.0 200 OK"
3616
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003617# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003618
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003619needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003620run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003621 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003622 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3623 psk=abc123" \
3624 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003625 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3626 0 \
3627 -s "Extra-header:" \
3628 -c "HTTP/1.0 200 OK"
3629
3630needs_more_time 2
3631run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3632 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003633 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3634 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003635 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3636 0 \
3637 -s "Extra-header:" \
3638 -c "HTTP/1.0 200 OK"
3639
3640needs_more_time 2
3641run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3642 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003643 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3644 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003645 0 \
3646 -s "Extra-header:" \
3647 -c "HTTP/1.0 200 OK"
3648
3649needs_more_time 2
3650run_test "DTLS proxy: 3d, FS, client auth" \
3651 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003652 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
3653 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003654 0 \
3655 -s "Extra-header:" \
3656 -c "HTTP/1.0 200 OK"
3657
3658needs_more_time 2
3659run_test "DTLS proxy: 3d, FS, ticket" \
3660 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003661 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
3662 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003663 0 \
3664 -s "Extra-header:" \
3665 -c "HTTP/1.0 200 OK"
3666
3667needs_more_time 2
3668run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
3669 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003670 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
3671 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003672 0 \
3673 -s "Extra-header:" \
3674 -c "HTTP/1.0 200 OK"
3675
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003676needs_more_time 2
3677run_test "DTLS proxy: 3d, max handshake, nbio" \
3678 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003679 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
3680 auth_mode=required" \
3681 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003682 0 \
3683 -s "Extra-header:" \
3684 -c "HTTP/1.0 200 OK"
3685
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003686needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02003687run_test "DTLS proxy: 3d, min handshake, resumption" \
3688 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3689 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3690 psk=abc123 debug_level=3" \
3691 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3692 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3693 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3694 0 \
3695 -s "a session has been resumed" \
3696 -c "a session has been resumed" \
3697 -s "Extra-header:" \
3698 -c "HTTP/1.0 200 OK"
3699
3700needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02003701run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
3702 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3703 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3704 psk=abc123 debug_level=3 nbio=2" \
3705 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3706 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
3707 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
3708 0 \
3709 -s "a session has been resumed" \
3710 -c "a session has been resumed" \
3711 -s "Extra-header:" \
3712 -c "HTTP/1.0 200 OK"
3713
3714needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003715requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003716run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003717 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003718 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3719 psk=abc123 renegotiation=1 debug_level=2" \
3720 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3721 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02003722 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3723 0 \
3724 -c "=> renegotiate" \
3725 -s "=> renegotiate" \
3726 -s "Extra-header:" \
3727 -c "HTTP/1.0 200 OK"
3728
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003729needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003730requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003731run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
3732 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003733 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3734 psk=abc123 renegotiation=1 debug_level=2" \
3735 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
3736 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003737 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3738 0 \
3739 -c "=> renegotiate" \
3740 -s "=> renegotiate" \
3741 -s "Extra-header:" \
3742 -c "HTTP/1.0 200 OK"
3743
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003744needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003745requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003746run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003747 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003748 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003749 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003750 debug_level=2" \
3751 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003752 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003753 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3754 0 \
3755 -c "=> renegotiate" \
3756 -s "=> renegotiate" \
3757 -s "Extra-header:" \
3758 -c "HTTP/1.0 200 OK"
3759
3760needs_more_time 4
Hanno Becker78891132017-10-24 11:54:55 +01003761requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003762run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003763 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003764 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003765 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003766 debug_level=2 nbio=2" \
3767 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02003768 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02003769 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3770 0 \
3771 -c "=> renegotiate" \
3772 -s "=> renegotiate" \
3773 -s "Extra-header:" \
3774 -c "HTTP/1.0 200 OK"
3775
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003776needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003777not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003778run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003779 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3780 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003781 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003782 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02003783 -c "HTTP/1.0 200 OK"
3784
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003785needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003786not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003787run_test "DTLS proxy: 3d, openssl server, fragmentation" \
3788 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3789 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003790 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003791 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003792 -c "HTTP/1.0 200 OK"
3793
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003794needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003795not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003796run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
3797 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
3798 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00003799 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003800 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003801 -c "HTTP/1.0 200 OK"
3802
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003803requires_gnutls
Manuel Pégourié-Gonnard127ab882014-10-09 17:59:32 +02003804needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003805not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003806run_test "DTLS proxy: 3d, gnutls server" \
3807 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3808 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003809 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003810 0 \
3811 -s "Extra-header:" \
3812 -c "Extra-header:"
3813
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003814requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003815needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003816not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003817run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
3818 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3819 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003820 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02003821 0 \
3822 -s "Extra-header:" \
3823 -c "Extra-header:"
3824
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003825requires_gnutls
Manuel Pégourié-Gonnard22404862015-05-14 12:11:45 +02003826needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02003827not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003828run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
3829 -p "$P_PXY drop=5 delay=5 duplicate=5" \
3830 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02003831 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02003832 0 \
3833 -s "Extra-header:" \
3834 -c "Extra-header:"
3835
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003836# Final report
3837
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003838echo "------------------------------------------------------------------------"
3839
3840if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003841 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003842else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01003843 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003844fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02003845PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02003846echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003847
3848exit $FAILS