blob: fa785a4f1e812a34134c6a851624c8a9f0e4d376 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# This file is part of mbed TLS (https://tls.mbed.org)
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01006#
Simon Butcher58eddef2016-05-19 23:43:11 +01007# Copyright (c) 2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes tests to prove various TLS/SSL options and extensions.
12#
13# The goal is not to cover every ciphersuite/version, but instead to cover
14# specific options (max fragment length, truncated hmac, etc) or procedures
15# (session resumption from cache or ticket, renego, etc).
16#
17# The tests assume a build with default options, with exceptions expressed
18# with a dependency. The tests focus on functionality and do not consider
19# performance.
20#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010021
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010022set -u
23
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010024# default values, can be overriden by the environment
25: ${P_SRV:=../programs/ssl/ssl_server2}
26: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020027: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010028: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020029: ${GNUTLS_CLI:=gnutls-cli}
30: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020031: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020033O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010034O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020035G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010036G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020037TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010038
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010039TESTS=0
40FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020041SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010042
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000043CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020044
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010045MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010046FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020047EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010048
Paul Bakkere20310a2016-05-10 11:18:17 +010049SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +010050RUN_TEST_NUMBER=''
51
Paul Bakkeracaac852016-05-10 11:47:13 +010052PRESERVE_LOGS=0
53
Gilles Peskinef93c7d32017-04-14 17:55:28 +020054# Pick a "unique" server port in the range 10000-19999, and a proxy
55# port which is this plus 10000. Each port number may be independently
56# overridden by a command line option.
57SRV_PORT=$(($$ % 10000 + 10000))
58PXY_PORT=$((SRV_PORT + 10000))
59
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010060print_usage() {
61 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +010062 printf " -h|--help\tPrint this help.\n"
63 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020064 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
65 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +010066 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +010067 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +010068 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +020069 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
70 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +010071 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010072}
73
74get_options() {
75 while [ $# -gt 0 ]; do
76 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010077 -f|--filter)
78 shift; FILTER=$1
79 ;;
80 -e|--exclude)
81 shift; EXCLUDE=$1
82 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010083 -m|--memcheck)
84 MEMCHECK=1
85 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +010086 -n|--number)
87 shift; RUN_TEST_NUMBER=$1
88 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +010089 -s|--show-numbers)
90 SHOW_TEST_NUMBER=1
91 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +010092 -p|--preserve-logs)
93 PRESERVE_LOGS=1
94 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +020095 --port)
96 shift; SRV_PORT=$1
97 ;;
98 --proxy-port)
99 shift; PXY_PORT=$1
100 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100101 --seed)
102 shift; SEED="$1"
103 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100104 -h|--help)
105 print_usage
106 exit 0
107 ;;
108 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200109 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100110 print_usage
111 exit 1
112 ;;
113 esac
114 shift
115 done
116}
117
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100118# skip next test if the flag is not enabled in config.h
119requires_config_enabled() {
120 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
121 SKIP_NEXT="YES"
122 fi
123}
124
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200125# skip next test if the flag is enabled in config.h
126requires_config_disabled() {
127 if grep "^#define $1" $CONFIG_H > /dev/null; then
128 SKIP_NEXT="YES"
129 fi
130}
131
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200132# skip next test if OpenSSL doesn't support FALLBACK_SCSV
133requires_openssl_with_fallback_scsv() {
134 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
135 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
136 then
137 OPENSSL_HAS_FBSCSV="YES"
138 else
139 OPENSSL_HAS_FBSCSV="NO"
140 fi
141 fi
142 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
143 SKIP_NEXT="YES"
144 fi
145}
146
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200147# skip next test if GnuTLS isn't available
148requires_gnutls() {
149 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200150 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200151 GNUTLS_AVAILABLE="YES"
152 else
153 GNUTLS_AVAILABLE="NO"
154 fi
155 fi
156 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
157 SKIP_NEXT="YES"
158 fi
159}
160
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200161# skip next test if IPv6 isn't available on this host
162requires_ipv6() {
163 if [ -z "${HAS_IPV6:-}" ]; then
164 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
165 SRV_PID=$!
166 sleep 1
167 kill $SRV_PID >/dev/null 2>&1
168 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
169 HAS_IPV6="NO"
170 else
171 HAS_IPV6="YES"
172 fi
173 rm -r $SRV_OUT
174 fi
175
176 if [ "$HAS_IPV6" = "NO" ]; then
177 SKIP_NEXT="YES"
178 fi
179}
180
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200181# skip the next test if valgrind is in use
182not_with_valgrind() {
183 if [ "$MEMCHECK" -gt 0 ]; then
184 SKIP_NEXT="YES"
185 fi
186}
187
Paul Bakker362689d2016-05-13 10:33:25 +0100188# skip the next test if valgrind is NOT in use
189only_with_valgrind() {
190 if [ "$MEMCHECK" -eq 0 ]; then
191 SKIP_NEXT="YES"
192 fi
193}
194
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200195# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100196client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200197 CLI_DELAY_FACTOR=$1
198}
199
Janos Follath74537a62016-09-02 13:45:28 +0100200# wait for the given seconds after the client finished in the next test
201server_needs_more_time() {
202 SRV_DELAY_SECONDS=$1
203}
204
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100205# print_name <name>
206print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100207 TESTS=$(( $TESTS + 1 ))
208 LINE=""
209
210 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
211 LINE="$TESTS "
212 fi
213
214 LINE="$LINE$1"
215 printf "$LINE "
216 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100217 for i in `seq 1 $LEN`; do printf '.'; done
218 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100219
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100220}
221
222# fail <message>
223fail() {
224 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100225 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100226
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200227 mv $SRV_OUT o-srv-${TESTS}.log
228 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200229 if [ -n "$PXY_CMD" ]; then
230 mv $PXY_OUT o-pxy-${TESTS}.log
231 fi
232 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100233
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200234 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot ]; then
235 echo " ! server output:"
236 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200237 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200238 echo " ! client output:"
239 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200240 if [ -n "$PXY_CMD" ]; then
241 echo " ! ========================================================"
242 echo " ! proxy output:"
243 cat o-pxy-${TESTS}.log
244 fi
245 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200246 fi
247
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200248 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100249}
250
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100251# is_polar <cmd_line>
252is_polar() {
253 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
254}
255
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200256# openssl s_server doesn't have -www with DTLS
257check_osrv_dtls() {
258 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
259 NEEDS_INPUT=1
260 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
261 else
262 NEEDS_INPUT=0
263 fi
264}
265
266# provide input to commands that need it
267provide_input() {
268 if [ $NEEDS_INPUT -eq 0 ]; then
269 return
270 fi
271
272 while true; do
273 echo "HTTP/1.0 200 OK"
274 sleep 1
275 done
276}
277
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100278# has_mem_err <log_file_name>
279has_mem_err() {
280 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
281 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
282 then
283 return 1 # false: does not have errors
284 else
285 return 0 # true: has errors
286 fi
287}
288
Gilles Peskine418b5362017-12-14 18:58:42 +0100289# Wait for process $2 to be listening on port $1
290if type lsof >/dev/null 2>/dev/null; then
291 wait_server_start() {
292 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200293 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100294 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200295 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100296 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200297 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100298 # Make a tight loop, server normally takes less than 1s to start.
299 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
300 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
301 echo "SERVERSTART TIMEOUT"
302 echo "SERVERSTART TIMEOUT" >> $SRV_OUT
303 break
304 fi
305 # Linux and *BSD support decimal arguments to sleep. On other
306 # OSes this may be a tight loop.
307 sleep 0.1 2>/dev/null || true
308 done
309 }
310else
311 wait_server_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200312 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100313 }
314fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200315
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100316# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100317# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100318# acceptable bounds
319check_server_hello_time() {
320 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100321 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100322 # Get the Unix timestamp for now
323 CUR_TIME=$(date +'%s')
324 THRESHOLD_IN_SECS=300
325
326 # Check if the ServerHello time was printed
327 if [ -z "$SERVER_HELLO_TIME" ]; then
328 return 1
329 fi
330
331 # Check the time in ServerHello is within acceptable bounds
332 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
333 # The time in ServerHello is at least 5 minutes before now
334 return 1
335 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100336 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100337 return 1
338 else
339 return 0
340 fi
341}
342
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200343# wait for client to terminate and set CLI_EXIT
344# must be called right after starting the client
345wait_client_done() {
346 CLI_PID=$!
347
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200348 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
349 CLI_DELAY_FACTOR=1
350
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200351 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200352 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200353
354 wait $CLI_PID
355 CLI_EXIT=$?
356
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200357 kill $DOG_PID >/dev/null 2>&1
358 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200359
360 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100361
362 sleep $SRV_DELAY_SECONDS
363 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200364}
365
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200366# check if the given command uses dtls and sets global variable DTLS
367detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200368 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200369 DTLS=1
370 else
371 DTLS=0
372 fi
373}
374
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200375# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100376# Options: -s pattern pattern that must be present in server output
377# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100378# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100379# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100380# -S pattern pattern that must be absent in server output
381# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100382# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100383# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100384run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100385 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200386 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100387
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100388 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
389 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200390 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100391 return
392 fi
393
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100394 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100395
Paul Bakkerb7584a52016-05-10 10:50:43 +0100396 # Do we only run numbered tests?
397 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
398 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
399 else
400 SKIP_NEXT="YES"
401 fi
402
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200403 # should we skip?
404 if [ "X$SKIP_NEXT" = "XYES" ]; then
405 SKIP_NEXT="NO"
406 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200407 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200408 return
409 fi
410
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 # does this test use a proxy?
412 if [ "X$1" = "X-p" ]; then
413 PXY_CMD="$2"
414 shift 2
415 else
416 PXY_CMD=""
417 fi
418
419 # get commands and client output
420 SRV_CMD="$1"
421 CLI_CMD="$2"
422 CLI_EXPECT="$3"
423 shift 3
424
425 # fix client port
426 if [ -n "$PXY_CMD" ]; then
427 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
428 else
429 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
430 fi
431
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200432 # update DTLS variable
433 detect_dtls "$SRV_CMD"
434
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100435 # prepend valgrind to our commands if active
436 if [ "$MEMCHECK" -gt 0 ]; then
437 if is_polar "$SRV_CMD"; then
438 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
439 fi
440 if is_polar "$CLI_CMD"; then
441 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
442 fi
443 fi
444
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200445 TIMES_LEFT=2
446 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200447 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200448
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200449 # run the commands
450 if [ -n "$PXY_CMD" ]; then
451 echo "$PXY_CMD" > $PXY_OUT
452 $PXY_CMD >> $PXY_OUT 2>&1 &
453 PXY_PID=$!
454 # assume proxy starts faster than server
455 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200456
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200457 check_osrv_dtls
458 echo "$SRV_CMD" > $SRV_OUT
459 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
460 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100461 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200462
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200463 echo "$CLI_CMD" > $CLI_OUT
464 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
465 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100466
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200467 # terminate the server (and the proxy)
468 kill $SRV_PID
469 wait $SRV_PID
470 if [ -n "$PXY_CMD" ]; then
471 kill $PXY_PID >/dev/null 2>&1
472 wait $PXY_PID
473 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100474
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200475 # retry only on timeouts
476 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
477 printf "RETRY "
478 else
479 TIMES_LEFT=0
480 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200481 done
482
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100483 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200484 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100485 # expected client exit to incorrectly succeed in case of catastrophic
486 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100487 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200488 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100489 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100490 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100491 return
492 fi
493 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100494 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200495 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100496 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100497 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100498 return
499 fi
500 fi
501
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100502 # check server exit code
503 if [ $? != 0 ]; then
504 fail "server fail"
505 return
506 fi
507
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100508 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100509 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
510 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100511 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200512 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100513 return
514 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100515
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100516 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200517 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100518 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100519 while [ $# -gt 0 ]
520 do
521 case $1 in
522 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100523 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100524 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100525 return
526 fi
527 ;;
528
529 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100530 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100531 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100532 return
533 fi
534 ;;
535
536 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100537 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100538 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100539 return
540 fi
541 ;;
542
543 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100544 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100545 fail "pattern '$2' MUST NOT be present in the Client output"
546 return
547 fi
548 ;;
549
550 # The filtering in the following two options (-u and -U) do the following
551 # - ignore valgrind output
552 # - filter out everything but lines right after the pattern occurances
553 # - keep one of each non-unique line
554 # - count how many lines remain
555 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
556 # if there were no duplicates.
557 "-U")
558 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
559 fail "lines following pattern '$2' must be unique in Server output"
560 return
561 fi
562 ;;
563
564 "-u")
565 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
566 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100567 return
568 fi
569 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100570 "-F")
571 if ! $2 "$SRV_OUT"; then
572 fail "function call to '$2' failed on Server output"
573 return
574 fi
575 ;;
576 "-f")
577 if ! $2 "$CLI_OUT"; then
578 fail "function call to '$2' failed on Client output"
579 return
580 fi
581 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100582
583 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200584 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100585 exit 1
586 esac
587 shift 2
588 done
589
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100590 # check valgrind's results
591 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200592 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100593 fail "Server has memory errors"
594 return
595 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200596 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100597 fail "Client has memory errors"
598 return
599 fi
600 fi
601
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100602 # if we're here, everything is ok
603 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100604 if [ "$PRESERVE_LOGS" -gt 0 ]; then
605 mv $SRV_OUT o-srv-${TESTS}.log
606 mv $CLI_OUT o-cli-${TESTS}.log
607 fi
608
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200609 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610}
611
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100612cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200613 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200614 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
615 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
616 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
617 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100618 exit 1
619}
620
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100621#
622# MAIN
623#
624
Manuel Pégourié-Gonnard19db8ea2015-03-10 13:41:04 +0000625if cd $( dirname $0 ); then :; else
626 echo "cd $( dirname $0 ) failed" >&2
627 exit 1
628fi
629
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100630get_options "$@"
631
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100632# sanity checks, avoid an avalanche of errors
633if [ ! -x "$P_SRV" ]; then
634 echo "Command '$P_SRV' is not an executable file"
635 exit 1
636fi
637if [ ! -x "$P_CLI" ]; then
638 echo "Command '$P_CLI' is not an executable file"
639 exit 1
640fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200641if [ ! -x "$P_PXY" ]; then
642 echo "Command '$P_PXY' is not an executable file"
643 exit 1
644fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100645if [ "$MEMCHECK" -gt 0 ]; then
646 if which valgrind >/dev/null 2>&1; then :; else
647 echo "Memcheck not possible. Valgrind not found"
648 exit 1
649 fi
650fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100651if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
652 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100653 exit 1
654fi
655
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200656# used by watchdog
657MAIN_PID="$$"
658
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200659# be more patient with valgrind
660if [ "$MEMCHECK" -gt 0 ]; then
661 START_DELAY=3
662 DOG_DELAY=30
663else
664 START_DELAY=1
665 DOG_DELAY=10
666fi
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200667CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100668SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200669
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200670# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000671# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200672P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
673P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100674P_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 +0200675O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200676O_CLI="$O_CLI -connect localhost:+SRV_PORT"
677G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000678G_CLI="$G_CLI -p +SRV_PORT localhost"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200679
Gilles Peskine62469d92017-05-10 10:13:59 +0200680# Allow SHA-1, because many of our test certificates use it
681P_SRV="$P_SRV allow_sha1=1"
682P_CLI="$P_CLI allow_sha1=1"
683
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200684# Also pick a unique name for intermediate files
685SRV_OUT="srv_out.$$"
686CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200687PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200688SESSION="session.$$"
689
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200690SKIP_NEXT="NO"
691
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100692trap cleanup INT TERM HUP
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100693
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200694# Basic test
695
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200696# Checks that:
697# - things work with all ciphersuites active (used with config-full in all.sh)
698# - the expected (highest security) parameters are selected
699# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200700run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200701 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200702 "$P_CLI" \
703 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200704 -s "Protocol is TLSv1.2" \
705 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
706 -s "client hello v3, signature_algorithm ext: 6" \
707 -s "ECDHE curve: secp521r1" \
708 -S "error" \
709 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200710
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000711run_test "Default, DTLS" \
712 "$P_SRV dtls=1" \
713 "$P_CLI dtls=1" \
714 0 \
715 -s "Protocol is DTLSv1.2" \
716 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
717
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100718# Test current time in ServerHello
719requires_config_enabled MBEDTLS_HAVE_TIME
720run_test "Default, ServerHello contains gmt_unix_time" \
721 "$P_SRV debug_level=3" \
722 "$P_CLI debug_level=3" \
723 0 \
724 -s "Protocol is TLSv1.2" \
725 -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
726 -s "client hello v3, signature_algorithm ext: 6" \
727 -s "ECDHE curve: secp521r1" \
728 -S "error" \
729 -C "error" \
730 -f "check_server_hello_time" \
731 -F "check_server_hello_time"
732
Simon Butcher8e004102016-10-14 00:48:33 +0100733# Test for uniqueness of IVs in AEAD ciphersuites
734run_test "Unique IV in GCM" \
735 "$P_SRV exchanges=20 debug_level=4" \
736 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
737 0 \
738 -u "IV used" \
739 -U "IV used"
740
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100741# Tests for rc4 option
742
Simon Butchera410af52016-05-19 22:12:18 +0100743requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100744run_test "RC4: server disabled, client enabled" \
745 "$P_SRV" \
746 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
747 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100748 -s "SSL - The server has no ciphersuites in common"
749
Simon Butchera410af52016-05-19 22:12:18 +0100750requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100751run_test "RC4: server half, client enabled" \
752 "$P_SRV arc4=1" \
753 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
754 1 \
755 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100756
757run_test "RC4: server enabled, client disabled" \
758 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
759 "$P_CLI" \
760 1 \
761 -s "SSL - The server has no ciphersuites in common"
762
763run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100764 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100765 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
766 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100767 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100768 -S "SSL - The server has no ciphersuites in common"
769
Gilles Peskinebc70a182017-05-09 15:59:24 +0200770# Tests for SHA-1 support
771
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200772requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200773run_test "SHA-1 forbidden by default in server certificate" \
774 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
775 "$P_CLI debug_level=2 allow_sha1=0" \
776 1 \
777 -c "The certificate is signed with an unacceptable hash"
778
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200779requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
780run_test "SHA-1 forbidden by default in server certificate" \
781 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
782 "$P_CLI debug_level=2 allow_sha1=0" \
783 0
784
Gilles Peskinebc70a182017-05-09 15:59:24 +0200785run_test "SHA-1 explicitly allowed in server certificate" \
786 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
787 "$P_CLI allow_sha1=1" \
788 0
789
790run_test "SHA-256 allowed by default in server certificate" \
791 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
792 "$P_CLI allow_sha1=0" \
793 0
794
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200795requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +0200796run_test "SHA-1 forbidden by default in client certificate" \
797 "$P_SRV auth_mode=required allow_sha1=0" \
798 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
799 1 \
800 -s "The certificate is signed with an unacceptable hash"
801
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200802requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
803run_test "SHA-1 forbidden by default in client certificate" \
804 "$P_SRV auth_mode=required allow_sha1=0" \
805 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
806 0
807
Gilles Peskinebc70a182017-05-09 15:59:24 +0200808run_test "SHA-1 explicitly allowed in client certificate" \
809 "$P_SRV auth_mode=required allow_sha1=1" \
810 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
811 0
812
813run_test "SHA-256 allowed by default in client certificate" \
814 "$P_SRV auth_mode=required allow_sha1=0" \
815 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
816 0
817
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100818# Tests for Truncated HMAC extension
819
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100820run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200821 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100822 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100823 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100824 -s "dumping 'computed mac' (20 bytes)" \
825 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100826
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100827run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +0200828 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100829 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
830 trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100831 0 \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100832 -s "dumping 'computed mac' (20 bytes)" \
833 -S "dumping 'computed mac' (10 bytes)"
834
835run_test "Truncated HMAC: client enabled, server default" \
836 "$P_SRV debug_level=4" \
837 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
838 trunc_hmac=1" \
839 0 \
Manuel Pégourié-Gonnard662c6e82015-05-06 17:39:23 +0100840 -s "dumping 'computed mac' (20 bytes)" \
841 -S "dumping 'computed mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +0100842
843run_test "Truncated HMAC: client enabled, server disabled" \
844 "$P_SRV debug_level=4 trunc_hmac=0" \
845 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
846 trunc_hmac=1" \
847 0 \
848 -s "dumping 'computed mac' (20 bytes)" \
849 -S "dumping 'computed mac' (10 bytes)"
850
851run_test "Truncated HMAC: client enabled, server enabled" \
852 "$P_SRV debug_level=4 trunc_hmac=1" \
853 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
854 trunc_hmac=1" \
855 0 \
856 -S "dumping 'computed mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +0100857 -s "dumping 'computed mac' (10 bytes)"
858
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100859# Tests for Encrypt-then-MAC extension
860
861run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100862 "$P_SRV debug_level=3 \
863 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100864 "$P_CLI debug_level=3" \
865 0 \
866 -c "client hello, adding encrypt_then_mac extension" \
867 -s "found encrypt then mac extension" \
868 -s "server hello, adding encrypt then mac extension" \
869 -c "found encrypt_then_mac extension" \
870 -c "using encrypt then mac" \
871 -s "using encrypt then mac"
872
873run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100874 "$P_SRV debug_level=3 etm=0 \
875 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100876 "$P_CLI debug_level=3 etm=1" \
877 0 \
878 -c "client hello, adding encrypt_then_mac extension" \
879 -s "found encrypt then mac extension" \
880 -S "server hello, adding encrypt then mac extension" \
881 -C "found encrypt_then_mac extension" \
882 -C "using encrypt then mac" \
883 -S "using encrypt then mac"
884
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +0100885run_test "Encrypt then MAC: client enabled, aead cipher" \
886 "$P_SRV debug_level=3 etm=1 \
887 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
888 "$P_CLI debug_level=3 etm=1" \
889 0 \
890 -c "client hello, adding encrypt_then_mac extension" \
891 -s "found encrypt then mac extension" \
892 -S "server hello, adding encrypt then mac extension" \
893 -C "found encrypt_then_mac extension" \
894 -C "using encrypt then mac" \
895 -S "using encrypt then mac"
896
897run_test "Encrypt then MAC: client enabled, stream cipher" \
898 "$P_SRV debug_level=3 etm=1 \
899 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100900 "$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 +0100901 0 \
902 -c "client hello, adding encrypt_then_mac extension" \
903 -s "found encrypt then mac extension" \
904 -S "server hello, adding encrypt then mac extension" \
905 -C "found encrypt_then_mac extension" \
906 -C "using encrypt then mac" \
907 -S "using encrypt then mac"
908
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100909run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100910 "$P_SRV debug_level=3 etm=1 \
911 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100912 "$P_CLI debug_level=3 etm=0" \
913 0 \
914 -C "client hello, adding encrypt_then_mac extension" \
915 -S "found encrypt then mac extension" \
916 -S "server hello, adding encrypt then mac extension" \
917 -C "found encrypt_then_mac extension" \
918 -C "using encrypt then mac" \
919 -S "using encrypt then mac"
920
Janos Follathe2681a42016-03-07 15:57:05 +0000921requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100922run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100923 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100924 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100925 "$P_CLI debug_level=3 force_version=ssl3" \
926 0 \
927 -C "client hello, adding encrypt_then_mac extension" \
928 -S "found encrypt then mac extension" \
929 -S "server hello, adding encrypt then mac extension" \
930 -C "found encrypt_then_mac extension" \
931 -C "using encrypt then mac" \
932 -S "using encrypt then mac"
933
Janos Follathe2681a42016-03-07 15:57:05 +0000934requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100935run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +0100936 "$P_SRV debug_level=3 force_version=ssl3 \
937 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100938 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100939 0 \
940 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +0100941 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100942 -S "server hello, adding encrypt then mac extension" \
943 -C "found encrypt_then_mac extension" \
944 -C "using encrypt then mac" \
945 -S "using encrypt then mac"
946
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +0200947# Tests for Extended Master Secret extension
948
949run_test "Extended Master Secret: default" \
950 "$P_SRV debug_level=3" \
951 "$P_CLI debug_level=3" \
952 0 \
953 -c "client hello, adding extended_master_secret extension" \
954 -s "found extended master secret extension" \
955 -s "server hello, adding extended master secret extension" \
956 -c "found extended_master_secret extension" \
957 -c "using extended master secret" \
958 -s "using extended master secret"
959
960run_test "Extended Master Secret: client enabled, server disabled" \
961 "$P_SRV debug_level=3 extended_ms=0" \
962 "$P_CLI debug_level=3 extended_ms=1" \
963 0 \
964 -c "client hello, adding extended_master_secret extension" \
965 -s "found extended master secret extension" \
966 -S "server hello, adding extended master secret extension" \
967 -C "found extended_master_secret extension" \
968 -C "using extended master secret" \
969 -S "using extended master secret"
970
971run_test "Extended Master Secret: client disabled, server enabled" \
972 "$P_SRV debug_level=3 extended_ms=1" \
973 "$P_CLI debug_level=3 extended_ms=0" \
974 0 \
975 -C "client hello, adding extended_master_secret extension" \
976 -S "found extended master secret extension" \
977 -S "server hello, adding extended master secret extension" \
978 -C "found extended_master_secret extension" \
979 -C "using extended master secret" \
980 -S "using extended master secret"
981
Janos Follathe2681a42016-03-07 15:57:05 +0000982requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200983run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100984 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200985 "$P_CLI debug_level=3 force_version=ssl3" \
986 0 \
987 -C "client hello, adding extended_master_secret extension" \
988 -S "found extended master secret extension" \
989 -S "server hello, adding extended master secret extension" \
990 -C "found extended_master_secret extension" \
991 -C "using extended master secret" \
992 -S "using extended master secret"
993
Janos Follathe2681a42016-03-07 15:57:05 +0000994requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200995run_test "Extended Master Secret: client enabled, server SSLv3" \
996 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +0100997 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +0200998 0 \
999 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001000 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001001 -S "server hello, adding extended master secret extension" \
1002 -C "found extended_master_secret extension" \
1003 -C "using extended master secret" \
1004 -S "using extended master secret"
1005
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001006# Tests for FALLBACK_SCSV
1007
1008run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001009 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001010 "$P_CLI debug_level=3 force_version=tls1_1" \
1011 0 \
1012 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001013 -S "received FALLBACK_SCSV" \
1014 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001015 -C "is a fatal alert message (msg 86)"
1016
1017run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001018 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001019 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1020 0 \
1021 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001022 -S "received FALLBACK_SCSV" \
1023 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001024 -C "is a fatal alert message (msg 86)"
1025
1026run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001027 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001028 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001029 1 \
1030 -c "adding FALLBACK_SCSV" \
1031 -s "received FALLBACK_SCSV" \
1032 -s "inapropriate fallback" \
1033 -c "is a fatal alert message (msg 86)"
1034
1035run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001036 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001037 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001038 0 \
1039 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001040 -s "received FALLBACK_SCSV" \
1041 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001042 -C "is a fatal alert message (msg 86)"
1043
1044requires_openssl_with_fallback_scsv
1045run_test "Fallback SCSV: default, openssl server" \
1046 "$O_SRV" \
1047 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1048 0 \
1049 -C "adding FALLBACK_SCSV" \
1050 -C "is a fatal alert message (msg 86)"
1051
1052requires_openssl_with_fallback_scsv
1053run_test "Fallback SCSV: enabled, openssl server" \
1054 "$O_SRV" \
1055 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1056 1 \
1057 -c "adding FALLBACK_SCSV" \
1058 -c "is a fatal alert message (msg 86)"
1059
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001060requires_openssl_with_fallback_scsv
1061run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001062 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001063 "$O_CLI -tls1_1" \
1064 0 \
1065 -S "received FALLBACK_SCSV" \
1066 -S "inapropriate fallback"
1067
1068requires_openssl_with_fallback_scsv
1069run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001070 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001071 "$O_CLI -tls1_1 -fallback_scsv" \
1072 1 \
1073 -s "received FALLBACK_SCSV" \
1074 -s "inapropriate fallback"
1075
1076requires_openssl_with_fallback_scsv
1077run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001078 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001079 "$O_CLI -fallback_scsv" \
1080 0 \
1081 -s "received FALLBACK_SCSV" \
1082 -S "inapropriate fallback"
1083
Gilles Peskined50177f2017-05-16 17:53:03 +02001084## ClientHello generated with
1085## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1086## then manually twiddling the ciphersuite list.
1087## The ClientHello content is spelled out below as a hex string as
1088## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1089## The expected response is an inappropriate_fallback alert.
1090requires_openssl_with_fallback_scsv
1091run_test "Fallback SCSV: beginning of list" \
1092 "$P_SRV debug_level=2" \
1093 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1094 0 \
1095 -s "received FALLBACK_SCSV" \
1096 -s "inapropriate fallback"
1097
1098requires_openssl_with_fallback_scsv
1099run_test "Fallback SCSV: end of list" \
1100 "$P_SRV debug_level=2" \
1101 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1102 0 \
1103 -s "received FALLBACK_SCSV" \
1104 -s "inapropriate fallback"
1105
1106## Here the expected response is a valid ServerHello prefix, up to the random.
1107requires_openssl_with_fallback_scsv
1108run_test "Fallback SCSV: not in list" \
1109 "$P_SRV debug_level=2" \
1110 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1111 0 \
1112 -S "received FALLBACK_SCSV" \
1113 -S "inapropriate fallback"
1114
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001115# Tests for CBC 1/n-1 record splitting
1116
1117run_test "CBC Record splitting: TLS 1.2, no splitting" \
1118 "$P_SRV" \
1119 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1120 request_size=123 force_version=tls1_2" \
1121 0 \
1122 -s "Read from client: 123 bytes read" \
1123 -S "Read from client: 1 bytes read" \
1124 -S "122 bytes read"
1125
1126run_test "CBC Record splitting: TLS 1.1, no splitting" \
1127 "$P_SRV" \
1128 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1129 request_size=123 force_version=tls1_1" \
1130 0 \
1131 -s "Read from client: 123 bytes read" \
1132 -S "Read from client: 1 bytes read" \
1133 -S "122 bytes read"
1134
1135run_test "CBC Record splitting: TLS 1.0, splitting" \
1136 "$P_SRV" \
1137 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1138 request_size=123 force_version=tls1" \
1139 0 \
1140 -S "Read from client: 123 bytes read" \
1141 -s "Read from client: 1 bytes read" \
1142 -s "122 bytes read"
1143
Janos Follathe2681a42016-03-07 15:57:05 +00001144requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001145run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001146 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001147 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1148 request_size=123 force_version=ssl3" \
1149 0 \
1150 -S "Read from client: 123 bytes read" \
1151 -s "Read from client: 1 bytes read" \
1152 -s "122 bytes read"
1153
1154run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001155 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001156 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1157 request_size=123 force_version=tls1" \
1158 0 \
1159 -s "Read from client: 123 bytes read" \
1160 -S "Read from client: 1 bytes read" \
1161 -S "122 bytes read"
1162
1163run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1164 "$P_SRV" \
1165 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1166 request_size=123 force_version=tls1 recsplit=0" \
1167 0 \
1168 -s "Read from client: 123 bytes read" \
1169 -S "Read from client: 1 bytes read" \
1170 -S "122 bytes read"
1171
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001172run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1173 "$P_SRV nbio=2" \
1174 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1175 request_size=123 force_version=tls1" \
1176 0 \
1177 -S "Read from client: 123 bytes read" \
1178 -s "Read from client: 1 bytes read" \
1179 -s "122 bytes read"
1180
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001181# Tests for Session Tickets
1182
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001183run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001184 "$P_SRV debug_level=3 tickets=1" \
1185 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001186 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001187 -c "client hello, adding session ticket extension" \
1188 -s "found session ticket extension" \
1189 -s "server hello, adding session ticket extension" \
1190 -c "found session_ticket extension" \
1191 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001192 -S "session successfully restored from cache" \
1193 -s "session successfully restored from ticket" \
1194 -s "a session has been resumed" \
1195 -c "a session has been resumed"
1196
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001197run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001198 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1199 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001200 0 \
1201 -c "client hello, adding session ticket extension" \
1202 -s "found session ticket extension" \
1203 -s "server hello, adding session ticket extension" \
1204 -c "found session_ticket extension" \
1205 -c "parse new session ticket" \
1206 -S "session successfully restored from cache" \
1207 -s "session successfully restored from ticket" \
1208 -s "a session has been resumed" \
1209 -c "a session has been resumed"
1210
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001211run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001212 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1213 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001214 0 \
1215 -c "client hello, adding session ticket extension" \
1216 -s "found session ticket extension" \
1217 -s "server hello, adding session ticket extension" \
1218 -c "found session_ticket extension" \
1219 -c "parse new session ticket" \
1220 -S "session successfully restored from cache" \
1221 -S "session successfully restored from ticket" \
1222 -S "a session has been resumed" \
1223 -C "a session has been resumed"
1224
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001225run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001226 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001227 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001228 0 \
1229 -c "client hello, adding session ticket extension" \
1230 -c "found session_ticket extension" \
1231 -c "parse new session ticket" \
1232 -c "a session has been resumed"
1233
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001234run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001235 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001236 "( $O_CLI -sess_out $SESSION; \
1237 $O_CLI -sess_in $SESSION; \
1238 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001239 0 \
1240 -s "found session ticket extension" \
1241 -s "server hello, adding session ticket extension" \
1242 -S "session successfully restored from cache" \
1243 -s "session successfully restored from ticket" \
1244 -s "a session has been resumed"
1245
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001246# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001247
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001248run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001249 "$P_SRV debug_level=3 tickets=0" \
1250 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001251 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001252 -c "client hello, adding session ticket extension" \
1253 -s "found session ticket extension" \
1254 -S "server hello, adding session ticket extension" \
1255 -C "found session_ticket extension" \
1256 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001257 -s "session successfully restored from cache" \
1258 -S "session successfully restored from ticket" \
1259 -s "a session has been resumed" \
1260 -c "a session has been resumed"
1261
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001262run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001263 "$P_SRV debug_level=3 tickets=1" \
1264 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001265 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001266 -C "client hello, adding session ticket extension" \
1267 -S "found session ticket extension" \
1268 -S "server hello, adding session ticket extension" \
1269 -C "found session_ticket extension" \
1270 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001271 -s "session successfully restored from cache" \
1272 -S "session successfully restored from ticket" \
1273 -s "a session has been resumed" \
1274 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001276run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001277 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1278 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001279 0 \
1280 -S "session successfully restored from cache" \
1281 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001282 -S "a session has been resumed" \
1283 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001285run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001286 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1287 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001288 0 \
1289 -s "session successfully restored from cache" \
1290 -S "session successfully restored from ticket" \
1291 -s "a session has been resumed" \
1292 -c "a session has been resumed"
1293
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001294run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001295 "$P_SRV debug_level=3 tickets=0" \
1296 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001297 0 \
1298 -s "session successfully restored from cache" \
1299 -S "session successfully restored from ticket" \
1300 -s "a session has been resumed" \
1301 -c "a session has been resumed"
1302
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001303run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001304 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1305 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001306 0 \
1307 -S "session successfully restored from cache" \
1308 -S "session successfully restored from ticket" \
1309 -S "a session has been resumed" \
1310 -C "a session has been resumed"
1311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001312run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001313 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1314 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001315 0 \
1316 -s "session successfully restored from cache" \
1317 -S "session successfully restored from ticket" \
1318 -s "a session has been resumed" \
1319 -c "a session has been resumed"
1320
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001321run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001322 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001323 "( $O_CLI -sess_out $SESSION; \
1324 $O_CLI -sess_in $SESSION; \
1325 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001326 0 \
1327 -s "found session ticket extension" \
1328 -S "server hello, adding session ticket extension" \
1329 -s "session successfully restored from cache" \
1330 -S "session successfully restored from ticket" \
1331 -s "a session has been resumed"
1332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001333run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001334 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001335 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001336 0 \
1337 -C "found session_ticket extension" \
1338 -C "parse new session ticket" \
1339 -c "a session has been resumed"
1340
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001341# Tests for Max Fragment Length extension
1342
Hanno Becker6428f8d2017-09-22 16:58:50 +01001343MAX_CONTENT_LEN_EXPECT='16384'
1344MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
1345
1346if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
1347 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
1348 printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
1349 printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
1350 printf "\n"
1351 printf "The tests assume this value and if it changes, the tests in this\n"
1352 printf "script should also be adjusted.\n"
1353 printf "\n"
1354
1355 exit 1
1356fi
1357
Hanno Becker4aed27e2017-09-18 15:00:34 +01001358requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001359run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001360 "$P_SRV debug_level=3" \
1361 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001362 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001363 -c "Maximum fragment length is 16384" \
1364 -s "Maximum fragment length is 16384" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001365 -C "client hello, adding max_fragment_length extension" \
1366 -S "found max fragment length extension" \
1367 -S "server hello, max_fragment_length extension" \
1368 -C "found max_fragment_length extension"
1369
Hanno Becker4aed27e2017-09-18 15:00:34 +01001370requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001371run_test "Max fragment length: enabled, default, larger message" \
1372 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001373 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001374 0 \
1375 -c "Maximum fragment length is 16384" \
1376 -s "Maximum fragment length is 16384" \
1377 -C "client hello, adding max_fragment_length extension" \
1378 -S "found max fragment length extension" \
1379 -S "server hello, max_fragment_length extension" \
1380 -C "found max_fragment_length extension" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001381 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001382 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001383 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001384
1385requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1386run_test "Max fragment length, DTLS: enabled, default, larger message" \
1387 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001388 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001389 1 \
1390 -c "Maximum fragment length is 16384" \
1391 -s "Maximum fragment length is 16384" \
1392 -C "client hello, adding max_fragment_length extension" \
1393 -S "found max fragment length extension" \
1394 -S "server hello, max_fragment_length extension" \
1395 -C "found max_fragment_length extension" \
1396 -c "fragment larger than.*maximum "
1397
1398requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1399run_test "Max fragment length: disabled, larger message" \
1400 "$P_SRV debug_level=3" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001401 "$P_CLI debug_level=3 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001402 0 \
1403 -C "Maximum fragment length is 16384" \
1404 -S "Maximum fragment length is 16384" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001405 -c "16385 bytes written in 2 fragments" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001406 -s "16384 bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001407 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001408
1409requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1410run_test "Max fragment length DTLS: disabled, larger message" \
1411 "$P_SRV debug_level=3 dtls=1" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001412 "$P_CLI debug_level=3 dtls=1 request_size=16385" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001413 1 \
1414 -C "Maximum fragment length is 16384" \
1415 -S "Maximum fragment length is 16384" \
1416 -c "fragment larger than.*maximum "
1417
1418requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001419run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001420 "$P_SRV debug_level=3" \
1421 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001422 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001423 -c "Maximum fragment length is 4096" \
1424 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001425 -c "client hello, adding max_fragment_length extension" \
1426 -s "found max fragment length extension" \
1427 -s "server hello, max_fragment_length extension" \
1428 -c "found max_fragment_length extension"
1429
Hanno Becker4aed27e2017-09-18 15:00:34 +01001430requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001431run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_SRV debug_level=3 max_frag_len=4096" \
1433 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001434 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001435 -c "Maximum fragment length is 16384" \
1436 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001437 -C "client hello, adding max_fragment_length extension" \
1438 -S "found max fragment length extension" \
1439 -S "server hello, max_fragment_length extension" \
1440 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001441
Hanno Becker4aed27e2017-09-18 15:00:34 +01001442requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001443requires_gnutls
1444run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001445 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001446 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001447 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001448 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001449 -c "client hello, adding max_fragment_length extension" \
1450 -c "found max_fragment_length extension"
1451
Hanno Becker4aed27e2017-09-18 15:00:34 +01001452requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001453run_test "Max fragment length: client, message just fits" \
1454 "$P_SRV debug_level=3" \
1455 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1456 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001457 -c "Maximum fragment length is 2048" \
1458 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001459 -c "client hello, adding max_fragment_length extension" \
1460 -s "found max fragment length extension" \
1461 -s "server hello, max_fragment_length extension" \
1462 -c "found max_fragment_length extension" \
1463 -c "2048 bytes written in 1 fragments" \
1464 -s "2048 bytes read"
1465
Hanno Becker4aed27e2017-09-18 15:00:34 +01001466requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001467run_test "Max fragment length: client, larger message" \
1468 "$P_SRV debug_level=3" \
1469 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1470 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001471 -c "Maximum fragment length is 2048" \
1472 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001473 -c "client hello, adding max_fragment_length extension" \
1474 -s "found max fragment length extension" \
1475 -s "server hello, max_fragment_length extension" \
1476 -c "found max_fragment_length extension" \
1477 -c "2345 bytes written in 2 fragments" \
1478 -s "2048 bytes read" \
1479 -s "297 bytes read"
1480
Hanno Becker4aed27e2017-09-18 15:00:34 +01001481requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00001482run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001483 "$P_SRV debug_level=3 dtls=1" \
1484 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
1485 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001486 -c "Maximum fragment length is 2048" \
1487 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001488 -c "client hello, adding max_fragment_length extension" \
1489 -s "found max fragment length extension" \
1490 -s "server hello, max_fragment_length extension" \
1491 -c "found max_fragment_length extension" \
1492 -c "fragment larger than.*maximum"
1493
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001494# Tests for renegotiation
1495
Hanno Becker6a243642017-10-12 15:18:45 +01001496# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001497run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001498 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001499 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001500 0 \
1501 -C "client hello, adding renegotiation extension" \
1502 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1503 -S "found renegotiation extension" \
1504 -s "server hello, secure renegotiation extension" \
1505 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001506 -C "=> renegotiate" \
1507 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001508 -S "write hello request"
1509
Hanno Becker6a243642017-10-12 15:18:45 +01001510requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001511run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001512 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001513 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001514 0 \
1515 -c "client hello, adding renegotiation extension" \
1516 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1517 -s "found renegotiation extension" \
1518 -s "server hello, secure renegotiation extension" \
1519 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001520 -c "=> renegotiate" \
1521 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001522 -S "write hello request"
1523
Hanno Becker6a243642017-10-12 15:18:45 +01001524requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001525run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001526 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001527 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001528 0 \
1529 -c "client hello, adding renegotiation extension" \
1530 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1531 -s "found renegotiation extension" \
1532 -s "server hello, secure renegotiation extension" \
1533 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001534 -c "=> renegotiate" \
1535 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001536 -s "write hello request"
1537
Janos Follathb0f148c2017-10-05 12:29:42 +01001538# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1539# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1540# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001541requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001542run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
1543 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
1544 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
1545 0 \
1546 -c "client hello, adding renegotiation extension" \
1547 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1548 -s "found renegotiation extension" \
1549 -s "server hello, secure renegotiation extension" \
1550 -c "found renegotiation extension" \
1551 -c "=> renegotiate" \
1552 -s "=> renegotiate" \
1553 -S "write hello request" \
1554 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1555
1556# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
1557# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
1558# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01001559requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01001560run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
1561 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
1562 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1563 0 \
1564 -c "client hello, adding renegotiation extension" \
1565 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1566 -s "found renegotiation extension" \
1567 -s "server hello, secure renegotiation extension" \
1568 -c "found renegotiation extension" \
1569 -c "=> renegotiate" \
1570 -s "=> renegotiate" \
1571 -s "write hello request" \
1572 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
1573
Hanno Becker6a243642017-10-12 15:18:45 +01001574requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001576 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001577 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001578 0 \
1579 -c "client hello, adding renegotiation extension" \
1580 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1581 -s "found renegotiation extension" \
1582 -s "server hello, secure renegotiation extension" \
1583 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001584 -c "=> renegotiate" \
1585 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001586 -s "write hello request"
1587
Hanno Becker6a243642017-10-12 15:18:45 +01001588requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001590 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001591 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001592 1 \
1593 -c "client hello, adding renegotiation extension" \
1594 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1595 -S "found renegotiation extension" \
1596 -s "server hello, secure renegotiation extension" \
1597 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001598 -c "=> renegotiate" \
1599 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001600 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02001601 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001602 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001603
Hanno Becker6a243642017-10-12 15:18:45 +01001604requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001605run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001606 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001607 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001608 0 \
1609 -C "client hello, adding renegotiation extension" \
1610 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1611 -S "found renegotiation extension" \
1612 -s "server hello, secure renegotiation extension" \
1613 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01001614 -C "=> renegotiate" \
1615 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001616 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02001617 -S "SSL - An unexpected message was received from our peer" \
1618 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01001619
Hanno Becker6a243642017-10-12 15:18:45 +01001620requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001621run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001622 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001623 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001624 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001625 0 \
1626 -C "client hello, adding renegotiation extension" \
1627 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1628 -S "found renegotiation extension" \
1629 -s "server hello, secure renegotiation extension" \
1630 -c "found renegotiation extension" \
1631 -C "=> renegotiate" \
1632 -S "=> renegotiate" \
1633 -s "write hello request" \
1634 -S "SSL - An unexpected message was received from our peer" \
1635 -S "failed"
1636
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001637# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01001638requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001639run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001640 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001641 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001642 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001643 0 \
1644 -C "client hello, adding renegotiation extension" \
1645 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1646 -S "found renegotiation extension" \
1647 -s "server hello, secure renegotiation extension" \
1648 -c "found renegotiation extension" \
1649 -C "=> renegotiate" \
1650 -S "=> renegotiate" \
1651 -s "write hello request" \
1652 -S "SSL - An unexpected message was received from our peer" \
1653 -S "failed"
1654
Hanno Becker6a243642017-10-12 15:18:45 +01001655requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001656run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001657 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001658 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001659 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001660 0 \
1661 -C "client hello, adding renegotiation extension" \
1662 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1663 -S "found renegotiation extension" \
1664 -s "server hello, secure renegotiation extension" \
1665 -c "found renegotiation extension" \
1666 -C "=> renegotiate" \
1667 -S "=> renegotiate" \
1668 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02001669 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001670
Hanno Becker6a243642017-10-12 15:18:45 +01001671requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001672run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001673 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001674 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001675 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02001676 0 \
1677 -c "client hello, adding renegotiation extension" \
1678 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1679 -s "found renegotiation extension" \
1680 -s "server hello, secure renegotiation extension" \
1681 -c "found renegotiation extension" \
1682 -c "=> renegotiate" \
1683 -s "=> renegotiate" \
1684 -s "write hello request" \
1685 -S "SSL - An unexpected message was received from our peer" \
1686 -S "failed"
1687
Hanno Becker6a243642017-10-12 15:18:45 +01001688requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001689run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001690 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001691 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
1692 0 \
1693 -C "client hello, adding renegotiation extension" \
1694 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1695 -S "found renegotiation extension" \
1696 -s "server hello, secure renegotiation extension" \
1697 -c "found renegotiation extension" \
1698 -S "record counter limit reached: renegotiate" \
1699 -C "=> renegotiate" \
1700 -S "=> renegotiate" \
1701 -S "write hello request" \
1702 -S "SSL - An unexpected message was received from our peer" \
1703 -S "failed"
1704
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001705# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01001706requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001707run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001708 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001709 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001710 0 \
1711 -c "client hello, adding renegotiation extension" \
1712 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1713 -s "found renegotiation extension" \
1714 -s "server hello, secure renegotiation extension" \
1715 -c "found renegotiation extension" \
1716 -s "record counter limit reached: renegotiate" \
1717 -c "=> renegotiate" \
1718 -s "=> renegotiate" \
1719 -s "write hello request" \
1720 -S "SSL - An unexpected message was received from our peer" \
1721 -S "failed"
1722
Hanno Becker6a243642017-10-12 15:18:45 +01001723requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001724run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001725 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01001726 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001727 0 \
1728 -c "client hello, adding renegotiation extension" \
1729 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1730 -s "found renegotiation extension" \
1731 -s "server hello, secure renegotiation extension" \
1732 -c "found renegotiation extension" \
1733 -s "record counter limit reached: renegotiate" \
1734 -c "=> renegotiate" \
1735 -s "=> renegotiate" \
1736 -s "write hello request" \
1737 -S "SSL - An unexpected message was received from our peer" \
1738 -S "failed"
1739
Hanno Becker6a243642017-10-12 15:18:45 +01001740requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001741run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001742 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01001743 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
1744 0 \
1745 -C "client hello, adding renegotiation extension" \
1746 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1747 -S "found renegotiation extension" \
1748 -s "server hello, secure renegotiation extension" \
1749 -c "found renegotiation extension" \
1750 -S "record counter limit reached: renegotiate" \
1751 -C "=> renegotiate" \
1752 -S "=> renegotiate" \
1753 -S "write hello request" \
1754 -S "SSL - An unexpected message was received from our peer" \
1755 -S "failed"
1756
Hanno Becker6a243642017-10-12 15:18:45 +01001757requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001759 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001760 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001761 0 \
1762 -c "client hello, adding renegotiation extension" \
1763 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1764 -s "found renegotiation extension" \
1765 -s "server hello, secure renegotiation extension" \
1766 -c "found renegotiation extension" \
1767 -c "=> renegotiate" \
1768 -s "=> renegotiate" \
1769 -S "write hello request"
1770
Hanno Becker6a243642017-10-12 15:18:45 +01001771requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01001773 "$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 +02001774 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02001775 0 \
1776 -c "client hello, adding renegotiation extension" \
1777 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1778 -s "found renegotiation extension" \
1779 -s "server hello, secure renegotiation extension" \
1780 -c "found renegotiation extension" \
1781 -c "=> renegotiate" \
1782 -s "=> renegotiate" \
1783 -s "write hello request"
1784
Hanno Becker6a243642017-10-12 15:18:45 +01001785requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001786run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02001787 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001788 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001789 0 \
1790 -c "client hello, adding renegotiation extension" \
1791 -c "found renegotiation extension" \
1792 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001793 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001794 -C "error" \
1795 -c "HTTP/1.0 200 [Oo][Kk]"
1796
Paul Bakker539d9722015-02-08 16:18:35 +01001797requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001798requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001799run_test "Renegotiation: gnutls server strict, client-initiated" \
1800 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001801 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001802 0 \
1803 -c "client hello, adding renegotiation extension" \
1804 -c "found renegotiation extension" \
1805 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001806 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02001807 -C "error" \
1808 -c "HTTP/1.0 200 [Oo][Kk]"
1809
Paul Bakker539d9722015-02-08 16:18:35 +01001810requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001811requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001812run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
1813 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1814 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
1815 1 \
1816 -c "client hello, adding renegotiation extension" \
1817 -C "found renegotiation extension" \
1818 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001819 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001820 -c "error" \
1821 -C "HTTP/1.0 200 [Oo][Kk]"
1822
Paul Bakker539d9722015-02-08 16:18:35 +01001823requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001824requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001825run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
1826 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1827 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1828 allow_legacy=0" \
1829 1 \
1830 -c "client hello, adding renegotiation extension" \
1831 -C "found renegotiation extension" \
1832 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001833 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001834 -c "error" \
1835 -C "HTTP/1.0 200 [Oo][Kk]"
1836
Paul Bakker539d9722015-02-08 16:18:35 +01001837requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001838requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001839run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
1840 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1841 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
1842 allow_legacy=1" \
1843 0 \
1844 -c "client hello, adding renegotiation extension" \
1845 -C "found renegotiation extension" \
1846 -c "=> renegotiate" \
1847 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01001848 -C "error" \
1849 -c "HTTP/1.0 200 [Oo][Kk]"
1850
Hanno Becker6a243642017-10-12 15:18:45 +01001851requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02001852run_test "Renegotiation: DTLS, client-initiated" \
1853 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
1854 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
1855 0 \
1856 -c "client hello, adding renegotiation extension" \
1857 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1858 -s "found renegotiation extension" \
1859 -s "server hello, secure renegotiation extension" \
1860 -c "found renegotiation extension" \
1861 -c "=> renegotiate" \
1862 -s "=> renegotiate" \
1863 -S "write hello request"
1864
Hanno Becker6a243642017-10-12 15:18:45 +01001865requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001866run_test "Renegotiation: DTLS, server-initiated" \
1867 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02001868 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
1869 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02001870 0 \
1871 -c "client hello, adding renegotiation extension" \
1872 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1873 -s "found renegotiation extension" \
1874 -s "server hello, secure renegotiation extension" \
1875 -c "found renegotiation extension" \
1876 -c "=> renegotiate" \
1877 -s "=> renegotiate" \
1878 -s "write hello request"
1879
Hanno Becker6a243642017-10-12 15:18:45 +01001880requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00001881run_test "Renegotiation: DTLS, renego_period overflow" \
1882 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
1883 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
1884 0 \
1885 -c "client hello, adding renegotiation extension" \
1886 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
1887 -s "found renegotiation extension" \
1888 -s "server hello, secure renegotiation extension" \
1889 -s "record counter limit reached: renegotiate" \
1890 -c "=> renegotiate" \
1891 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01001892 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00001893
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00001894requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01001895requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001896run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
1897 "$G_SRV -u --mtu 4096" \
1898 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
1899 0 \
1900 -c "client hello, adding renegotiation extension" \
1901 -c "found renegotiation extension" \
1902 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02001903 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02001904 -C "error" \
1905 -s "Extra-header:"
1906
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001907# Test for the "secure renegotation" extension only (no actual renegotiation)
1908
Paul Bakker539d9722015-02-08 16:18:35 +01001909requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001910run_test "Renego ext: gnutls server strict, client default" \
1911 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
1912 "$P_CLI debug_level=3" \
1913 0 \
1914 -c "found renegotiation extension" \
1915 -C "error" \
1916 -c "HTTP/1.0 200 [Oo][Kk]"
1917
Paul Bakker539d9722015-02-08 16:18:35 +01001918requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001919run_test "Renego ext: gnutls server unsafe, client default" \
1920 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1921 "$P_CLI debug_level=3" \
1922 0 \
1923 -C "found renegotiation extension" \
1924 -C "error" \
1925 -c "HTTP/1.0 200 [Oo][Kk]"
1926
Paul Bakker539d9722015-02-08 16:18:35 +01001927requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001928run_test "Renego ext: gnutls server unsafe, client break legacy" \
1929 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1930 "$P_CLI debug_level=3 allow_legacy=-1" \
1931 1 \
1932 -C "found renegotiation extension" \
1933 -c "error" \
1934 -C "HTTP/1.0 200 [Oo][Kk]"
1935
Paul Bakker539d9722015-02-08 16:18:35 +01001936requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001937run_test "Renego ext: gnutls client strict, server default" \
1938 "$P_SRV debug_level=3" \
1939 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \
1940 0 \
1941 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1942 -s "server hello, secure renegotiation extension"
1943
Paul Bakker539d9722015-02-08 16:18:35 +01001944requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001945run_test "Renego ext: gnutls client unsafe, server default" \
1946 "$P_SRV debug_level=3" \
1947 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1948 0 \
1949 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1950 -S "server hello, secure renegotiation extension"
1951
Paul Bakker539d9722015-02-08 16:18:35 +01001952requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01001953run_test "Renego ext: gnutls client unsafe, server break legacy" \
1954 "$P_SRV debug_level=3 allow_legacy=-1" \
1955 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
1956 1 \
1957 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
1958 -S "server hello, secure renegotiation extension"
1959
Janos Follath0b242342016-02-17 10:11:21 +00001960# Tests for silently dropping trailing extra bytes in .der certificates
1961
1962requires_gnutls
1963run_test "DER format: no trailing bytes" \
1964 "$P_SRV crt_file=data_files/server5-der0.crt \
1965 key_file=data_files/server5.key" \
1966 "$G_CLI " \
1967 0 \
1968 -c "Handshake was completed" \
1969
1970requires_gnutls
1971run_test "DER format: with a trailing zero byte" \
1972 "$P_SRV crt_file=data_files/server5-der1a.crt \
1973 key_file=data_files/server5.key" \
1974 "$G_CLI " \
1975 0 \
1976 -c "Handshake was completed" \
1977
1978requires_gnutls
1979run_test "DER format: with a trailing random byte" \
1980 "$P_SRV crt_file=data_files/server5-der1b.crt \
1981 key_file=data_files/server5.key" \
1982 "$G_CLI " \
1983 0 \
1984 -c "Handshake was completed" \
1985
1986requires_gnutls
1987run_test "DER format: with 2 trailing random bytes" \
1988 "$P_SRV crt_file=data_files/server5-der2.crt \
1989 key_file=data_files/server5.key" \
1990 "$G_CLI " \
1991 0 \
1992 -c "Handshake was completed" \
1993
1994requires_gnutls
1995run_test "DER format: with 4 trailing random bytes" \
1996 "$P_SRV crt_file=data_files/server5-der4.crt \
1997 key_file=data_files/server5.key" \
1998 "$G_CLI " \
1999 0 \
2000 -c "Handshake was completed" \
2001
2002requires_gnutls
2003run_test "DER format: with 8 trailing random bytes" \
2004 "$P_SRV crt_file=data_files/server5-der8.crt \
2005 key_file=data_files/server5.key" \
2006 "$G_CLI " \
2007 0 \
2008 -c "Handshake was completed" \
2009
2010requires_gnutls
2011run_test "DER format: with 9 trailing random bytes" \
2012 "$P_SRV crt_file=data_files/server5-der9.crt \
2013 key_file=data_files/server5.key" \
2014 "$G_CLI " \
2015 0 \
2016 -c "Handshake was completed" \
2017
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002018# Tests for auth_mode
2019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002021 "$P_SRV crt_file=data_files/server5-badsign.crt \
2022 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002023 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002024 1 \
2025 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002026 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002027 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002028 -c "X509 - Certificate verification failed"
2029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002030run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002031 "$P_SRV crt_file=data_files/server5-badsign.crt \
2032 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002033 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002034 0 \
2035 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002036 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002037 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002038 -C "X509 - Certificate verification failed"
2039
Hanno Beckere6706e62017-05-15 16:05:15 +01002040run_test "Authentication: server goodcert, client optional, no trusted CA" \
2041 "$P_SRV" \
2042 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2043 0 \
2044 -c "x509_verify_cert() returned" \
2045 -c "! The certificate is not correctly signed by the trusted CA" \
2046 -c "! Certificate verification flags"\
2047 -C "! mbedtls_ssl_handshake returned" \
2048 -C "X509 - Certificate verification failed" \
2049 -C "SSL - No CA Chain is set, but required to operate"
2050
2051run_test "Authentication: server goodcert, client required, no trusted CA" \
2052 "$P_SRV" \
2053 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2054 1 \
2055 -c "x509_verify_cert() returned" \
2056 -c "! The certificate is not correctly signed by the trusted CA" \
2057 -c "! Certificate verification flags"\
2058 -c "! mbedtls_ssl_handshake returned" \
2059 -c "SSL - No CA Chain is set, but required to operate"
2060
2061# The purpose of the next two tests is to test the client's behaviour when receiving a server
2062# certificate with an unsupported elliptic curve. This should usually not happen because
2063# the client informs the server about the supported curves - it does, though, in the
2064# corner case of a static ECDH suite, because the server doesn't check the curve on that
2065# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2066# different means to have the server ignoring the client's supported curve list.
2067
2068requires_config_enabled MBEDTLS_ECP_C
2069run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2070 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2071 crt_file=data_files/server5.ku-ka.crt" \
2072 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2073 1 \
2074 -c "bad certificate (EC key curve)"\
2075 -c "! Certificate verification flags"\
2076 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2077
2078requires_config_enabled MBEDTLS_ECP_C
2079run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2080 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2081 crt_file=data_files/server5.ku-ka.crt" \
2082 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2083 1 \
2084 -c "bad certificate (EC key curve)"\
2085 -c "! Certificate verification flags"\
2086 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002088run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002089 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002090 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002091 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002092 0 \
2093 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002094 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002095 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002096 -C "X509 - Certificate verification failed"
2097
Simon Butcher99000142016-10-13 17:21:01 +01002098run_test "Authentication: client SHA256, server required" \
2099 "$P_SRV auth_mode=required" \
2100 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2101 key_file=data_files/server6.key \
2102 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2103 0 \
2104 -c "Supported Signature Algorithm found: 4," \
2105 -c "Supported Signature Algorithm found: 5,"
2106
2107run_test "Authentication: client SHA384, server required" \
2108 "$P_SRV auth_mode=required" \
2109 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2110 key_file=data_files/server6.key \
2111 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2112 0 \
2113 -c "Supported Signature Algorithm found: 4," \
2114 -c "Supported Signature Algorithm found: 5,"
2115
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002116requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2117run_test "Authentication: client has no cert, server required (SSLv3)" \
2118 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2119 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2120 key_file=data_files/server5.key" \
2121 1 \
2122 -S "skip write certificate request" \
2123 -C "skip parse certificate request" \
2124 -c "got a certificate request" \
2125 -c "got no certificate to send" \
2126 -S "x509_verify_cert() returned" \
2127 -s "client has no certificate" \
2128 -s "! mbedtls_ssl_handshake returned" \
2129 -c "! mbedtls_ssl_handshake returned" \
2130 -s "No client certification received from the client, but required by the authentication mode"
2131
2132run_test "Authentication: client has no cert, server required (TLS)" \
2133 "$P_SRV debug_level=3 auth_mode=required" \
2134 "$P_CLI debug_level=3 crt_file=none \
2135 key_file=data_files/server5.key" \
2136 1 \
2137 -S "skip write certificate request" \
2138 -C "skip parse certificate request" \
2139 -c "got a certificate request" \
2140 -c "= write certificate$" \
2141 -C "skip write certificate$" \
2142 -S "x509_verify_cert() returned" \
2143 -s "client has no certificate" \
2144 -s "! mbedtls_ssl_handshake returned" \
2145 -c "! mbedtls_ssl_handshake returned" \
2146 -s "No client certification received from the client, but required by the authentication mode"
2147
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002148run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002149 "$P_SRV debug_level=3 auth_mode=required" \
2150 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002151 key_file=data_files/server5.key" \
2152 1 \
2153 -S "skip write certificate request" \
2154 -C "skip parse certificate request" \
2155 -c "got a certificate request" \
2156 -C "skip write certificate" \
2157 -C "skip write certificate verify" \
2158 -S "skip parse certificate verify" \
2159 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002160 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002161 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002162 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002163 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002164 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002165# We don't check that the client receives the alert because it might
2166# detect that its write end of the connection is closed and abort
2167# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002168
Janos Follath89baba22017-04-10 14:34:35 +01002169run_test "Authentication: client cert not trusted, server required" \
2170 "$P_SRV debug_level=3 auth_mode=required" \
2171 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2172 key_file=data_files/server5.key" \
2173 1 \
2174 -S "skip write certificate request" \
2175 -C "skip parse certificate request" \
2176 -c "got a certificate request" \
2177 -C "skip write certificate" \
2178 -C "skip write certificate verify" \
2179 -S "skip parse certificate verify" \
2180 -s "x509_verify_cert() returned" \
2181 -s "! The certificate is not correctly signed by the trusted CA" \
2182 -s "! mbedtls_ssl_handshake returned" \
2183 -c "! mbedtls_ssl_handshake returned" \
2184 -s "X509 - Certificate verification failed"
2185
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002186run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002187 "$P_SRV debug_level=3 auth_mode=optional" \
2188 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002189 key_file=data_files/server5.key" \
2190 0 \
2191 -S "skip write certificate request" \
2192 -C "skip parse certificate request" \
2193 -c "got a certificate request" \
2194 -C "skip write certificate" \
2195 -C "skip write certificate verify" \
2196 -S "skip parse certificate verify" \
2197 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002198 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002199 -S "! mbedtls_ssl_handshake returned" \
2200 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002201 -S "X509 - Certificate verification failed"
2202
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002203run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002204 "$P_SRV debug_level=3 auth_mode=none" \
2205 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002206 key_file=data_files/server5.key" \
2207 0 \
2208 -s "skip write certificate request" \
2209 -C "skip parse certificate request" \
2210 -c "got no certificate request" \
2211 -c "skip write certificate" \
2212 -c "skip write certificate verify" \
2213 -s "skip parse certificate verify" \
2214 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002215 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002216 -S "! mbedtls_ssl_handshake returned" \
2217 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002218 -S "X509 - Certificate verification failed"
2219
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002220run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002221 "$P_SRV debug_level=3 auth_mode=optional" \
2222 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002223 0 \
2224 -S "skip write certificate request" \
2225 -C "skip parse certificate request" \
2226 -c "got a certificate request" \
2227 -C "skip write certificate$" \
2228 -C "got no certificate to send" \
2229 -S "SSLv3 client has no certificate" \
2230 -c "skip write certificate verify" \
2231 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002232 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002233 -S "! mbedtls_ssl_handshake returned" \
2234 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002235 -S "X509 - Certificate verification failed"
2236
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002237run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002238 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002239 "$O_CLI" \
2240 0 \
2241 -S "skip write certificate request" \
2242 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002243 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002244 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002245 -S "X509 - Certificate verification failed"
2246
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002247run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002248 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002249 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002250 0 \
2251 -C "skip parse certificate request" \
2252 -c "got a certificate request" \
2253 -C "skip write certificate$" \
2254 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002255 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002256
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002257run_test "Authentication: client no cert, openssl server required" \
2258 "$O_SRV -Verify 10" \
2259 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2260 1 \
2261 -C "skip parse certificate request" \
2262 -c "got a certificate request" \
2263 -C "skip write certificate$" \
2264 -c "skip write certificate verify" \
2265 -c "! mbedtls_ssl_handshake returned"
2266
Janos Follathe2681a42016-03-07 15:57:05 +00002267requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002268run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002269 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002270 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002271 0 \
2272 -S "skip write certificate request" \
2273 -C "skip parse certificate request" \
2274 -c "got a certificate request" \
2275 -C "skip write certificate$" \
2276 -c "skip write certificate verify" \
2277 -c "got no certificate to send" \
2278 -s "SSLv3 client has no certificate" \
2279 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002280 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002281 -S "! mbedtls_ssl_handshake returned" \
2282 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002283 -S "X509 - Certificate verification failed"
2284
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002285# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2286# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002287
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002288MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002289MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002290
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002291if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002292 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002293 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002294 printf "test value of ${MAX_IM_CA}. \n"
2295 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002296 printf "The tests assume this value and if it changes, the tests in this\n"
2297 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002298 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002299
2300 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002301fi
2302
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002303run_test "Authentication: server max_int chain, client default" \
2304 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2305 key_file=data_files/dir-maxpath/09.key" \
2306 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2307 0 \
2308 -C "X509 - A fatal error occured"
2309
2310run_test "Authentication: server max_int+1 chain, client default" \
2311 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2312 key_file=data_files/dir-maxpath/10.key" \
2313 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2314 1 \
2315 -c "X509 - A fatal error occured"
2316
2317run_test "Authentication: server max_int+1 chain, client optional" \
2318 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2319 key_file=data_files/dir-maxpath/10.key" \
2320 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2321 auth_mode=optional" \
2322 1 \
2323 -c "X509 - A fatal error occured"
2324
2325run_test "Authentication: server max_int+1 chain, client none" \
2326 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2327 key_file=data_files/dir-maxpath/10.key" \
2328 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2329 auth_mode=none" \
2330 0 \
2331 -C "X509 - A fatal error occured"
2332
2333run_test "Authentication: client max_int+1 chain, server default" \
2334 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2335 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2336 key_file=data_files/dir-maxpath/10.key" \
2337 0 \
2338 -S "X509 - A fatal error occured"
2339
2340run_test "Authentication: client max_int+1 chain, server optional" \
2341 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2342 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2343 key_file=data_files/dir-maxpath/10.key" \
2344 1 \
2345 -s "X509 - A fatal error occured"
2346
2347run_test "Authentication: client max_int+1 chain, server required" \
2348 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2349 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2350 key_file=data_files/dir-maxpath/10.key" \
2351 1 \
2352 -s "X509 - A fatal error occured"
2353
2354run_test "Authentication: client max_int chain, server required" \
2355 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2356 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2357 key_file=data_files/dir-maxpath/09.key" \
2358 0 \
2359 -S "X509 - A fatal error occured"
2360
Janos Follath89baba22017-04-10 14:34:35 +01002361# Tests for CA list in CertificateRequest messages
2362
2363run_test "Authentication: send CA list in CertificateRequest (default)" \
2364 "$P_SRV debug_level=3 auth_mode=required" \
2365 "$P_CLI crt_file=data_files/server6.crt \
2366 key_file=data_files/server6.key" \
2367 0 \
2368 -s "requested DN"
2369
2370run_test "Authentication: do not send CA list in CertificateRequest" \
2371 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2372 "$P_CLI crt_file=data_files/server6.crt \
2373 key_file=data_files/server6.key" \
2374 0 \
2375 -S "requested DN"
2376
2377run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2378 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2379 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2380 key_file=data_files/server5.key" \
2381 1 \
2382 -S "requested DN" \
2383 -s "x509_verify_cert() returned" \
2384 -s "! The certificate is not correctly signed by the trusted CA" \
2385 -s "! mbedtls_ssl_handshake returned" \
2386 -c "! mbedtls_ssl_handshake returned" \
2387 -s "X509 - Certificate verification failed"
2388
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002389# Tests for certificate selection based on SHA verson
2390
2391run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2392 "$P_SRV crt_file=data_files/server5.crt \
2393 key_file=data_files/server5.key \
2394 crt_file2=data_files/server5-sha1.crt \
2395 key_file2=data_files/server5.key" \
2396 "$P_CLI force_version=tls1_2" \
2397 0 \
2398 -c "signed using.*ECDSA with SHA256" \
2399 -C "signed using.*ECDSA with SHA1"
2400
2401run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2402 "$P_SRV crt_file=data_files/server5.crt \
2403 key_file=data_files/server5.key \
2404 crt_file2=data_files/server5-sha1.crt \
2405 key_file2=data_files/server5.key" \
2406 "$P_CLI force_version=tls1_1" \
2407 0 \
2408 -C "signed using.*ECDSA with SHA256" \
2409 -c "signed using.*ECDSA with SHA1"
2410
2411run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2412 "$P_SRV crt_file=data_files/server5.crt \
2413 key_file=data_files/server5.key \
2414 crt_file2=data_files/server5-sha1.crt \
2415 key_file2=data_files/server5.key" \
2416 "$P_CLI force_version=tls1" \
2417 0 \
2418 -C "signed using.*ECDSA with SHA256" \
2419 -c "signed using.*ECDSA with SHA1"
2420
2421run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2422 "$P_SRV crt_file=data_files/server5.crt \
2423 key_file=data_files/server5.key \
2424 crt_file2=data_files/server6.crt \
2425 key_file2=data_files/server6.key" \
2426 "$P_CLI force_version=tls1_1" \
2427 0 \
2428 -c "serial number.*09" \
2429 -c "signed using.*ECDSA with SHA256" \
2430 -C "signed using.*ECDSA with SHA1"
2431
2432run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2433 "$P_SRV crt_file=data_files/server6.crt \
2434 key_file=data_files/server6.key \
2435 crt_file2=data_files/server5.crt \
2436 key_file2=data_files/server5.key" \
2437 "$P_CLI force_version=tls1_1" \
2438 0 \
2439 -c "serial number.*0A" \
2440 -c "signed using.*ECDSA with SHA256" \
2441 -C "signed using.*ECDSA with SHA1"
2442
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002443# tests for SNI
2444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002445run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002446 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002447 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002448 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002449 0 \
2450 -S "parse ServerName extension" \
2451 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2452 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002454run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002455 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002456 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002457 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 +02002458 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002459 0 \
2460 -s "parse ServerName extension" \
2461 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2462 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002464run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002465 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002466 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002467 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 +02002468 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002469 0 \
2470 -s "parse ServerName extension" \
2471 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2472 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002474run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002475 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002476 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002477 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 +02002478 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002479 1 \
2480 -s "parse ServerName extension" \
2481 -s "ssl_sni_wrapper() returned" \
2482 -s "mbedtls_ssl_handshake returned" \
2483 -c "mbedtls_ssl_handshake returned" \
2484 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002485
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002486run_test "SNI: client auth no override: optional" \
2487 "$P_SRV debug_level=3 auth_mode=optional \
2488 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2489 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
2490 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002491 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002492 -S "skip write certificate request" \
2493 -C "skip parse certificate request" \
2494 -c "got a certificate request" \
2495 -C "skip write certificate" \
2496 -C "skip write certificate verify" \
2497 -S "skip parse certificate verify"
2498
2499run_test "SNI: client auth override: none -> optional" \
2500 "$P_SRV debug_level=3 auth_mode=none \
2501 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2502 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
2503 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002504 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002505 -S "skip write certificate request" \
2506 -C "skip parse certificate request" \
2507 -c "got a certificate request" \
2508 -C "skip write certificate" \
2509 -C "skip write certificate verify" \
2510 -S "skip parse certificate verify"
2511
2512run_test "SNI: client auth override: optional -> none" \
2513 "$P_SRV debug_level=3 auth_mode=optional \
2514 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2515 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
2516 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002517 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02002518 -s "skip write certificate request" \
2519 -C "skip parse certificate request" \
2520 -c "got no certificate request" \
2521 -c "skip write certificate" \
2522 -c "skip write certificate verify" \
2523 -s "skip parse certificate verify"
2524
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002525run_test "SNI: CA no override" \
2526 "$P_SRV debug_level=3 auth_mode=optional \
2527 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2528 ca_file=data_files/test-ca.crt \
2529 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
2530 "$P_CLI debug_level=3 server_name=localhost \
2531 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2532 1 \
2533 -S "skip write certificate request" \
2534 -C "skip parse certificate request" \
2535 -c "got a certificate request" \
2536 -C "skip write certificate" \
2537 -C "skip write certificate verify" \
2538 -S "skip parse certificate verify" \
2539 -s "x509_verify_cert() returned" \
2540 -s "! The certificate is not correctly signed by the trusted CA" \
2541 -S "The certificate has been revoked (is on a CRL)"
2542
2543run_test "SNI: CA override" \
2544 "$P_SRV debug_level=3 auth_mode=optional \
2545 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2546 ca_file=data_files/test-ca.crt \
2547 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
2548 "$P_CLI debug_level=3 server_name=localhost \
2549 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2550 0 \
2551 -S "skip write certificate request" \
2552 -C "skip parse certificate request" \
2553 -c "got a certificate request" \
2554 -C "skip write certificate" \
2555 -C "skip write certificate verify" \
2556 -S "skip parse certificate verify" \
2557 -S "x509_verify_cert() returned" \
2558 -S "! The certificate is not correctly signed by the trusted CA" \
2559 -S "The certificate has been revoked (is on a CRL)"
2560
2561run_test "SNI: CA override with CRL" \
2562 "$P_SRV debug_level=3 auth_mode=optional \
2563 crt_file=data_files/server5.crt key_file=data_files/server5.key \
2564 ca_file=data_files/test-ca.crt \
2565 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
2566 "$P_CLI debug_level=3 server_name=localhost \
2567 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
2568 1 \
2569 -S "skip write certificate request" \
2570 -C "skip parse certificate request" \
2571 -c "got a certificate request" \
2572 -C "skip write certificate" \
2573 -C "skip write certificate verify" \
2574 -S "skip parse certificate verify" \
2575 -s "x509_verify_cert() returned" \
2576 -S "! The certificate is not correctly signed by the trusted CA" \
2577 -s "The certificate has been revoked (is on a CRL)"
2578
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002579# Tests for non-blocking I/O: exercise a variety of handshake flows
2580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002581run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002582 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2583 "$P_CLI nbio=2 tickets=0" \
2584 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002585 -S "mbedtls_ssl_handshake returned" \
2586 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002587 -c "Read from server: .* bytes read"
2588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002589run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002590 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
2591 "$P_CLI nbio=2 tickets=0" \
2592 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002593 -S "mbedtls_ssl_handshake returned" \
2594 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002595 -c "Read from server: .* bytes read"
2596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002597run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002598 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2599 "$P_CLI nbio=2 tickets=1" \
2600 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002601 -S "mbedtls_ssl_handshake returned" \
2602 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002603 -c "Read from server: .* bytes read"
2604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002605run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002606 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2607 "$P_CLI nbio=2 tickets=1" \
2608 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002609 -S "mbedtls_ssl_handshake returned" \
2610 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002611 -c "Read from server: .* bytes read"
2612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002613run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002614 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
2615 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2616 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002617 -S "mbedtls_ssl_handshake returned" \
2618 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002619 -c "Read from server: .* bytes read"
2620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002621run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002622 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
2623 "$P_CLI nbio=2 tickets=1 reconnect=1" \
2624 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002625 -S "mbedtls_ssl_handshake returned" \
2626 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002627 -c "Read from server: .* bytes read"
2628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002629run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002630 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
2631 "$P_CLI nbio=2 tickets=0 reconnect=1" \
2632 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002633 -S "mbedtls_ssl_handshake returned" \
2634 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01002635 -c "Read from server: .* bytes read"
2636
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002637# Tests for version negotiation
2638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002639run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002640 "$P_SRV" \
2641 "$P_CLI" \
2642 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002643 -S "mbedtls_ssl_handshake returned" \
2644 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002645 -s "Protocol is TLSv1.2" \
2646 -c "Protocol is TLSv1.2"
2647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002649 "$P_SRV" \
2650 "$P_CLI max_version=tls1_1" \
2651 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002652 -S "mbedtls_ssl_handshake returned" \
2653 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002654 -s "Protocol is TLSv1.1" \
2655 -c "Protocol is TLSv1.1"
2656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002657run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002658 "$P_SRV max_version=tls1_1" \
2659 "$P_CLI" \
2660 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002661 -S "mbedtls_ssl_handshake returned" \
2662 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002663 -s "Protocol is TLSv1.1" \
2664 -c "Protocol is TLSv1.1"
2665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002666run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002667 "$P_SRV max_version=tls1_1" \
2668 "$P_CLI max_version=tls1_1" \
2669 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002670 -S "mbedtls_ssl_handshake returned" \
2671 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002672 -s "Protocol is TLSv1.1" \
2673 -c "Protocol is TLSv1.1"
2674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002675run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002676 "$P_SRV min_version=tls1_1" \
2677 "$P_CLI max_version=tls1_1" \
2678 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002679 -S "mbedtls_ssl_handshake returned" \
2680 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002681 -s "Protocol is TLSv1.1" \
2682 -c "Protocol is TLSv1.1"
2683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002684run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002685 "$P_SRV max_version=tls1_1" \
2686 "$P_CLI min_version=tls1_1" \
2687 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002688 -S "mbedtls_ssl_handshake returned" \
2689 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002690 -s "Protocol is TLSv1.1" \
2691 -c "Protocol is TLSv1.1"
2692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002693run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002694 "$P_SRV max_version=tls1_1" \
2695 "$P_CLI min_version=tls1_2" \
2696 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002697 -s "mbedtls_ssl_handshake returned" \
2698 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002699 -c "SSL - Handshake protocol not within min/max boundaries"
2700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002701run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002702 "$P_SRV min_version=tls1_2" \
2703 "$P_CLI max_version=tls1_1" \
2704 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002705 -s "mbedtls_ssl_handshake returned" \
2706 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01002707 -s "SSL - Handshake protocol not within min/max boundaries"
2708
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002709# Tests for ALPN extension
2710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002711run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002712 "$P_SRV debug_level=3" \
2713 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002714 0 \
2715 -C "client hello, adding alpn extension" \
2716 -S "found alpn extension" \
2717 -C "got an alert message, type: \\[2:120]" \
2718 -S "server hello, adding alpn extension" \
2719 -C "found alpn extension " \
2720 -C "Application Layer Protocol is" \
2721 -S "Application Layer Protocol is"
2722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002723run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002724 "$P_SRV debug_level=3" \
2725 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002726 0 \
2727 -c "client hello, adding alpn extension" \
2728 -s "found alpn extension" \
2729 -C "got an alert message, type: \\[2:120]" \
2730 -S "server hello, adding alpn extension" \
2731 -C "found alpn extension " \
2732 -c "Application Layer Protocol is (none)" \
2733 -S "Application Layer Protocol is"
2734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002736 "$P_SRV debug_level=3 alpn=abc,1234" \
2737 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002738 0 \
2739 -C "client hello, adding alpn extension" \
2740 -S "found alpn extension" \
2741 -C "got an alert message, type: \\[2:120]" \
2742 -S "server hello, adding alpn extension" \
2743 -C "found alpn extension " \
2744 -C "Application Layer Protocol is" \
2745 -s "Application Layer Protocol is (none)"
2746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002747run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002748 "$P_SRV debug_level=3 alpn=abc,1234" \
2749 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002750 0 \
2751 -c "client hello, adding alpn extension" \
2752 -s "found alpn extension" \
2753 -C "got an alert message, type: \\[2:120]" \
2754 -s "server hello, adding alpn extension" \
2755 -c "found alpn extension" \
2756 -c "Application Layer Protocol is abc" \
2757 -s "Application Layer Protocol is abc"
2758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002759run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002760 "$P_SRV debug_level=3 alpn=abc,1234" \
2761 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002762 0 \
2763 -c "client hello, adding alpn extension" \
2764 -s "found alpn extension" \
2765 -C "got an alert message, type: \\[2:120]" \
2766 -s "server hello, adding alpn extension" \
2767 -c "found alpn extension" \
2768 -c "Application Layer Protocol is abc" \
2769 -s "Application Layer Protocol is abc"
2770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002771run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002772 "$P_SRV debug_level=3 alpn=abc,1234" \
2773 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002774 0 \
2775 -c "client hello, adding alpn extension" \
2776 -s "found alpn extension" \
2777 -C "got an alert message, type: \\[2:120]" \
2778 -s "server hello, adding alpn extension" \
2779 -c "found alpn extension" \
2780 -c "Application Layer Protocol is 1234" \
2781 -s "Application Layer Protocol is 1234"
2782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002783run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002784 "$P_SRV debug_level=3 alpn=abc,123" \
2785 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02002786 1 \
2787 -c "client hello, adding alpn extension" \
2788 -s "found alpn extension" \
2789 -c "got an alert message, type: \\[2:120]" \
2790 -S "server hello, adding alpn extension" \
2791 -C "found alpn extension" \
2792 -C "Application Layer Protocol is 1234" \
2793 -S "Application Layer Protocol is 1234"
2794
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02002795
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002796# Tests for keyUsage in leaf certificates, part 1:
2797# server-side certificate/suite selection
2798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002799run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002800 "$P_SRV key_file=data_files/server2.key \
2801 crt_file=data_files/server2.ku-ds.crt" \
2802 "$P_CLI" \
2803 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02002804 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002805
2806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002807run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002808 "$P_SRV key_file=data_files/server2.key \
2809 crt_file=data_files/server2.ku-ke.crt" \
2810 "$P_CLI" \
2811 0 \
2812 -c "Ciphersuite is TLS-RSA-WITH-"
2813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002814run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002815 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002816 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002817 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002818 1 \
2819 -C "Ciphersuite is "
2820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002821run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002822 "$P_SRV key_file=data_files/server5.key \
2823 crt_file=data_files/server5.ku-ds.crt" \
2824 "$P_CLI" \
2825 0 \
2826 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
2827
2828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002829run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002830 "$P_SRV key_file=data_files/server5.key \
2831 crt_file=data_files/server5.ku-ka.crt" \
2832 "$P_CLI" \
2833 0 \
2834 -c "Ciphersuite is TLS-ECDH-"
2835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002836run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002837 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002838 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02002839 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002840 1 \
2841 -C "Ciphersuite is "
2842
2843# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002844# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002846run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002847 "$O_SRV -key data_files/server2.key \
2848 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002849 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002850 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2851 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002852 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002853 -C "Processing of the Certificate handshake message failed" \
2854 -c "Ciphersuite is TLS-"
2855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002856run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002857 "$O_SRV -key data_files/server2.key \
2858 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002859 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002860 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2861 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002862 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002863 -C "Processing of the Certificate handshake message failed" \
2864 -c "Ciphersuite is TLS-"
2865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002866run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002867 "$O_SRV -key data_files/server2.key \
2868 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002869 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002870 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2871 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002872 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002873 -C "Processing of the Certificate handshake message failed" \
2874 -c "Ciphersuite is TLS-"
2875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002876run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002877 "$O_SRV -key data_files/server2.key \
2878 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002879 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002880 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2881 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002882 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002883 -c "Processing of the Certificate handshake message failed" \
2884 -C "Ciphersuite is TLS-"
2885
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002886run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
2887 "$O_SRV -key data_files/server2.key \
2888 -cert data_files/server2.ku-ke.crt" \
2889 "$P_CLI debug_level=1 auth_mode=optional \
2890 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2891 0 \
2892 -c "bad certificate (usage extensions)" \
2893 -C "Processing of the Certificate handshake message failed" \
2894 -c "Ciphersuite is TLS-" \
2895 -c "! Usage does not match the keyUsage extension"
2896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002897run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002898 "$O_SRV -key data_files/server2.key \
2899 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002900 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002901 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
2902 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002903 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002904 -C "Processing of the Certificate handshake message failed" \
2905 -c "Ciphersuite is TLS-"
2906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002907run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002908 "$O_SRV -key data_files/server2.key \
2909 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002910 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002911 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2912 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002913 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02002914 -c "Processing of the Certificate handshake message failed" \
2915 -C "Ciphersuite is TLS-"
2916
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01002917run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
2918 "$O_SRV -key data_files/server2.key \
2919 -cert data_files/server2.ku-ds.crt" \
2920 "$P_CLI debug_level=1 auth_mode=optional \
2921 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
2922 0 \
2923 -c "bad certificate (usage extensions)" \
2924 -C "Processing of the Certificate handshake message failed" \
2925 -c "Ciphersuite is TLS-" \
2926 -c "! Usage does not match the keyUsage extension"
2927
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002928# Tests for keyUsage in leaf certificates, part 3:
2929# server-side checking of client cert
2930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002931run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002932 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002933 "$O_CLI -key data_files/server2.key \
2934 -cert data_files/server2.ku-ds.crt" \
2935 0 \
2936 -S "bad certificate (usage extensions)" \
2937 -S "Processing of the Certificate handshake message failed"
2938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002939run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002940 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002941 "$O_CLI -key data_files/server2.key \
2942 -cert data_files/server2.ku-ke.crt" \
2943 0 \
2944 -s "bad certificate (usage extensions)" \
2945 -S "Processing of the Certificate handshake message failed"
2946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002947run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002948 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002949 "$O_CLI -key data_files/server2.key \
2950 -cert data_files/server2.ku-ke.crt" \
2951 1 \
2952 -s "bad certificate (usage extensions)" \
2953 -s "Processing of the Certificate handshake message failed"
2954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002955run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002956 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002957 "$O_CLI -key data_files/server5.key \
2958 -cert data_files/server5.ku-ds.crt" \
2959 0 \
2960 -S "bad certificate (usage extensions)" \
2961 -S "Processing of the Certificate handshake message failed"
2962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002963run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002964 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02002965 "$O_CLI -key data_files/server5.key \
2966 -cert data_files/server5.ku-ka.crt" \
2967 0 \
2968 -s "bad certificate (usage extensions)" \
2969 -S "Processing of the Certificate handshake message failed"
2970
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002971# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
2972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002973run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002974 "$P_SRV key_file=data_files/server5.key \
2975 crt_file=data_files/server5.eku-srv.crt" \
2976 "$P_CLI" \
2977 0
2978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002979run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002980 "$P_SRV key_file=data_files/server5.key \
2981 crt_file=data_files/server5.eku-srv.crt" \
2982 "$P_CLI" \
2983 0
2984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002985run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002986 "$P_SRV key_file=data_files/server5.key \
2987 crt_file=data_files/server5.eku-cs_any.crt" \
2988 "$P_CLI" \
2989 0
2990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002991run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002992 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002993 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02002994 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02002995 1
2996
2997# Tests for extendedKeyUsage, part 2: client-side checking of server cert
2998
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002999run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003000 "$O_SRV -key data_files/server5.key \
3001 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003002 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003003 0 \
3004 -C "bad certificate (usage extensions)" \
3005 -C "Processing of the Certificate handshake message failed" \
3006 -c "Ciphersuite is TLS-"
3007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003008run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003009 "$O_SRV -key data_files/server5.key \
3010 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003011 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003012 0 \
3013 -C "bad certificate (usage extensions)" \
3014 -C "Processing of the Certificate handshake message failed" \
3015 -c "Ciphersuite is TLS-"
3016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003017run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003018 "$O_SRV -key data_files/server5.key \
3019 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003020 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003021 0 \
3022 -C "bad certificate (usage extensions)" \
3023 -C "Processing of the Certificate handshake message failed" \
3024 -c "Ciphersuite is TLS-"
3025
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003026run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003027 "$O_SRV -key data_files/server5.key \
3028 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003029 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003030 1 \
3031 -c "bad certificate (usage extensions)" \
3032 -c "Processing of the Certificate handshake message failed" \
3033 -C "Ciphersuite is TLS-"
3034
3035# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3036
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003037run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003038 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003039 "$O_CLI -key data_files/server5.key \
3040 -cert data_files/server5.eku-cli.crt" \
3041 0 \
3042 -S "bad certificate (usage extensions)" \
3043 -S "Processing of the Certificate handshake message failed"
3044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003045run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003046 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003047 "$O_CLI -key data_files/server5.key \
3048 -cert data_files/server5.eku-srv_cli.crt" \
3049 0 \
3050 -S "bad certificate (usage extensions)" \
3051 -S "Processing of the Certificate handshake message failed"
3052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003053run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003054 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003055 "$O_CLI -key data_files/server5.key \
3056 -cert data_files/server5.eku-cs_any.crt" \
3057 0 \
3058 -S "bad certificate (usage extensions)" \
3059 -S "Processing of the Certificate handshake message failed"
3060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003061run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003062 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003063 "$O_CLI -key data_files/server5.key \
3064 -cert data_files/server5.eku-cs.crt" \
3065 0 \
3066 -s "bad certificate (usage extensions)" \
3067 -S "Processing of the Certificate handshake message failed"
3068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003069run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003070 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003071 "$O_CLI -key data_files/server5.key \
3072 -cert data_files/server5.eku-cs.crt" \
3073 1 \
3074 -s "bad certificate (usage extensions)" \
3075 -s "Processing of the Certificate handshake message failed"
3076
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003077# Tests for DHM parameters loading
3078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003079run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003080 "$P_SRV" \
3081 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3082 debug_level=3" \
3083 0 \
3084 -c "value of 'DHM: P ' (2048 bits)" \
3085 -c "value of 'DHM: G ' (2048 bits)"
3086
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003087run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003088 "$P_SRV dhm_file=data_files/dhparams.pem" \
3089 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3090 debug_level=3" \
3091 0 \
3092 -c "value of 'DHM: P ' (1024 bits)" \
3093 -c "value of 'DHM: G ' (2 bits)"
3094
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003095# Tests for DHM client-side size checking
3096
3097run_test "DHM size: server default, client default, OK" \
3098 "$P_SRV" \
3099 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3100 debug_level=1" \
3101 0 \
3102 -C "DHM prime too short:"
3103
3104run_test "DHM size: server default, client 2048, OK" \
3105 "$P_SRV" \
3106 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3107 debug_level=1 dhmlen=2048" \
3108 0 \
3109 -C "DHM prime too short:"
3110
3111run_test "DHM size: server 1024, client default, OK" \
3112 "$P_SRV dhm_file=data_files/dhparams.pem" \
3113 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3114 debug_level=1" \
3115 0 \
3116 -C "DHM prime too short:"
3117
3118run_test "DHM size: server 1000, client default, rejected" \
3119 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3120 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3121 debug_level=1" \
3122 1 \
3123 -c "DHM prime too short:"
3124
3125run_test "DHM size: server default, client 2049, rejected" \
3126 "$P_SRV" \
3127 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3128 debug_level=1 dhmlen=2049" \
3129 1 \
3130 -c "DHM prime too short:"
3131
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003132# Tests for PSK callback
3133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003134run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003135 "$P_SRV psk=abc123 psk_identity=foo" \
3136 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3137 psk_identity=foo psk=abc123" \
3138 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003139 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003140 -S "SSL - Unknown identity received" \
3141 -S "SSL - Verification of the message MAC failed"
3142
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003143run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003144 "$P_SRV" \
3145 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3146 psk_identity=foo psk=abc123" \
3147 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003148 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003149 -S "SSL - Unknown identity received" \
3150 -S "SSL - Verification of the message MAC failed"
3151
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003152run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003153 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3154 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3155 psk_identity=foo psk=abc123" \
3156 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003157 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003158 -s "SSL - Unknown identity received" \
3159 -S "SSL - Verification of the message MAC failed"
3160
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003161run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003162 "$P_SRV psk_list=abc,dead,def,beef" \
3163 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3164 psk_identity=abc psk=dead" \
3165 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003166 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003167 -S "SSL - Unknown identity received" \
3168 -S "SSL - Verification of the message MAC failed"
3169
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003170run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003171 "$P_SRV psk_list=abc,dead,def,beef" \
3172 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3173 psk_identity=def psk=beef" \
3174 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003175 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003176 -S "SSL - Unknown identity received" \
3177 -S "SSL - Verification of the message MAC failed"
3178
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003179run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003180 "$P_SRV psk_list=abc,dead,def,beef" \
3181 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3182 psk_identity=ghi psk=beef" \
3183 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003184 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003185 -s "SSL - Unknown identity received" \
3186 -S "SSL - Verification of the message MAC failed"
3187
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003188run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003189 "$P_SRV psk_list=abc,dead,def,beef" \
3190 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3191 psk_identity=abc psk=beef" \
3192 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003193 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003194 -S "SSL - Unknown identity received" \
3195 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003196
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003197# Tests for EC J-PAKE
3198
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003199requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003200run_test "ECJPAKE: client not configured" \
3201 "$P_SRV debug_level=3" \
3202 "$P_CLI debug_level=3" \
3203 0 \
3204 -C "add ciphersuite: c0ff" \
3205 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003206 -S "found ecjpake kkpp extension" \
3207 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003208 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003209 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003210 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003211 -S "None of the common ciphersuites is usable"
3212
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003213requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003214run_test "ECJPAKE: server not configured" \
3215 "$P_SRV debug_level=3" \
3216 "$P_CLI debug_level=3 ecjpake_pw=bla \
3217 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3218 1 \
3219 -c "add ciphersuite: c0ff" \
3220 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003221 -s "found ecjpake kkpp extension" \
3222 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003223 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003224 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003225 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003226 -s "None of the common ciphersuites is usable"
3227
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003228requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003229run_test "ECJPAKE: working, TLS" \
3230 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3231 "$P_CLI debug_level=3 ecjpake_pw=bla \
3232 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02003233 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003234 -c "add ciphersuite: c0ff" \
3235 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003236 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003237 -s "found ecjpake kkpp extension" \
3238 -S "skip ecjpake kkpp extension" \
3239 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003240 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003241 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003242 -S "None of the common ciphersuites is usable" \
3243 -S "SSL - Verification of the message MAC failed"
3244
Janos Follath74537a62016-09-02 13:45:28 +01003245server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003246requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003247run_test "ECJPAKE: password mismatch, TLS" \
3248 "$P_SRV debug_level=3 ecjpake_pw=bla" \
3249 "$P_CLI debug_level=3 ecjpake_pw=bad \
3250 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3251 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003252 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003253 -s "SSL - Verification of the message MAC failed"
3254
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003255requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003256run_test "ECJPAKE: working, DTLS" \
3257 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3258 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3259 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3260 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003261 -c "re-using cached ecjpake parameters" \
3262 -S "SSL - Verification of the message MAC failed"
3263
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003264requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003265run_test "ECJPAKE: working, DTLS, no cookie" \
3266 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
3267 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
3268 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3269 0 \
3270 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003271 -S "SSL - Verification of the message MAC failed"
3272
Janos Follath74537a62016-09-02 13:45:28 +01003273server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003274requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003275run_test "ECJPAKE: password mismatch, DTLS" \
3276 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
3277 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
3278 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3279 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02003280 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02003281 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003282
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003283# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003284requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02003285run_test "ECJPAKE: working, DTLS, nolog" \
3286 "$P_SRV dtls=1 ecjpake_pw=bla" \
3287 "$P_CLI dtls=1 ecjpake_pw=bla \
3288 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
3289 0
3290
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003291# Tests for ciphersuites per version
3292
Janos Follathe2681a42016-03-07 15:57:05 +00003293requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003294run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003295 "$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 +02003296 "$P_CLI force_version=ssl3" \
3297 0 \
3298 -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
3299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003300run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003301 "$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 +01003302 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003303 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003304 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003305
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003306run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003307 "$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 +02003308 "$P_CLI force_version=tls1_1" \
3309 0 \
3310 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
3311
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003312run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003313 "$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 +02003314 "$P_CLI force_version=tls1_2" \
3315 0 \
3316 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
3317
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003318# Test for ClientHello without extensions
3319
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02003320requires_gnutls
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003321run_test "ClientHello without extensions, SHA-1 allowed" \
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02003322 "$P_SRV debug_level=3" \
3323 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3324 0 \
3325 -s "dumping 'client hello extensions' (0 bytes)"
3326
Gilles Peskine5d2511c2017-05-12 13:16:40 +02003327requires_gnutls
3328run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
3329 "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
3330 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
3331 0 \
3332 -s "dumping 'client hello extensions' (0 bytes)"
3333
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003334# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003335
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003336run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003337 "$P_SRV" \
3338 "$P_CLI request_size=100" \
3339 0 \
3340 -s "Read from client: 100 bytes read$"
3341
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003342run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02003343 "$P_SRV" \
3344 "$P_CLI request_size=500" \
3345 0 \
3346 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02003347
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003348# Tests for small packets
3349
Janos Follathe2681a42016-03-07 15:57:05 +00003350requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003351run_test "Small packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003352 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003353 "$P_CLI request_size=1 force_version=ssl3 \
3354 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3355 0 \
3356 -s "Read from client: 1 bytes read"
3357
Janos Follathe2681a42016-03-07 15:57:05 +00003358requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003359run_test "Small packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003360 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003361 "$P_CLI request_size=1 force_version=ssl3 \
3362 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3363 0 \
3364 -s "Read from client: 1 bytes read"
3365
3366run_test "Small packet TLS 1.0 BlockCipher" \
3367 "$P_SRV" \
3368 "$P_CLI request_size=1 force_version=tls1 \
3369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3370 0 \
3371 -s "Read from client: 1 bytes read"
3372
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003373run_test "Small packet TLS 1.0 BlockCipher without EtM" \
3374 "$P_SRV" \
3375 "$P_CLI request_size=1 force_version=tls1 etm=0 \
3376 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3377 0 \
3378 -s "Read from client: 1 bytes read"
3379
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003380run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
3381 "$P_SRV" \
3382 "$P_CLI request_size=1 force_version=tls1 \
3383 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3384 trunc_hmac=1" \
3385 0 \
3386 -s "Read from client: 1 bytes read"
3387
3388run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003389 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003390 "$P_CLI request_size=1 force_version=tls1 \
3391 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3392 trunc_hmac=1" \
3393 0 \
3394 -s "Read from client: 1 bytes read"
3395
3396run_test "Small packet TLS 1.1 BlockCipher" \
3397 "$P_SRV" \
3398 "$P_CLI request_size=1 force_version=tls1_1 \
3399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3400 0 \
3401 -s "Read from client: 1 bytes read"
3402
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003403run_test "Small packet TLS 1.1 BlockCipher without EtM" \
3404 "$P_SRV" \
3405 "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
3406 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3407 0 \
3408 -s "Read from client: 1 bytes read"
3409
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003410run_test "Small packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003411 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003412 "$P_CLI request_size=1 force_version=tls1_1 \
3413 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3414 0 \
3415 -s "Read from client: 1 bytes read"
3416
3417run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
3418 "$P_SRV" \
3419 "$P_CLI request_size=1 force_version=tls1_1 \
3420 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3421 trunc_hmac=1" \
3422 0 \
3423 -s "Read from client: 1 bytes read"
3424
3425run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003426 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003427 "$P_CLI request_size=1 force_version=tls1_1 \
3428 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3429 trunc_hmac=1" \
3430 0 \
3431 -s "Read from client: 1 bytes read"
3432
3433run_test "Small packet TLS 1.2 BlockCipher" \
3434 "$P_SRV" \
3435 "$P_CLI request_size=1 force_version=tls1_2 \
3436 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3437 0 \
3438 -s "Read from client: 1 bytes read"
3439
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01003440run_test "Small packet TLS 1.2 BlockCipher without EtM" \
3441 "$P_SRV" \
3442 "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
3443 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3444 0 \
3445 -s "Read from client: 1 bytes read"
3446
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003447run_test "Small packet TLS 1.2 BlockCipher larger MAC" \
3448 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003449 "$P_CLI request_size=1 force_version=tls1_2 \
3450 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003451 0 \
3452 -s "Read from client: 1 bytes read"
3453
3454run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
3455 "$P_SRV" \
3456 "$P_CLI request_size=1 force_version=tls1_2 \
3457 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3458 trunc_hmac=1" \
3459 0 \
3460 -s "Read from client: 1 bytes read"
3461
3462run_test "Small packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003463 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003464 "$P_CLI request_size=1 force_version=tls1_2 \
3465 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3466 0 \
3467 -s "Read from client: 1 bytes read"
3468
3469run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003470 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02003471 "$P_CLI request_size=1 force_version=tls1_2 \
3472 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3473 trunc_hmac=1" \
3474 0 \
3475 -s "Read from client: 1 bytes read"
3476
3477run_test "Small packet TLS 1.2 AEAD" \
3478 "$P_SRV" \
3479 "$P_CLI request_size=1 force_version=tls1_2 \
3480 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3481 0 \
3482 -s "Read from client: 1 bytes read"
3483
3484run_test "Small packet TLS 1.2 AEAD shorter tag" \
3485 "$P_SRV" \
3486 "$P_CLI request_size=1 force_version=tls1_2 \
3487 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3488 0 \
3489 -s "Read from client: 1 bytes read"
3490
Janos Follath00efff72016-05-06 13:48:23 +01003491# A test for extensions in SSLv3
3492
3493requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
3494run_test "SSLv3 with extensions, server side" \
3495 "$P_SRV min_version=ssl3 debug_level=3" \
3496 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
3497 0 \
3498 -S "dumping 'client hello extensions'" \
3499 -S "server hello, total extension length:"
3500
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003501# Test for large packets
3502
Janos Follathe2681a42016-03-07 15:57:05 +00003503requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003504run_test "Large packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01003505 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003506 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003507 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3508 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003509 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003510 -s "Read from client: 16384 bytes read"
3511
Janos Follathe2681a42016-03-07 15:57:05 +00003512requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003513run_test "Large packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003514 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003515 "$P_CLI request_size=16384 force_version=ssl3 \
3516 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3517 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003518 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003519 -s "Read from client: 16384 bytes read"
3520
3521run_test "Large packet TLS 1.0 BlockCipher" \
3522 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003523 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003524 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3525 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003526 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003527 -s "Read from client: 16384 bytes read"
3528
3529run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
3530 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003531 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3533 trunc_hmac=1" \
3534 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003535 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003536 -s "Read from client: 16384 bytes read"
3537
3538run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003539 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003540 "$P_CLI request_size=16384 force_version=tls1 \
3541 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3542 trunc_hmac=1" \
3543 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003544 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003545 -s "Read from client: 16384 bytes read"
3546
3547run_test "Large packet TLS 1.1 BlockCipher" \
3548 "$P_SRV" \
3549 "$P_CLI request_size=16384 force_version=tls1_1 \
3550 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3551 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003552 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003553 -s "Read from client: 16384 bytes read"
3554
3555run_test "Large packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003556 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003557 "$P_CLI request_size=16384 force_version=tls1_1 \
3558 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3559 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003560 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003561 -s "Read from client: 16384 bytes read"
3562
3563run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
3564 "$P_SRV" \
3565 "$P_CLI request_size=16384 force_version=tls1_1 \
3566 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3567 trunc_hmac=1" \
3568 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003569 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003570 -s "Read from client: 16384 bytes read"
3571
3572run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003573 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003574 "$P_CLI request_size=16384 force_version=tls1_1 \
3575 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3576 trunc_hmac=1" \
3577 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003578 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003579 -s "Read from client: 16384 bytes read"
3580
3581run_test "Large packet TLS 1.2 BlockCipher" \
3582 "$P_SRV" \
3583 "$P_CLI request_size=16384 force_version=tls1_2 \
3584 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
3585 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003586 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003587 -s "Read from client: 16384 bytes read"
3588
3589run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
3590 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01003591 "$P_CLI request_size=16384 force_version=tls1_2 \
3592 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003593 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003594 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003595 -s "Read from client: 16384 bytes read"
3596
3597run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
3598 "$P_SRV" \
3599 "$P_CLI request_size=16384 force_version=tls1_2 \
3600 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
3601 trunc_hmac=1" \
3602 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003603 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003604 -s "Read from client: 16384 bytes read"
3605
3606run_test "Large packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003607 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003608 "$P_CLI request_size=16384 force_version=tls1_2 \
3609 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
3610 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003611 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003612 -s "Read from client: 16384 bytes read"
3613
3614run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01003615 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003616 "$P_CLI request_size=16384 force_version=tls1_2 \
3617 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
3618 trunc_hmac=1" \
3619 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003620 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003621 -s "Read from client: 16384 bytes read"
3622
3623run_test "Large packet TLS 1.2 AEAD" \
3624 "$P_SRV" \
3625 "$P_CLI request_size=16384 force_version=tls1_2 \
3626 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
3627 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003628 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003629 -s "Read from client: 16384 bytes read"
3630
3631run_test "Large packet TLS 1.2 AEAD shorter tag" \
3632 "$P_SRV" \
3633 "$P_CLI request_size=16384 force_version=tls1_2 \
3634 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
3635 0 \
Hanno Becker09930d12017-09-18 15:04:19 +01003636 -c "16384 bytes written in 1 fragments" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02003637 -s "Read from client: 16384 bytes read"
3638
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003639# Tests for DTLS HelloVerifyRequest
3640
3641run_test "DTLS cookie: enabled" \
3642 "$P_SRV dtls=1 debug_level=2" \
3643 "$P_CLI dtls=1 debug_level=2" \
3644 0 \
3645 -s "cookie verification failed" \
3646 -s "cookie verification passed" \
3647 -S "cookie verification skipped" \
3648 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003649 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003650 -S "SSL - The requested feature is not available"
3651
3652run_test "DTLS cookie: disabled" \
3653 "$P_SRV dtls=1 debug_level=2 cookies=0" \
3654 "$P_CLI dtls=1 debug_level=2" \
3655 0 \
3656 -S "cookie verification failed" \
3657 -S "cookie verification passed" \
3658 -s "cookie verification skipped" \
3659 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003660 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003661 -S "SSL - The requested feature is not available"
3662
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003663run_test "DTLS cookie: default (failing)" \
3664 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
3665 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
3666 1 \
3667 -s "cookie verification failed" \
3668 -S "cookie verification passed" \
3669 -S "cookie verification skipped" \
3670 -C "received hello verify request" \
3671 -S "hello verification requested" \
3672 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003673
3674requires_ipv6
3675run_test "DTLS cookie: enabled, IPv6" \
3676 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
3677 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
3678 0 \
3679 -s "cookie verification failed" \
3680 -s "cookie verification passed" \
3681 -S "cookie verification skipped" \
3682 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003683 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003684 -S "SSL - The requested feature is not available"
3685
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003686run_test "DTLS cookie: enabled, nbio" \
3687 "$P_SRV dtls=1 nbio=2 debug_level=2" \
3688 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3689 0 \
3690 -s "cookie verification failed" \
3691 -s "cookie verification passed" \
3692 -S "cookie verification skipped" \
3693 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02003694 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02003695 -S "SSL - The requested feature is not available"
3696
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003697# Tests for client reconnecting from the same port with DTLS
3698
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003699not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003700run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003701 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3702 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-1000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003703 0 \
3704 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003705 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003706 -S "Client initiated reconnection from same port"
3707
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003708not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003709run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003710 "$P_SRV dtls=1 exchanges=2 read_timeout=1000" \
3711 "$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 +02003712 0 \
3713 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003714 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003715 -s "Client initiated reconnection from same port"
3716
Paul Bakker362689d2016-05-13 10:33:25 +01003717not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
3718run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003719 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
3720 "$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 +02003721 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003722 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02003723 -s "Client initiated reconnection from same port"
3724
Paul Bakker362689d2016-05-13 10:33:25 +01003725only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
3726run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
3727 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
3728 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
3729 0 \
3730 -S "The operation timed out" \
3731 -s "Client initiated reconnection from same port"
3732
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003733run_test "DTLS client reconnect from same port: no cookies" \
3734 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02003735 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
3736 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02003737 -s "The operation timed out" \
3738 -S "Client initiated reconnection from same port"
3739
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003740# Tests for various cases of client authentication with DTLS
3741# (focused on handshake flows and message parsing)
3742
3743run_test "DTLS client auth: required" \
3744 "$P_SRV dtls=1 auth_mode=required" \
3745 "$P_CLI dtls=1" \
3746 0 \
3747 -s "Verifying peer X.509 certificate... ok"
3748
3749run_test "DTLS client auth: optional, client has no cert" \
3750 "$P_SRV dtls=1 auth_mode=optional" \
3751 "$P_CLI dtls=1 crt_file=none key_file=none" \
3752 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003753 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003754
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003755run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003756 "$P_SRV dtls=1 auth_mode=none" \
3757 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
3758 0 \
3759 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003760 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02003761
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02003762run_test "DTLS wrong PSK: badmac alert" \
3763 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
3764 "$P_CLI dtls=1 psk=abc124" \
3765 1 \
3766 -s "SSL - Verification of the message MAC failed" \
3767 -c "SSL - A fatal alert message was received from our peer"
3768
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02003769# Tests for receiving fragmented handshake messages with DTLS
3770
3771requires_gnutls
3772run_test "DTLS reassembly: no fragmentation (gnutls server)" \
3773 "$G_SRV -u --mtu 2048 -a" \
3774 "$P_CLI dtls=1 debug_level=2" \
3775 0 \
3776 -C "found fragmented DTLS handshake message" \
3777 -C "error"
3778
3779requires_gnutls
3780run_test "DTLS reassembly: some fragmentation (gnutls server)" \
3781 "$G_SRV -u --mtu 512" \
3782 "$P_CLI dtls=1 debug_level=2" \
3783 0 \
3784 -c "found fragmented DTLS handshake message" \
3785 -C "error"
3786
3787requires_gnutls
3788run_test "DTLS reassembly: more fragmentation (gnutls server)" \
3789 "$G_SRV -u --mtu 128" \
3790 "$P_CLI dtls=1 debug_level=2" \
3791 0 \
3792 -c "found fragmented DTLS handshake message" \
3793 -C "error"
3794
3795requires_gnutls
3796run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
3797 "$G_SRV -u --mtu 128" \
3798 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3799 0 \
3800 -c "found fragmented DTLS handshake message" \
3801 -C "error"
3802
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003803requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003804requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003805run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
3806 "$G_SRV -u --mtu 256" \
3807 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
3808 0 \
3809 -c "found fragmented DTLS handshake message" \
3810 -c "client hello, adding renegotiation extension" \
3811 -c "found renegotiation extension" \
3812 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003813 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003814 -C "error" \
3815 -s "Extra-header:"
3816
3817requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003818requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003819run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
3820 "$G_SRV -u --mtu 256" \
3821 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
3822 0 \
3823 -c "found fragmented DTLS handshake message" \
3824 -c "client hello, adding renegotiation extension" \
3825 -c "found renegotiation extension" \
3826 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003827 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02003828 -C "error" \
3829 -s "Extra-header:"
3830
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003831run_test "DTLS reassembly: no fragmentation (openssl server)" \
3832 "$O_SRV -dtls1 -mtu 2048" \
3833 "$P_CLI dtls=1 debug_level=2" \
3834 0 \
3835 -C "found fragmented DTLS handshake message" \
3836 -C "error"
3837
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003838run_test "DTLS reassembly: some fragmentation (openssl server)" \
3839 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003840 "$P_CLI dtls=1 debug_level=2" \
3841 0 \
3842 -c "found fragmented DTLS handshake message" \
3843 -C "error"
3844
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003845run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02003846 "$O_SRV -dtls1 -mtu 256" \
3847 "$P_CLI dtls=1 debug_level=2" \
3848 0 \
3849 -c "found fragmented DTLS handshake message" \
3850 -C "error"
3851
3852run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
3853 "$O_SRV -dtls1 -mtu 256" \
3854 "$P_CLI dtls=1 nbio=2 debug_level=2" \
3855 0 \
3856 -c "found fragmented DTLS handshake message" \
3857 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003858
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003859# Tests for specific things with "unreliable" UDP connection
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003860
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003861not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003862run_test "DTLS proxy: reference" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02003863 -p "$P_PXY" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003864 "$P_SRV dtls=1 debug_level=2" \
3865 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003866 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003867 -C "replayed record" \
3868 -S "replayed record" \
3869 -C "record from another epoch" \
3870 -S "record from another epoch" \
3871 -C "discarding invalid record" \
3872 -S "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003873 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003874 -s "Extra-header:" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003875 -c "HTTP/1.0 200 OK"
3876
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003877not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003878run_test "DTLS proxy: duplicate every packet" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003879 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003880 "$P_SRV dtls=1 debug_level=2" \
3881 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02003882 0 \
Manuel Pégourié-Gonnardb47368a2014-09-24 13:29:58 +02003883 -c "replayed record" \
3884 -s "replayed record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003885 -c "discarding invalid record" \
3886 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003887 -S "resend" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003888 -s "Extra-header:" \
3889 -c "HTTP/1.0 200 OK"
3890
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003891run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
3892 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003893 "$P_SRV dtls=1 debug_level=2 anti_replay=0" \
3894 "$P_CLI dtls=1 debug_level=2" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003895 0 \
3896 -c "replayed record" \
3897 -S "replayed record" \
3898 -c "discarding invalid record" \
3899 -s "discarding invalid record" \
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +02003900 -c "resend" \
3901 -s "resend" \
Manuel Pégourié-Gonnard27393132014-09-24 14:41:11 +02003902 -s "Extra-header:" \
3903 -c "HTTP/1.0 200 OK"
3904
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003905run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02003906 -p "$P_PXY bad_ad=1" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003907 "$P_SRV dtls=1 debug_level=1" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003908 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003909 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003910 -c "discarding invalid record (mac)" \
3911 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003912 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003913 -c "HTTP/1.0 200 OK" \
3914 -S "too many records with bad MAC" \
3915 -S "Verification of the message MAC failed"
3916
3917run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
3918 -p "$P_PXY bad_ad=1" \
3919 "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \
3920 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3921 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003922 -C "discarding invalid record (mac)" \
3923 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003924 -S "Extra-header:" \
3925 -C "HTTP/1.0 200 OK" \
3926 -s "too many records with bad MAC" \
3927 -s "Verification of the message MAC failed"
3928
3929run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
3930 -p "$P_PXY bad_ad=1" \
3931 "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \
3932 "$P_CLI dtls=1 debug_level=1 read_timeout=100" \
3933 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003934 -c "discarding invalid record (mac)" \
3935 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003936 -s "Extra-header:" \
3937 -c "HTTP/1.0 200 OK" \
3938 -S "too many records with bad MAC" \
3939 -S "Verification of the message MAC failed"
3940
3941run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
3942 -p "$P_PXY bad_ad=1" \
3943 "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \
3944 "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \
3945 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02003946 -c "discarding invalid record (mac)" \
3947 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02003948 -s "Extra-header:" \
3949 -c "HTTP/1.0 200 OK" \
3950 -s "too many records with bad MAC" \
3951 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003952
3953run_test "DTLS proxy: delay ChangeCipherSpec" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003954 -p "$P_PXY delay_ccs=1" \
3955 "$P_SRV dtls=1 debug_level=1" \
3956 "$P_CLI dtls=1 debug_level=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003957 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003958 -c "record from another epoch" \
3959 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003960 -c "discarding invalid record" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02003961 -s "discarding invalid record" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003962 -s "Extra-header:" \
3963 -c "HTTP/1.0 200 OK"
3964
Manuel Pégourié-Gonnard7a66cbc2014-09-26 16:31:46 +02003965# Tests for "randomly unreliable connection": try a variety of flows and peers
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003966
Janos Follath74537a62016-09-02 13:45:28 +01003967client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003968run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02003969 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003970 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
3971 psk=abc123" \
3972 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003973 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
3974 0 \
3975 -s "Extra-header:" \
3976 -c "HTTP/1.0 200 OK"
3977
Janos Follath74537a62016-09-02 13:45:28 +01003978client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003979run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
3980 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003981 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3982 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003983 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3984 0 \
3985 -s "Extra-header:" \
3986 -c "HTTP/1.0 200 OK"
3987
Janos Follath74537a62016-09-02 13:45:28 +01003988client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003989run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
3990 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02003991 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \
3992 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003993 0 \
3994 -s "Extra-header:" \
3995 -c "HTTP/1.0 200 OK"
3996
Janos Follath74537a62016-09-02 13:45:28 +01003997client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02003998run_test "DTLS proxy: 3d, FS, client auth" \
3999 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004000 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \
4001 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004002 0 \
4003 -s "Extra-header:" \
4004 -c "HTTP/1.0 200 OK"
4005
Janos Follath74537a62016-09-02 13:45:28 +01004006client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004007run_test "DTLS proxy: 3d, FS, ticket" \
4008 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004009 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \
4010 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004011 0 \
4012 -s "Extra-header:" \
4013 -c "HTTP/1.0 200 OK"
4014
Janos Follath74537a62016-09-02 13:45:28 +01004015client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02004016run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
4017 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004018 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \
4019 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02004020 0 \
4021 -s "Extra-header:" \
4022 -c "HTTP/1.0 200 OK"
4023
Janos Follath74537a62016-09-02 13:45:28 +01004024client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004025run_test "DTLS proxy: 3d, max handshake, nbio" \
4026 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004027 "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \
4028 auth_mode=required" \
4029 "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004030 0 \
4031 -s "Extra-header:" \
4032 -c "HTTP/1.0 200 OK"
4033
Janos Follath74537a62016-09-02 13:45:28 +01004034client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02004035run_test "DTLS proxy: 3d, min handshake, resumption" \
4036 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4037 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4038 psk=abc123 debug_level=3" \
4039 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4040 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4041 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4042 0 \
4043 -s "a session has been resumed" \
4044 -c "a session has been resumed" \
4045 -s "Extra-header:" \
4046 -c "HTTP/1.0 200 OK"
4047
Janos Follath74537a62016-09-02 13:45:28 +01004048client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02004049run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
4050 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4051 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4052 psk=abc123 debug_level=3 nbio=2" \
4053 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4054 debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \
4055 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
4056 0 \
4057 -s "a session has been resumed" \
4058 -c "a session has been resumed" \
4059 -s "Extra-header:" \
4060 -c "HTTP/1.0 200 OK"
4061
Janos Follath74537a62016-09-02 13:45:28 +01004062client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004063requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004064run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004065 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004066 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4067 psk=abc123 renegotiation=1 debug_level=2" \
4068 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4069 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02004070 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4071 0 \
4072 -c "=> renegotiate" \
4073 -s "=> renegotiate" \
4074 -s "Extra-header:" \
4075 -c "HTTP/1.0 200 OK"
4076
Janos Follath74537a62016-09-02 13:45:28 +01004077client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004078requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004079run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
4080 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02004081 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
4082 psk=abc123 renegotiation=1 debug_level=2" \
4083 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
4084 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004085 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4086 0 \
4087 -c "=> renegotiate" \
4088 -s "=> renegotiate" \
4089 -s "Extra-header:" \
4090 -c "HTTP/1.0 200 OK"
4091
Janos Follath74537a62016-09-02 13:45:28 +01004092client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004093requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004094run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004095 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004096 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004097 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004098 debug_level=2" \
4099 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004100 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004101 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4102 0 \
4103 -c "=> renegotiate" \
4104 -s "=> renegotiate" \
4105 -s "Extra-header:" \
4106 -c "HTTP/1.0 200 OK"
4107
Janos Follath74537a62016-09-02 13:45:28 +01004108client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01004109requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004110run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004111 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004112 "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004113 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004114 debug_level=2 nbio=2" \
4115 "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02004116 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02004117 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
4118 0 \
4119 -c "=> renegotiate" \
4120 -s "=> renegotiate" \
4121 -s "Extra-header:" \
4122 -c "HTTP/1.0 200 OK"
4123
Janos Follath74537a62016-09-02 13:45:28 +01004124client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004125not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004126run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004127 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4128 "$O_SRV -dtls1 -mtu 2048" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004129 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004130 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02004131 -c "HTTP/1.0 200 OK"
4132
Janos Follath74537a62016-09-02 13:45:28 +01004133client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004134not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004135run_test "DTLS proxy: 3d, openssl server, fragmentation" \
4136 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4137 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004138 "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004139 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004140 -c "HTTP/1.0 200 OK"
4141
Janos Follath74537a62016-09-02 13:45:28 +01004142client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004143not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004144run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
4145 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
4146 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard8fe411e2015-03-09 16:09:53 +00004147 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004148 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004149 -c "HTTP/1.0 200 OK"
4150
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004151requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004152client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004153not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004154run_test "DTLS proxy: 3d, gnutls server" \
4155 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4156 "$G_SRV -u --mtu 2048 -a" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004157 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004158 0 \
4159 -s "Extra-header:" \
4160 -c "Extra-header:"
4161
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004162requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004163client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004164not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004165run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
4166 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4167 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004168 "$P_CLI dtls=1 hs_timeout=250-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02004169 0 \
4170 -s "Extra-header:" \
4171 -c "Extra-header:"
4172
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00004173requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01004174client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02004175not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004176run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
4177 -p "$P_PXY drop=5 delay=5 duplicate=5" \
4178 "$G_SRV -u --mtu 512" \
Manuel Pégourié-Gonnardf1384472014-10-14 22:57:46 +02004179 "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02004180 0 \
4181 -s "Extra-header:" \
4182 -c "Extra-header:"
4183
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004184# Final report
4185
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004186echo "------------------------------------------------------------------------"
4187
4188if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004189 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004190else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01004191 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004192fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02004193PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02004194echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01004195
4196exit $FAILS