blob: af6b0af8ba07eefc507c3bcf9018a584d6bb1b74 [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#
Bence Szépkútia2947ac2020-08-19 16:37:36 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkútif744bd72020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Simon Butcher58eddef2016-05-19 23:43:11 +010047# Purpose
48#
49# Executes tests to prove various TLS/SSL options and extensions.
50#
51# The goal is not to cover every ciphersuite/version, but instead to cover
52# specific options (max fragment length, truncated hmac, etc) or procedures
53# (session resumption from cache or ticket, renego, etc).
54#
55# The tests assume a build with default options, with exceptions expressed
56# with a dependency. The tests focus on functionality and do not consider
57# performance.
58#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010059
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010060set -u
61
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010062# Limit the size of each log to 10 GiB, in case of failures with this script
63# where it may output seemingly unlimited length error logs.
64ulimit -f 20971520
65
Angus Grattonc4dd0732018-04-11 16:28:39 +100066if cd $( dirname $0 ); then :; else
67 echo "cd $( dirname $0 ) failed" >&2
68 exit 1
69fi
70
Antonin Décimod5f47592019-01-23 15:24:37 +010071# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010072: ${P_SRV:=../programs/ssl/ssl_server2}
73: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020074: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010075: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020076: ${GNUTLS_CLI:=gnutls-cli}
77: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020078: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010079
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020080O_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 +010081O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020082G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010083G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020084TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010085
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020086# alternative versions of OpenSSL and GnuTLS (no default path)
87
88if [ -n "${OPENSSL_LEGACY:-}" ]; then
89 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
90 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
91else
92 O_LEGACY_SRV=false
93 O_LEGACY_CLI=false
94fi
95
Hanno Becker58e9dc32018-08-17 15:53:21 +010096if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020097 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
98else
99 G_NEXT_SRV=false
100fi
101
Hanno Becker58e9dc32018-08-17 15:53:21 +0100102if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200103 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
104else
105 G_NEXT_CLI=false
106fi
107
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100108TESTS=0
109FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200110SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100111
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000112CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200113
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100114MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100115FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200116EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100117
Paul Bakkere20310a2016-05-10 11:18:17 +0100118SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100119RUN_TEST_NUMBER=''
120
Paul Bakkeracaac852016-05-10 11:47:13 +0100121PRESERVE_LOGS=0
122
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200123# Pick a "unique" server port in the range 10000-19999, and a proxy
124# port which is this plus 10000. Each port number may be independently
125# overridden by a command line option.
126SRV_PORT=$(($$ % 10000 + 10000))
127PXY_PORT=$((SRV_PORT + 10000))
128
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100129print_usage() {
130 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100131 printf " -h|--help\tPrint this help.\n"
132 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200133 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
134 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100135 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100136 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100137 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200138 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
139 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100140 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100141}
142
143get_options() {
144 while [ $# -gt 0 ]; do
145 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100146 -f|--filter)
147 shift; FILTER=$1
148 ;;
149 -e|--exclude)
150 shift; EXCLUDE=$1
151 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100152 -m|--memcheck)
153 MEMCHECK=1
154 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100155 -n|--number)
156 shift; RUN_TEST_NUMBER=$1
157 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100158 -s|--show-numbers)
159 SHOW_TEST_NUMBER=1
160 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100161 -p|--preserve-logs)
162 PRESERVE_LOGS=1
163 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200164 --port)
165 shift; SRV_PORT=$1
166 ;;
167 --proxy-port)
168 shift; PXY_PORT=$1
169 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100170 --seed)
171 shift; SEED="$1"
172 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100173 -h|--help)
174 print_usage
175 exit 0
176 ;;
177 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200178 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100179 print_usage
180 exit 1
181 ;;
182 esac
183 shift
184 done
185}
186
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100187# Skip next test; use this macro to skip tests which are legitimate
188# in theory and expected to be re-introduced at some point, but
189# aren't expected to succeed at the moment due to problems outside
190# our control (such as bugs in other TLS implementations).
191skip_next_test() {
192 SKIP_NEXT="YES"
193}
194
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100195# skip next test if the flag is not enabled in config.h
196requires_config_enabled() {
197 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
198 SKIP_NEXT="YES"
199 fi
200}
201
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200202# skip next test if the flag is enabled in config.h
203requires_config_disabled() {
204 if grep "^#define $1" $CONFIG_H > /dev/null; then
205 SKIP_NEXT="YES"
206 fi
207}
208
Hanno Becker7c48dd12018-08-28 16:09:22 +0100209get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100210 # This function uses the query_config command line option to query the
211 # required Mbed TLS compile time configuration from the ssl_server2
212 # program. The command will always return a success value if the
213 # configuration is defined and the value will be printed to stdout.
214 #
215 # Note that if the configuration is not defined or is defined to nothing,
216 # the output of this function will be an empty string.
217 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100218}
219
220requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100221 VAL="$( get_config_value_or_default "$1" )"
222 if [ -z "$VAL" ]; then
223 # Should never happen
224 echo "Mbed TLS configuration $1 is not defined"
225 exit 1
226 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100227 SKIP_NEXT="YES"
228 fi
229}
230
231requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100232 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100233 if [ -z "$VAL" ]; then
234 # Should never happen
235 echo "Mbed TLS configuration $1 is not defined"
236 exit 1
237 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100238 SKIP_NEXT="YES"
239 fi
240}
241
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200242# skip next test if OpenSSL doesn't support FALLBACK_SCSV
243requires_openssl_with_fallback_scsv() {
244 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
245 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
246 then
247 OPENSSL_HAS_FBSCSV="YES"
248 else
249 OPENSSL_HAS_FBSCSV="NO"
250 fi
251 fi
252 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
253 SKIP_NEXT="YES"
254 fi
255}
256
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200257# skip next test if GnuTLS isn't available
258requires_gnutls() {
259 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200260 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200261 GNUTLS_AVAILABLE="YES"
262 else
263 GNUTLS_AVAILABLE="NO"
264 fi
265 fi
266 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
267 SKIP_NEXT="YES"
268 fi
269}
270
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200271# skip next test if GnuTLS-next isn't available
272requires_gnutls_next() {
273 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
274 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
275 GNUTLS_NEXT_AVAILABLE="YES"
276 else
277 GNUTLS_NEXT_AVAILABLE="NO"
278 fi
279 fi
280 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
281 SKIP_NEXT="YES"
282 fi
283}
284
285# skip next test if OpenSSL-legacy isn't available
286requires_openssl_legacy() {
287 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
288 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
289 OPENSSL_LEGACY_AVAILABLE="YES"
290 else
291 OPENSSL_LEGACY_AVAILABLE="NO"
292 fi
293 fi
294 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
295 SKIP_NEXT="YES"
296 fi
297}
298
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200299# skip next test if IPv6 isn't available on this host
300requires_ipv6() {
301 if [ -z "${HAS_IPV6:-}" ]; then
302 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
303 SRV_PID=$!
304 sleep 1
305 kill $SRV_PID >/dev/null 2>&1
306 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
307 HAS_IPV6="NO"
308 else
309 HAS_IPV6="YES"
310 fi
311 rm -r $SRV_OUT
312 fi
313
314 if [ "$HAS_IPV6" = "NO" ]; then
315 SKIP_NEXT="YES"
316 fi
317}
318
Andrzej Kurekb4593462018-10-11 08:43:30 -0400319# skip next test if it's i686 or uname is not available
320requires_not_i686() {
321 if [ -z "${IS_I686:-}" ]; then
322 IS_I686="YES"
323 if which "uname" >/dev/null 2>&1; then
324 if [ -z "$(uname -a | grep i686)" ]; then
325 IS_I686="NO"
326 fi
327 fi
328 fi
329 if [ "$IS_I686" = "YES" ]; then
330 SKIP_NEXT="YES"
331 fi
332}
333
Angus Grattonc4dd0732018-04-11 16:28:39 +1000334# Calculate the input & output maximum content lengths set in the config
335MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
336MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
337MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
338
339if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
340 MAX_CONTENT_LEN="$MAX_IN_LEN"
341fi
342if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
343 MAX_CONTENT_LEN="$MAX_OUT_LEN"
344fi
345
346# skip the next test if the SSL output buffer is less than 16KB
347requires_full_size_output_buffer() {
348 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
349 SKIP_NEXT="YES"
350 fi
351}
352
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200353# skip the next test if valgrind is in use
354not_with_valgrind() {
355 if [ "$MEMCHECK" -gt 0 ]; then
356 SKIP_NEXT="YES"
357 fi
358}
359
Paul Bakker362689d2016-05-13 10:33:25 +0100360# skip the next test if valgrind is NOT in use
361only_with_valgrind() {
362 if [ "$MEMCHECK" -eq 0 ]; then
363 SKIP_NEXT="YES"
364 fi
365}
366
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200367# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100368client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200369 CLI_DELAY_FACTOR=$1
370}
371
Janos Follath74537a62016-09-02 13:45:28 +0100372# wait for the given seconds after the client finished in the next test
373server_needs_more_time() {
374 SRV_DELAY_SECONDS=$1
375}
376
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100377# print_name <name>
378print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100379 TESTS=$(( $TESTS + 1 ))
380 LINE=""
381
382 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
383 LINE="$TESTS "
384 fi
385
386 LINE="$LINE$1"
387 printf "$LINE "
388 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100389 for i in `seq 1 $LEN`; do printf '.'; done
390 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100391
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100392}
393
394# fail <message>
395fail() {
396 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100397 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100398
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200399 mv $SRV_OUT o-srv-${TESTS}.log
400 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200401 if [ -n "$PXY_CMD" ]; then
402 mv $PXY_OUT o-pxy-${TESTS}.log
403 fi
404 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100405
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200406 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200407 echo " ! server output:"
408 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200409 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200410 echo " ! client output:"
411 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200412 if [ -n "$PXY_CMD" ]; then
413 echo " ! ========================================================"
414 echo " ! proxy output:"
415 cat o-pxy-${TESTS}.log
416 fi
417 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200418 fi
419
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200420 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100421}
422
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100423# is_polar <cmd_line>
424is_polar() {
425 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
426}
427
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200428# openssl s_server doesn't have -www with DTLS
429check_osrv_dtls() {
430 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
431 NEEDS_INPUT=1
432 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
433 else
434 NEEDS_INPUT=0
435 fi
436}
437
438# provide input to commands that need it
439provide_input() {
440 if [ $NEEDS_INPUT -eq 0 ]; then
441 return
442 fi
443
444 while true; do
445 echo "HTTP/1.0 200 OK"
446 sleep 1
447 done
448}
449
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100450# has_mem_err <log_file_name>
451has_mem_err() {
452 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
453 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
454 then
455 return 1 # false: does not have errors
456 else
457 return 0 # true: has errors
458 fi
459}
460
Unknown43dc0d62019-09-02 10:42:57 -0400461# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100462if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400463 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100464 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200465 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100466 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200467 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100468 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200469 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100470 # Make a tight loop, server normally takes less than 1s to start.
471 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
472 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400473 echo "$3 START TIMEOUT"
474 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100475 break
476 fi
477 # Linux and *BSD support decimal arguments to sleep. On other
478 # OSes this may be a tight loop.
479 sleep 0.1 2>/dev/null || true
480 done
481 }
482else
Unknown43dc0d62019-09-02 10:42:57 -0400483 echo "Warning: lsof not available, wait_app_start = sleep"
484 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200485 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100486 }
487fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200488
Unknown43dc0d62019-09-02 10:42:57 -0400489# Wait for server process $2 to be listening on port $1.
490wait_server_start() {
491 wait_app_start $1 $2 "SERVER" $SRV_OUT
492}
493
494# Wait for proxy process $2 to be listening on port $1.
495wait_proxy_start() {
496 wait_app_start $1 $2 "PROXY" $PXY_OUT
497}
498
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100499# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100500# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100501# acceptable bounds
502check_server_hello_time() {
503 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100504 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100505 # Get the Unix timestamp for now
506 CUR_TIME=$(date +'%s')
507 THRESHOLD_IN_SECS=300
508
509 # Check if the ServerHello time was printed
510 if [ -z "$SERVER_HELLO_TIME" ]; then
511 return 1
512 fi
513
514 # Check the time in ServerHello is within acceptable bounds
515 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
516 # The time in ServerHello is at least 5 minutes before now
517 return 1
518 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100519 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100520 return 1
521 else
522 return 0
523 fi
524}
525
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200526# wait for client to terminate and set CLI_EXIT
527# must be called right after starting the client
528wait_client_done() {
529 CLI_PID=$!
530
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200531 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
532 CLI_DELAY_FACTOR=1
533
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200534 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200535 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200536
537 wait $CLI_PID
538 CLI_EXIT=$?
539
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200540 kill $DOG_PID >/dev/null 2>&1
541 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200542
543 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100544
545 sleep $SRV_DELAY_SECONDS
546 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200547}
548
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200549# check if the given command uses dtls and sets global variable DTLS
550detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200551 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200552 DTLS=1
553 else
554 DTLS=0
555 fi
556}
557
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200558# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100559# Options: -s pattern pattern that must be present in server output
560# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100561# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100562# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100563# -S pattern pattern that must be absent in server output
564# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100565# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100566# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100567run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100568 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200569 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100570
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100571 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
572 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200573 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100574 return
575 fi
576
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100577 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100578
Paul Bakkerb7584a52016-05-10 10:50:43 +0100579 # Do we only run numbered tests?
580 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
581 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
582 else
583 SKIP_NEXT="YES"
584 fi
585
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200586 # should we skip?
587 if [ "X$SKIP_NEXT" = "XYES" ]; then
588 SKIP_NEXT="NO"
589 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200590 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200591 return
592 fi
593
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200594 # does this test use a proxy?
595 if [ "X$1" = "X-p" ]; then
596 PXY_CMD="$2"
597 shift 2
598 else
599 PXY_CMD=""
600 fi
601
602 # get commands and client output
603 SRV_CMD="$1"
604 CLI_CMD="$2"
605 CLI_EXPECT="$3"
606 shift 3
607
Hanno Becker7a11e722019-05-10 14:38:42 +0100608 # Check if test uses files
609 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
610 if [ ! -z "$TEST_USES_FILES" ]; then
611 requires_config_enabled MBEDTLS_FS_IO
612 fi
613
614 # should we skip?
615 if [ "X$SKIP_NEXT" = "XYES" ]; then
616 SKIP_NEXT="NO"
617 echo "SKIP"
618 SKIPS=$(( $SKIPS + 1 ))
619 return
620 fi
621
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200622 # update DTLS variable
623 detect_dtls "$SRV_CMD"
624
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200625 # if the test uses DTLS but no custom proxy, add a simple proxy
626 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200627 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200628 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200629 case " $SRV_CMD " in
630 *' server_addr=::1 '*)
631 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
632 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200633 fi
634
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200635 # fix client port
636 if [ -n "$PXY_CMD" ]; then
637 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
638 else
639 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
640 fi
641
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100642 # prepend valgrind to our commands if active
643 if [ "$MEMCHECK" -gt 0 ]; then
644 if is_polar "$SRV_CMD"; then
645 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
646 fi
647 if is_polar "$CLI_CMD"; then
648 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
649 fi
650 fi
651
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200652 TIMES_LEFT=2
653 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200654 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200655
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200656 # run the commands
657 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200658 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200659 $PXY_CMD >> $PXY_OUT 2>&1 &
660 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400661 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200662 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200663
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200664 check_osrv_dtls
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200665 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200666 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
667 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100668 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200669
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200670 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200671 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
672 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100673
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100674 sleep 0.05
675
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200676 # terminate the server (and the proxy)
677 kill $SRV_PID
678 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100679
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200680 if [ -n "$PXY_CMD" ]; then
681 kill $PXY_PID >/dev/null 2>&1
682 wait $PXY_PID
683 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100684
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200685 # retry only on timeouts
686 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
687 printf "RETRY "
688 else
689 TIMES_LEFT=0
690 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200691 done
692
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100693 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200694 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100695 # expected client exit to incorrectly succeed in case of catastrophic
696 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100697 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200698 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100699 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100700 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100701 return
702 fi
703 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100704 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200705 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100706 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100707 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100708 return
709 fi
710 fi
711
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100712 # check server exit code
713 if [ $? != 0 ]; then
714 fail "server fail"
715 return
716 fi
717
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100718 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100719 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
720 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100721 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200722 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100723 return
724 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100725
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100726 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200727 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100728 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100729 while [ $# -gt 0 ]
730 do
731 case $1 in
732 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100733 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 +0100734 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100735 return
736 fi
737 ;;
738
739 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100740 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 +0100741 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100742 return
743 fi
744 ;;
745
746 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100747 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 +0100748 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100749 return
750 fi
751 ;;
752
753 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100754 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 +0100755 fail "pattern '$2' MUST NOT be present in the Client output"
756 return
757 fi
758 ;;
759
760 # The filtering in the following two options (-u and -U) do the following
761 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100762 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100763 # - keep one of each non-unique line
764 # - count how many lines remain
765 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
766 # if there were no duplicates.
767 "-U")
768 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
769 fail "lines following pattern '$2' must be unique in Server output"
770 return
771 fi
772 ;;
773
774 "-u")
775 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
776 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100777 return
778 fi
779 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100780 "-F")
781 if ! $2 "$SRV_OUT"; then
782 fail "function call to '$2' failed on Server output"
783 return
784 fi
785 ;;
786 "-f")
787 if ! $2 "$CLI_OUT"; then
788 fail "function call to '$2' failed on Client output"
789 return
790 fi
791 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100792
793 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200794 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100795 exit 1
796 esac
797 shift 2
798 done
799
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100800 # check valgrind's results
801 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200802 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100803 fail "Server has memory errors"
804 return
805 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200806 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100807 fail "Client has memory errors"
808 return
809 fi
810 fi
811
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100812 # if we're here, everything is ok
813 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100814 if [ "$PRESERVE_LOGS" -gt 0 ]; then
815 mv $SRV_OUT o-srv-${TESTS}.log
816 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100817 if [ -n "$PXY_CMD" ]; then
818 mv $PXY_OUT o-pxy-${TESTS}.log
819 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100820 fi
821
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200822 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100823}
824
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100825cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200826 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200827 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
828 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
829 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
830 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100831 exit 1
832}
833
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100834#
835# MAIN
836#
837
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100838get_options "$@"
839
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100840# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100841P_SRV_BIN="${P_SRV%%[ ]*}"
842P_CLI_BIN="${P_CLI%%[ ]*}"
843P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100844if [ ! -x "$P_SRV_BIN" ]; then
845 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100846 exit 1
847fi
Hanno Becker17c04932017-10-10 14:44:53 +0100848if [ ! -x "$P_CLI_BIN" ]; then
849 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100850 exit 1
851fi
Hanno Becker17c04932017-10-10 14:44:53 +0100852if [ ! -x "$P_PXY_BIN" ]; then
853 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200854 exit 1
855fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100856if [ "$MEMCHECK" -gt 0 ]; then
857 if which valgrind >/dev/null 2>&1; then :; else
858 echo "Memcheck not possible. Valgrind not found"
859 exit 1
860 fi
861fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100862if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
863 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100864 exit 1
865fi
866
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200867# used by watchdog
868MAIN_PID="$$"
869
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100870# We use somewhat arbitrary delays for tests:
871# - how long do we wait for the server to start (when lsof not available)?
872# - how long do we allow for the client to finish?
873# (not to check performance, just to avoid waiting indefinitely)
874# Things are slower with valgrind, so give extra time here.
875#
876# Note: without lsof, there is a trade-off between the running time of this
877# script and the risk of spurious errors because we didn't wait long enough.
878# The watchdog delay on the other hand doesn't affect normal running time of
879# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200880if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100881 START_DELAY=6
882 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200883else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100884 START_DELAY=2
885 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200886fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100887
888# some particular tests need more time:
889# - for the client, we multiply the usual watchdog limit by a factor
890# - for the server, we sleep for a number of seconds after the client exits
891# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200892CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100893SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200894
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200895# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000896# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200897P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
898P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100899P_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 +0200900O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200901O_CLI="$O_CLI -connect localhost:+SRV_PORT"
902G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200903G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200904
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200905if [ -n "${OPENSSL_LEGACY:-}" ]; then
906 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
907 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
908fi
909
Hanno Becker58e9dc32018-08-17 15:53:21 +0100910if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200911 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
912fi
913
Hanno Becker58e9dc32018-08-17 15:53:21 +0100914if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200915 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200916fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100917
Gilles Peskine62469d92017-05-10 10:13:59 +0200918# Allow SHA-1, because many of our test certificates use it
919P_SRV="$P_SRV allow_sha1=1"
920P_CLI="$P_CLI allow_sha1=1"
921
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200922# Also pick a unique name for intermediate files
923SRV_OUT="srv_out.$$"
924CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200925PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200926SESSION="session.$$"
927
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200928SKIP_NEXT="NO"
929
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100930trap cleanup INT TERM HUP
931
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200932# Basic test
933
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200934# Checks that:
935# - things work with all ciphersuites active (used with config-full in all.sh)
936# - the expected (highest security) parameters are selected
937# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200938run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200939 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200940 "$P_CLI" \
941 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200942 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200943 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200944 -s "client hello v3, signature_algorithm ext: 6" \
945 -s "ECDHE curve: secp521r1" \
946 -S "error" \
947 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200948
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000949run_test "Default, DTLS" \
950 "$P_SRV dtls=1" \
951 "$P_CLI dtls=1" \
952 0 \
953 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200954 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000955
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +0100956requires_config_enabled MBEDTLS_ZLIB_SUPPORT
957run_test "Default (compression enabled)" \
958 "$P_SRV debug_level=3" \
959 "$P_CLI debug_level=3" \
960 0 \
961 -s "Allocating compression buffer" \
962 -c "Allocating compression buffer" \
963 -s "Record expansion is unknown (compression)" \
964 -c "Record expansion is unknown (compression)" \
965 -S "error" \
966 -C "error"
967
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100968# Test current time in ServerHello
969requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200970run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100971 "$P_SRV debug_level=3" \
972 "$P_CLI debug_level=3" \
973 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100974 -f "check_server_hello_time" \
975 -F "check_server_hello_time"
976
Simon Butcher8e004102016-10-14 00:48:33 +0100977# Test for uniqueness of IVs in AEAD ciphersuites
978run_test "Unique IV in GCM" \
979 "$P_SRV exchanges=20 debug_level=4" \
980 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
981 0 \
982 -u "IV used" \
983 -U "IV used"
984
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100985# Tests for rc4 option
986
Simon Butchera410af52016-05-19 22:12:18 +0100987requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100988run_test "RC4: server disabled, client enabled" \
989 "$P_SRV" \
990 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
991 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100992 -s "SSL - The server has no ciphersuites in common"
993
Simon Butchera410af52016-05-19 22:12:18 +0100994requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100995run_test "RC4: server half, client enabled" \
996 "$P_SRV arc4=1" \
997 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
998 1 \
999 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001000
1001run_test "RC4: server enabled, client disabled" \
1002 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1003 "$P_CLI" \
1004 1 \
1005 -s "SSL - The server has no ciphersuites in common"
1006
1007run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001008 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001009 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1010 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001011 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001012 -S "SSL - The server has no ciphersuites in common"
1013
Hanno Beckerd26bb202018-08-17 09:54:10 +01001014# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1015
1016requires_gnutls
1017requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1018run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1019 "$G_SRV"\
1020 "$P_CLI force_version=tls1_1" \
1021 0
1022
1023requires_gnutls
1024requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1025run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1026 "$G_SRV"\
1027 "$P_CLI force_version=tls1" \
1028 0
1029
Gilles Peskinebc70a182017-05-09 15:59:24 +02001030# Tests for SHA-1 support
1031
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001032requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001033run_test "SHA-1 forbidden by default in server certificate" \
1034 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1035 "$P_CLI debug_level=2 allow_sha1=0" \
1036 1 \
1037 -c "The certificate is signed with an unacceptable hash"
1038
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001039requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1040run_test "SHA-1 forbidden by default in server certificate" \
1041 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1042 "$P_CLI debug_level=2 allow_sha1=0" \
1043 0
1044
Gilles Peskinebc70a182017-05-09 15:59:24 +02001045run_test "SHA-1 explicitly allowed in server certificate" \
1046 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1047 "$P_CLI allow_sha1=1" \
1048 0
1049
1050run_test "SHA-256 allowed by default in server certificate" \
1051 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1052 "$P_CLI allow_sha1=0" \
1053 0
1054
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001055requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001056run_test "SHA-1 forbidden by default in client certificate" \
1057 "$P_SRV auth_mode=required allow_sha1=0" \
1058 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1059 1 \
1060 -s "The certificate is signed with an unacceptable hash"
1061
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001062requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1063run_test "SHA-1 forbidden by default in client certificate" \
1064 "$P_SRV auth_mode=required allow_sha1=0" \
1065 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1066 0
1067
Gilles Peskinebc70a182017-05-09 15:59:24 +02001068run_test "SHA-1 explicitly allowed in client certificate" \
1069 "$P_SRV auth_mode=required allow_sha1=1" \
1070 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1071 0
1072
1073run_test "SHA-256 allowed by default in client certificate" \
1074 "$P_SRV auth_mode=required allow_sha1=0" \
1075 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1076 0
1077
Hanno Becker7ae8a762018-08-14 15:43:35 +01001078# Tests for datagram packing
1079run_test "DTLS: multiple records in same datagram, client and server" \
1080 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1081 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1082 0 \
1083 -c "next record in same datagram" \
1084 -s "next record in same datagram"
1085
1086run_test "DTLS: multiple records in same datagram, client only" \
1087 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1088 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1089 0 \
1090 -s "next record in same datagram" \
1091 -C "next record in same datagram"
1092
1093run_test "DTLS: multiple records in same datagram, server only" \
1094 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1095 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1096 0 \
1097 -S "next record in same datagram" \
1098 -c "next record in same datagram"
1099
1100run_test "DTLS: multiple records in same datagram, neither client nor server" \
1101 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1102 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1103 0 \
1104 -S "next record in same datagram" \
1105 -C "next record in same datagram"
1106
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001107# Tests for Truncated HMAC extension
1108
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001109run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001110 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001111 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001112 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001113 -s "dumping 'expected mac' (20 bytes)" \
1114 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001115
Hanno Becker32c55012017-11-10 08:42:54 +00001116requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001117run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001118 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001119 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001120 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001121 -s "dumping 'expected mac' (20 bytes)" \
1122 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001123
Hanno Becker32c55012017-11-10 08:42:54 +00001124requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001125run_test "Truncated HMAC: client enabled, server default" \
1126 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001127 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001128 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001129 -s "dumping 'expected mac' (20 bytes)" \
1130 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001131
Hanno Becker32c55012017-11-10 08:42:54 +00001132requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001133run_test "Truncated HMAC: client enabled, server disabled" \
1134 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001135 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001136 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001137 -s "dumping 'expected mac' (20 bytes)" \
1138 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001139
Hanno Becker32c55012017-11-10 08:42:54 +00001140requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001141run_test "Truncated HMAC: client disabled, server enabled" \
1142 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001143 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001144 0 \
1145 -s "dumping 'expected mac' (20 bytes)" \
1146 -S "dumping 'expected mac' (10 bytes)"
1147
1148requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001149run_test "Truncated HMAC: client enabled, server enabled" \
1150 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001151 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001152 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001153 -S "dumping 'expected mac' (20 bytes)" \
1154 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001155
Hanno Becker4c4f4102017-11-10 09:16:05 +00001156run_test "Truncated HMAC, DTLS: client default, server default" \
1157 "$P_SRV dtls=1 debug_level=4" \
1158 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1159 0 \
1160 -s "dumping 'expected mac' (20 bytes)" \
1161 -S "dumping 'expected mac' (10 bytes)"
1162
1163requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1164run_test "Truncated HMAC, DTLS: client disabled, server default" \
1165 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001166 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001167 0 \
1168 -s "dumping 'expected mac' (20 bytes)" \
1169 -S "dumping 'expected mac' (10 bytes)"
1170
1171requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1172run_test "Truncated HMAC, DTLS: client enabled, server default" \
1173 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001174 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001175 0 \
1176 -s "dumping 'expected mac' (20 bytes)" \
1177 -S "dumping 'expected mac' (10 bytes)"
1178
1179requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1180run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1181 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001182 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001183 0 \
1184 -s "dumping 'expected mac' (20 bytes)" \
1185 -S "dumping 'expected mac' (10 bytes)"
1186
1187requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1188run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1189 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001190 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001191 0 \
1192 -s "dumping 'expected mac' (20 bytes)" \
1193 -S "dumping 'expected mac' (10 bytes)"
1194
1195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1196run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1197 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001198 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001199 0 \
1200 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001201 -s "dumping 'expected mac' (10 bytes)"
1202
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001203# Tests for Encrypt-then-MAC extension
1204
1205run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001206 "$P_SRV debug_level=3 \
1207 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001208 "$P_CLI debug_level=3" \
1209 0 \
1210 -c "client hello, adding encrypt_then_mac extension" \
1211 -s "found encrypt then mac extension" \
1212 -s "server hello, adding encrypt then mac extension" \
1213 -c "found encrypt_then_mac extension" \
1214 -c "using encrypt then mac" \
1215 -s "using encrypt then mac"
1216
1217run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001218 "$P_SRV debug_level=3 etm=0 \
1219 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001220 "$P_CLI debug_level=3 etm=1" \
1221 0 \
1222 -c "client hello, adding encrypt_then_mac extension" \
1223 -s "found encrypt then mac extension" \
1224 -S "server hello, adding encrypt then mac extension" \
1225 -C "found encrypt_then_mac extension" \
1226 -C "using encrypt then mac" \
1227 -S "using encrypt then mac"
1228
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001229run_test "Encrypt then MAC: client enabled, aead cipher" \
1230 "$P_SRV debug_level=3 etm=1 \
1231 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1232 "$P_CLI debug_level=3 etm=1" \
1233 0 \
1234 -c "client hello, adding encrypt_then_mac extension" \
1235 -s "found encrypt then mac extension" \
1236 -S "server hello, adding encrypt then mac extension" \
1237 -C "found encrypt_then_mac extension" \
1238 -C "using encrypt then mac" \
1239 -S "using encrypt then mac"
1240
1241run_test "Encrypt then MAC: client enabled, stream cipher" \
1242 "$P_SRV debug_level=3 etm=1 \
1243 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001244 "$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 +01001245 0 \
1246 -c "client hello, adding encrypt_then_mac extension" \
1247 -s "found encrypt then mac extension" \
1248 -S "server hello, adding encrypt then mac extension" \
1249 -C "found encrypt_then_mac extension" \
1250 -C "using encrypt then mac" \
1251 -S "using encrypt then mac"
1252
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001253run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001254 "$P_SRV debug_level=3 etm=1 \
1255 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001256 "$P_CLI debug_level=3 etm=0" \
1257 0 \
1258 -C "client hello, adding encrypt_then_mac extension" \
1259 -S "found encrypt then mac extension" \
1260 -S "server hello, adding encrypt then mac extension" \
1261 -C "found encrypt_then_mac extension" \
1262 -C "using encrypt then mac" \
1263 -S "using encrypt then mac"
1264
Janos Follathe2681a42016-03-07 15:57:05 +00001265requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001266run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001267 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001268 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001269 "$P_CLI debug_level=3 force_version=ssl3" \
1270 0 \
1271 -C "client hello, adding encrypt_then_mac extension" \
1272 -S "found encrypt then mac extension" \
1273 -S "server hello, adding encrypt then mac extension" \
1274 -C "found encrypt_then_mac extension" \
1275 -C "using encrypt then mac" \
1276 -S "using encrypt then mac"
1277
Janos Follathe2681a42016-03-07 15:57:05 +00001278requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001279run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001280 "$P_SRV debug_level=3 force_version=ssl3 \
1281 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001282 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001283 0 \
1284 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001285 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001286 -S "server hello, adding encrypt then mac extension" \
1287 -C "found encrypt_then_mac extension" \
1288 -C "using encrypt then mac" \
1289 -S "using encrypt then mac"
1290
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001291# Tests for Extended Master Secret extension
1292
1293run_test "Extended Master Secret: default" \
1294 "$P_SRV debug_level=3" \
1295 "$P_CLI debug_level=3" \
1296 0 \
1297 -c "client hello, adding extended_master_secret extension" \
1298 -s "found extended master secret extension" \
1299 -s "server hello, adding extended master secret extension" \
1300 -c "found extended_master_secret extension" \
1301 -c "using extended master secret" \
1302 -s "using extended master secret"
1303
1304run_test "Extended Master Secret: client enabled, server disabled" \
1305 "$P_SRV debug_level=3 extended_ms=0" \
1306 "$P_CLI debug_level=3 extended_ms=1" \
1307 0 \
1308 -c "client hello, adding extended_master_secret extension" \
1309 -s "found extended master secret extension" \
1310 -S "server hello, adding extended master secret extension" \
1311 -C "found extended_master_secret extension" \
1312 -C "using extended master secret" \
1313 -S "using extended master secret"
1314
1315run_test "Extended Master Secret: client disabled, server enabled" \
1316 "$P_SRV debug_level=3 extended_ms=1" \
1317 "$P_CLI debug_level=3 extended_ms=0" \
1318 0 \
1319 -C "client hello, adding extended_master_secret extension" \
1320 -S "found extended master secret extension" \
1321 -S "server hello, adding extended master secret extension" \
1322 -C "found extended_master_secret extension" \
1323 -C "using extended master secret" \
1324 -S "using extended master secret"
1325
Janos Follathe2681a42016-03-07 15:57:05 +00001326requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001327run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001328 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001329 "$P_CLI debug_level=3 force_version=ssl3" \
1330 0 \
1331 -C "client hello, adding extended_master_secret extension" \
1332 -S "found extended master secret extension" \
1333 -S "server hello, adding extended master secret extension" \
1334 -C "found extended_master_secret extension" \
1335 -C "using extended master secret" \
1336 -S "using extended master secret"
1337
Janos Follathe2681a42016-03-07 15:57:05 +00001338requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001339run_test "Extended Master Secret: client enabled, server SSLv3" \
1340 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001341 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001342 0 \
1343 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001344 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001345 -S "server hello, adding extended master secret extension" \
1346 -C "found extended_master_secret extension" \
1347 -C "using extended master secret" \
1348 -S "using extended master secret"
1349
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001350# Tests for FALLBACK_SCSV
1351
1352run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001353 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001354 "$P_CLI debug_level=3 force_version=tls1_1" \
1355 0 \
1356 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001357 -S "received FALLBACK_SCSV" \
1358 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001359 -C "is a fatal alert message (msg 86)"
1360
1361run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001362 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001363 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1364 0 \
1365 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001366 -S "received FALLBACK_SCSV" \
1367 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001368 -C "is a fatal alert message (msg 86)"
1369
1370run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001371 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001372 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001373 1 \
1374 -c "adding FALLBACK_SCSV" \
1375 -s "received FALLBACK_SCSV" \
1376 -s "inapropriate fallback" \
1377 -c "is a fatal alert message (msg 86)"
1378
1379run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001380 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001381 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001382 0 \
1383 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001384 -s "received FALLBACK_SCSV" \
1385 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001386 -C "is a fatal alert message (msg 86)"
1387
1388requires_openssl_with_fallback_scsv
1389run_test "Fallback SCSV: default, openssl server" \
1390 "$O_SRV" \
1391 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1392 0 \
1393 -C "adding FALLBACK_SCSV" \
1394 -C "is a fatal alert message (msg 86)"
1395
1396requires_openssl_with_fallback_scsv
1397run_test "Fallback SCSV: enabled, openssl server" \
1398 "$O_SRV" \
1399 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1400 1 \
1401 -c "adding FALLBACK_SCSV" \
1402 -c "is a fatal alert message (msg 86)"
1403
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001404requires_openssl_with_fallback_scsv
1405run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001406 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001407 "$O_CLI -tls1_1" \
1408 0 \
1409 -S "received FALLBACK_SCSV" \
1410 -S "inapropriate fallback"
1411
1412requires_openssl_with_fallback_scsv
1413run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001414 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001415 "$O_CLI -tls1_1 -fallback_scsv" \
1416 1 \
1417 -s "received FALLBACK_SCSV" \
1418 -s "inapropriate fallback"
1419
1420requires_openssl_with_fallback_scsv
1421run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001422 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001423 "$O_CLI -fallback_scsv" \
1424 0 \
1425 -s "received FALLBACK_SCSV" \
1426 -S "inapropriate fallback"
1427
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001428# Test sending and receiving empty application data records
1429
1430run_test "Encrypt then MAC: empty application data record" \
1431 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1432 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1433 0 \
1434 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1435 -s "dumping 'input payload after decrypt' (0 bytes)" \
1436 -c "0 bytes written in 1 fragments"
1437
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001438run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001439 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1440 "$P_CLI auth_mode=none etm=0 request_size=0" \
1441 0 \
1442 -s "dumping 'input payload after decrypt' (0 bytes)" \
1443 -c "0 bytes written in 1 fragments"
1444
1445run_test "Encrypt then MAC, DTLS: empty application data record" \
1446 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1447 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1448 0 \
1449 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1450 -s "dumping 'input payload after decrypt' (0 bytes)" \
1451 -c "0 bytes written in 1 fragments"
1452
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001453run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001454 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1455 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1456 0 \
1457 -s "dumping 'input payload after decrypt' (0 bytes)" \
1458 -c "0 bytes written in 1 fragments"
1459
Gilles Peskined50177f2017-05-16 17:53:03 +02001460## ClientHello generated with
1461## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1462## then manually twiddling the ciphersuite list.
1463## The ClientHello content is spelled out below as a hex string as
1464## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1465## The expected response is an inappropriate_fallback alert.
1466requires_openssl_with_fallback_scsv
1467run_test "Fallback SCSV: beginning of list" \
1468 "$P_SRV debug_level=2" \
1469 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1470 0 \
1471 -s "received FALLBACK_SCSV" \
1472 -s "inapropriate fallback"
1473
1474requires_openssl_with_fallback_scsv
1475run_test "Fallback SCSV: end of list" \
1476 "$P_SRV debug_level=2" \
1477 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1478 0 \
1479 -s "received FALLBACK_SCSV" \
1480 -s "inapropriate fallback"
1481
1482## Here the expected response is a valid ServerHello prefix, up to the random.
1483requires_openssl_with_fallback_scsv
1484run_test "Fallback SCSV: not in list" \
1485 "$P_SRV debug_level=2" \
1486 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1487 0 \
1488 -S "received FALLBACK_SCSV" \
1489 -S "inapropriate fallback"
1490
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001491# Tests for CBC 1/n-1 record splitting
1492
1493run_test "CBC Record splitting: TLS 1.2, no splitting" \
1494 "$P_SRV" \
1495 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1496 request_size=123 force_version=tls1_2" \
1497 0 \
1498 -s "Read from client: 123 bytes read" \
1499 -S "Read from client: 1 bytes read" \
1500 -S "122 bytes read"
1501
1502run_test "CBC Record splitting: TLS 1.1, no splitting" \
1503 "$P_SRV" \
1504 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1505 request_size=123 force_version=tls1_1" \
1506 0 \
1507 -s "Read from client: 123 bytes read" \
1508 -S "Read from client: 1 bytes read" \
1509 -S "122 bytes read"
1510
1511run_test "CBC Record splitting: TLS 1.0, splitting" \
1512 "$P_SRV" \
1513 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1514 request_size=123 force_version=tls1" \
1515 0 \
1516 -S "Read from client: 123 bytes read" \
1517 -s "Read from client: 1 bytes read" \
1518 -s "122 bytes read"
1519
Janos Follathe2681a42016-03-07 15:57:05 +00001520requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001521run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001522 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001523 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1524 request_size=123 force_version=ssl3" \
1525 0 \
1526 -S "Read from client: 123 bytes read" \
1527 -s "Read from client: 1 bytes read" \
1528 -s "122 bytes read"
1529
1530run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001531 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001532 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1533 request_size=123 force_version=tls1" \
1534 0 \
1535 -s "Read from client: 123 bytes read" \
1536 -S "Read from client: 1 bytes read" \
1537 -S "122 bytes read"
1538
1539run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1540 "$P_SRV" \
1541 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1542 request_size=123 force_version=tls1 recsplit=0" \
1543 0 \
1544 -s "Read from client: 123 bytes read" \
1545 -S "Read from client: 1 bytes read" \
1546 -S "122 bytes read"
1547
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001548run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1549 "$P_SRV nbio=2" \
1550 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1551 request_size=123 force_version=tls1" \
1552 0 \
1553 -S "Read from client: 123 bytes read" \
1554 -s "Read from client: 1 bytes read" \
1555 -s "122 bytes read"
1556
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001557# Tests for Session Tickets
1558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001559run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001560 "$P_SRV debug_level=3 tickets=1" \
1561 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001562 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001563 -c "client hello, adding session ticket extension" \
1564 -s "found session ticket extension" \
1565 -s "server hello, adding session ticket extension" \
1566 -c "found session_ticket extension" \
1567 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001568 -S "session successfully restored from cache" \
1569 -s "session successfully restored from ticket" \
1570 -s "a session has been resumed" \
1571 -c "a session has been resumed"
1572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001573run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001574 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1575 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001576 0 \
1577 -c "client hello, adding session ticket extension" \
1578 -s "found session ticket extension" \
1579 -s "server hello, adding session ticket extension" \
1580 -c "found session_ticket extension" \
1581 -c "parse new session ticket" \
1582 -S "session successfully restored from cache" \
1583 -s "session successfully restored from ticket" \
1584 -s "a session has been resumed" \
1585 -c "a session has been resumed"
1586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001587run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001588 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1589 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001590 0 \
1591 -c "client hello, adding session ticket extension" \
1592 -s "found session ticket extension" \
1593 -s "server hello, adding session ticket extension" \
1594 -c "found session_ticket extension" \
1595 -c "parse new session ticket" \
1596 -S "session successfully restored from cache" \
1597 -S "session successfully restored from ticket" \
1598 -S "a session has been resumed" \
1599 -C "a session has been resumed"
1600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001601run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001602 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001604 0 \
1605 -c "client hello, adding session ticket extension" \
1606 -c "found session_ticket extension" \
1607 -c "parse new session ticket" \
1608 -c "a session has been resumed"
1609
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001610run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001611 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001612 "( $O_CLI -sess_out $SESSION; \
1613 $O_CLI -sess_in $SESSION; \
1614 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001615 0 \
1616 -s "found session ticket extension" \
1617 -s "server hello, adding session ticket extension" \
1618 -S "session successfully restored from cache" \
1619 -s "session successfully restored from ticket" \
1620 -s "a session has been resumed"
1621
Hanno Becker1d739932018-08-21 13:55:22 +01001622# Tests for Session Tickets with DTLS
1623
1624run_test "Session resume using tickets, DTLS: basic" \
1625 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001626 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001627 0 \
1628 -c "client hello, adding session ticket extension" \
1629 -s "found session ticket extension" \
1630 -s "server hello, adding session ticket extension" \
1631 -c "found session_ticket extension" \
1632 -c "parse new session ticket" \
1633 -S "session successfully restored from cache" \
1634 -s "session successfully restored from ticket" \
1635 -s "a session has been resumed" \
1636 -c "a session has been resumed"
1637
1638run_test "Session resume using tickets, DTLS: cache disabled" \
1639 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001640 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001641 0 \
1642 -c "client hello, adding session ticket extension" \
1643 -s "found session ticket extension" \
1644 -s "server hello, adding session ticket extension" \
1645 -c "found session_ticket extension" \
1646 -c "parse new session ticket" \
1647 -S "session successfully restored from cache" \
1648 -s "session successfully restored from ticket" \
1649 -s "a session has been resumed" \
1650 -c "a session has been resumed"
1651
1652run_test "Session resume using tickets, DTLS: timeout" \
1653 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001654 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01001655 0 \
1656 -c "client hello, adding session ticket extension" \
1657 -s "found session ticket extension" \
1658 -s "server hello, adding session ticket extension" \
1659 -c "found session_ticket extension" \
1660 -c "parse new session ticket" \
1661 -S "session successfully restored from cache" \
1662 -S "session successfully restored from ticket" \
1663 -S "a session has been resumed" \
1664 -C "a session has been resumed"
1665
1666run_test "Session resume using tickets, DTLS: openssl server" \
1667 "$O_SRV -dtls1" \
1668 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1669 0 \
1670 -c "client hello, adding session ticket extension" \
1671 -c "found session_ticket extension" \
1672 -c "parse new session ticket" \
1673 -c "a session has been resumed"
1674
1675run_test "Session resume using tickets, DTLS: openssl client" \
1676 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1677 "( $O_CLI -dtls1 -sess_out $SESSION; \
1678 $O_CLI -dtls1 -sess_in $SESSION; \
1679 rm -f $SESSION )" \
1680 0 \
1681 -s "found session ticket extension" \
1682 -s "server hello, adding session ticket extension" \
1683 -S "session successfully restored from cache" \
1684 -s "session successfully restored from ticket" \
1685 -s "a session has been resumed"
1686
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001687# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001689run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001690 "$P_SRV debug_level=3 tickets=0" \
1691 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001692 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001693 -c "client hello, adding session ticket extension" \
1694 -s "found session ticket extension" \
1695 -S "server hello, adding session ticket extension" \
1696 -C "found session_ticket extension" \
1697 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001698 -s "session successfully restored from cache" \
1699 -S "session successfully restored from ticket" \
1700 -s "a session has been resumed" \
1701 -c "a session has been resumed"
1702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001703run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001704 "$P_SRV debug_level=3 tickets=1" \
1705 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001706 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001707 -C "client hello, adding session ticket extension" \
1708 -S "found session ticket extension" \
1709 -S "server hello, adding session ticket extension" \
1710 -C "found session_ticket extension" \
1711 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001712 -s "session successfully restored from cache" \
1713 -S "session successfully restored from ticket" \
1714 -s "a session has been resumed" \
1715 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001716
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001717run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1719 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001720 0 \
1721 -S "session successfully restored from cache" \
1722 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001723 -S "a session has been resumed" \
1724 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001726run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001727 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1728 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001729 0 \
1730 -s "session successfully restored from cache" \
1731 -S "session successfully restored from ticket" \
1732 -s "a session has been resumed" \
1733 -c "a session has been resumed"
1734
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001735run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001736 "$P_SRV debug_level=3 tickets=0" \
1737 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001738 0 \
1739 -s "session successfully restored from cache" \
1740 -S "session successfully restored from ticket" \
1741 -s "a session has been resumed" \
1742 -c "a session has been resumed"
1743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1746 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001747 0 \
1748 -S "session successfully restored from cache" \
1749 -S "session successfully restored from ticket" \
1750 -S "a session has been resumed" \
1751 -C "a session has been resumed"
1752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001753run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001754 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1755 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001756 0 \
1757 -s "session successfully restored from cache" \
1758 -S "session successfully restored from ticket" \
1759 -s "a session has been resumed" \
1760 -c "a session has been resumed"
1761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001762run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001763 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001764 "( $O_CLI -sess_out $SESSION; \
1765 $O_CLI -sess_in $SESSION; \
1766 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001767 0 \
1768 -s "found session ticket extension" \
1769 -S "server hello, adding session ticket extension" \
1770 -s "session successfully restored from cache" \
1771 -S "session successfully restored from ticket" \
1772 -s "a session has been resumed"
1773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001774run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001775 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001776 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001777 0 \
1778 -C "found session_ticket extension" \
1779 -C "parse new session ticket" \
1780 -c "a session has been resumed"
1781
Hanno Becker1d739932018-08-21 13:55:22 +01001782# Tests for Session Resume based on session-ID and cache, DTLS
1783
1784run_test "Session resume using cache, DTLS: tickets enabled on client" \
1785 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001786 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001787 0 \
1788 -c "client hello, adding session ticket extension" \
1789 -s "found session ticket extension" \
1790 -S "server hello, adding session ticket extension" \
1791 -C "found session_ticket extension" \
1792 -C "parse new session ticket" \
1793 -s "session successfully restored from cache" \
1794 -S "session successfully restored from ticket" \
1795 -s "a session has been resumed" \
1796 -c "a session has been resumed"
1797
1798run_test "Session resume using cache, DTLS: tickets enabled on server" \
1799 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001800 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001801 0 \
1802 -C "client hello, adding session ticket extension" \
1803 -S "found session ticket extension" \
1804 -S "server hello, adding session ticket extension" \
1805 -C "found session_ticket extension" \
1806 -C "parse new session ticket" \
1807 -s "session successfully restored from cache" \
1808 -S "session successfully restored from ticket" \
1809 -s "a session has been resumed" \
1810 -c "a session has been resumed"
1811
1812run_test "Session resume using cache, DTLS: cache_max=0" \
1813 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001814 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001815 0 \
1816 -S "session successfully restored from cache" \
1817 -S "session successfully restored from ticket" \
1818 -S "a session has been resumed" \
1819 -C "a session has been resumed"
1820
1821run_test "Session resume using cache, DTLS: cache_max=1" \
1822 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001823 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001824 0 \
1825 -s "session successfully restored from cache" \
1826 -S "session successfully restored from ticket" \
1827 -s "a session has been resumed" \
1828 -c "a session has been resumed"
1829
1830run_test "Session resume using cache, DTLS: timeout > delay" \
1831 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001832 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=0" \
Hanno Becker1d739932018-08-21 13:55:22 +01001833 0 \
1834 -s "session successfully restored from cache" \
1835 -S "session successfully restored from ticket" \
1836 -s "a session has been resumed" \
1837 -c "a session has been resumed"
1838
1839run_test "Session resume using cache, DTLS: timeout < delay" \
1840 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001841 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01001842 0 \
1843 -S "session successfully restored from cache" \
1844 -S "session successfully restored from ticket" \
1845 -S "a session has been resumed" \
1846 -C "a session has been resumed"
1847
1848run_test "Session resume using cache, DTLS: no timeout" \
1849 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001850 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_delay=2" \
Hanno Becker1d739932018-08-21 13:55:22 +01001851 0 \
1852 -s "session successfully restored from cache" \
1853 -S "session successfully restored from ticket" \
1854 -s "a session has been resumed" \
1855 -c "a session has been resumed"
1856
1857run_test "Session resume using cache, DTLS: openssl client" \
1858 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1859 "( $O_CLI -dtls1 -sess_out $SESSION; \
1860 $O_CLI -dtls1 -sess_in $SESSION; \
1861 rm -f $SESSION )" \
1862 0 \
1863 -s "found session ticket extension" \
1864 -S "server hello, adding session ticket extension" \
1865 -s "session successfully restored from cache" \
1866 -S "session successfully restored from ticket" \
1867 -s "a session has been resumed"
1868
1869run_test "Session resume using cache, DTLS: openssl server" \
1870 "$O_SRV -dtls1" \
1871 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1872 0 \
1873 -C "found session_ticket extension" \
1874 -C "parse new session ticket" \
1875 -c "a session has been resumed"
1876
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001877# Tests for Max Fragment Length extension
1878
Angus Grattonc4dd0732018-04-11 16:28:39 +10001879if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1880 printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01001881 exit 1
1882fi
1883
Angus Grattonc4dd0732018-04-11 16:28:39 +10001884if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1885 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1886fi
1887
Hanno Becker4aed27e2017-09-18 15:00:34 +01001888requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001889run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001890 "$P_SRV debug_level=3" \
1891 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001892 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001893 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1894 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001895 -C "client hello, adding max_fragment_length extension" \
1896 -S "found max fragment length extension" \
1897 -S "server hello, max_fragment_length extension" \
1898 -C "found max_fragment_length extension"
1899
Hanno Becker4aed27e2017-09-18 15:00:34 +01001900requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001901run_test "Max fragment length: enabled, default, larger message" \
1902 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001903 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001904 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001905 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1906 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001907 -C "client hello, adding max_fragment_length extension" \
1908 -S "found max fragment length extension" \
1909 -S "server hello, max_fragment_length extension" \
1910 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001911 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1912 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001913 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001914
1915requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1916run_test "Max fragment length, DTLS: enabled, default, larger message" \
1917 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001918 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001919 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001920 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1921 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001922 -C "client hello, adding max_fragment_length extension" \
1923 -S "found max fragment length extension" \
1924 -S "server hello, max_fragment_length extension" \
1925 -C "found max_fragment_length extension" \
1926 -c "fragment larger than.*maximum "
1927
Angus Grattonc4dd0732018-04-11 16:28:39 +10001928# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1929# (session fragment length will be 16384 regardless of mbedtls
1930# content length configuration.)
1931
Hanno Beckerc5266962017-09-18 15:01:50 +01001932requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1933run_test "Max fragment length: disabled, larger message" \
1934 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001935 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001936 0 \
1937 -C "Maximum fragment length is 16384" \
1938 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001939 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1940 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001941 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001942
1943requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1944run_test "Max fragment length DTLS: disabled, larger message" \
1945 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001946 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001947 1 \
1948 -C "Maximum fragment length is 16384" \
1949 -S "Maximum fragment length is 16384" \
1950 -c "fragment larger than.*maximum "
1951
1952requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001953run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001954 "$P_SRV debug_level=3" \
1955 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001956 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001957 -c "Maximum fragment length is 4096" \
1958 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001959 -c "client hello, adding max_fragment_length extension" \
1960 -s "found max fragment length extension" \
1961 -s "server hello, max_fragment_length extension" \
1962 -c "found max_fragment_length extension"
1963
Hanno Becker4aed27e2017-09-18 15:00:34 +01001964requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001965run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001966 "$P_SRV debug_level=3 max_frag_len=4096" \
1967 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001968 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001969 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001970 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001971 -C "client hello, adding max_fragment_length extension" \
1972 -S "found max fragment length extension" \
1973 -S "server hello, max_fragment_length extension" \
1974 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001975
Hanno Becker4aed27e2017-09-18 15:00:34 +01001976requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001977requires_gnutls
1978run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001979 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001980 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001981 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001982 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001983 -c "client hello, adding max_fragment_length extension" \
1984 -c "found max_fragment_length extension"
1985
Hanno Becker4aed27e2017-09-18 15:00:34 +01001986requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001987run_test "Max fragment length: client, message just fits" \
1988 "$P_SRV debug_level=3" \
1989 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1990 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001991 -c "Maximum fragment length is 2048" \
1992 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001993 -c "client hello, adding max_fragment_length extension" \
1994 -s "found max fragment length extension" \
1995 -s "server hello, max_fragment_length extension" \
1996 -c "found max_fragment_length extension" \
1997 -c "2048 bytes written in 1 fragments" \
1998 -s "2048 bytes read"
1999
Hanno Becker4aed27e2017-09-18 15:00:34 +01002000requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002001run_test "Max fragment length: client, larger message" \
2002 "$P_SRV debug_level=3" \
2003 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2004 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002005 -c "Maximum fragment length is 2048" \
2006 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002007 -c "client hello, adding max_fragment_length extension" \
2008 -s "found max fragment length extension" \
2009 -s "server hello, max_fragment_length extension" \
2010 -c "found max_fragment_length extension" \
2011 -c "2345 bytes written in 2 fragments" \
2012 -s "2048 bytes read" \
2013 -s "297 bytes read"
2014
Hanno Becker4aed27e2017-09-18 15:00:34 +01002015requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002016run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002017 "$P_SRV debug_level=3 dtls=1" \
2018 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2019 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002020 -c "Maximum fragment length is 2048" \
2021 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002022 -c "client hello, adding max_fragment_length extension" \
2023 -s "found max fragment length extension" \
2024 -s "server hello, max_fragment_length extension" \
2025 -c "found max_fragment_length extension" \
2026 -c "fragment larger than.*maximum"
2027
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002028# Tests for renegotiation
2029
Hanno Becker6a243642017-10-12 15:18:45 +01002030# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002032 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002033 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002034 0 \
2035 -C "client hello, adding renegotiation extension" \
2036 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2037 -S "found renegotiation extension" \
2038 -s "server hello, secure renegotiation extension" \
2039 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002040 -C "=> renegotiate" \
2041 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002042 -S "write hello request"
2043
Hanno Becker6a243642017-10-12 15:18:45 +01002044requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002045run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002046 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002047 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002048 0 \
2049 -c "client hello, adding renegotiation extension" \
2050 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2051 -s "found renegotiation extension" \
2052 -s "server hello, secure renegotiation extension" \
2053 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002054 -c "=> renegotiate" \
2055 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002056 -S "write hello request"
2057
Hanno Becker6a243642017-10-12 15:18:45 +01002058requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002059run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002060 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002061 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002062 0 \
2063 -c "client hello, adding renegotiation extension" \
2064 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2065 -s "found renegotiation extension" \
2066 -s "server hello, secure renegotiation extension" \
2067 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002068 -c "=> renegotiate" \
2069 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002070 -s "write hello request"
2071
Janos Follathb0f148c2017-10-05 12:29:42 +01002072# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2073# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2074# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002075requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002076run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2077 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2078 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2079 0 \
2080 -c "client hello, adding renegotiation extension" \
2081 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2082 -s "found renegotiation extension" \
2083 -s "server hello, secure renegotiation extension" \
2084 -c "found renegotiation extension" \
2085 -c "=> renegotiate" \
2086 -s "=> renegotiate" \
2087 -S "write hello request" \
2088 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2089
2090# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2091# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2092# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002093requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002094run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2095 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2096 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2097 0 \
2098 -c "client hello, adding renegotiation extension" \
2099 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2100 -s "found renegotiation extension" \
2101 -s "server hello, secure renegotiation extension" \
2102 -c "found renegotiation extension" \
2103 -c "=> renegotiate" \
2104 -s "=> renegotiate" \
2105 -s "write hello request" \
2106 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2107
Hanno Becker6a243642017-10-12 15:18:45 +01002108requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002109run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002110 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002111 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002112 0 \
2113 -c "client hello, adding renegotiation extension" \
2114 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2115 -s "found renegotiation extension" \
2116 -s "server hello, secure renegotiation extension" \
2117 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002118 -c "=> renegotiate" \
2119 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002120 -s "write hello request"
2121
Hanno Becker6a243642017-10-12 15:18:45 +01002122requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002123run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002124 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002125 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002126 1 \
2127 -c "client hello, adding renegotiation extension" \
2128 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2129 -S "found renegotiation extension" \
2130 -s "server hello, secure renegotiation extension" \
2131 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002132 -c "=> renegotiate" \
2133 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002134 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002135 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002136 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002137
Hanno Becker6a243642017-10-12 15:18:45 +01002138requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002139run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002140 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002141 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002142 0 \
2143 -C "client hello, adding renegotiation extension" \
2144 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2145 -S "found renegotiation extension" \
2146 -s "server hello, secure renegotiation extension" \
2147 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002148 -C "=> renegotiate" \
2149 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002150 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002151 -S "SSL - An unexpected message was received from our peer" \
2152 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002153
Hanno Becker6a243642017-10-12 15:18:45 +01002154requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002155run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002156 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002157 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002159 0 \
2160 -C "client hello, adding renegotiation extension" \
2161 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2162 -S "found renegotiation extension" \
2163 -s "server hello, secure renegotiation extension" \
2164 -c "found renegotiation extension" \
2165 -C "=> renegotiate" \
2166 -S "=> renegotiate" \
2167 -s "write hello request" \
2168 -S "SSL - An unexpected message was received from our peer" \
2169 -S "failed"
2170
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002171# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002172requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002173run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002174 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002175 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002176 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002177 0 \
2178 -C "client hello, adding renegotiation extension" \
2179 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2180 -S "found renegotiation extension" \
2181 -s "server hello, secure renegotiation extension" \
2182 -c "found renegotiation extension" \
2183 -C "=> renegotiate" \
2184 -S "=> renegotiate" \
2185 -s "write hello request" \
2186 -S "SSL - An unexpected message was received from our peer" \
2187 -S "failed"
2188
Hanno Becker6a243642017-10-12 15:18:45 +01002189requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002190run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002191 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002192 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002194 0 \
2195 -C "client hello, adding renegotiation extension" \
2196 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2197 -S "found renegotiation extension" \
2198 -s "server hello, secure renegotiation extension" \
2199 -c "found renegotiation extension" \
2200 -C "=> renegotiate" \
2201 -S "=> renegotiate" \
2202 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002203 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002204
Hanno Becker6a243642017-10-12 15:18:45 +01002205requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002206run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002207 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002208 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002209 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002210 0 \
2211 -c "client hello, adding renegotiation extension" \
2212 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2213 -s "found renegotiation extension" \
2214 -s "server hello, secure renegotiation extension" \
2215 -c "found renegotiation extension" \
2216 -c "=> renegotiate" \
2217 -s "=> renegotiate" \
2218 -s "write hello request" \
2219 -S "SSL - An unexpected message was received from our peer" \
2220 -S "failed"
2221
Hanno Becker6a243642017-10-12 15:18:45 +01002222requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002223run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002224 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002225 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2226 0 \
2227 -C "client hello, adding renegotiation extension" \
2228 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2229 -S "found renegotiation extension" \
2230 -s "server hello, secure renegotiation extension" \
2231 -c "found renegotiation extension" \
2232 -S "record counter limit reached: renegotiate" \
2233 -C "=> renegotiate" \
2234 -S "=> renegotiate" \
2235 -S "write hello request" \
2236 -S "SSL - An unexpected message was received from our peer" \
2237 -S "failed"
2238
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002239# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002240requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002241run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002242 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002243 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002244 0 \
2245 -c "client hello, adding renegotiation extension" \
2246 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2247 -s "found renegotiation extension" \
2248 -s "server hello, secure renegotiation extension" \
2249 -c "found renegotiation extension" \
2250 -s "record counter limit reached: renegotiate" \
2251 -c "=> renegotiate" \
2252 -s "=> renegotiate" \
2253 -s "write hello request" \
2254 -S "SSL - An unexpected message was received from our peer" \
2255 -S "failed"
2256
Hanno Becker6a243642017-10-12 15:18:45 +01002257requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002258run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002259 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002260 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002261 0 \
2262 -c "client hello, adding renegotiation extension" \
2263 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2264 -s "found renegotiation extension" \
2265 -s "server hello, secure renegotiation extension" \
2266 -c "found renegotiation extension" \
2267 -s "record counter limit reached: renegotiate" \
2268 -c "=> renegotiate" \
2269 -s "=> renegotiate" \
2270 -s "write hello request" \
2271 -S "SSL - An unexpected message was received from our peer" \
2272 -S "failed"
2273
Hanno Becker6a243642017-10-12 15:18:45 +01002274requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002275run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002276 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002277 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2278 0 \
2279 -C "client hello, adding renegotiation extension" \
2280 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2281 -S "found renegotiation extension" \
2282 -s "server hello, secure renegotiation extension" \
2283 -c "found renegotiation extension" \
2284 -S "record counter limit reached: renegotiate" \
2285 -C "=> renegotiate" \
2286 -S "=> renegotiate" \
2287 -S "write hello request" \
2288 -S "SSL - An unexpected message was received from our peer" \
2289 -S "failed"
2290
Hanno Becker6a243642017-10-12 15:18:45 +01002291requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002292run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002293 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002294 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002295 0 \
2296 -c "client hello, adding renegotiation extension" \
2297 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2298 -s "found renegotiation extension" \
2299 -s "server hello, secure renegotiation extension" \
2300 -c "found renegotiation extension" \
2301 -c "=> renegotiate" \
2302 -s "=> renegotiate" \
2303 -S "write hello request"
2304
Hanno Becker6a243642017-10-12 15:18:45 +01002305requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002306run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002307 "$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 +02002308 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002309 0 \
2310 -c "client hello, adding renegotiation extension" \
2311 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2312 -s "found renegotiation extension" \
2313 -s "server hello, secure renegotiation extension" \
2314 -c "found renegotiation extension" \
2315 -c "=> renegotiate" \
2316 -s "=> renegotiate" \
2317 -s "write hello request"
2318
Hanno Becker6a243642017-10-12 15:18:45 +01002319requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002320run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002321 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002322 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002323 0 \
2324 -c "client hello, adding renegotiation extension" \
2325 -c "found renegotiation extension" \
2326 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002327 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002328 -C "error" \
2329 -c "HTTP/1.0 200 [Oo][Kk]"
2330
Paul Bakker539d9722015-02-08 16:18:35 +01002331requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002332requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002333run_test "Renegotiation: gnutls server strict, client-initiated" \
2334 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002335 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002336 0 \
2337 -c "client hello, adding renegotiation extension" \
2338 -c "found renegotiation extension" \
2339 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002340 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002341 -C "error" \
2342 -c "HTTP/1.0 200 [Oo][Kk]"
2343
Paul Bakker539d9722015-02-08 16:18:35 +01002344requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002345requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002346run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2347 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2348 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2349 1 \
2350 -c "client hello, adding renegotiation extension" \
2351 -C "found renegotiation extension" \
2352 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002353 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002354 -c "error" \
2355 -C "HTTP/1.0 200 [Oo][Kk]"
2356
Paul Bakker539d9722015-02-08 16:18:35 +01002357requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002358requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002359run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2360 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2361 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2362 allow_legacy=0" \
2363 1 \
2364 -c "client hello, adding renegotiation extension" \
2365 -C "found renegotiation extension" \
2366 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002367 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002368 -c "error" \
2369 -C "HTTP/1.0 200 [Oo][Kk]"
2370
Paul Bakker539d9722015-02-08 16:18:35 +01002371requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002372requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002373run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2374 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2375 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2376 allow_legacy=1" \
2377 0 \
2378 -c "client hello, adding renegotiation extension" \
2379 -C "found renegotiation extension" \
2380 -c "=> renegotiate" \
2381 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002382 -C "error" \
2383 -c "HTTP/1.0 200 [Oo][Kk]"
2384
Hanno Becker6a243642017-10-12 15:18:45 +01002385requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002386run_test "Renegotiation: DTLS, client-initiated" \
2387 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2388 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2389 0 \
2390 -c "client hello, adding renegotiation extension" \
2391 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2392 -s "found renegotiation extension" \
2393 -s "server hello, secure renegotiation extension" \
2394 -c "found renegotiation extension" \
2395 -c "=> renegotiate" \
2396 -s "=> renegotiate" \
2397 -S "write hello request"
2398
Hanno Becker6a243642017-10-12 15:18:45 +01002399requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002400run_test "Renegotiation: DTLS, server-initiated" \
2401 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002402 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2403 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002404 0 \
2405 -c "client hello, adding renegotiation extension" \
2406 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2407 -s "found renegotiation extension" \
2408 -s "server hello, secure renegotiation extension" \
2409 -c "found renegotiation extension" \
2410 -c "=> renegotiate" \
2411 -s "=> renegotiate" \
2412 -s "write hello request"
2413
Hanno Becker6a243642017-10-12 15:18:45 +01002414requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002415run_test "Renegotiation: DTLS, renego_period overflow" \
2416 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2417 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2418 0 \
2419 -c "client hello, adding renegotiation extension" \
2420 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2421 -s "found renegotiation extension" \
2422 -s "server hello, secure renegotiation extension" \
2423 -s "record counter limit reached: renegotiate" \
2424 -c "=> renegotiate" \
2425 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002426 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002427
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002428requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002429requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002430run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2431 "$G_SRV -u --mtu 4096" \
2432 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2433 0 \
2434 -c "client hello, adding renegotiation extension" \
2435 -c "found renegotiation extension" \
2436 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002437 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002438 -C "error" \
2439 -s "Extra-header:"
2440
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002441# Test for the "secure renegotation" extension only (no actual renegotiation)
2442
Paul Bakker539d9722015-02-08 16:18:35 +01002443requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002444run_test "Renego ext: gnutls server strict, client default" \
2445 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2446 "$P_CLI debug_level=3" \
2447 0 \
2448 -c "found renegotiation extension" \
2449 -C "error" \
2450 -c "HTTP/1.0 200 [Oo][Kk]"
2451
Paul Bakker539d9722015-02-08 16:18:35 +01002452requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002453run_test "Renego ext: gnutls server unsafe, client default" \
2454 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2455 "$P_CLI debug_level=3" \
2456 0 \
2457 -C "found renegotiation extension" \
2458 -C "error" \
2459 -c "HTTP/1.0 200 [Oo][Kk]"
2460
Paul Bakker539d9722015-02-08 16:18:35 +01002461requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002462run_test "Renego ext: gnutls server unsafe, client break legacy" \
2463 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2464 "$P_CLI debug_level=3 allow_legacy=-1" \
2465 1 \
2466 -C "found renegotiation extension" \
2467 -c "error" \
2468 -C "HTTP/1.0 200 [Oo][Kk]"
2469
Paul Bakker539d9722015-02-08 16:18:35 +01002470requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002471run_test "Renego ext: gnutls client strict, server default" \
2472 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002473 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002474 0 \
2475 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2476 -s "server hello, secure renegotiation extension"
2477
Paul Bakker539d9722015-02-08 16:18:35 +01002478requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002479run_test "Renego ext: gnutls client unsafe, server default" \
2480 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002481 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002482 0 \
2483 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2484 -S "server hello, secure renegotiation extension"
2485
Paul Bakker539d9722015-02-08 16:18:35 +01002486requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002487run_test "Renego ext: gnutls client unsafe, server break legacy" \
2488 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002489 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002490 1 \
2491 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2492 -S "server hello, secure renegotiation extension"
2493
Janos Follath0b242342016-02-17 10:11:21 +00002494# Tests for silently dropping trailing extra bytes in .der certificates
2495
2496requires_gnutls
2497run_test "DER format: no trailing bytes" \
2498 "$P_SRV crt_file=data_files/server5-der0.crt \
2499 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002500 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002501 0 \
2502 -c "Handshake was completed" \
2503
2504requires_gnutls
2505run_test "DER format: with a trailing zero byte" \
2506 "$P_SRV crt_file=data_files/server5-der1a.crt \
2507 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002508 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002509 0 \
2510 -c "Handshake was completed" \
2511
2512requires_gnutls
2513run_test "DER format: with a trailing random byte" \
2514 "$P_SRV crt_file=data_files/server5-der1b.crt \
2515 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002516 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002517 0 \
2518 -c "Handshake was completed" \
2519
2520requires_gnutls
2521run_test "DER format: with 2 trailing random bytes" \
2522 "$P_SRV crt_file=data_files/server5-der2.crt \
2523 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002524 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002525 0 \
2526 -c "Handshake was completed" \
2527
2528requires_gnutls
2529run_test "DER format: with 4 trailing random bytes" \
2530 "$P_SRV crt_file=data_files/server5-der4.crt \
2531 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002532 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002533 0 \
2534 -c "Handshake was completed" \
2535
2536requires_gnutls
2537run_test "DER format: with 8 trailing random bytes" \
2538 "$P_SRV crt_file=data_files/server5-der8.crt \
2539 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002540 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002541 0 \
2542 -c "Handshake was completed" \
2543
2544requires_gnutls
2545run_test "DER format: with 9 trailing random bytes" \
2546 "$P_SRV crt_file=data_files/server5-der9.crt \
2547 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002548 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002549 0 \
2550 -c "Handshake was completed" \
2551
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002552# Tests for auth_mode
2553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002554run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002555 "$P_SRV crt_file=data_files/server5-badsign.crt \
2556 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002557 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002558 1 \
2559 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002560 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002561 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002562 -c "X509 - Certificate verification failed"
2563
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002564run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002565 "$P_SRV crt_file=data_files/server5-badsign.crt \
2566 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002567 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002568 0 \
2569 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002570 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002571 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002572 -C "X509 - Certificate verification failed"
2573
Hanno Beckere6706e62017-05-15 16:05:15 +01002574run_test "Authentication: server goodcert, client optional, no trusted CA" \
2575 "$P_SRV" \
2576 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2577 0 \
2578 -c "x509_verify_cert() returned" \
2579 -c "! The certificate is not correctly signed by the trusted CA" \
2580 -c "! Certificate verification flags"\
2581 -C "! mbedtls_ssl_handshake returned" \
2582 -C "X509 - Certificate verification failed" \
2583 -C "SSL - No CA Chain is set, but required to operate"
2584
2585run_test "Authentication: server goodcert, client required, no trusted CA" \
2586 "$P_SRV" \
2587 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2588 1 \
2589 -c "x509_verify_cert() returned" \
2590 -c "! The certificate is not correctly signed by the trusted CA" \
2591 -c "! Certificate verification flags"\
2592 -c "! mbedtls_ssl_handshake returned" \
2593 -c "SSL - No CA Chain is set, but required to operate"
2594
2595# The purpose of the next two tests is to test the client's behaviour when receiving a server
2596# certificate with an unsupported elliptic curve. This should usually not happen because
2597# the client informs the server about the supported curves - it does, though, in the
2598# corner case of a static ECDH suite, because the server doesn't check the curve on that
2599# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2600# different means to have the server ignoring the client's supported curve list.
2601
2602requires_config_enabled MBEDTLS_ECP_C
2603run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2604 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2605 crt_file=data_files/server5.ku-ka.crt" \
2606 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2607 1 \
2608 -c "bad certificate (EC key curve)"\
2609 -c "! Certificate verification flags"\
2610 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2611
2612requires_config_enabled MBEDTLS_ECP_C
2613run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2614 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2615 crt_file=data_files/server5.ku-ka.crt" \
2616 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2617 1 \
2618 -c "bad certificate (EC key curve)"\
2619 -c "! Certificate verification flags"\
2620 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2621
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002622run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002623 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002624 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002625 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002626 0 \
2627 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002628 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002629 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002630 -C "X509 - Certificate verification failed"
2631
Simon Butcher99000142016-10-13 17:21:01 +01002632run_test "Authentication: client SHA256, server required" \
2633 "$P_SRV auth_mode=required" \
2634 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2635 key_file=data_files/server6.key \
2636 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2637 0 \
2638 -c "Supported Signature Algorithm found: 4," \
2639 -c "Supported Signature Algorithm found: 5,"
2640
2641run_test "Authentication: client SHA384, server required" \
2642 "$P_SRV auth_mode=required" \
2643 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2644 key_file=data_files/server6.key \
2645 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2646 0 \
2647 -c "Supported Signature Algorithm found: 4," \
2648 -c "Supported Signature Algorithm found: 5,"
2649
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002650requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2651run_test "Authentication: client has no cert, server required (SSLv3)" \
2652 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2653 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2654 key_file=data_files/server5.key" \
2655 1 \
2656 -S "skip write certificate request" \
2657 -C "skip parse certificate request" \
2658 -c "got a certificate request" \
2659 -c "got no certificate to send" \
2660 -S "x509_verify_cert() returned" \
2661 -s "client has no certificate" \
2662 -s "! mbedtls_ssl_handshake returned" \
2663 -c "! mbedtls_ssl_handshake returned" \
2664 -s "No client certification received from the client, but required by the authentication mode"
2665
2666run_test "Authentication: client has no cert, server required (TLS)" \
2667 "$P_SRV debug_level=3 auth_mode=required" \
2668 "$P_CLI debug_level=3 crt_file=none \
2669 key_file=data_files/server5.key" \
2670 1 \
2671 -S "skip write certificate request" \
2672 -C "skip parse certificate request" \
2673 -c "got a certificate request" \
2674 -c "= write certificate$" \
2675 -C "skip write certificate$" \
2676 -S "x509_verify_cert() returned" \
2677 -s "client has no certificate" \
2678 -s "! mbedtls_ssl_handshake returned" \
2679 -c "! mbedtls_ssl_handshake returned" \
2680 -s "No client certification received from the client, but required by the authentication mode"
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002683 "$P_SRV debug_level=3 auth_mode=required" \
2684 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002685 key_file=data_files/server5.key" \
2686 1 \
2687 -S "skip write certificate request" \
2688 -C "skip parse certificate request" \
2689 -c "got a certificate request" \
2690 -C "skip write certificate" \
2691 -C "skip write certificate verify" \
2692 -S "skip parse certificate verify" \
2693 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002694 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002695 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002696 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002697 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002698 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002699# We don't check that the client receives the alert because it might
2700# detect that its write end of the connection is closed and abort
2701# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002702
Janos Follath89baba22017-04-10 14:34:35 +01002703run_test "Authentication: client cert not trusted, server required" \
2704 "$P_SRV debug_level=3 auth_mode=required" \
2705 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2706 key_file=data_files/server5.key" \
2707 1 \
2708 -S "skip write certificate request" \
2709 -C "skip parse certificate request" \
2710 -c "got a certificate request" \
2711 -C "skip write certificate" \
2712 -C "skip write certificate verify" \
2713 -S "skip parse certificate verify" \
2714 -s "x509_verify_cert() returned" \
2715 -s "! The certificate is not correctly signed by the trusted CA" \
2716 -s "! mbedtls_ssl_handshake returned" \
2717 -c "! mbedtls_ssl_handshake returned" \
2718 -s "X509 - Certificate verification failed"
2719
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002720run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002721 "$P_SRV debug_level=3 auth_mode=optional" \
2722 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002723 key_file=data_files/server5.key" \
2724 0 \
2725 -S "skip write certificate request" \
2726 -C "skip parse certificate request" \
2727 -c "got a certificate request" \
2728 -C "skip write certificate" \
2729 -C "skip write certificate verify" \
2730 -S "skip parse certificate verify" \
2731 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002732 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002733 -S "! mbedtls_ssl_handshake returned" \
2734 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002735 -S "X509 - Certificate verification failed"
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002738 "$P_SRV debug_level=3 auth_mode=none" \
2739 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002740 key_file=data_files/server5.key" \
2741 0 \
2742 -s "skip write certificate request" \
2743 -C "skip parse certificate request" \
2744 -c "got no certificate request" \
2745 -c "skip write certificate" \
2746 -c "skip write certificate verify" \
2747 -s "skip parse certificate verify" \
2748 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002749 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002750 -S "! mbedtls_ssl_handshake returned" \
2751 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002752 -S "X509 - Certificate verification failed"
2753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002754run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002755 "$P_SRV debug_level=3 auth_mode=optional" \
2756 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002757 0 \
2758 -S "skip write certificate request" \
2759 -C "skip parse certificate request" \
2760 -c "got a certificate request" \
2761 -C "skip write certificate$" \
2762 -C "got no certificate to send" \
2763 -S "SSLv3 client has no certificate" \
2764 -c "skip write certificate verify" \
2765 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002766 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002767 -S "! mbedtls_ssl_handshake returned" \
2768 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002769 -S "X509 - Certificate verification failed"
2770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002771run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002772 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002773 "$O_CLI" \
2774 0 \
2775 -S "skip write certificate request" \
2776 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002777 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002778 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002779 -S "X509 - Certificate verification failed"
2780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002781run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002782 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002783 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002784 0 \
2785 -C "skip parse certificate request" \
2786 -c "got a certificate request" \
2787 -C "skip write certificate$" \
2788 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002789 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002790
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002791run_test "Authentication: client no cert, openssl server required" \
2792 "$O_SRV -Verify 10" \
2793 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2794 1 \
2795 -C "skip parse certificate request" \
2796 -c "got a certificate request" \
2797 -C "skip write certificate$" \
2798 -c "skip write certificate verify" \
2799 -c "! mbedtls_ssl_handshake returned"
2800
Janos Follathe2681a42016-03-07 15:57:05 +00002801requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002802run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002803 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002804 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002805 0 \
2806 -S "skip write certificate request" \
2807 -C "skip parse certificate request" \
2808 -c "got a certificate request" \
2809 -C "skip write certificate$" \
2810 -c "skip write certificate verify" \
2811 -c "got no certificate to send" \
2812 -s "SSLv3 client has no certificate" \
2813 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002814 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002815 -S "! mbedtls_ssl_handshake returned" \
2816 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002817 -S "X509 - Certificate verification failed"
2818
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002819# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2820# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002821
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002822MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002823MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002824
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002825if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002826 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002827 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002828 printf "test value of ${MAX_IM_CA}. \n"
2829 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002830 printf "The tests assume this value and if it changes, the tests in this\n"
2831 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002832 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002833
2834 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002835fi
2836
Angus Grattonc4dd0732018-04-11 16:28:39 +10002837requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002838run_test "Authentication: server max_int chain, client default" \
2839 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2840 key_file=data_files/dir-maxpath/09.key" \
2841 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2842 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002843 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002844
Angus Grattonc4dd0732018-04-11 16:28:39 +10002845requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002846run_test "Authentication: server max_int+1 chain, client default" \
2847 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2848 key_file=data_files/dir-maxpath/10.key" \
2849 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2850 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002851 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002852
Angus Grattonc4dd0732018-04-11 16:28:39 +10002853requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002854run_test "Authentication: server max_int+1 chain, client optional" \
2855 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2856 key_file=data_files/dir-maxpath/10.key" \
2857 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2858 auth_mode=optional" \
2859 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002860 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002861
Angus Grattonc4dd0732018-04-11 16:28:39 +10002862requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002863run_test "Authentication: server max_int+1 chain, client none" \
2864 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2865 key_file=data_files/dir-maxpath/10.key" \
2866 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2867 auth_mode=none" \
2868 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002869 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002870
Angus Grattonc4dd0732018-04-11 16:28:39 +10002871requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002872run_test "Authentication: client max_int+1 chain, server default" \
2873 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2874 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2875 key_file=data_files/dir-maxpath/10.key" \
2876 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002877 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002878
Angus Grattonc4dd0732018-04-11 16:28:39 +10002879requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002880run_test "Authentication: client max_int+1 chain, server optional" \
2881 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2882 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2883 key_file=data_files/dir-maxpath/10.key" \
2884 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002885 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002886
Angus Grattonc4dd0732018-04-11 16:28:39 +10002887requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002888run_test "Authentication: client max_int+1 chain, server required" \
2889 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2890 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2891 key_file=data_files/dir-maxpath/10.key" \
2892 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002893 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002894
Angus Grattonc4dd0732018-04-11 16:28:39 +10002895requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002896run_test "Authentication: client max_int chain, server required" \
2897 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2898 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2899 key_file=data_files/dir-maxpath/09.key" \
2900 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002901 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002902
Janos Follath89baba22017-04-10 14:34:35 +01002903# Tests for CA list in CertificateRequest messages
2904
2905run_test "Authentication: send CA list in CertificateRequest (default)" \
2906 "$P_SRV debug_level=3 auth_mode=required" \
2907 "$P_CLI crt_file=data_files/server6.crt \
2908 key_file=data_files/server6.key" \
2909 0 \
2910 -s "requested DN"
2911
2912run_test "Authentication: do not send CA list in CertificateRequest" \
2913 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2914 "$P_CLI crt_file=data_files/server6.crt \
2915 key_file=data_files/server6.key" \
2916 0 \
2917 -S "requested DN"
2918
2919run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2920 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2921 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2922 key_file=data_files/server5.key" \
2923 1 \
2924 -S "requested DN" \
2925 -s "x509_verify_cert() returned" \
2926 -s "! The certificate is not correctly signed by the trusted CA" \
2927 -s "! mbedtls_ssl_handshake returned" \
2928 -c "! mbedtls_ssl_handshake returned" \
2929 -s "X509 - Certificate verification failed"
2930
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002931# Tests for certificate selection based on SHA verson
2932
2933run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2934 "$P_SRV crt_file=data_files/server5.crt \
2935 key_file=data_files/server5.key \
2936 crt_file2=data_files/server5-sha1.crt \
2937 key_file2=data_files/server5.key" \
2938 "$P_CLI force_version=tls1_2" \
2939 0 \
2940 -c "signed using.*ECDSA with SHA256" \
2941 -C "signed using.*ECDSA with SHA1"
2942
2943run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2944 "$P_SRV crt_file=data_files/server5.crt \
2945 key_file=data_files/server5.key \
2946 crt_file2=data_files/server5-sha1.crt \
2947 key_file2=data_files/server5.key" \
2948 "$P_CLI force_version=tls1_1" \
2949 0 \
2950 -C "signed using.*ECDSA with SHA256" \
2951 -c "signed using.*ECDSA with SHA1"
2952
2953run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2954 "$P_SRV crt_file=data_files/server5.crt \
2955 key_file=data_files/server5.key \
2956 crt_file2=data_files/server5-sha1.crt \
2957 key_file2=data_files/server5.key" \
2958 "$P_CLI force_version=tls1" \
2959 0 \
2960 -C "signed using.*ECDSA with SHA256" \
2961 -c "signed using.*ECDSA with SHA1"
2962
2963run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2964 "$P_SRV crt_file=data_files/server5.crt \
2965 key_file=data_files/server5.key \
2966 crt_file2=data_files/server6.crt \
2967 key_file2=data_files/server6.key" \
2968 "$P_CLI force_version=tls1_1" \
2969 0 \
2970 -c "serial number.*09" \
2971 -c "signed using.*ECDSA with SHA256" \
2972 -C "signed using.*ECDSA with SHA1"
2973
2974run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2975 "$P_SRV crt_file=data_files/server6.crt \
2976 key_file=data_files/server6.key \
2977 crt_file2=data_files/server5.crt \
2978 key_file2=data_files/server5.key" \
2979 "$P_CLI force_version=tls1_1" \
2980 0 \
2981 -c "serial number.*0A" \
2982 -c "signed using.*ECDSA with SHA256" \
2983 -C "signed using.*ECDSA with SHA1"
2984
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002985# tests for SNI
2986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002987run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002988 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002989 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002990 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002991 0 \
2992 -S "parse ServerName extension" \
2993 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2994 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002996run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002997 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002998 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002999 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 +02003000 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003001 0 \
3002 -s "parse ServerName extension" \
3003 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3004 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003005
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003006run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003007 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003008 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003009 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 +02003010 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003011 0 \
3012 -s "parse ServerName extension" \
3013 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3014 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003015
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003016run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003017 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003018 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003019 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 +02003020 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003021 1 \
3022 -s "parse ServerName extension" \
3023 -s "ssl_sni_wrapper() returned" \
3024 -s "mbedtls_ssl_handshake returned" \
3025 -c "mbedtls_ssl_handshake returned" \
3026 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003027
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003028run_test "SNI: client auth no override: optional" \
3029 "$P_SRV debug_level=3 auth_mode=optional \
3030 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3031 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3032 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003033 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003034 -S "skip write certificate request" \
3035 -C "skip parse certificate request" \
3036 -c "got a certificate request" \
3037 -C "skip write certificate" \
3038 -C "skip write certificate verify" \
3039 -S "skip parse certificate verify"
3040
3041run_test "SNI: client auth override: none -> optional" \
3042 "$P_SRV debug_level=3 auth_mode=none \
3043 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3044 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3045 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003046 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003047 -S "skip write certificate request" \
3048 -C "skip parse certificate request" \
3049 -c "got a certificate request" \
3050 -C "skip write certificate" \
3051 -C "skip write certificate verify" \
3052 -S "skip parse certificate verify"
3053
3054run_test "SNI: client auth override: optional -> none" \
3055 "$P_SRV debug_level=3 auth_mode=optional \
3056 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3057 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3058 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003059 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003060 -s "skip write certificate request" \
3061 -C "skip parse certificate request" \
3062 -c "got no certificate request" \
3063 -c "skip write certificate" \
3064 -c "skip write certificate verify" \
3065 -s "skip parse certificate verify"
3066
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003067run_test "SNI: CA no override" \
3068 "$P_SRV debug_level=3 auth_mode=optional \
3069 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3070 ca_file=data_files/test-ca.crt \
3071 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3072 "$P_CLI debug_level=3 server_name=localhost \
3073 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3074 1 \
3075 -S "skip write certificate request" \
3076 -C "skip parse certificate request" \
3077 -c "got a certificate request" \
3078 -C "skip write certificate" \
3079 -C "skip write certificate verify" \
3080 -S "skip parse certificate verify" \
3081 -s "x509_verify_cert() returned" \
3082 -s "! The certificate is not correctly signed by the trusted CA" \
3083 -S "The certificate has been revoked (is on a CRL)"
3084
3085run_test "SNI: CA override" \
3086 "$P_SRV debug_level=3 auth_mode=optional \
3087 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3088 ca_file=data_files/test-ca.crt \
3089 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3090 "$P_CLI debug_level=3 server_name=localhost \
3091 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3092 0 \
3093 -S "skip write certificate request" \
3094 -C "skip parse certificate request" \
3095 -c "got a certificate request" \
3096 -C "skip write certificate" \
3097 -C "skip write certificate verify" \
3098 -S "skip parse certificate verify" \
3099 -S "x509_verify_cert() returned" \
3100 -S "! The certificate is not correctly signed by the trusted CA" \
3101 -S "The certificate has been revoked (is on a CRL)"
3102
3103run_test "SNI: CA override with CRL" \
3104 "$P_SRV debug_level=3 auth_mode=optional \
3105 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3106 ca_file=data_files/test-ca.crt \
3107 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3108 "$P_CLI debug_level=3 server_name=localhost \
3109 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3110 1 \
3111 -S "skip write certificate request" \
3112 -C "skip parse certificate request" \
3113 -c "got a certificate request" \
3114 -C "skip write certificate" \
3115 -C "skip write certificate verify" \
3116 -S "skip parse certificate verify" \
3117 -s "x509_verify_cert() returned" \
3118 -S "! The certificate is not correctly signed by the trusted CA" \
3119 -s "The certificate has been revoked (is on a CRL)"
3120
Andres AG1a834452016-12-07 10:01:30 +00003121# Tests for SNI and DTLS
3122
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003123run_test "SNI: DTLS, no SNI callback" \
3124 "$P_SRV debug_level=3 dtls=1 \
3125 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3126 "$P_CLI server_name=localhost dtls=1" \
3127 0 \
3128 -S "parse ServerName extension" \
3129 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3130 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3131
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003132run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003133 "$P_SRV debug_level=3 dtls=1 \
3134 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3135 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3136 "$P_CLI server_name=localhost dtls=1" \
3137 0 \
3138 -s "parse ServerName extension" \
3139 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3140 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3141
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003142run_test "SNI: DTLS, matching cert 2" \
3143 "$P_SRV debug_level=3 dtls=1 \
3144 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3145 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3146 "$P_CLI server_name=polarssl.example dtls=1" \
3147 0 \
3148 -s "parse ServerName extension" \
3149 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3150 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3151
3152run_test "SNI: DTLS, no matching cert" \
3153 "$P_SRV debug_level=3 dtls=1 \
3154 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3155 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3156 "$P_CLI server_name=nonesuch.example dtls=1" \
3157 1 \
3158 -s "parse ServerName extension" \
3159 -s "ssl_sni_wrapper() returned" \
3160 -s "mbedtls_ssl_handshake returned" \
3161 -c "mbedtls_ssl_handshake returned" \
3162 -c "SSL - A fatal alert message was received from our peer"
3163
3164run_test "SNI: DTLS, client auth no override: optional" \
3165 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3166 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3167 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3168 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3169 0 \
3170 -S "skip write certificate request" \
3171 -C "skip parse certificate request" \
3172 -c "got a certificate request" \
3173 -C "skip write certificate" \
3174 -C "skip write certificate verify" \
3175 -S "skip parse certificate verify"
3176
3177run_test "SNI: DTLS, client auth override: none -> optional" \
3178 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3179 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3180 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3181 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3182 0 \
3183 -S "skip write certificate request" \
3184 -C "skip parse certificate request" \
3185 -c "got a certificate request" \
3186 -C "skip write certificate" \
3187 -C "skip write certificate verify" \
3188 -S "skip parse certificate verify"
3189
3190run_test "SNI: DTLS, client auth override: optional -> none" \
3191 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3192 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3193 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3194 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3195 0 \
3196 -s "skip write certificate request" \
3197 -C "skip parse certificate request" \
3198 -c "got no certificate request" \
3199 -c "skip write certificate" \
3200 -c "skip write certificate verify" \
3201 -s "skip parse certificate verify"
3202
3203run_test "SNI: DTLS, CA no override" \
3204 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3205 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3206 ca_file=data_files/test-ca.crt \
3207 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3208 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3209 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3210 1 \
3211 -S "skip write certificate request" \
3212 -C "skip parse certificate request" \
3213 -c "got a certificate request" \
3214 -C "skip write certificate" \
3215 -C "skip write certificate verify" \
3216 -S "skip parse certificate verify" \
3217 -s "x509_verify_cert() returned" \
3218 -s "! The certificate is not correctly signed by the trusted CA" \
3219 -S "The certificate has been revoked (is on a CRL)"
3220
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003221run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003222 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3223 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3224 ca_file=data_files/test-ca.crt \
3225 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3226 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3227 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3228 0 \
3229 -S "skip write certificate request" \
3230 -C "skip parse certificate request" \
3231 -c "got a certificate request" \
3232 -C "skip write certificate" \
3233 -C "skip write certificate verify" \
3234 -S "skip parse certificate verify" \
3235 -S "x509_verify_cert() returned" \
3236 -S "! The certificate is not correctly signed by the trusted CA" \
3237 -S "The certificate has been revoked (is on a CRL)"
3238
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003239run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003240 "$P_SRV debug_level=3 auth_mode=optional \
3241 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3242 ca_file=data_files/test-ca.crt \
3243 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3244 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3245 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3246 1 \
3247 -S "skip write certificate request" \
3248 -C "skip parse certificate request" \
3249 -c "got a certificate request" \
3250 -C "skip write certificate" \
3251 -C "skip write certificate verify" \
3252 -S "skip parse certificate verify" \
3253 -s "x509_verify_cert() returned" \
3254 -S "! The certificate is not correctly signed by the trusted CA" \
3255 -s "The certificate has been revoked (is on a CRL)"
3256
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003257# Tests for non-blocking I/O: exercise a variety of handshake flows
3258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003259run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003260 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3261 "$P_CLI nbio=2 tickets=0" \
3262 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003263 -S "mbedtls_ssl_handshake returned" \
3264 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003265 -c "Read from server: .* bytes read"
3266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003267run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003268 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3269 "$P_CLI nbio=2 tickets=0" \
3270 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003271 -S "mbedtls_ssl_handshake returned" \
3272 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003273 -c "Read from server: .* bytes read"
3274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003275run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003276 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3277 "$P_CLI nbio=2 tickets=1" \
3278 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003279 -S "mbedtls_ssl_handshake returned" \
3280 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003281 -c "Read from server: .* bytes read"
3282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003284 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3285 "$P_CLI nbio=2 tickets=1" \
3286 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003287 -S "mbedtls_ssl_handshake returned" \
3288 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003289 -c "Read from server: .* bytes read"
3290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003291run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003292 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3293 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3294 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003295 -S "mbedtls_ssl_handshake returned" \
3296 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003297 -c "Read from server: .* bytes read"
3298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003299run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003300 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3301 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3302 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003303 -S "mbedtls_ssl_handshake returned" \
3304 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003305 -c "Read from server: .* bytes read"
3306
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003307run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003308 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3309 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3310 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003311 -S "mbedtls_ssl_handshake returned" \
3312 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003313 -c "Read from server: .* bytes read"
3314
Hanno Becker00076712017-11-15 16:39:08 +00003315# Tests for event-driven I/O: exercise a variety of handshake flows
3316
3317run_test "Event-driven I/O: basic handshake" \
3318 "$P_SRV event=1 tickets=0 auth_mode=none" \
3319 "$P_CLI event=1 tickets=0" \
3320 0 \
3321 -S "mbedtls_ssl_handshake returned" \
3322 -C "mbedtls_ssl_handshake returned" \
3323 -c "Read from server: .* bytes read"
3324
3325run_test "Event-driven I/O: client auth" \
3326 "$P_SRV event=1 tickets=0 auth_mode=required" \
3327 "$P_CLI event=1 tickets=0" \
3328 0 \
3329 -S "mbedtls_ssl_handshake returned" \
3330 -C "mbedtls_ssl_handshake returned" \
3331 -c "Read from server: .* bytes read"
3332
3333run_test "Event-driven I/O: ticket" \
3334 "$P_SRV event=1 tickets=1 auth_mode=none" \
3335 "$P_CLI event=1 tickets=1" \
3336 0 \
3337 -S "mbedtls_ssl_handshake returned" \
3338 -C "mbedtls_ssl_handshake returned" \
3339 -c "Read from server: .* bytes read"
3340
3341run_test "Event-driven I/O: ticket + client auth" \
3342 "$P_SRV event=1 tickets=1 auth_mode=required" \
3343 "$P_CLI event=1 tickets=1" \
3344 0 \
3345 -S "mbedtls_ssl_handshake returned" \
3346 -C "mbedtls_ssl_handshake returned" \
3347 -c "Read from server: .* bytes read"
3348
3349run_test "Event-driven I/O: ticket + client auth + resume" \
3350 "$P_SRV event=1 tickets=1 auth_mode=required" \
3351 "$P_CLI event=1 tickets=1 reconnect=1" \
3352 0 \
3353 -S "mbedtls_ssl_handshake returned" \
3354 -C "mbedtls_ssl_handshake returned" \
3355 -c "Read from server: .* bytes read"
3356
3357run_test "Event-driven I/O: ticket + resume" \
3358 "$P_SRV event=1 tickets=1 auth_mode=none" \
3359 "$P_CLI event=1 tickets=1 reconnect=1" \
3360 0 \
3361 -S "mbedtls_ssl_handshake returned" \
3362 -C "mbedtls_ssl_handshake returned" \
3363 -c "Read from server: .* bytes read"
3364
3365run_test "Event-driven I/O: session-id resume" \
3366 "$P_SRV event=1 tickets=0 auth_mode=none" \
3367 "$P_CLI event=1 tickets=0 reconnect=1" \
3368 0 \
3369 -S "mbedtls_ssl_handshake returned" \
3370 -C "mbedtls_ssl_handshake returned" \
3371 -c "Read from server: .* bytes read"
3372
Hanno Becker6a33f592018-03-13 11:38:46 +00003373run_test "Event-driven I/O, DTLS: basic handshake" \
3374 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3375 "$P_CLI dtls=1 event=1 tickets=0" \
3376 0 \
3377 -c "Read from server: .* bytes read"
3378
3379run_test "Event-driven I/O, DTLS: client auth" \
3380 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3381 "$P_CLI dtls=1 event=1 tickets=0" \
3382 0 \
3383 -c "Read from server: .* bytes read"
3384
3385run_test "Event-driven I/O, DTLS: ticket" \
3386 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3387 "$P_CLI dtls=1 event=1 tickets=1" \
3388 0 \
3389 -c "Read from server: .* bytes read"
3390
3391run_test "Event-driven I/O, DTLS: ticket + client auth" \
3392 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3393 "$P_CLI dtls=1 event=1 tickets=1" \
3394 0 \
3395 -c "Read from server: .* bytes read"
3396
3397run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3398 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003399 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003400 0 \
3401 -c "Read from server: .* bytes read"
3402
3403run_test "Event-driven I/O, DTLS: ticket + resume" \
3404 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003405 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003406 0 \
3407 -c "Read from server: .* bytes read"
3408
3409run_test "Event-driven I/O, DTLS: session-id resume" \
3410 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003411 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003412 0 \
3413 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003414
3415# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3416# During session resumption, the client will send its ApplicationData record
3417# within the same datagram as the Finished messages. In this situation, the
3418# server MUST NOT idle on the underlying transport after handshake completion,
3419# because the ApplicationData request has already been queued internally.
3420run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003421 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003422 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003423 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003424 0 \
3425 -c "Read from server: .* bytes read"
3426
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003427# Tests for version negotiation
3428
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003429run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003430 "$P_SRV" \
3431 "$P_CLI" \
3432 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003433 -S "mbedtls_ssl_handshake returned" \
3434 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003435 -s "Protocol is TLSv1.2" \
3436 -c "Protocol is TLSv1.2"
3437
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003438run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003439 "$P_SRV" \
3440 "$P_CLI max_version=tls1_1" \
3441 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003442 -S "mbedtls_ssl_handshake returned" \
3443 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003444 -s "Protocol is TLSv1.1" \
3445 -c "Protocol is TLSv1.1"
3446
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003447run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003448 "$P_SRV max_version=tls1_1" \
3449 "$P_CLI" \
3450 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003451 -S "mbedtls_ssl_handshake returned" \
3452 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003453 -s "Protocol is TLSv1.1" \
3454 -c "Protocol is TLSv1.1"
3455
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003456run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003457 "$P_SRV max_version=tls1_1" \
3458 "$P_CLI max_version=tls1_1" \
3459 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003460 -S "mbedtls_ssl_handshake returned" \
3461 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003462 -s "Protocol is TLSv1.1" \
3463 -c "Protocol is TLSv1.1"
3464
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003465run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003466 "$P_SRV min_version=tls1_1" \
3467 "$P_CLI max_version=tls1_1" \
3468 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003469 -S "mbedtls_ssl_handshake returned" \
3470 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003471 -s "Protocol is TLSv1.1" \
3472 -c "Protocol is TLSv1.1"
3473
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003474run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003475 "$P_SRV max_version=tls1_1" \
3476 "$P_CLI min_version=tls1_1" \
3477 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003478 -S "mbedtls_ssl_handshake returned" \
3479 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003480 -s "Protocol is TLSv1.1" \
3481 -c "Protocol is TLSv1.1"
3482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003483run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003484 "$P_SRV max_version=tls1_1" \
3485 "$P_CLI min_version=tls1_2" \
3486 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003487 -s "mbedtls_ssl_handshake returned" \
3488 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003489 -c "SSL - Handshake protocol not within min/max boundaries"
3490
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003491run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003492 "$P_SRV min_version=tls1_2" \
3493 "$P_CLI max_version=tls1_1" \
3494 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003495 -s "mbedtls_ssl_handshake returned" \
3496 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003497 -s "SSL - Handshake protocol not within min/max boundaries"
3498
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003499# Tests for ALPN extension
3500
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003501run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003502 "$P_SRV debug_level=3" \
3503 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003504 0 \
3505 -C "client hello, adding alpn extension" \
3506 -S "found alpn extension" \
3507 -C "got an alert message, type: \\[2:120]" \
3508 -S "server hello, adding alpn extension" \
3509 -C "found alpn extension " \
3510 -C "Application Layer Protocol is" \
3511 -S "Application Layer Protocol is"
3512
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003513run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003514 "$P_SRV debug_level=3" \
3515 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003516 0 \
3517 -c "client hello, adding alpn extension" \
3518 -s "found alpn extension" \
3519 -C "got an alert message, type: \\[2:120]" \
3520 -S "server hello, adding alpn extension" \
3521 -C "found alpn extension " \
3522 -c "Application Layer Protocol is (none)" \
3523 -S "Application Layer Protocol is"
3524
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003525run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003526 "$P_SRV debug_level=3 alpn=abc,1234" \
3527 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003528 0 \
3529 -C "client hello, adding alpn extension" \
3530 -S "found alpn extension" \
3531 -C "got an alert message, type: \\[2:120]" \
3532 -S "server hello, adding alpn extension" \
3533 -C "found alpn extension " \
3534 -C "Application Layer Protocol is" \
3535 -s "Application Layer Protocol is (none)"
3536
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003537run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003538 "$P_SRV debug_level=3 alpn=abc,1234" \
3539 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003540 0 \
3541 -c "client hello, adding alpn extension" \
3542 -s "found alpn extension" \
3543 -C "got an alert message, type: \\[2:120]" \
3544 -s "server hello, adding alpn extension" \
3545 -c "found alpn extension" \
3546 -c "Application Layer Protocol is abc" \
3547 -s "Application Layer Protocol is abc"
3548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003549run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003550 "$P_SRV debug_level=3 alpn=abc,1234" \
3551 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003552 0 \
3553 -c "client hello, adding alpn extension" \
3554 -s "found alpn extension" \
3555 -C "got an alert message, type: \\[2:120]" \
3556 -s "server hello, adding alpn extension" \
3557 -c "found alpn extension" \
3558 -c "Application Layer Protocol is abc" \
3559 -s "Application Layer Protocol is abc"
3560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003561run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003562 "$P_SRV debug_level=3 alpn=abc,1234" \
3563 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003564 0 \
3565 -c "client hello, adding alpn extension" \
3566 -s "found alpn extension" \
3567 -C "got an alert message, type: \\[2:120]" \
3568 -s "server hello, adding alpn extension" \
3569 -c "found alpn extension" \
3570 -c "Application Layer Protocol is 1234" \
3571 -s "Application Layer Protocol is 1234"
3572
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003573run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003574 "$P_SRV debug_level=3 alpn=abc,123" \
3575 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003576 1 \
3577 -c "client hello, adding alpn extension" \
3578 -s "found alpn extension" \
3579 -c "got an alert message, type: \\[2:120]" \
3580 -S "server hello, adding alpn extension" \
3581 -C "found alpn extension" \
3582 -C "Application Layer Protocol is 1234" \
3583 -S "Application Layer Protocol is 1234"
3584
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003585
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003586# Tests for keyUsage in leaf certificates, part 1:
3587# server-side certificate/suite selection
3588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003589run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003590 "$P_SRV key_file=data_files/server2.key \
3591 crt_file=data_files/server2.ku-ds.crt" \
3592 "$P_CLI" \
3593 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003594 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003595
3596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003597run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003598 "$P_SRV key_file=data_files/server2.key \
3599 crt_file=data_files/server2.ku-ke.crt" \
3600 "$P_CLI" \
3601 0 \
3602 -c "Ciphersuite is TLS-RSA-WITH-"
3603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003604run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003605 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003606 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003607 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003608 1 \
3609 -C "Ciphersuite is "
3610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003611run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003612 "$P_SRV key_file=data_files/server5.key \
3613 crt_file=data_files/server5.ku-ds.crt" \
3614 "$P_CLI" \
3615 0 \
3616 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3617
3618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003619run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003620 "$P_SRV key_file=data_files/server5.key \
3621 crt_file=data_files/server5.ku-ka.crt" \
3622 "$P_CLI" \
3623 0 \
3624 -c "Ciphersuite is TLS-ECDH-"
3625
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003626run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003627 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003628 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003629 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003630 1 \
3631 -C "Ciphersuite is "
3632
3633# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003634# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003635
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003636run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003637 "$O_SRV -key data_files/server2.key \
3638 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003639 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003640 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3641 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003642 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003643 -C "Processing of the Certificate handshake message failed" \
3644 -c "Ciphersuite is TLS-"
3645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003646run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003647 "$O_SRV -key data_files/server2.key \
3648 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003649 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003650 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3651 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003652 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003653 -C "Processing of the Certificate handshake message failed" \
3654 -c "Ciphersuite is TLS-"
3655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003656run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003657 "$O_SRV -key data_files/server2.key \
3658 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003659 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003660 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3661 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003662 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003663 -C "Processing of the Certificate handshake message failed" \
3664 -c "Ciphersuite is TLS-"
3665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003666run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003667 "$O_SRV -key data_files/server2.key \
3668 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003669 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003670 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3671 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003672 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003673 -c "Processing of the Certificate handshake message failed" \
3674 -C "Ciphersuite is TLS-"
3675
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003676run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3677 "$O_SRV -key data_files/server2.key \
3678 -cert data_files/server2.ku-ke.crt" \
3679 "$P_CLI debug_level=1 auth_mode=optional \
3680 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3681 0 \
3682 -c "bad certificate (usage extensions)" \
3683 -C "Processing of the Certificate handshake message failed" \
3684 -c "Ciphersuite is TLS-" \
3685 -c "! Usage does not match the keyUsage extension"
3686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003687run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003688 "$O_SRV -key data_files/server2.key \
3689 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003690 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003691 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3692 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003693 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003694 -C "Processing of the Certificate handshake message failed" \
3695 -c "Ciphersuite is TLS-"
3696
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003697run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003698 "$O_SRV -key data_files/server2.key \
3699 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003700 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003701 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3702 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003703 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003704 -c "Processing of the Certificate handshake message failed" \
3705 -C "Ciphersuite is TLS-"
3706
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003707run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3708 "$O_SRV -key data_files/server2.key \
3709 -cert data_files/server2.ku-ds.crt" \
3710 "$P_CLI debug_level=1 auth_mode=optional \
3711 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3712 0 \
3713 -c "bad certificate (usage extensions)" \
3714 -C "Processing of the Certificate handshake message failed" \
3715 -c "Ciphersuite is TLS-" \
3716 -c "! Usage does not match the keyUsage extension"
3717
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003718# Tests for keyUsage in leaf certificates, part 3:
3719# server-side checking of client cert
3720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003721run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003722 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003723 "$O_CLI -key data_files/server2.key \
3724 -cert data_files/server2.ku-ds.crt" \
3725 0 \
3726 -S "bad certificate (usage extensions)" \
3727 -S "Processing of the Certificate handshake message failed"
3728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003729run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003730 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003731 "$O_CLI -key data_files/server2.key \
3732 -cert data_files/server2.ku-ke.crt" \
3733 0 \
3734 -s "bad certificate (usage extensions)" \
3735 -S "Processing of the Certificate handshake message failed"
3736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003737run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003738 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003739 "$O_CLI -key data_files/server2.key \
3740 -cert data_files/server2.ku-ke.crt" \
3741 1 \
3742 -s "bad certificate (usage extensions)" \
3743 -s "Processing of the Certificate handshake message failed"
3744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003745run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003746 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003747 "$O_CLI -key data_files/server5.key \
3748 -cert data_files/server5.ku-ds.crt" \
3749 0 \
3750 -S "bad certificate (usage extensions)" \
3751 -S "Processing of the Certificate handshake message failed"
3752
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003753run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003754 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003755 "$O_CLI -key data_files/server5.key \
3756 -cert data_files/server5.ku-ka.crt" \
3757 0 \
3758 -s "bad certificate (usage extensions)" \
3759 -S "Processing of the Certificate handshake message failed"
3760
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003761# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003763run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003764 "$P_SRV key_file=data_files/server5.key \
3765 crt_file=data_files/server5.eku-srv.crt" \
3766 "$P_CLI" \
3767 0
3768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003769run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003770 "$P_SRV key_file=data_files/server5.key \
3771 crt_file=data_files/server5.eku-srv.crt" \
3772 "$P_CLI" \
3773 0
3774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003775run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003776 "$P_SRV key_file=data_files/server5.key \
3777 crt_file=data_files/server5.eku-cs_any.crt" \
3778 "$P_CLI" \
3779 0
3780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003781run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003782 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003783 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003784 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003785 1
3786
3787# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003789run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003790 "$O_SRV -key data_files/server5.key \
3791 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003792 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003793 0 \
3794 -C "bad certificate (usage extensions)" \
3795 -C "Processing of the Certificate handshake message failed" \
3796 -c "Ciphersuite is TLS-"
3797
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003798run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003799 "$O_SRV -key data_files/server5.key \
3800 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003801 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003802 0 \
3803 -C "bad certificate (usage extensions)" \
3804 -C "Processing of the Certificate handshake message failed" \
3805 -c "Ciphersuite is TLS-"
3806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003807run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003808 "$O_SRV -key data_files/server5.key \
3809 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003810 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003811 0 \
3812 -C "bad certificate (usage extensions)" \
3813 -C "Processing of the Certificate handshake message failed" \
3814 -c "Ciphersuite is TLS-"
3815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003816run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003817 "$O_SRV -key data_files/server5.key \
3818 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003819 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003820 1 \
3821 -c "bad certificate (usage extensions)" \
3822 -c "Processing of the Certificate handshake message failed" \
3823 -C "Ciphersuite is TLS-"
3824
3825# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003827run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003828 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003829 "$O_CLI -key data_files/server5.key \
3830 -cert data_files/server5.eku-cli.crt" \
3831 0 \
3832 -S "bad certificate (usage extensions)" \
3833 -S "Processing of the Certificate handshake message failed"
3834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003835run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003836 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003837 "$O_CLI -key data_files/server5.key \
3838 -cert data_files/server5.eku-srv_cli.crt" \
3839 0 \
3840 -S "bad certificate (usage extensions)" \
3841 -S "Processing of the Certificate handshake message failed"
3842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003843run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003844 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003845 "$O_CLI -key data_files/server5.key \
3846 -cert data_files/server5.eku-cs_any.crt" \
3847 0 \
3848 -S "bad certificate (usage extensions)" \
3849 -S "Processing of the Certificate handshake message failed"
3850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003851run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003852 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003853 "$O_CLI -key data_files/server5.key \
3854 -cert data_files/server5.eku-cs.crt" \
3855 0 \
3856 -s "bad certificate (usage extensions)" \
3857 -S "Processing of the Certificate handshake message failed"
3858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003859run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003860 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003861 "$O_CLI -key data_files/server5.key \
3862 -cert data_files/server5.eku-cs.crt" \
3863 1 \
3864 -s "bad certificate (usage extensions)" \
3865 -s "Processing of the Certificate handshake message failed"
3866
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003867# Tests for DHM parameters loading
3868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003869run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003870 "$P_SRV" \
3871 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3872 debug_level=3" \
3873 0 \
3874 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003875 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003877run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003878 "$P_SRV dhm_file=data_files/dhparams.pem" \
3879 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3880 debug_level=3" \
3881 0 \
3882 -c "value of 'DHM: P ' (1024 bits)" \
3883 -c "value of 'DHM: G ' (2 bits)"
3884
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003885# Tests for DHM client-side size checking
3886
3887run_test "DHM size: server default, client default, OK" \
3888 "$P_SRV" \
3889 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3890 debug_level=1" \
3891 0 \
3892 -C "DHM prime too short:"
3893
3894run_test "DHM size: server default, client 2048, OK" \
3895 "$P_SRV" \
3896 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3897 debug_level=1 dhmlen=2048" \
3898 0 \
3899 -C "DHM prime too short:"
3900
3901run_test "DHM size: server 1024, client default, OK" \
3902 "$P_SRV dhm_file=data_files/dhparams.pem" \
3903 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3904 debug_level=1" \
3905 0 \
3906 -C "DHM prime too short:"
3907
3908run_test "DHM size: server 1000, client default, rejected" \
3909 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3910 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3911 debug_level=1" \
3912 1 \
3913 -c "DHM prime too short:"
3914
3915run_test "DHM size: server default, client 2049, rejected" \
3916 "$P_SRV" \
3917 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3918 debug_level=1 dhmlen=2049" \
3919 1 \
3920 -c "DHM prime too short:"
3921
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003922# Tests for PSK callback
3923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003924run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003925 "$P_SRV psk=abc123 psk_identity=foo" \
3926 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3927 psk_identity=foo psk=abc123" \
3928 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003929 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003930 -S "SSL - Unknown identity received" \
3931 -S "SSL - Verification of the message MAC failed"
3932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003933run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003934 "$P_SRV" \
3935 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3936 psk_identity=foo psk=abc123" \
3937 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003938 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003939 -S "SSL - Unknown identity received" \
3940 -S "SSL - Verification of the message MAC failed"
3941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003942run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003943 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3944 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3945 psk_identity=foo psk=abc123" \
3946 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003947 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003948 -s "SSL - Unknown identity received" \
3949 -S "SSL - Verification of the message MAC failed"
3950
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003951run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003952 "$P_SRV psk_list=abc,dead,def,beef" \
3953 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3954 psk_identity=abc psk=dead" \
3955 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003956 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003957 -S "SSL - Unknown identity received" \
3958 -S "SSL - Verification of the message MAC failed"
3959
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003960run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003961 "$P_SRV psk_list=abc,dead,def,beef" \
3962 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3963 psk_identity=def psk=beef" \
3964 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003965 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003966 -S "SSL - Unknown identity received" \
3967 -S "SSL - Verification of the message MAC failed"
3968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003969run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003970 "$P_SRV psk_list=abc,dead,def,beef" \
3971 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3972 psk_identity=ghi psk=beef" \
3973 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003974 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003975 -s "SSL - Unknown identity received" \
3976 -S "SSL - Verification of the message MAC failed"
3977
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003978run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003979 "$P_SRV psk_list=abc,dead,def,beef" \
3980 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3981 psk_identity=abc psk=beef" \
3982 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003983 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003984 -S "SSL - Unknown identity received" \
3985 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003986
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003987# Tests for EC J-PAKE
3988
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003989requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003990run_test "ECJPAKE: client not configured" \
3991 "$P_SRV debug_level=3" \
3992 "$P_CLI debug_level=3" \
3993 0 \
3994 -C "add ciphersuite: c0ff" \
3995 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003996 -S "found ecjpake kkpp extension" \
3997 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003998 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003999 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004000 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004001 -S "None of the common ciphersuites is usable"
4002
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004003requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004004run_test "ECJPAKE: server not configured" \
4005 "$P_SRV debug_level=3" \
4006 "$P_CLI debug_level=3 ecjpake_pw=bla \
4007 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4008 1 \
4009 -c "add ciphersuite: c0ff" \
4010 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004011 -s "found ecjpake kkpp extension" \
4012 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004013 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004014 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004015 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004016 -s "None of the common ciphersuites is usable"
4017
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004018requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004019run_test "ECJPAKE: working, TLS" \
4020 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4021 "$P_CLI debug_level=3 ecjpake_pw=bla \
4022 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004023 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004024 -c "add ciphersuite: c0ff" \
4025 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004026 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004027 -s "found ecjpake kkpp extension" \
4028 -S "skip ecjpake kkpp extension" \
4029 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004030 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004031 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004032 -S "None of the common ciphersuites is usable" \
4033 -S "SSL - Verification of the message MAC failed"
4034
Janos Follath74537a62016-09-02 13:45:28 +01004035server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004036requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004037run_test "ECJPAKE: password mismatch, TLS" \
4038 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4039 "$P_CLI debug_level=3 ecjpake_pw=bad \
4040 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4041 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004042 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004043 -s "SSL - Verification of the message MAC failed"
4044
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004045requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004046run_test "ECJPAKE: working, DTLS" \
4047 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4048 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4049 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4050 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004051 -c "re-using cached ecjpake parameters" \
4052 -S "SSL - Verification of the message MAC failed"
4053
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004054requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004055run_test "ECJPAKE: working, DTLS, no cookie" \
4056 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4057 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4058 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4059 0 \
4060 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004061 -S "SSL - Verification of the message MAC failed"
4062
Janos Follath74537a62016-09-02 13:45:28 +01004063server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004064requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004065run_test "ECJPAKE: password mismatch, DTLS" \
4066 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4067 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4068 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4069 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004070 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004071 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004072
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004073# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004074requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004075run_test "ECJPAKE: working, DTLS, nolog" \
4076 "$P_SRV dtls=1 ecjpake_pw=bla" \
4077 "$P_CLI dtls=1 ecjpake_pw=bla \
4078 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4079 0
4080
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004081# Tests for ciphersuites per version
4082
Janos Follathe2681a42016-03-07 15:57:05 +00004083requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004084requires_config_enabled MBEDTLS_CAMELLIA_C
4085requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004086run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004087 "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +02004088 "$P_CLI force_version=ssl3" \
4089 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004090 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004091
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004092requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4093requires_config_enabled MBEDTLS_CAMELLIA_C
4094requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004095run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004096 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +01004097 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004098 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004099 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004100
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004101requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4102requires_config_enabled MBEDTLS_CAMELLIA_C
4103requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004104run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004105 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +02004106 "$P_CLI force_version=tls1_1" \
4107 0 \
4108 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4109
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004110requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4111requires_config_enabled MBEDTLS_CAMELLIA_C
4112requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004113run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004114 "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-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 +02004115 "$P_CLI force_version=tls1_2" \
4116 0 \
4117 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4118
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004119# Test for ClientHello without extensions
4120
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004121requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004122run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004123 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004124 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004125 0 \
4126 -s "dumping 'client hello extensions' (0 bytes)"
4127
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004128# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004129
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004130run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004131 "$P_SRV" \
4132 "$P_CLI request_size=100" \
4133 0 \
4134 -s "Read from client: 100 bytes read$"
4135
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004136run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004137 "$P_SRV" \
4138 "$P_CLI request_size=500" \
4139 0 \
4140 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004141
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004142# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004143
Janos Follathe2681a42016-03-07 15:57:05 +00004144requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004145run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004146 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004147 "$P_CLI request_size=1 force_version=ssl3 \
4148 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4149 0 \
4150 -s "Read from client: 1 bytes read"
4151
Janos Follathe2681a42016-03-07 15:57:05 +00004152requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004153run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004154 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004155 "$P_CLI request_size=1 force_version=ssl3 \
4156 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4157 0 \
4158 -s "Read from client: 1 bytes read"
4159
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004160run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004161 "$P_SRV" \
4162 "$P_CLI request_size=1 force_version=tls1 \
4163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4164 0 \
4165 -s "Read from client: 1 bytes read"
4166
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004167run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004168 "$P_SRV" \
4169 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4170 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4171 0 \
4172 -s "Read from client: 1 bytes read"
4173
Hanno Becker32c55012017-11-10 08:42:54 +00004174requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004175run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004176 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004177 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004178 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004179 0 \
4180 -s "Read from client: 1 bytes read"
4181
Hanno Becker32c55012017-11-10 08:42:54 +00004182requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004183run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004184 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004185 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004186 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004187 0 \
4188 -s "Read from client: 1 bytes read"
4189
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004190run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004191 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004192 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004193 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4194 0 \
4195 -s "Read from client: 1 bytes read"
4196
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004197run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004198 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4199 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004200 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004201 0 \
4202 -s "Read from client: 1 bytes read"
4203
4204requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004205run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004206 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004207 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004208 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004209 0 \
4210 -s "Read from client: 1 bytes read"
4211
Hanno Becker8501f982017-11-10 08:59:04 +00004212requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004213run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004214 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4215 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4216 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004217 0 \
4218 -s "Read from client: 1 bytes read"
4219
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004220run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004221 "$P_SRV" \
4222 "$P_CLI request_size=1 force_version=tls1_1 \
4223 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4224 0 \
4225 -s "Read from client: 1 bytes read"
4226
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004227run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004228 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004229 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004231 0 \
4232 -s "Read from client: 1 bytes read"
4233
4234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004235run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004236 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004237 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004238 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004239 0 \
4240 -s "Read from client: 1 bytes read"
4241
4242requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004243run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004244 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004245 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004246 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004247 0 \
4248 -s "Read from client: 1 bytes read"
4249
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004250run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004251 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004252 "$P_CLI request_size=1 force_version=tls1_1 \
4253 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4254 0 \
4255 -s "Read from client: 1 bytes read"
4256
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004257run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004258 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004259 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004260 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004261 0 \
4262 -s "Read from client: 1 bytes read"
4263
Hanno Becker8501f982017-11-10 08:59:04 +00004264requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004265run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004266 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004267 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004268 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004269 0 \
4270 -s "Read from client: 1 bytes read"
4271
Hanno Becker32c55012017-11-10 08:42:54 +00004272requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004273run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004274 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004275 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004276 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004277 0 \
4278 -s "Read from client: 1 bytes read"
4279
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004280run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004281 "$P_SRV" \
4282 "$P_CLI request_size=1 force_version=tls1_2 \
4283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4284 0 \
4285 -s "Read from client: 1 bytes read"
4286
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004287run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004288 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004289 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004290 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004291 0 \
4292 -s "Read from client: 1 bytes read"
4293
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004294run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004295 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004296 "$P_CLI request_size=1 force_version=tls1_2 \
4297 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004298 0 \
4299 -s "Read from client: 1 bytes read"
4300
Hanno Becker32c55012017-11-10 08:42:54 +00004301requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004302run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004303 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004304 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004305 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004306 0 \
4307 -s "Read from client: 1 bytes read"
4308
Hanno Becker8501f982017-11-10 08:59:04 +00004309requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004310run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004311 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004312 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004313 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004314 0 \
4315 -s "Read from client: 1 bytes read"
4316
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004317run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004318 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004319 "$P_CLI request_size=1 force_version=tls1_2 \
4320 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4321 0 \
4322 -s "Read from client: 1 bytes read"
4323
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004324run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004325 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004326 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004328 0 \
4329 -s "Read from client: 1 bytes read"
4330
Hanno Becker32c55012017-11-10 08:42:54 +00004331requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004332run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004333 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004334 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004335 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004336 0 \
4337 -s "Read from client: 1 bytes read"
4338
Hanno Becker8501f982017-11-10 08:59:04 +00004339requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004340run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004341 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004342 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004343 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004344 0 \
4345 -s "Read from client: 1 bytes read"
4346
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004347run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004348 "$P_SRV" \
4349 "$P_CLI request_size=1 force_version=tls1_2 \
4350 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4351 0 \
4352 -s "Read from client: 1 bytes read"
4353
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004354run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004355 "$P_SRV" \
4356 "$P_CLI request_size=1 force_version=tls1_2 \
4357 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4358 0 \
4359 -s "Read from client: 1 bytes read"
4360
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004361# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004362
4363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004364run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004365 "$P_SRV dtls=1 force_version=dtls1" \
4366 "$P_CLI dtls=1 request_size=1 \
4367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4368 0 \
4369 -s "Read from client: 1 bytes read"
4370
4371requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004372run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004373 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4374 "$P_CLI dtls=1 request_size=1 \
4375 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4376 0 \
4377 -s "Read from client: 1 bytes read"
4378
4379requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4380requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004381run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004382 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4383 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004384 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4385 0 \
4386 -s "Read from client: 1 bytes read"
4387
4388requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4389requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004390run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004391 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004392 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004393 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004394 0 \
4395 -s "Read from client: 1 bytes read"
4396
4397requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004398run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004399 "$P_SRV dtls=1 force_version=dtls1_2" \
4400 "$P_CLI dtls=1 request_size=1 \
4401 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4402 0 \
4403 -s "Read from client: 1 bytes read"
4404
4405requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004406run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004407 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004408 "$P_CLI dtls=1 request_size=1 \
4409 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4410 0 \
4411 -s "Read from client: 1 bytes read"
4412
4413requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4414requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004415run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004416 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004417 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004419 0 \
4420 -s "Read from client: 1 bytes read"
4421
4422requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4423requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004424run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004425 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004426 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004428 0 \
4429 -s "Read from client: 1 bytes read"
4430
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004431# Tests for small server packets
4432
4433requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4434run_test "Small server packet SSLv3 BlockCipher" \
4435 "$P_SRV response_size=1 min_version=ssl3" \
4436 "$P_CLI force_version=ssl3 \
4437 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4438 0 \
4439 -c "Read from server: 1 bytes read"
4440
4441requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4442run_test "Small server packet SSLv3 StreamCipher" \
4443 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4444 "$P_CLI force_version=ssl3 \
4445 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4446 0 \
4447 -c "Read from server: 1 bytes read"
4448
4449run_test "Small server packet TLS 1.0 BlockCipher" \
4450 "$P_SRV response_size=1" \
4451 "$P_CLI force_version=tls1 \
4452 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4453 0 \
4454 -c "Read from server: 1 bytes read"
4455
4456run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4457 "$P_SRV response_size=1" \
4458 "$P_CLI force_version=tls1 etm=0 \
4459 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4460 0 \
4461 -c "Read from server: 1 bytes read"
4462
4463requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4464run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4465 "$P_SRV response_size=1 trunc_hmac=1" \
4466 "$P_CLI force_version=tls1 \
4467 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4468 0 \
4469 -c "Read from server: 1 bytes read"
4470
4471requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4472run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4473 "$P_SRV response_size=1 trunc_hmac=1" \
4474 "$P_CLI force_version=tls1 \
4475 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4476 0 \
4477 -c "Read from server: 1 bytes read"
4478
4479run_test "Small server packet TLS 1.0 StreamCipher" \
4480 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4481 "$P_CLI force_version=tls1 \
4482 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4483 0 \
4484 -c "Read from server: 1 bytes read"
4485
4486run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4487 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4488 "$P_CLI force_version=tls1 \
4489 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4490 0 \
4491 -c "Read from server: 1 bytes read"
4492
4493requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4494run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4495 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4496 "$P_CLI force_version=tls1 \
4497 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4498 0 \
4499 -c "Read from server: 1 bytes read"
4500
4501requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4502run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4503 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4504 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4505 trunc_hmac=1 etm=0" \
4506 0 \
4507 -c "Read from server: 1 bytes read"
4508
4509run_test "Small server packet TLS 1.1 BlockCipher" \
4510 "$P_SRV response_size=1" \
4511 "$P_CLI force_version=tls1_1 \
4512 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4513 0 \
4514 -c "Read from server: 1 bytes read"
4515
4516run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4517 "$P_SRV response_size=1" \
4518 "$P_CLI force_version=tls1_1 \
4519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4520 0 \
4521 -c "Read from server: 1 bytes read"
4522
4523requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4524run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4525 "$P_SRV response_size=1 trunc_hmac=1" \
4526 "$P_CLI force_version=tls1_1 \
4527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4528 0 \
4529 -c "Read from server: 1 bytes read"
4530
4531requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4532run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4533 "$P_SRV response_size=1 trunc_hmac=1" \
4534 "$P_CLI force_version=tls1_1 \
4535 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4536 0 \
4537 -c "Read from server: 1 bytes read"
4538
4539run_test "Small server packet TLS 1.1 StreamCipher" \
4540 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4541 "$P_CLI force_version=tls1_1 \
4542 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4543 0 \
4544 -c "Read from server: 1 bytes read"
4545
4546run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4547 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4548 "$P_CLI force_version=tls1_1 \
4549 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4550 0 \
4551 -c "Read from server: 1 bytes read"
4552
4553requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4554run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4555 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4556 "$P_CLI force_version=tls1_1 \
4557 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4558 0 \
4559 -c "Read from server: 1 bytes read"
4560
4561requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4562run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4563 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4564 "$P_CLI force_version=tls1_1 \
4565 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4566 0 \
4567 -c "Read from server: 1 bytes read"
4568
4569run_test "Small server packet TLS 1.2 BlockCipher" \
4570 "$P_SRV response_size=1" \
4571 "$P_CLI force_version=tls1_2 \
4572 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4573 0 \
4574 -c "Read from server: 1 bytes read"
4575
4576run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4577 "$P_SRV response_size=1" \
4578 "$P_CLI force_version=tls1_2 \
4579 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4580 0 \
4581 -c "Read from server: 1 bytes read"
4582
4583run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4584 "$P_SRV response_size=1" \
4585 "$P_CLI force_version=tls1_2 \
4586 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4587 0 \
4588 -c "Read from server: 1 bytes read"
4589
4590requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4591run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4592 "$P_SRV response_size=1 trunc_hmac=1" \
4593 "$P_CLI force_version=tls1_2 \
4594 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4595 0 \
4596 -c "Read from server: 1 bytes read"
4597
4598requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4599run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4600 "$P_SRV response_size=1 trunc_hmac=1" \
4601 "$P_CLI force_version=tls1_2 \
4602 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4603 0 \
4604 -c "Read from server: 1 bytes read"
4605
4606run_test "Small server packet TLS 1.2 StreamCipher" \
4607 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4608 "$P_CLI force_version=tls1_2 \
4609 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4610 0 \
4611 -c "Read from server: 1 bytes read"
4612
4613run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4614 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4615 "$P_CLI force_version=tls1_2 \
4616 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4617 0 \
4618 -c "Read from server: 1 bytes read"
4619
4620requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4621run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4622 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4623 "$P_CLI force_version=tls1_2 \
4624 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4625 0 \
4626 -c "Read from server: 1 bytes read"
4627
4628requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4629run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4630 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4631 "$P_CLI force_version=tls1_2 \
4632 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4633 0 \
4634 -c "Read from server: 1 bytes read"
4635
4636run_test "Small server packet TLS 1.2 AEAD" \
4637 "$P_SRV response_size=1" \
4638 "$P_CLI force_version=tls1_2 \
4639 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4640 0 \
4641 -c "Read from server: 1 bytes read"
4642
4643run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4644 "$P_SRV response_size=1" \
4645 "$P_CLI force_version=tls1_2 \
4646 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4647 0 \
4648 -c "Read from server: 1 bytes read"
4649
4650# Tests for small server packets in DTLS
4651
4652requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4653run_test "Small server packet DTLS 1.0" \
4654 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4655 "$P_CLI dtls=1 \
4656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4657 0 \
4658 -c "Read from server: 1 bytes read"
4659
4660requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4661run_test "Small server packet DTLS 1.0, without EtM" \
4662 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4663 "$P_CLI dtls=1 \
4664 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4665 0 \
4666 -c "Read from server: 1 bytes read"
4667
4668requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4669requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4670run_test "Small server packet DTLS 1.0, truncated hmac" \
4671 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4672 "$P_CLI dtls=1 trunc_hmac=1 \
4673 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4674 0 \
4675 -c "Read from server: 1 bytes read"
4676
4677requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4678requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4679run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4680 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4681 "$P_CLI dtls=1 \
4682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4683 0 \
4684 -c "Read from server: 1 bytes read"
4685
4686requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4687run_test "Small server packet DTLS 1.2" \
4688 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4689 "$P_CLI dtls=1 \
4690 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4691 0 \
4692 -c "Read from server: 1 bytes read"
4693
4694requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4695run_test "Small server packet DTLS 1.2, without EtM" \
4696 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4697 "$P_CLI dtls=1 \
4698 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4699 0 \
4700 -c "Read from server: 1 bytes read"
4701
4702requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4703requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4704run_test "Small server packet DTLS 1.2, truncated hmac" \
4705 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4706 "$P_CLI dtls=1 \
4707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4708 0 \
4709 -c "Read from server: 1 bytes read"
4710
4711requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4712requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4713run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4714 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4715 "$P_CLI dtls=1 \
4716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4717 0 \
4718 -c "Read from server: 1 bytes read"
4719
Janos Follath00efff72016-05-06 13:48:23 +01004720# A test for extensions in SSLv3
4721
4722requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4723run_test "SSLv3 with extensions, server side" \
4724 "$P_SRV min_version=ssl3 debug_level=3" \
4725 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4726 0 \
4727 -S "dumping 'client hello extensions'" \
4728 -S "server hello, total extension length:"
4729
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004730# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004731
Angus Grattonc4dd0732018-04-11 16:28:39 +10004732# How many fragments do we expect to write $1 bytes?
4733fragments_for_write() {
4734 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4735}
4736
Janos Follathe2681a42016-03-07 15:57:05 +00004737requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004738run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004739 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004740 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4742 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004743 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4744 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004745
Janos Follathe2681a42016-03-07 15:57:05 +00004746requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004747run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004748 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004749 "$P_CLI request_size=16384 force_version=ssl3 \
4750 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4751 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004752 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4753 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004754
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004755run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004756 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004757 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4759 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004760 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4761 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004762
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004763run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004764 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004765 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4767 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004768 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004769
Hanno Becker32c55012017-11-10 08:42:54 +00004770requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004771run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004772 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004773 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004774 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004775 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004776 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4777 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004778
Hanno Becker32c55012017-11-10 08:42:54 +00004779requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004780run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004781 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004782 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004783 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004784 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004785 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004786
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004787run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004788 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004789 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004790 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4791 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004792 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004793
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004794run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004795 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4796 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004798 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004799 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004800
4801requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004802run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004803 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004804 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004805 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004806 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004807 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004808
Hanno Becker278fc7a2017-11-10 09:16:28 +00004809requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004810run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004811 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004812 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004813 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004814 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004815 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4816 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004817
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004818run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004819 "$P_SRV" \
4820 "$P_CLI request_size=16384 force_version=tls1_1 \
4821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4822 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004823 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4824 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004825
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004826run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004827 "$P_SRV" \
4828 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004830 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004831 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004832
Hanno Becker32c55012017-11-10 08:42:54 +00004833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004834run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004835 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004836 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004838 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004839 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004840
Hanno Becker32c55012017-11-10 08:42:54 +00004841requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004842run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004843 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004844 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004845 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004846 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004847 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004848
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004849run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004850 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4851 "$P_CLI request_size=16384 force_version=tls1_1 \
4852 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4853 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004854 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4855 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004856
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004857run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004858 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004859 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004860 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004861 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004862 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4863 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004864
Hanno Becker278fc7a2017-11-10 09:16:28 +00004865requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004866run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004867 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004868 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004870 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004871 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004872
Hanno Becker278fc7a2017-11-10 09:16:28 +00004873requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004874run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004875 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004876 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004877 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004878 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004879 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4880 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004881
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004882run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004883 "$P_SRV" \
4884 "$P_CLI request_size=16384 force_version=tls1_2 \
4885 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4886 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004887 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4888 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004889
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004890run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004891 "$P_SRV" \
4892 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4893 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4894 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004895 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004896
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004897run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004898 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004899 "$P_CLI request_size=16384 force_version=tls1_2 \
4900 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004901 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004902 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4903 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004904
Hanno Becker32c55012017-11-10 08:42:54 +00004905requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004906run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004907 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004908 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004909 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004910 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004911 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004912
Hanno Becker278fc7a2017-11-10 09:16:28 +00004913requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004914run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004915 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004916 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004917 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004918 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004919 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4920 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004921
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004922run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004923 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004924 "$P_CLI request_size=16384 force_version=tls1_2 \
4925 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4926 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004927 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4928 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004929
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004930run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004931 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004932 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004933 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4934 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004935 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004936
Hanno Becker32c55012017-11-10 08:42:54 +00004937requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004938run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004939 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004940 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004941 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004942 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004943 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004944
Hanno Becker278fc7a2017-11-10 09:16:28 +00004945requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004946run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004947 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004948 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004949 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004950 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004951 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4952 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004954run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004955 "$P_SRV" \
4956 "$P_CLI request_size=16384 force_version=tls1_2 \
4957 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4958 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004959 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4960 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004961
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004962run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004963 "$P_SRV" \
4964 "$P_CLI request_size=16384 force_version=tls1_2 \
4965 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4966 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004967 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4968 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004969
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004970# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004971requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4972run_test "Large server packet SSLv3 StreamCipher" \
4973 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4974 "$P_CLI force_version=ssl3 \
4975 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4976 0 \
4977 -c "Read from server: 16384 bytes read"
4978
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004979# Checking next 4 tests logs for 1n-1 split against BEAST too
4980requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4981run_test "Large server packet SSLv3 BlockCipher" \
4982 "$P_SRV response_size=16384 min_version=ssl3" \
4983 "$P_CLI force_version=ssl3 recsplit=0 \
4984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4985 0 \
4986 -c "Read from server: 1 bytes read"\
4987 -c "16383 bytes read"\
4988 -C "Read from server: 16384 bytes read"
4989
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004990run_test "Large server packet TLS 1.0 BlockCipher" \
4991 "$P_SRV response_size=16384" \
4992 "$P_CLI force_version=tls1 recsplit=0 \
4993 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4994 0 \
4995 -c "Read from server: 1 bytes read"\
4996 -c "16383 bytes read"\
4997 -C "Read from server: 16384 bytes read"
4998
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004999run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5000 "$P_SRV response_size=16384" \
5001 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5002 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5003 0 \
5004 -c "Read from server: 1 bytes read"\
5005 -c "16383 bytes read"\
5006 -C "Read from server: 16384 bytes read"
5007
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005008requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5009run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5010 "$P_SRV response_size=16384" \
5011 "$P_CLI force_version=tls1 recsplit=0 \
5012 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5013 trunc_hmac=1" \
5014 0 \
5015 -c "Read from server: 1 bytes read"\
5016 -c "16383 bytes read"\
5017 -C "Read from server: 16384 bytes read"
5018
5019requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5020run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5021 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5022 "$P_CLI force_version=tls1 \
5023 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5024 trunc_hmac=1" \
5025 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005026 -s "16384 bytes written in 1 fragments" \
5027 -c "Read from server: 16384 bytes read"
5028
5029run_test "Large server packet TLS 1.0 StreamCipher" \
5030 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5031 "$P_CLI force_version=tls1 \
5032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5033 0 \
5034 -s "16384 bytes written in 1 fragments" \
5035 -c "Read from server: 16384 bytes read"
5036
5037run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5038 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5039 "$P_CLI force_version=tls1 \
5040 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5041 0 \
5042 -s "16384 bytes written in 1 fragments" \
5043 -c "Read from server: 16384 bytes read"
5044
5045requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5046run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5047 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5048 "$P_CLI force_version=tls1 \
5049 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5050 0 \
5051 -s "16384 bytes written in 1 fragments" \
5052 -c "Read from server: 16384 bytes read"
5053
5054requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5055run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5056 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5057 "$P_CLI force_version=tls1 \
5058 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5059 0 \
5060 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005061 -c "Read from server: 16384 bytes read"
5062
5063run_test "Large server packet TLS 1.1 BlockCipher" \
5064 "$P_SRV response_size=16384" \
5065 "$P_CLI force_version=tls1_1 \
5066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5067 0 \
5068 -c "Read from server: 16384 bytes read"
5069
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005070run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5071 "$P_SRV response_size=16384" \
5072 "$P_CLI force_version=tls1_1 etm=0 \
5073 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005074 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005075 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005076 -c "Read from server: 16384 bytes read"
5077
5078requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5079run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5080 "$P_SRV response_size=16384" \
5081 "$P_CLI force_version=tls1_1 \
5082 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5083 trunc_hmac=1" \
5084 0 \
5085 -c "Read from server: 16384 bytes read"
5086
5087requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005088run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5089 "$P_SRV response_size=16384 trunc_hmac=1" \
5090 "$P_CLI force_version=tls1_1 \
5091 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5092 0 \
5093 -s "16384 bytes written in 1 fragments" \
5094 -c "Read from server: 16384 bytes read"
5095
5096run_test "Large server packet TLS 1.1 StreamCipher" \
5097 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5098 "$P_CLI force_version=tls1_1 \
5099 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5100 0 \
5101 -c "Read from server: 16384 bytes read"
5102
5103run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5104 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5105 "$P_CLI force_version=tls1_1 \
5106 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5107 0 \
5108 -s "16384 bytes written in 1 fragments" \
5109 -c "Read from server: 16384 bytes read"
5110
5111requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005112run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5113 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5114 "$P_CLI force_version=tls1_1 \
5115 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5116 trunc_hmac=1" \
5117 0 \
5118 -c "Read from server: 16384 bytes read"
5119
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005120run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5121 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5122 "$P_CLI force_version=tls1_1 \
5123 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5124 0 \
5125 -s "16384 bytes written in 1 fragments" \
5126 -c "Read from server: 16384 bytes read"
5127
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005128run_test "Large server packet TLS 1.2 BlockCipher" \
5129 "$P_SRV response_size=16384" \
5130 "$P_CLI force_version=tls1_2 \
5131 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5132 0 \
5133 -c "Read from server: 16384 bytes read"
5134
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005135run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5136 "$P_SRV response_size=16384" \
5137 "$P_CLI force_version=tls1_2 etm=0 \
5138 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5139 0 \
5140 -s "16384 bytes written in 1 fragments" \
5141 -c "Read from server: 16384 bytes read"
5142
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005143run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5144 "$P_SRV response_size=16384" \
5145 "$P_CLI force_version=tls1_2 \
5146 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5147 0 \
5148 -c "Read from server: 16384 bytes read"
5149
5150requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5151run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5152 "$P_SRV response_size=16384" \
5153 "$P_CLI force_version=tls1_2 \
5154 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5155 trunc_hmac=1" \
5156 0 \
5157 -c "Read from server: 16384 bytes read"
5158
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005159run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5160 "$P_SRV response_size=16384 trunc_hmac=1" \
5161 "$P_CLI force_version=tls1_2 \
5162 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5163 0 \
5164 -s "16384 bytes written in 1 fragments" \
5165 -c "Read from server: 16384 bytes read"
5166
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005167run_test "Large server packet TLS 1.2 StreamCipher" \
5168 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5169 "$P_CLI force_version=tls1_2 \
5170 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5171 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005172 -s "16384 bytes written in 1 fragments" \
5173 -c "Read from server: 16384 bytes read"
5174
5175run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5176 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5177 "$P_CLI force_version=tls1_2 \
5178 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5179 0 \
5180 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005181 -c "Read from server: 16384 bytes read"
5182
5183requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5184run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5185 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5186 "$P_CLI force_version=tls1_2 \
5187 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5188 trunc_hmac=1" \
5189 0 \
5190 -c "Read from server: 16384 bytes read"
5191
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5193run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5194 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5195 "$P_CLI force_version=tls1_2 \
5196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5197 0 \
5198 -s "16384 bytes written in 1 fragments" \
5199 -c "Read from server: 16384 bytes read"
5200
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005201run_test "Large server packet TLS 1.2 AEAD" \
5202 "$P_SRV response_size=16384" \
5203 "$P_CLI force_version=tls1_2 \
5204 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5205 0 \
5206 -c "Read from server: 16384 bytes read"
5207
5208run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5209 "$P_SRV response_size=16384" \
5210 "$P_CLI force_version=tls1_2 \
5211 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5212 0 \
5213 -c "Read from server: 16384 bytes read"
5214
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005215# Tests for restartable ECC
5216
5217requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5218run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005219 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005220 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005221 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005222 debug_level=1" \
5223 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005224 -C "x509_verify_cert.*4b00" \
5225 -C "mbedtls_pk_verify.*4b00" \
5226 -C "mbedtls_ecdh_make_public.*4b00" \
5227 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005228
5229requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5230run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005231 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005232 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005233 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005234 debug_level=1 ec_max_ops=0" \
5235 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005236 -C "x509_verify_cert.*4b00" \
5237 -C "mbedtls_pk_verify.*4b00" \
5238 -C "mbedtls_ecdh_make_public.*4b00" \
5239 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005240
5241requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5242run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005243 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005244 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005245 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005246 debug_level=1 ec_max_ops=65535" \
5247 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005248 -C "x509_verify_cert.*4b00" \
5249 -C "mbedtls_pk_verify.*4b00" \
5250 -C "mbedtls_ecdh_make_public.*4b00" \
5251 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005252
5253requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5254run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005255 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005256 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005257 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005258 debug_level=1 ec_max_ops=1000" \
5259 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005260 -c "x509_verify_cert.*4b00" \
5261 -c "mbedtls_pk_verify.*4b00" \
5262 -c "mbedtls_ecdh_make_public.*4b00" \
5263 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005264
5265requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005266run_test "EC restart: TLS, max_ops=1000, badsign" \
5267 "$P_SRV auth_mode=required \
5268 crt_file=data_files/server5-badsign.crt \
5269 key_file=data_files/server5.key" \
5270 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5271 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5272 debug_level=1 ec_max_ops=1000" \
5273 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005274 -c "x509_verify_cert.*4b00" \
5275 -C "mbedtls_pk_verify.*4b00" \
5276 -C "mbedtls_ecdh_make_public.*4b00" \
5277 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005278 -c "! The certificate is not correctly signed by the trusted CA" \
5279 -c "! mbedtls_ssl_handshake returned" \
5280 -c "X509 - Certificate verification failed"
5281
5282requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5283run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5284 "$P_SRV auth_mode=required \
5285 crt_file=data_files/server5-badsign.crt \
5286 key_file=data_files/server5.key" \
5287 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5288 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5289 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5290 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005291 -c "x509_verify_cert.*4b00" \
5292 -c "mbedtls_pk_verify.*4b00" \
5293 -c "mbedtls_ecdh_make_public.*4b00" \
5294 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005295 -c "! The certificate is not correctly signed by the trusted CA" \
5296 -C "! mbedtls_ssl_handshake returned" \
5297 -C "X509 - Certificate verification failed"
5298
5299requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5300run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5301 "$P_SRV auth_mode=required \
5302 crt_file=data_files/server5-badsign.crt \
5303 key_file=data_files/server5.key" \
5304 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5305 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5306 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5307 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005308 -C "x509_verify_cert.*4b00" \
5309 -c "mbedtls_pk_verify.*4b00" \
5310 -c "mbedtls_ecdh_make_public.*4b00" \
5311 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005312 -C "! The certificate is not correctly signed by the trusted CA" \
5313 -C "! mbedtls_ssl_handshake returned" \
5314 -C "X509 - Certificate verification failed"
5315
5316requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005317run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005318 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005319 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005320 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005321 dtls=1 debug_level=1 ec_max_ops=1000" \
5322 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005323 -c "x509_verify_cert.*4b00" \
5324 -c "mbedtls_pk_verify.*4b00" \
5325 -c "mbedtls_ecdh_make_public.*4b00" \
5326 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005327
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005328requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5329run_test "EC restart: TLS, max_ops=1000 no client auth" \
5330 "$P_SRV" \
5331 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5332 debug_level=1 ec_max_ops=1000" \
5333 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005334 -c "x509_verify_cert.*4b00" \
5335 -c "mbedtls_pk_verify.*4b00" \
5336 -c "mbedtls_ecdh_make_public.*4b00" \
5337 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005338
5339requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5340run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5341 "$P_SRV psk=abc123" \
5342 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5343 psk=abc123 debug_level=1 ec_max_ops=1000" \
5344 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005345 -C "x509_verify_cert.*4b00" \
5346 -C "mbedtls_pk_verify.*4b00" \
5347 -C "mbedtls_ecdh_make_public.*4b00" \
5348 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005349
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005350# Tests of asynchronous private key support in SSL
5351
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005352requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005353run_test "SSL async private: sign, delay=0" \
5354 "$P_SRV \
5355 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005356 "$P_CLI" \
5357 0 \
5358 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005359 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005360
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005361requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005362run_test "SSL async private: sign, delay=1" \
5363 "$P_SRV \
5364 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005365 "$P_CLI" \
5366 0 \
5367 -s "Async sign callback: using key slot " \
5368 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005369 -s "Async resume (slot [0-9]): sign done, status=0"
5370
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005371requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5372run_test "SSL async private: sign, delay=2" \
5373 "$P_SRV \
5374 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5375 "$P_CLI" \
5376 0 \
5377 -s "Async sign callback: using key slot " \
5378 -U "Async sign callback: using key slot " \
5379 -s "Async resume (slot [0-9]): call 1 more times." \
5380 -s "Async resume (slot [0-9]): call 0 more times." \
5381 -s "Async resume (slot [0-9]): sign done, status=0"
5382
Gilles Peskined3268832018-04-26 06:23:59 +02005383# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5384# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5385requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5386requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5387run_test "SSL async private: sign, RSA, TLS 1.1" \
5388 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5389 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5390 "$P_CLI force_version=tls1_1" \
5391 0 \
5392 -s "Async sign callback: using key slot " \
5393 -s "Async resume (slot [0-9]): sign done, status=0"
5394
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005395requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005396run_test "SSL async private: sign, SNI" \
5397 "$P_SRV debug_level=3 \
5398 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5399 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5400 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5401 "$P_CLI server_name=polarssl.example" \
5402 0 \
5403 -s "Async sign callback: using key slot " \
5404 -s "Async resume (slot [0-9]): sign done, status=0" \
5405 -s "parse ServerName extension" \
5406 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5407 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5408
5409requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005410run_test "SSL async private: decrypt, delay=0" \
5411 "$P_SRV \
5412 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5413 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5414 0 \
5415 -s "Async decrypt callback: using key slot " \
5416 -s "Async resume (slot [0-9]): decrypt done, status=0"
5417
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005418requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005419run_test "SSL async private: decrypt, delay=1" \
5420 "$P_SRV \
5421 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5422 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5423 0 \
5424 -s "Async decrypt callback: using key slot " \
5425 -s "Async resume (slot [0-9]): call 0 more times." \
5426 -s "Async resume (slot [0-9]): decrypt done, status=0"
5427
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005428requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005429run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5430 "$P_SRV psk=abc123 \
5431 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5432 "$P_CLI psk=abc123 \
5433 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5434 0 \
5435 -s "Async decrypt callback: using key slot " \
5436 -s "Async resume (slot [0-9]): decrypt done, status=0"
5437
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005438requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005439run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5440 "$P_SRV psk=abc123 \
5441 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5442 "$P_CLI psk=abc123 \
5443 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5444 0 \
5445 -s "Async decrypt callback: using key slot " \
5446 -s "Async resume (slot [0-9]): call 0 more times." \
5447 -s "Async resume (slot [0-9]): decrypt done, status=0"
5448
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005449requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005450run_test "SSL async private: sign callback not present" \
5451 "$P_SRV \
5452 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5453 "$P_CLI; [ \$? -eq 1 ] &&
5454 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5455 0 \
5456 -S "Async sign callback" \
5457 -s "! mbedtls_ssl_handshake returned" \
5458 -s "The own private key or pre-shared key is not set, but needed" \
5459 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5460 -s "Successful connection"
5461
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005462requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005463run_test "SSL async private: decrypt callback not present" \
5464 "$P_SRV debug_level=1 \
5465 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5466 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5467 [ \$? -eq 1 ] && $P_CLI" \
5468 0 \
5469 -S "Async decrypt callback" \
5470 -s "! mbedtls_ssl_handshake returned" \
5471 -s "got no RSA private key" \
5472 -s "Async resume (slot [0-9]): sign done, status=0" \
5473 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005474
5475# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005476requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005477run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005478 "$P_SRV \
5479 async_operations=s async_private_delay1=1 \
5480 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5481 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005482 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5483 0 \
5484 -s "Async sign callback: using key slot 0," \
5485 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005486 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005487
5488# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005489requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005490run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005491 "$P_SRV \
5492 async_operations=s async_private_delay2=1 \
5493 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5494 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005495 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5496 0 \
5497 -s "Async sign callback: using key slot 0," \
5498 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005499 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005500
5501# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005502requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005503run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005504 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005505 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005506 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5507 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005508 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5509 0 \
5510 -s "Async sign callback: using key slot 1," \
5511 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005512 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005513
5514# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005515requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005516run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005517 "$P_SRV \
5518 async_operations=s async_private_delay1=1 \
5519 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5520 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005521 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5522 0 \
5523 -s "Async sign callback: no key matches this certificate."
5524
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005525requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005526run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005527 "$P_SRV \
5528 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5529 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005530 "$P_CLI" \
5531 1 \
5532 -s "Async sign callback: injected error" \
5533 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005534 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005535 -s "! mbedtls_ssl_handshake returned"
5536
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005537requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005538run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005539 "$P_SRV \
5540 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5541 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005542 "$P_CLI" \
5543 1 \
5544 -s "Async sign callback: using key slot " \
5545 -S "Async resume" \
5546 -s "Async cancel"
5547
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005548requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005549run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005550 "$P_SRV \
5551 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5552 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005553 "$P_CLI" \
5554 1 \
5555 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005556 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005557 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005558 -s "! mbedtls_ssl_handshake returned"
5559
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005560requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005561run_test "SSL async private: decrypt, error in start" \
5562 "$P_SRV \
5563 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5564 async_private_error=1" \
5565 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5566 1 \
5567 -s "Async decrypt callback: injected error" \
5568 -S "Async resume" \
5569 -S "Async cancel" \
5570 -s "! mbedtls_ssl_handshake returned"
5571
5572requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5573run_test "SSL async private: decrypt, cancel after start" \
5574 "$P_SRV \
5575 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5576 async_private_error=2" \
5577 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5578 1 \
5579 -s "Async decrypt callback: using key slot " \
5580 -S "Async resume" \
5581 -s "Async cancel"
5582
5583requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5584run_test "SSL async private: decrypt, error in resume" \
5585 "$P_SRV \
5586 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5587 async_private_error=3" \
5588 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5589 1 \
5590 -s "Async decrypt callback: using key slot " \
5591 -s "Async resume callback: decrypt done but injected error" \
5592 -S "Async cancel" \
5593 -s "! mbedtls_ssl_handshake returned"
5594
5595requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005596run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005597 "$P_SRV \
5598 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5599 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005600 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5601 0 \
5602 -s "Async cancel" \
5603 -s "! mbedtls_ssl_handshake returned" \
5604 -s "Async resume" \
5605 -s "Successful connection"
5606
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005607requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005608run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005609 "$P_SRV \
5610 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5611 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005612 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5613 0 \
5614 -s "! mbedtls_ssl_handshake returned" \
5615 -s "Async resume" \
5616 -s "Successful connection"
5617
5618# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005619requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005620run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005621 "$P_SRV \
5622 async_operations=s async_private_delay1=1 async_private_error=-2 \
5623 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5624 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005625 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5626 [ \$? -eq 1 ] &&
5627 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5628 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005629 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005630 -S "Async resume" \
5631 -s "Async cancel" \
5632 -s "! mbedtls_ssl_handshake returned" \
5633 -s "Async sign callback: no key matches this certificate." \
5634 -s "Successful connection"
5635
5636# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005637requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005638run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005639 "$P_SRV \
5640 async_operations=s async_private_delay1=1 async_private_error=-3 \
5641 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5642 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005643 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5644 [ \$? -eq 1 ] &&
5645 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5646 0 \
5647 -s "Async resume" \
5648 -s "! mbedtls_ssl_handshake returned" \
5649 -s "Async sign callback: no key matches this certificate." \
5650 -s "Successful connection"
5651
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005652requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005653requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005654run_test "SSL async private: renegotiation: client-initiated; sign" \
5655 "$P_SRV \
5656 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005657 exchanges=2 renegotiation=1" \
5658 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5659 0 \
5660 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005661 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005662
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005663requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005664requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005665run_test "SSL async private: renegotiation: server-initiated; sign" \
5666 "$P_SRV \
5667 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005668 exchanges=2 renegotiation=1 renegotiate=1" \
5669 "$P_CLI exchanges=2 renegotiation=1" \
5670 0 \
5671 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005672 -s "Async resume (slot [0-9]): sign done, status=0"
5673
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005674requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005675requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5676run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5677 "$P_SRV \
5678 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5679 exchanges=2 renegotiation=1" \
5680 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5681 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5682 0 \
5683 -s "Async decrypt callback: using key slot " \
5684 -s "Async resume (slot [0-9]): decrypt done, status=0"
5685
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005686requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005687requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5688run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5689 "$P_SRV \
5690 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5691 exchanges=2 renegotiation=1 renegotiate=1" \
5692 "$P_CLI exchanges=2 renegotiation=1 \
5693 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5694 0 \
5695 -s "Async decrypt callback: using key slot " \
5696 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005697
Ron Eldor58093c82018-06-28 13:22:05 +03005698# Tests for ECC extensions (rfc 4492)
5699
Ron Eldor643df7c2018-06-28 16:17:00 +03005700requires_config_enabled MBEDTLS_AES_C
5701requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5702requires_config_enabled MBEDTLS_SHA256_C
5703requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005704run_test "Force a non ECC ciphersuite in the client side" \
5705 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005706 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005707 0 \
5708 -C "client hello, adding supported_elliptic_curves extension" \
5709 -C "client hello, adding supported_point_formats extension" \
5710 -S "found supported elliptic curves extension" \
5711 -S "found supported point formats extension"
5712
Ron Eldor643df7c2018-06-28 16:17:00 +03005713requires_config_enabled MBEDTLS_AES_C
5714requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5715requires_config_enabled MBEDTLS_SHA256_C
5716requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005717run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005718 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005719 "$P_CLI debug_level=3" \
5720 0 \
5721 -C "found supported_point_formats extension" \
5722 -S "server hello, supported_point_formats extension"
5723
Ron Eldor643df7c2018-06-28 16:17:00 +03005724requires_config_enabled MBEDTLS_AES_C
5725requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5726requires_config_enabled MBEDTLS_SHA256_C
5727requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005728run_test "Force an ECC ciphersuite in the client side" \
5729 "$P_SRV debug_level=3" \
5730 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5731 0 \
5732 -c "client hello, adding supported_elliptic_curves extension" \
5733 -c "client hello, adding supported_point_formats extension" \
5734 -s "found supported elliptic curves extension" \
5735 -s "found supported point formats extension"
5736
Ron Eldor643df7c2018-06-28 16:17:00 +03005737requires_config_enabled MBEDTLS_AES_C
5738requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5739requires_config_enabled MBEDTLS_SHA256_C
5740requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005741run_test "Force an ECC ciphersuite in the server side" \
5742 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5743 "$P_CLI debug_level=3" \
5744 0 \
5745 -c "found supported_point_formats extension" \
5746 -s "server hello, supported_point_formats extension"
5747
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005748# Tests for DTLS HelloVerifyRequest
5749
5750run_test "DTLS cookie: enabled" \
5751 "$P_SRV dtls=1 debug_level=2" \
5752 "$P_CLI dtls=1 debug_level=2" \
5753 0 \
5754 -s "cookie verification failed" \
5755 -s "cookie verification passed" \
5756 -S "cookie verification skipped" \
5757 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005758 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005759 -S "SSL - The requested feature is not available"
5760
5761run_test "DTLS cookie: disabled" \
5762 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5763 "$P_CLI dtls=1 debug_level=2" \
5764 0 \
5765 -S "cookie verification failed" \
5766 -S "cookie verification passed" \
5767 -s "cookie verification skipped" \
5768 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005769 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005770 -S "SSL - The requested feature is not available"
5771
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005772run_test "DTLS cookie: default (failing)" \
5773 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5774 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5775 1 \
5776 -s "cookie verification failed" \
5777 -S "cookie verification passed" \
5778 -S "cookie verification skipped" \
5779 -C "received hello verify request" \
5780 -S "hello verification requested" \
5781 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005782
5783requires_ipv6
5784run_test "DTLS cookie: enabled, IPv6" \
5785 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5786 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5787 0 \
5788 -s "cookie verification failed" \
5789 -s "cookie verification passed" \
5790 -S "cookie verification skipped" \
5791 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005792 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005793 -S "SSL - The requested feature is not available"
5794
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005795run_test "DTLS cookie: enabled, nbio" \
5796 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5797 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5798 0 \
5799 -s "cookie verification failed" \
5800 -s "cookie verification passed" \
5801 -S "cookie verification skipped" \
5802 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005803 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005804 -S "SSL - The requested feature is not available"
5805
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005806# Tests for client reconnecting from the same port with DTLS
5807
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005808not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005809run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005810 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5811 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005812 0 \
5813 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005814 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005815 -S "Client initiated reconnection from same port"
5816
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005817not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005818run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005819 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5820 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000 reconnect_hard=1" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005821 0 \
5822 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005823 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005824 -s "Client initiated reconnection from same port"
5825
Paul Bakker362689d2016-05-13 10:33:25 +01005826not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5827run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005828 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5829 "$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 +02005830 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005831 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005832 -s "Client initiated reconnection from same port"
5833
Paul Bakker362689d2016-05-13 10:33:25 +01005834only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5835run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5836 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5837 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5838 0 \
5839 -S "The operation timed out" \
5840 -s "Client initiated reconnection from same port"
5841
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005842run_test "DTLS client reconnect from same port: no cookies" \
5843 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005844 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5845 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005846 -s "The operation timed out" \
5847 -S "Client initiated reconnection from same port"
5848
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005849run_test "DTLS client reconnect from same port: attacker-injected" \
5850 -p "$P_PXY inject_clihlo=1" \
5851 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5852 "$P_CLI dtls=1 exchanges=2" \
5853 0 \
5854 -s "possible client reconnect from the same port" \
5855 -S "Client initiated reconnection from same port"
5856
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005857# Tests for various cases of client authentication with DTLS
5858# (focused on handshake flows and message parsing)
5859
5860run_test "DTLS client auth: required" \
5861 "$P_SRV dtls=1 auth_mode=required" \
5862 "$P_CLI dtls=1" \
5863 0 \
5864 -s "Verifying peer X.509 certificate... ok"
5865
5866run_test "DTLS client auth: optional, client has no cert" \
5867 "$P_SRV dtls=1 auth_mode=optional" \
5868 "$P_CLI dtls=1 crt_file=none key_file=none" \
5869 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005870 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005871
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005872run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005873 "$P_SRV dtls=1 auth_mode=none" \
5874 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5875 0 \
5876 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005877 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005878
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005879run_test "DTLS wrong PSK: badmac alert" \
5880 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5881 "$P_CLI dtls=1 psk=abc124" \
5882 1 \
5883 -s "SSL - Verification of the message MAC failed" \
5884 -c "SSL - A fatal alert message was received from our peer"
5885
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005886# Tests for receiving fragmented handshake messages with DTLS
5887
5888requires_gnutls
5889run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5890 "$G_SRV -u --mtu 2048 -a" \
5891 "$P_CLI dtls=1 debug_level=2" \
5892 0 \
5893 -C "found fragmented DTLS handshake message" \
5894 -C "error"
5895
5896requires_gnutls
5897run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5898 "$G_SRV -u --mtu 512" \
5899 "$P_CLI dtls=1 debug_level=2" \
5900 0 \
5901 -c "found fragmented DTLS handshake message" \
5902 -C "error"
5903
5904requires_gnutls
5905run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5906 "$G_SRV -u --mtu 128" \
5907 "$P_CLI dtls=1 debug_level=2" \
5908 0 \
5909 -c "found fragmented DTLS handshake message" \
5910 -C "error"
5911
5912requires_gnutls
5913run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5914 "$G_SRV -u --mtu 128" \
5915 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5916 0 \
5917 -c "found fragmented DTLS handshake message" \
5918 -C "error"
5919
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005920requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005921requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005922run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5923 "$G_SRV -u --mtu 256" \
5924 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5925 0 \
5926 -c "found fragmented DTLS handshake message" \
5927 -c "client hello, adding renegotiation extension" \
5928 -c "found renegotiation extension" \
5929 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005930 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005931 -C "error" \
5932 -s "Extra-header:"
5933
5934requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005935requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005936run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5937 "$G_SRV -u --mtu 256" \
5938 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5939 0 \
5940 -c "found fragmented DTLS handshake message" \
5941 -c "client hello, adding renegotiation extension" \
5942 -c "found renegotiation extension" \
5943 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005944 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005945 -C "error" \
5946 -s "Extra-header:"
5947
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005948run_test "DTLS reassembly: no fragmentation (openssl server)" \
5949 "$O_SRV -dtls1 -mtu 2048" \
5950 "$P_CLI dtls=1 debug_level=2" \
5951 0 \
5952 -C "found fragmented DTLS handshake message" \
5953 -C "error"
5954
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005955run_test "DTLS reassembly: some fragmentation (openssl server)" \
5956 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005957 "$P_CLI dtls=1 debug_level=2" \
5958 0 \
5959 -c "found fragmented DTLS handshake message" \
5960 -C "error"
5961
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005962run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005963 "$O_SRV -dtls1 -mtu 256" \
5964 "$P_CLI dtls=1 debug_level=2" \
5965 0 \
5966 -c "found fragmented DTLS handshake message" \
5967 -C "error"
5968
5969run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5970 "$O_SRV -dtls1 -mtu 256" \
5971 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5972 0 \
5973 -c "found fragmented DTLS handshake message" \
5974 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005975
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005976# Tests for sending fragmented handshake messages with DTLS
5977#
5978# Use client auth when we need the client to send large messages,
5979# and use large cert chains on both sides too (the long chains we have all use
5980# both RSA and ECDSA, but ideally we should have long chains with either).
5981# Sizes reached (UDP payload):
5982# - 2037B for server certificate
5983# - 1542B for client certificate
5984# - 1013B for newsessionticket
5985# - all others below 512B
5986# All those tests assume MAX_CONTENT_LEN is at least 2048
5987
5988requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5989requires_config_enabled MBEDTLS_RSA_C
5990requires_config_enabled MBEDTLS_ECDSA_C
5991requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
5992run_test "DTLS fragmenting: none (for reference)" \
5993 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5994 crt_file=data_files/server7_int-ca.crt \
5995 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005996 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005997 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005998 "$P_CLI dtls=1 debug_level=2 \
5999 crt_file=data_files/server8_int-ca2.crt \
6000 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006001 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006002 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006003 0 \
6004 -S "found fragmented DTLS handshake message" \
6005 -C "found fragmented DTLS handshake message" \
6006 -C "error"
6007
6008requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6009requires_config_enabled MBEDTLS_RSA_C
6010requires_config_enabled MBEDTLS_ECDSA_C
6011requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006012run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006013 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6014 crt_file=data_files/server7_int-ca.crt \
6015 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006016 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006017 max_frag_len=1024" \
6018 "$P_CLI dtls=1 debug_level=2 \
6019 crt_file=data_files/server8_int-ca2.crt \
6020 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006021 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006022 max_frag_len=2048" \
6023 0 \
6024 -S "found fragmented DTLS handshake message" \
6025 -c "found fragmented DTLS handshake message" \
6026 -C "error"
6027
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006028# With the MFL extension, the server has no way of forcing
6029# the client to not exceed a certain MTU; hence, the following
6030# test can't be replicated with an MTU proxy such as the one
6031# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006032requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6033requires_config_enabled MBEDTLS_RSA_C
6034requires_config_enabled MBEDTLS_ECDSA_C
6035requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006036run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006037 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6038 crt_file=data_files/server7_int-ca.crt \
6039 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006040 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006041 max_frag_len=512" \
6042 "$P_CLI dtls=1 debug_level=2 \
6043 crt_file=data_files/server8_int-ca2.crt \
6044 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006045 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006046 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006047 0 \
6048 -S "found fragmented DTLS handshake message" \
6049 -c "found fragmented DTLS handshake message" \
6050 -C "error"
6051
6052requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6053requires_config_enabled MBEDTLS_RSA_C
6054requires_config_enabled MBEDTLS_ECDSA_C
6055requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006056run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006057 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6058 crt_file=data_files/server7_int-ca.crt \
6059 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006060 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006061 max_frag_len=2048" \
6062 "$P_CLI dtls=1 debug_level=2 \
6063 crt_file=data_files/server8_int-ca2.crt \
6064 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006065 hs_timeout=2500-60000 \
6066 max_frag_len=1024" \
6067 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006068 -S "found fragmented DTLS handshake message" \
6069 -c "found fragmented DTLS handshake message" \
6070 -C "error"
6071
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006072# While not required by the standard defining the MFL extension
6073# (according to which it only applies to records, not to datagrams),
6074# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6075# as otherwise there wouldn't be any means to communicate MTU restrictions
6076# to the peer.
6077# The next test checks that no datagrams significantly larger than the
6078# negotiated MFL are sent.
6079requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6080requires_config_enabled MBEDTLS_RSA_C
6081requires_config_enabled MBEDTLS_ECDSA_C
6082requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6083run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006084 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006085 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6086 crt_file=data_files/server7_int-ca.crt \
6087 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006088 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006089 max_frag_len=2048" \
6090 "$P_CLI dtls=1 debug_level=2 \
6091 crt_file=data_files/server8_int-ca2.crt \
6092 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006093 hs_timeout=2500-60000 \
6094 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006095 0 \
6096 -S "found fragmented DTLS handshake message" \
6097 -c "found fragmented DTLS handshake message" \
6098 -C "error"
6099
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006100requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6101requires_config_enabled MBEDTLS_RSA_C
6102requires_config_enabled MBEDTLS_ECDSA_C
6103requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006104run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006105 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6106 crt_file=data_files/server7_int-ca.crt \
6107 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006108 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006109 max_frag_len=2048" \
6110 "$P_CLI dtls=1 debug_level=2 \
6111 crt_file=data_files/server8_int-ca2.crt \
6112 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006113 hs_timeout=2500-60000 \
6114 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006115 0 \
6116 -s "found fragmented DTLS handshake message" \
6117 -c "found fragmented DTLS handshake message" \
6118 -C "error"
6119
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006120# While not required by the standard defining the MFL extension
6121# (according to which it only applies to records, not to datagrams),
6122# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6123# as otherwise there wouldn't be any means to communicate MTU restrictions
6124# to the peer.
6125# The next test checks that no datagrams significantly larger than the
6126# negotiated MFL are sent.
6127requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6128requires_config_enabled MBEDTLS_RSA_C
6129requires_config_enabled MBEDTLS_ECDSA_C
6130requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6131run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006132 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006133 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6134 crt_file=data_files/server7_int-ca.crt \
6135 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006136 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006137 max_frag_len=2048" \
6138 "$P_CLI dtls=1 debug_level=2 \
6139 crt_file=data_files/server8_int-ca2.crt \
6140 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006141 hs_timeout=2500-60000 \
6142 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006143 0 \
6144 -s "found fragmented DTLS handshake message" \
6145 -c "found fragmented DTLS handshake message" \
6146 -C "error"
6147
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006148requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6149requires_config_enabled MBEDTLS_RSA_C
6150requires_config_enabled MBEDTLS_ECDSA_C
6151run_test "DTLS fragmenting: none (for reference) (MTU)" \
6152 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6153 crt_file=data_files/server7_int-ca.crt \
6154 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006155 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006156 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006157 "$P_CLI dtls=1 debug_level=2 \
6158 crt_file=data_files/server8_int-ca2.crt \
6159 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006160 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006161 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006162 0 \
6163 -S "found fragmented DTLS handshake message" \
6164 -C "found fragmented DTLS handshake message" \
6165 -C "error"
6166
6167requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6168requires_config_enabled MBEDTLS_RSA_C
6169requires_config_enabled MBEDTLS_ECDSA_C
6170run_test "DTLS fragmenting: client (MTU)" \
6171 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6172 crt_file=data_files/server7_int-ca.crt \
6173 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006174 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006175 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006176 "$P_CLI dtls=1 debug_level=2 \
6177 crt_file=data_files/server8_int-ca2.crt \
6178 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006179 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006180 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006181 0 \
6182 -s "found fragmented DTLS handshake message" \
6183 -C "found fragmented DTLS handshake message" \
6184 -C "error"
6185
6186requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6187requires_config_enabled MBEDTLS_RSA_C
6188requires_config_enabled MBEDTLS_ECDSA_C
6189run_test "DTLS fragmenting: server (MTU)" \
6190 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6191 crt_file=data_files/server7_int-ca.crt \
6192 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006193 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006194 mtu=512" \
6195 "$P_CLI dtls=1 debug_level=2 \
6196 crt_file=data_files/server8_int-ca2.crt \
6197 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006198 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006199 mtu=2048" \
6200 0 \
6201 -S "found fragmented DTLS handshake message" \
6202 -c "found fragmented DTLS handshake message" \
6203 -C "error"
6204
6205requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6206requires_config_enabled MBEDTLS_RSA_C
6207requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006208run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006209 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006210 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6211 crt_file=data_files/server7_int-ca.crt \
6212 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006213 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006214 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006215 "$P_CLI dtls=1 debug_level=2 \
6216 crt_file=data_files/server8_int-ca2.crt \
6217 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006218 hs_timeout=2500-60000 \
6219 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006220 0 \
6221 -s "found fragmented DTLS handshake message" \
6222 -c "found fragmented DTLS handshake message" \
6223 -C "error"
6224
Andrzej Kurek77826052018-10-11 07:34:08 -04006225# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006226requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6227requires_config_enabled MBEDTLS_RSA_C
6228requires_config_enabled MBEDTLS_ECDSA_C
6229requires_config_enabled MBEDTLS_SHA256_C
6230requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6231requires_config_enabled MBEDTLS_AES_C
6232requires_config_enabled MBEDTLS_GCM_C
6233run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006234 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006235 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6236 crt_file=data_files/server7_int-ca.crt \
6237 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006238 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006239 mtu=512" \
6240 "$P_CLI dtls=1 debug_level=2 \
6241 crt_file=data_files/server8_int-ca2.crt \
6242 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006243 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6244 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006245 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006246 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006247 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006248 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006249 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006250
Andrzej Kurek7311c782018-10-11 06:49:41 -04006251# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006252# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006253# The ratio of max/min timeout should ideally equal 4 to accept two
6254# retransmissions, but in some cases (like both the server and client using
6255# fragmentation and auto-reduction) an extra retransmission might occur,
6256# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006257not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006258requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6259requires_config_enabled MBEDTLS_RSA_C
6260requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006261requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6262requires_config_enabled MBEDTLS_AES_C
6263requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006264run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6265 -p "$P_PXY mtu=508" \
6266 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6267 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006268 key_file=data_files/server7.key \
6269 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006270 "$P_CLI dtls=1 debug_level=2 \
6271 crt_file=data_files/server8_int-ca2.crt \
6272 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006273 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6274 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006275 0 \
6276 -s "found fragmented DTLS handshake message" \
6277 -c "found fragmented DTLS handshake message" \
6278 -C "error"
6279
Andrzej Kurek77826052018-10-11 07:34:08 -04006280# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006281only_with_valgrind
6282requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6283requires_config_enabled MBEDTLS_RSA_C
6284requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006285requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6286requires_config_enabled MBEDTLS_AES_C
6287requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006288run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6289 -p "$P_PXY mtu=508" \
6290 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6291 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006292 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006293 hs_timeout=250-10000" \
6294 "$P_CLI dtls=1 debug_level=2 \
6295 crt_file=data_files/server8_int-ca2.crt \
6296 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006297 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006298 hs_timeout=250-10000" \
6299 0 \
6300 -s "found fragmented DTLS handshake message" \
6301 -c "found fragmented DTLS handshake message" \
6302 -C "error"
6303
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006304# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
Manuel Pégourié-Gonnard3d183ce2018-08-22 09:56:22 +02006305# OTOH the client might resend if the server is to slow to reset after sending
6306# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006307not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006308requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6309requires_config_enabled MBEDTLS_RSA_C
6310requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006311run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006312 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006313 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6314 crt_file=data_files/server7_int-ca.crt \
6315 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006316 hs_timeout=10000-60000 \
6317 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006318 "$P_CLI dtls=1 debug_level=2 \
6319 crt_file=data_files/server8_int-ca2.crt \
6320 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006321 hs_timeout=10000-60000 \
6322 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006323 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006324 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006325 -s "found fragmented DTLS handshake message" \
6326 -c "found fragmented DTLS handshake message" \
6327 -C "error"
6328
Andrzej Kurek77826052018-10-11 07:34:08 -04006329# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006330# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6331# OTOH the client might resend if the server is to slow to reset after sending
6332# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006333not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006334requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6335requires_config_enabled MBEDTLS_RSA_C
6336requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006337requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6338requires_config_enabled MBEDTLS_AES_C
6339requires_config_enabled MBEDTLS_GCM_C
6340run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006341 -p "$P_PXY mtu=512" \
6342 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6343 crt_file=data_files/server7_int-ca.crt \
6344 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006345 hs_timeout=10000-60000 \
6346 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006347 "$P_CLI dtls=1 debug_level=2 \
6348 crt_file=data_files/server8_int-ca2.crt \
6349 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006350 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6351 hs_timeout=10000-60000 \
6352 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006353 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006354 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006355 -s "found fragmented DTLS handshake message" \
6356 -c "found fragmented DTLS handshake message" \
6357 -C "error"
6358
Andrzej Kurek7311c782018-10-11 06:49:41 -04006359not_with_valgrind # spurious autoreduction due to timeout
6360requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6361requires_config_enabled MBEDTLS_RSA_C
6362requires_config_enabled MBEDTLS_ECDSA_C
6363run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006364 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006365 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6366 crt_file=data_files/server7_int-ca.crt \
6367 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006368 hs_timeout=10000-60000 \
6369 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006370 "$P_CLI dtls=1 debug_level=2 \
6371 crt_file=data_files/server8_int-ca2.crt \
6372 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006373 hs_timeout=10000-60000 \
6374 mtu=1024 nbio=2" \
6375 0 \
6376 -S "autoreduction" \
6377 -s "found fragmented DTLS handshake message" \
6378 -c "found fragmented DTLS handshake message" \
6379 -C "error"
6380
Andrzej Kurek77826052018-10-11 07:34:08 -04006381# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006382not_with_valgrind # spurious autoreduction due to timeout
6383requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6384requires_config_enabled MBEDTLS_RSA_C
6385requires_config_enabled MBEDTLS_ECDSA_C
6386requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6387requires_config_enabled MBEDTLS_AES_C
6388requires_config_enabled MBEDTLS_GCM_C
6389run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6390 -p "$P_PXY mtu=512" \
6391 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6392 crt_file=data_files/server7_int-ca.crt \
6393 key_file=data_files/server7.key \
6394 hs_timeout=10000-60000 \
6395 mtu=512 nbio=2" \
6396 "$P_CLI dtls=1 debug_level=2 \
6397 crt_file=data_files/server8_int-ca2.crt \
6398 key_file=data_files/server8.key \
6399 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6400 hs_timeout=10000-60000 \
6401 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006402 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006403 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006404 -s "found fragmented DTLS handshake message" \
6405 -c "found fragmented DTLS handshake message" \
6406 -C "error"
6407
Andrzej Kurek77826052018-10-11 07:34:08 -04006408# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006409# This ensures things still work after session_reset().
6410# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006411# Since we don't support reading fragmented ClientHello yet,
6412# up the MTU to 1450 (larger than ClientHello with session ticket,
6413# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006414# An autoreduction on the client-side might happen if the server is
6415# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006416# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006417# resumed listening, which would result in a spurious autoreduction.
6418not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006419requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6420requires_config_enabled MBEDTLS_RSA_C
6421requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006422requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6423requires_config_enabled MBEDTLS_AES_C
6424requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006425run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6426 -p "$P_PXY mtu=1450" \
6427 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6428 crt_file=data_files/server7_int-ca.crt \
6429 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006430 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006431 mtu=1450" \
6432 "$P_CLI dtls=1 debug_level=2 \
6433 crt_file=data_files/server8_int-ca2.crt \
6434 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006435 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006436 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006437 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006438 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006439 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006440 -s "found fragmented DTLS handshake message" \
6441 -c "found fragmented DTLS handshake message" \
6442 -C "error"
6443
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006444# An autoreduction on the client-side might happen if the server is
6445# slow to reset, therefore omitting '-C "autoreduction"' below.
6446not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006447requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6448requires_config_enabled MBEDTLS_RSA_C
6449requires_config_enabled MBEDTLS_ECDSA_C
6450requires_config_enabled MBEDTLS_SHA256_C
6451requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6452requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6453requires_config_enabled MBEDTLS_CHACHAPOLY_C
6454run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6455 -p "$P_PXY mtu=512" \
6456 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6457 crt_file=data_files/server7_int-ca.crt \
6458 key_file=data_files/server7.key \
6459 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006460 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006461 mtu=512" \
6462 "$P_CLI dtls=1 debug_level=2 \
6463 crt_file=data_files/server8_int-ca2.crt \
6464 key_file=data_files/server8.key \
6465 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006466 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006467 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006468 mtu=512" \
6469 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006470 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006471 -s "found fragmented DTLS handshake message" \
6472 -c "found fragmented DTLS handshake message" \
6473 -C "error"
6474
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006475# An autoreduction on the client-side might happen if the server is
6476# slow to reset, therefore omitting '-C "autoreduction"' below.
6477not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006478requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6479requires_config_enabled MBEDTLS_RSA_C
6480requires_config_enabled MBEDTLS_ECDSA_C
6481requires_config_enabled MBEDTLS_SHA256_C
6482requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6483requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6484requires_config_enabled MBEDTLS_AES_C
6485requires_config_enabled MBEDTLS_GCM_C
6486run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6487 -p "$P_PXY mtu=512" \
6488 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6489 crt_file=data_files/server7_int-ca.crt \
6490 key_file=data_files/server7.key \
6491 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006492 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006493 mtu=512" \
6494 "$P_CLI dtls=1 debug_level=2 \
6495 crt_file=data_files/server8_int-ca2.crt \
6496 key_file=data_files/server8.key \
6497 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006498 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006499 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006500 mtu=512" \
6501 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006502 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006503 -s "found fragmented DTLS handshake message" \
6504 -c "found fragmented DTLS handshake message" \
6505 -C "error"
6506
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006507# An autoreduction on the client-side might happen if the server is
6508# slow to reset, therefore omitting '-C "autoreduction"' below.
6509not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006510requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6511requires_config_enabled MBEDTLS_RSA_C
6512requires_config_enabled MBEDTLS_ECDSA_C
6513requires_config_enabled MBEDTLS_SHA256_C
6514requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6515requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6516requires_config_enabled MBEDTLS_AES_C
6517requires_config_enabled MBEDTLS_CCM_C
6518run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006519 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006520 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6521 crt_file=data_files/server7_int-ca.crt \
6522 key_file=data_files/server7.key \
6523 exchanges=2 renegotiation=1 \
6524 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006525 hs_timeout=10000-60000 \
6526 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006527 "$P_CLI dtls=1 debug_level=2 \
6528 crt_file=data_files/server8_int-ca2.crt \
6529 key_file=data_files/server8.key \
6530 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006531 hs_timeout=10000-60000 \
6532 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006533 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006534 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006535 -s "found fragmented DTLS handshake message" \
6536 -c "found fragmented DTLS handshake message" \
6537 -C "error"
6538
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006539# An autoreduction on the client-side might happen if the server is
6540# slow to reset, therefore omitting '-C "autoreduction"' below.
6541not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006542requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6543requires_config_enabled MBEDTLS_RSA_C
6544requires_config_enabled MBEDTLS_ECDSA_C
6545requires_config_enabled MBEDTLS_SHA256_C
6546requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6547requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6548requires_config_enabled MBEDTLS_AES_C
6549requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6550requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6551run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006552 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006553 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6554 crt_file=data_files/server7_int-ca.crt \
6555 key_file=data_files/server7.key \
6556 exchanges=2 renegotiation=1 \
6557 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006558 hs_timeout=10000-60000 \
6559 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006560 "$P_CLI dtls=1 debug_level=2 \
6561 crt_file=data_files/server8_int-ca2.crt \
6562 key_file=data_files/server8.key \
6563 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006564 hs_timeout=10000-60000 \
6565 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006566 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006567 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006568 -s "found fragmented DTLS handshake message" \
6569 -c "found fragmented DTLS handshake message" \
6570 -C "error"
6571
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006572# An autoreduction on the client-side might happen if the server is
6573# slow to reset, therefore omitting '-C "autoreduction"' below.
6574not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006575requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6576requires_config_enabled MBEDTLS_RSA_C
6577requires_config_enabled MBEDTLS_ECDSA_C
6578requires_config_enabled MBEDTLS_SHA256_C
6579requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6580requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6581requires_config_enabled MBEDTLS_AES_C
6582requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6583run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006584 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006585 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6586 crt_file=data_files/server7_int-ca.crt \
6587 key_file=data_files/server7.key \
6588 exchanges=2 renegotiation=1 \
6589 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006590 hs_timeout=10000-60000 \
6591 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006592 "$P_CLI dtls=1 debug_level=2 \
6593 crt_file=data_files/server8_int-ca2.crt \
6594 key_file=data_files/server8.key \
6595 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006596 hs_timeout=10000-60000 \
6597 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006598 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006599 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006600 -s "found fragmented DTLS handshake message" \
6601 -c "found fragmented DTLS handshake message" \
6602 -C "error"
6603
Andrzej Kurek77826052018-10-11 07:34:08 -04006604# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006605requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6606requires_config_enabled MBEDTLS_RSA_C
6607requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006608requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6609requires_config_enabled MBEDTLS_AES_C
6610requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006611client_needs_more_time 2
6612run_test "DTLS fragmenting: proxy MTU + 3d" \
6613 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006614 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006615 crt_file=data_files/server7_int-ca.crt \
6616 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006617 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006618 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006619 crt_file=data_files/server8_int-ca2.crt \
6620 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006621 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006622 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006623 0 \
6624 -s "found fragmented DTLS handshake message" \
6625 -c "found fragmented DTLS handshake message" \
6626 -C "error"
6627
Andrzej Kurek77826052018-10-11 07:34:08 -04006628# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006629requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6630requires_config_enabled MBEDTLS_RSA_C
6631requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006632requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6633requires_config_enabled MBEDTLS_AES_C
6634requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006635client_needs_more_time 2
6636run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6637 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6638 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6639 crt_file=data_files/server7_int-ca.crt \
6640 key_file=data_files/server7.key \
6641 hs_timeout=250-10000 mtu=512 nbio=2" \
6642 "$P_CLI dtls=1 debug_level=2 \
6643 crt_file=data_files/server8_int-ca2.crt \
6644 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006645 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006646 hs_timeout=250-10000 mtu=512 nbio=2" \
6647 0 \
6648 -s "found fragmented DTLS handshake message" \
6649 -c "found fragmented DTLS handshake message" \
6650 -C "error"
6651
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006652# interop tests for DTLS fragmentating with reliable connection
6653#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006654# here and below we just want to test that the we fragment in a way that
6655# pleases other implementations, so we don't need the peer to fragment
6656requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6657requires_config_enabled MBEDTLS_RSA_C
6658requires_config_enabled MBEDTLS_ECDSA_C
6659requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006660requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006661run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6662 "$G_SRV -u" \
6663 "$P_CLI dtls=1 debug_level=2 \
6664 crt_file=data_files/server8_int-ca2.crt \
6665 key_file=data_files/server8.key \
6666 mtu=512 force_version=dtls1_2" \
6667 0 \
6668 -c "fragmenting handshake message" \
6669 -C "error"
6670
6671requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6672requires_config_enabled MBEDTLS_RSA_C
6673requires_config_enabled MBEDTLS_ECDSA_C
6674requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006675requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006676run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6677 "$G_SRV -u" \
6678 "$P_CLI dtls=1 debug_level=2 \
6679 crt_file=data_files/server8_int-ca2.crt \
6680 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006681 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006682 0 \
6683 -c "fragmenting handshake message" \
6684 -C "error"
6685
Hanno Beckerb9a00862018-08-28 10:20:22 +01006686# We use --insecure for the GnuTLS client because it expects
6687# the hostname / IP it connects to to be the name used in the
6688# certificate obtained from the server. Here, however, it
6689# connects to 127.0.0.1 while our test certificates use 'localhost'
6690# as the server name in the certificate. This will make the
6691# certifiate validation fail, but passing --insecure makes
6692# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006693requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6694requires_config_enabled MBEDTLS_RSA_C
6695requires_config_enabled MBEDTLS_ECDSA_C
6696requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006697requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006698requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006699run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006700 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006701 crt_file=data_files/server7_int-ca.crt \
6702 key_file=data_files/server7.key \
6703 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006704 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006705 0 \
6706 -s "fragmenting handshake message"
6707
Hanno Beckerb9a00862018-08-28 10:20:22 +01006708# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006709requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6710requires_config_enabled MBEDTLS_RSA_C
6711requires_config_enabled MBEDTLS_ECDSA_C
6712requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006713requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006714requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006715run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006716 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006717 crt_file=data_files/server7_int-ca.crt \
6718 key_file=data_files/server7.key \
6719 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006720 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006721 0 \
6722 -s "fragmenting handshake message"
6723
6724requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6725requires_config_enabled MBEDTLS_RSA_C
6726requires_config_enabled MBEDTLS_ECDSA_C
6727requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6728run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6729 "$O_SRV -dtls1_2 -verify 10" \
6730 "$P_CLI dtls=1 debug_level=2 \
6731 crt_file=data_files/server8_int-ca2.crt \
6732 key_file=data_files/server8.key \
6733 mtu=512 force_version=dtls1_2" \
6734 0 \
6735 -c "fragmenting handshake message" \
6736 -C "error"
6737
6738requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6739requires_config_enabled MBEDTLS_RSA_C
6740requires_config_enabled MBEDTLS_ECDSA_C
6741requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6742run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6743 "$O_SRV -dtls1 -verify 10" \
6744 "$P_CLI dtls=1 debug_level=2 \
6745 crt_file=data_files/server8_int-ca2.crt \
6746 key_file=data_files/server8.key \
6747 mtu=512 force_version=dtls1" \
6748 0 \
6749 -c "fragmenting handshake message" \
6750 -C "error"
6751
6752requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6753requires_config_enabled MBEDTLS_RSA_C
6754requires_config_enabled MBEDTLS_ECDSA_C
6755requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6756run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6757 "$P_SRV dtls=1 debug_level=2 \
6758 crt_file=data_files/server7_int-ca.crt \
6759 key_file=data_files/server7.key \
6760 mtu=512 force_version=dtls1_2" \
6761 "$O_CLI -dtls1_2" \
6762 0 \
6763 -s "fragmenting handshake message"
6764
6765requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6766requires_config_enabled MBEDTLS_RSA_C
6767requires_config_enabled MBEDTLS_ECDSA_C
6768requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6769run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6770 "$P_SRV dtls=1 debug_level=2 \
6771 crt_file=data_files/server7_int-ca.crt \
6772 key_file=data_files/server7.key \
6773 mtu=512 force_version=dtls1" \
6774 "$O_CLI -dtls1" \
6775 0 \
6776 -s "fragmenting handshake message"
6777
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006778# interop tests for DTLS fragmentating with unreliable connection
6779#
6780# again we just want to test that the we fragment in a way that
6781# pleases other implementations, so we don't need the peer to fragment
6782requires_gnutls_next
6783requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6784requires_config_enabled MBEDTLS_RSA_C
6785requires_config_enabled MBEDTLS_ECDSA_C
6786requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006787client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006788run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6789 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6790 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006791 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006792 crt_file=data_files/server8_int-ca2.crt \
6793 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006794 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006795 0 \
6796 -c "fragmenting handshake message" \
6797 -C "error"
6798
6799requires_gnutls_next
6800requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6801requires_config_enabled MBEDTLS_RSA_C
6802requires_config_enabled MBEDTLS_ECDSA_C
6803requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006804client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006805run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6806 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6807 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006808 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006809 crt_file=data_files/server8_int-ca2.crt \
6810 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006811 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006812 0 \
6813 -c "fragmenting handshake message" \
6814 -C "error"
6815
k-stachowiakabb843e2019-02-18 16:14:03 +01006816requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006817requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6818requires_config_enabled MBEDTLS_RSA_C
6819requires_config_enabled MBEDTLS_ECDSA_C
6820requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6821client_needs_more_time 4
6822run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6823 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6824 "$P_SRV dtls=1 debug_level=2 \
6825 crt_file=data_files/server7_int-ca.crt \
6826 key_file=data_files/server7.key \
6827 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006828 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006829 0 \
6830 -s "fragmenting handshake message"
6831
k-stachowiakabb843e2019-02-18 16:14:03 +01006832requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006833requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6834requires_config_enabled MBEDTLS_RSA_C
6835requires_config_enabled MBEDTLS_ECDSA_C
6836requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6837client_needs_more_time 4
6838run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6839 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6840 "$P_SRV dtls=1 debug_level=2 \
6841 crt_file=data_files/server7_int-ca.crt \
6842 key_file=data_files/server7.key \
6843 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006844 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006845 0 \
6846 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006847
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006848## Interop test with OpenSSL might trigger a bug in recent versions (including
6849## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006850## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006851## They should be re-enabled once a fixed version of OpenSSL is available
6852## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006853skip_next_test
6854requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6855requires_config_enabled MBEDTLS_RSA_C
6856requires_config_enabled MBEDTLS_ECDSA_C
6857requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6858client_needs_more_time 4
6859run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6860 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6861 "$O_SRV -dtls1_2 -verify 10" \
6862 "$P_CLI dtls=1 debug_level=2 \
6863 crt_file=data_files/server8_int-ca2.crt \
6864 key_file=data_files/server8.key \
6865 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6866 0 \
6867 -c "fragmenting handshake message" \
6868 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006869
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006870skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006871requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6872requires_config_enabled MBEDTLS_RSA_C
6873requires_config_enabled MBEDTLS_ECDSA_C
6874requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006875client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006876run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6877 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006878 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006879 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006880 crt_file=data_files/server8_int-ca2.crt \
6881 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006882 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006883 0 \
6884 -c "fragmenting handshake message" \
6885 -C "error"
6886
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006887skip_next_test
6888requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6889requires_config_enabled MBEDTLS_RSA_C
6890requires_config_enabled MBEDTLS_ECDSA_C
6891requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6892client_needs_more_time 4
6893run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6894 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6895 "$P_SRV dtls=1 debug_level=2 \
6896 crt_file=data_files/server7_int-ca.crt \
6897 key_file=data_files/server7.key \
6898 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6899 "$O_CLI -dtls1_2" \
6900 0 \
6901 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006902
6903# -nbio is added to prevent s_client from blocking in case of duplicated
6904# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006905skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006906requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6907requires_config_enabled MBEDTLS_RSA_C
6908requires_config_enabled MBEDTLS_ECDSA_C
6909requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006910client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006911run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6912 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006913 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006914 crt_file=data_files/server7_int-ca.crt \
6915 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006916 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006917 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006918 0 \
6919 -s "fragmenting handshake message"
6920
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006921# Tests for specific things with "unreliable" UDP connection
6922
6923not_with_valgrind # spurious resend due to timeout
6924run_test "DTLS proxy: reference" \
6925 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006926 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6927 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006928 0 \
6929 -C "replayed record" \
6930 -S "replayed record" \
6931 -C "record from another epoch" \
6932 -S "record from another epoch" \
6933 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006934 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006935 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006936 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006937 -c "HTTP/1.0 200 OK"
6938
6939not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006940run_test "DTLS proxy: duplicate every packet" \
6941 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006942 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6943 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006944 0 \
6945 -c "replayed record" \
6946 -s "replayed record" \
6947 -c "record from another epoch" \
6948 -s "record from another epoch" \
6949 -S "resend" \
6950 -s "Extra-header:" \
6951 -c "HTTP/1.0 200 OK"
6952
6953run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6954 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006955 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6956 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006957 0 \
6958 -c "replayed record" \
6959 -S "replayed record" \
6960 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006961 -s "record from another epoch" \
6962 -c "resend" \
6963 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006964 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006965 -c "HTTP/1.0 200 OK"
6966
6967run_test "DTLS proxy: multiple records in same datagram" \
6968 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006969 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6970 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006971 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006972 -c "next record in same datagram" \
6973 -s "next record in same datagram"
6974
6975run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6976 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006977 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6978 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006979 0 \
6980 -c "next record in same datagram" \
6981 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006982
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006983run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6984 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006985 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6986 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006987 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006988 -c "discarding invalid record (mac)" \
6989 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006990 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006991 -c "HTTP/1.0 200 OK" \
6992 -S "too many records with bad MAC" \
6993 -S "Verification of the message MAC failed"
6994
6995run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
6996 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006997 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
6998 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006999 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007000 -C "discarding invalid record (mac)" \
7001 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007002 -S "Extra-header:" \
7003 -C "HTTP/1.0 200 OK" \
7004 -s "too many records with bad MAC" \
7005 -s "Verification of the message MAC failed"
7006
7007run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7008 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007009 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7010 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007011 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007012 -c "discarding invalid record (mac)" \
7013 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007014 -s "Extra-header:" \
7015 -c "HTTP/1.0 200 OK" \
7016 -S "too many records with bad MAC" \
7017 -S "Verification of the message MAC failed"
7018
7019run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7020 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007021 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7022 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007023 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007024 -c "discarding invalid record (mac)" \
7025 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007026 -s "Extra-header:" \
7027 -c "HTTP/1.0 200 OK" \
7028 -s "too many records with bad MAC" \
7029 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007030
7031run_test "DTLS proxy: delay ChangeCipherSpec" \
7032 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007033 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7034 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007035 0 \
7036 -c "record from another epoch" \
7037 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007038 -s "Extra-header:" \
7039 -c "HTTP/1.0 200 OK"
7040
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007041# Tests for reordering support with DTLS
7042
Hanno Becker56cdfd12018-08-17 13:42:15 +01007043run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7044 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007045 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7046 hs_timeout=2500-60000" \
7047 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7048 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007049 0 \
7050 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007051 -c "Next handshake message has been buffered - load"\
7052 -S "Buffering HS message" \
7053 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007054 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007055 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007056 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007057 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007058
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007059run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7060 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007061 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7062 hs_timeout=2500-60000" \
7063 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7064 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007065 0 \
7066 -c "Buffering HS message" \
7067 -c "found fragmented DTLS handshake message"\
7068 -c "Next handshake message 1 not or only partially bufffered" \
7069 -c "Next handshake message has been buffered - load"\
7070 -S "Buffering HS message" \
7071 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007072 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007073 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007074 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007075 -S "Remember CCS message"
7076
Hanno Beckera1adcca2018-08-24 14:41:07 +01007077# The client buffers the ServerKeyExchange before receiving the fragmented
7078# Certificate message; at the time of writing, together these are aroudn 1200b
7079# in size, so that the bound below ensures that the certificate can be reassembled
7080# while keeping the ServerKeyExchange.
7081requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7082run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007083 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007084 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7085 hs_timeout=2500-60000" \
7086 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7087 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007088 0 \
7089 -c "Buffering HS message" \
7090 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007091 -C "attempt to make space by freeing buffered messages" \
7092 -S "Buffering HS message" \
7093 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007094 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007095 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007096 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007097 -S "Remember CCS message"
7098
7099# The size constraints ensure that the delayed certificate message can't
7100# be reassembled while keeping the ServerKeyExchange message, but it can
7101# when dropping it first.
7102requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7103requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7104run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7105 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007106 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7107 hs_timeout=2500-60000" \
7108 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7109 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007110 0 \
7111 -c "Buffering HS message" \
7112 -c "attempt to make space by freeing buffered future messages" \
7113 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007114 -S "Buffering HS message" \
7115 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007116 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007117 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007118 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007119 -S "Remember CCS message"
7120
Hanno Becker56cdfd12018-08-17 13:42:15 +01007121run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7122 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007123 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7124 hs_timeout=2500-60000" \
7125 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7126 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007127 0 \
7128 -C "Buffering HS message" \
7129 -C "Next handshake message has been buffered - load"\
7130 -s "Buffering HS message" \
7131 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007132 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007133 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007134 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007135 -S "Remember CCS message"
7136
7137run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7138 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007139 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7140 hs_timeout=2500-60000" \
7141 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7142 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007143 0 \
7144 -C "Buffering HS message" \
7145 -C "Next handshake message has been buffered - load"\
7146 -S "Buffering HS message" \
7147 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007148 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007149 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007150 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007151 -S "Remember CCS message"
7152
7153run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7154 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007155 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7156 hs_timeout=2500-60000" \
7157 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7158 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007159 0 \
7160 -C "Buffering HS message" \
7161 -C "Next handshake message has been buffered - load"\
7162 -S "Buffering HS message" \
7163 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007164 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007165 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007166 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007167 -s "Remember CCS message"
7168
Hanno Beckera1adcca2018-08-24 14:41:07 +01007169run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007170 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007171 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7172 hs_timeout=2500-60000" \
7173 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7174 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007175 0 \
7176 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007177 -s "Found buffered record from current epoch - load" \
7178 -c "Buffer record from epoch 1" \
7179 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007180
Hanno Beckera1adcca2018-08-24 14:41:07 +01007181# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7182# from the server are delayed, so that the encrypted Finished message
7183# is received and buffered. When the fragmented NewSessionTicket comes
7184# in afterwards, the encrypted Finished message must be freed in order
7185# to make space for the NewSessionTicket to be reassembled.
7186# This works only in very particular circumstances:
7187# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7188# of the NewSessionTicket, but small enough to also allow buffering of
7189# the encrypted Finished message.
7190# - The MTU setting on the server must be so small that the NewSessionTicket
7191# needs to be fragmented.
7192# - All messages sent by the server must be small enough to be either sent
7193# without fragmentation or be reassembled within the bounds of
7194# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7195# handshake, omitting CRTs.
7196requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7197requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7198run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7199 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7200 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7201 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7202 0 \
7203 -s "Buffer record from epoch 1" \
7204 -s "Found buffered record from current epoch - load" \
7205 -c "Buffer record from epoch 1" \
7206 -C "Found buffered record from current epoch - load" \
7207 -c "Enough space available after freeing future epoch record"
7208
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007209# Tests for "randomly unreliable connection": try a variety of flows and peers
7210
7211client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007212run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7213 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007214 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007215 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007216 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007217 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7218 0 \
7219 -s "Extra-header:" \
7220 -c "HTTP/1.0 200 OK"
7221
Janos Follath74537a62016-09-02 13:45:28 +01007222client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007223run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7224 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007225 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7226 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007227 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7228 0 \
7229 -s "Extra-header:" \
7230 -c "HTTP/1.0 200 OK"
7231
Janos Follath74537a62016-09-02 13:45:28 +01007232client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007233run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7234 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007235 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7236 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007237 0 \
7238 -s "Extra-header:" \
7239 -c "HTTP/1.0 200 OK"
7240
Janos Follath74537a62016-09-02 13:45:28 +01007241client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007242run_test "DTLS proxy: 3d, FS, client auth" \
7243 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007244 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7245 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007246 0 \
7247 -s "Extra-header:" \
7248 -c "HTTP/1.0 200 OK"
7249
Janos Follath74537a62016-09-02 13:45:28 +01007250client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007251run_test "DTLS proxy: 3d, FS, ticket" \
7252 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007253 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7254 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007255 0 \
7256 -s "Extra-header:" \
7257 -c "HTTP/1.0 200 OK"
7258
Janos Follath74537a62016-09-02 13:45:28 +01007259client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007260run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7261 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007262 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7263 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007264 0 \
7265 -s "Extra-header:" \
7266 -c "HTTP/1.0 200 OK"
7267
Janos Follath74537a62016-09-02 13:45:28 +01007268client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007269run_test "DTLS proxy: 3d, max handshake, nbio" \
7270 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007271 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007272 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007273 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007274 0 \
7275 -s "Extra-header:" \
7276 -c "HTTP/1.0 200 OK"
7277
Janos Follath74537a62016-09-02 13:45:28 +01007278client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007279run_test "DTLS proxy: 3d, min handshake, resumption" \
7280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007281 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007282 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007283 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007284 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007285 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7286 0 \
7287 -s "a session has been resumed" \
7288 -c "a session has been resumed" \
7289 -s "Extra-header:" \
7290 -c "HTTP/1.0 200 OK"
7291
Janos Follath74537a62016-09-02 13:45:28 +01007292client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007293run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7294 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007295 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007296 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007297 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007298 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007299 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7300 0 \
7301 -s "a session has been resumed" \
7302 -c "a session has been resumed" \
7303 -s "Extra-header:" \
7304 -c "HTTP/1.0 200 OK"
7305
Janos Follath74537a62016-09-02 13:45:28 +01007306client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007307requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007308run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007309 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007310 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007311 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007312 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007313 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007314 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7315 0 \
7316 -c "=> renegotiate" \
7317 -s "=> renegotiate" \
7318 -s "Extra-header:" \
7319 -c "HTTP/1.0 200 OK"
7320
Janos Follath74537a62016-09-02 13:45:28 +01007321client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007322requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007323run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7324 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007325 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007326 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007327 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007328 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007329 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7330 0 \
7331 -c "=> renegotiate" \
7332 -s "=> renegotiate" \
7333 -s "Extra-header:" \
7334 -c "HTTP/1.0 200 OK"
7335
Janos Follath74537a62016-09-02 13:45:28 +01007336client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007337requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007338run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007339 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007340 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007341 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007342 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007343 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007344 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007345 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7346 0 \
7347 -c "=> renegotiate" \
7348 -s "=> renegotiate" \
7349 -s "Extra-header:" \
7350 -c "HTTP/1.0 200 OK"
7351
Janos Follath74537a62016-09-02 13:45:28 +01007352client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007353requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007354run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007355 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007356 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007357 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007358 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007359 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007360 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007361 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7362 0 \
7363 -c "=> renegotiate" \
7364 -s "=> renegotiate" \
7365 -s "Extra-header:" \
7366 -c "HTTP/1.0 200 OK"
7367
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007368## Interop tests with OpenSSL might trigger a bug in recent versions (including
7369## all versions installed on the CI machines), reported here:
7370## Bug report: https://github.com/openssl/openssl/issues/6902
7371## They should be re-enabled once a fixed version of OpenSSL is available
7372## (this should happen in some 1.1.1_ release according to the ticket).
7373skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007374client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007375not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007376run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007377 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7378 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007379 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007380 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007381 -c "HTTP/1.0 200 OK"
7382
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007383skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007384client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007385not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007386run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7387 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7388 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007389 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007390 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007391 -c "HTTP/1.0 200 OK"
7392
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007393skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007394client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007395not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007396run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7397 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7398 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007399 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007400 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007401 -c "HTTP/1.0 200 OK"
7402
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007403requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007404client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007405not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007406run_test "DTLS proxy: 3d, gnutls server" \
7407 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7408 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007409 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007410 0 \
7411 -s "Extra-header:" \
7412 -c "Extra-header:"
7413
k-stachowiakabb843e2019-02-18 16:14:03 +01007414requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007415client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007416not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007417run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7418 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007419 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007420 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007421 0 \
7422 -s "Extra-header:" \
7423 -c "Extra-header:"
7424
k-stachowiakabb843e2019-02-18 16:14:03 +01007425requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007426client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007427not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007428run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7429 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007430 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007431 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007432 0 \
7433 -s "Extra-header:" \
7434 -c "Extra-header:"
7435
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007436# Final report
7437
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007438echo "------------------------------------------------------------------------"
7439
7440if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007441 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007442else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007443 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007444fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007445PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007446echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007447
7448exit $FAILS