blob: d3ab3bba1f1eb98599150c048bd52b2db92bbefb [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 Peskine663d0992020-08-26 22:50:38 +0200133 printf " -f|--filter\tOnly matching tests are executed (BRE)\n"
134 printf " -e|--exclude\tMatching tests are excluded (BRE)\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"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200387 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100388 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
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200665 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $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
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200670 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $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
Gilles Peskine634fe272021-02-02 23:29:03 +0100679 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100680
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200681 if [ -n "$PXY_CMD" ]; then
682 kill $PXY_PID >/dev/null 2>&1
683 wait $PXY_PID
684 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100685
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200686 # retry only on timeouts
687 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
688 printf "RETRY "
689 else
690 TIMES_LEFT=0
691 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200692 done
693
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100694 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200695 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100696 # expected client exit to incorrectly succeed in case of catastrophic
697 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100698 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200699 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100700 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100701 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100702 return
703 fi
704 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100705 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200706 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100707 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100708 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100709 return
710 fi
711 fi
712
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100713 # check server exit code
Gilles Peskine634fe272021-02-02 23:29:03 +0100714 if [ $SRV_RET != 0 ]; then
715 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100716 return
717 fi
718
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100719 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100720 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
721 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100722 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200723 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100724 return
725 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100726
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100727 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200728 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100729 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100730 while [ $# -gt 0 ]
731 do
732 case $1 in
733 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100734 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 +0100735 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100736 return
737 fi
738 ;;
739
740 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100741 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 +0100742 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100743 return
744 fi
745 ;;
746
747 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100748 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 +0100749 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100750 return
751 fi
752 ;;
753
754 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100755 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 +0100756 fail "pattern '$2' MUST NOT be present in the Client output"
757 return
758 fi
759 ;;
760
761 # The filtering in the following two options (-u and -U) do the following
762 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100763 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100764 # - keep one of each non-unique line
765 # - count how many lines remain
766 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
767 # if there were no duplicates.
768 "-U")
769 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
770 fail "lines following pattern '$2' must be unique in Server output"
771 return
772 fi
773 ;;
774
775 "-u")
776 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
777 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100778 return
779 fi
780 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100781 "-F")
782 if ! $2 "$SRV_OUT"; then
783 fail "function call to '$2' failed on Server output"
784 return
785 fi
786 ;;
787 "-f")
788 if ! $2 "$CLI_OUT"; then
789 fail "function call to '$2' failed on Client output"
790 return
791 fi
792 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100793
794 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200795 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100796 exit 1
797 esac
798 shift 2
799 done
800
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100801 # check valgrind's results
802 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200803 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100804 fail "Server has memory errors"
805 return
806 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200807 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100808 fail "Client has memory errors"
809 return
810 fi
811 fi
812
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100813 # if we're here, everything is ok
814 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100815 if [ "$PRESERVE_LOGS" -gt 0 ]; then
816 mv $SRV_OUT o-srv-${TESTS}.log
817 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100818 if [ -n "$PXY_CMD" ]; then
819 mv $PXY_OUT o-pxy-${TESTS}.log
820 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100821 fi
822
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200823 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100824}
825
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100826cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200827 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200828 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
829 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
830 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
831 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100832 exit 1
833}
834
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100835#
836# MAIN
837#
838
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100839get_options "$@"
840
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100841# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100842P_SRV_BIN="${P_SRV%%[ ]*}"
843P_CLI_BIN="${P_CLI%%[ ]*}"
844P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100845if [ ! -x "$P_SRV_BIN" ]; then
846 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100847 exit 1
848fi
Hanno Becker17c04932017-10-10 14:44:53 +0100849if [ ! -x "$P_CLI_BIN" ]; then
850 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100851 exit 1
852fi
Hanno Becker17c04932017-10-10 14:44:53 +0100853if [ ! -x "$P_PXY_BIN" ]; then
854 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200855 exit 1
856fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100857if [ "$MEMCHECK" -gt 0 ]; then
858 if which valgrind >/dev/null 2>&1; then :; else
859 echo "Memcheck not possible. Valgrind not found"
860 exit 1
861 fi
862fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100863if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
864 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100865 exit 1
866fi
867
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200868# used by watchdog
869MAIN_PID="$$"
870
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100871# We use somewhat arbitrary delays for tests:
872# - how long do we wait for the server to start (when lsof not available)?
873# - how long do we allow for the client to finish?
874# (not to check performance, just to avoid waiting indefinitely)
875# Things are slower with valgrind, so give extra time here.
876#
877# Note: without lsof, there is a trade-off between the running time of this
878# script and the risk of spurious errors because we didn't wait long enough.
879# The watchdog delay on the other hand doesn't affect normal running time of
880# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200881if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100882 START_DELAY=6
883 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200884else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100885 START_DELAY=2
886 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200887fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100888
889# some particular tests need more time:
890# - for the client, we multiply the usual watchdog limit by a factor
891# - for the server, we sleep for a number of seconds after the client exits
892# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200893CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100894SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200895
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200896# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000897# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200898P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
899P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100900P_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 +0200901O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200902O_CLI="$O_CLI -connect localhost:+SRV_PORT"
903G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200904G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200905
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200906if [ -n "${OPENSSL_LEGACY:-}" ]; then
907 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
908 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
909fi
910
Hanno Becker58e9dc32018-08-17 15:53:21 +0100911if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200912 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
913fi
914
Hanno Becker58e9dc32018-08-17 15:53:21 +0100915if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200916 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200917fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100918
Gilles Peskine62469d92017-05-10 10:13:59 +0200919# Allow SHA-1, because many of our test certificates use it
920P_SRV="$P_SRV allow_sha1=1"
921P_CLI="$P_CLI allow_sha1=1"
922
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200923# Also pick a unique name for intermediate files
924SRV_OUT="srv_out.$$"
925CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200926PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200927SESSION="session.$$"
928
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200929SKIP_NEXT="NO"
930
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100931trap cleanup INT TERM HUP
932
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200933# Basic test
934
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200935# Checks that:
936# - things work with all ciphersuites active (used with config-full in all.sh)
937# - the expected (highest security) parameters are selected
938# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200939run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200940 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200941 "$P_CLI" \
942 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200943 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200944 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200945 -s "client hello v3, signature_algorithm ext: 6" \
946 -s "ECDHE curve: secp521r1" \
947 -S "error" \
948 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200949
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000950run_test "Default, DTLS" \
951 "$P_SRV dtls=1" \
952 "$P_CLI dtls=1" \
953 0 \
954 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200955 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000956
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +0100957requires_config_enabled MBEDTLS_ZLIB_SUPPORT
958run_test "Default (compression enabled)" \
959 "$P_SRV debug_level=3" \
960 "$P_CLI debug_level=3" \
961 0 \
962 -s "Allocating compression buffer" \
963 -c "Allocating compression buffer" \
964 -s "Record expansion is unknown (compression)" \
965 -c "Record expansion is unknown (compression)" \
966 -S "error" \
967 -C "error"
968
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100969# Test current time in ServerHello
970requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200971run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100972 "$P_SRV debug_level=3" \
973 "$P_CLI debug_level=3" \
974 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100975 -f "check_server_hello_time" \
976 -F "check_server_hello_time"
977
Simon Butcher8e004102016-10-14 00:48:33 +0100978# Test for uniqueness of IVs in AEAD ciphersuites
979run_test "Unique IV in GCM" \
980 "$P_SRV exchanges=20 debug_level=4" \
981 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
982 0 \
983 -u "IV used" \
984 -U "IV used"
985
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100986# Tests for rc4 option
987
Simon Butchera410af52016-05-19 22:12:18 +0100988requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100989run_test "RC4: server disabled, client enabled" \
990 "$P_SRV" \
991 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
992 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100993 -s "SSL - The server has no ciphersuites in common"
994
Simon Butchera410af52016-05-19 22:12:18 +0100995requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100996run_test "RC4: server half, client enabled" \
997 "$P_SRV arc4=1" \
998 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
999 1 \
1000 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001001
1002run_test "RC4: server enabled, client disabled" \
1003 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1004 "$P_CLI" \
1005 1 \
1006 -s "SSL - The server has no ciphersuites in common"
1007
1008run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001009 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001010 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1011 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001012 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001013 -S "SSL - The server has no ciphersuites in common"
1014
Hanno Beckerd26bb202018-08-17 09:54:10 +01001015# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1016
1017requires_gnutls
1018requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1019run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1020 "$G_SRV"\
1021 "$P_CLI force_version=tls1_1" \
1022 0
1023
1024requires_gnutls
1025requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1026run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1027 "$G_SRV"\
1028 "$P_CLI force_version=tls1" \
1029 0
1030
Gilles Peskinebc70a182017-05-09 15:59:24 +02001031# Tests for SHA-1 support
1032
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001033requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001034run_test "SHA-1 forbidden by default in server certificate" \
1035 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1036 "$P_CLI debug_level=2 allow_sha1=0" \
1037 1 \
1038 -c "The certificate is signed with an unacceptable hash"
1039
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001040requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1041run_test "SHA-1 forbidden by default in server certificate" \
1042 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1043 "$P_CLI debug_level=2 allow_sha1=0" \
1044 0
1045
Gilles Peskinebc70a182017-05-09 15:59:24 +02001046run_test "SHA-1 explicitly allowed in server certificate" \
1047 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1048 "$P_CLI allow_sha1=1" \
1049 0
1050
1051run_test "SHA-256 allowed by default in server certificate" \
1052 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1053 "$P_CLI allow_sha1=0" \
1054 0
1055
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001056requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001057run_test "SHA-1 forbidden by default in client certificate" \
1058 "$P_SRV auth_mode=required allow_sha1=0" \
1059 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1060 1 \
1061 -s "The certificate is signed with an unacceptable hash"
1062
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001063requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1064run_test "SHA-1 forbidden by default in client certificate" \
1065 "$P_SRV auth_mode=required allow_sha1=0" \
1066 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1067 0
1068
Gilles Peskinebc70a182017-05-09 15:59:24 +02001069run_test "SHA-1 explicitly allowed in client certificate" \
1070 "$P_SRV auth_mode=required allow_sha1=1" \
1071 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1072 0
1073
1074run_test "SHA-256 allowed by default in client certificate" \
1075 "$P_SRV auth_mode=required allow_sha1=0" \
1076 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1077 0
1078
Hanno Becker7ae8a762018-08-14 15:43:35 +01001079# Tests for datagram packing
1080run_test "DTLS: multiple records in same datagram, client and server" \
1081 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1082 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1083 0 \
1084 -c "next record in same datagram" \
1085 -s "next record in same datagram"
1086
1087run_test "DTLS: multiple records in same datagram, client only" \
1088 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1089 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1090 0 \
1091 -s "next record in same datagram" \
1092 -C "next record in same datagram"
1093
1094run_test "DTLS: multiple records in same datagram, server only" \
1095 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1096 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1097 0 \
1098 -S "next record in same datagram" \
1099 -c "next record in same datagram"
1100
1101run_test "DTLS: multiple records in same datagram, neither client nor server" \
1102 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1103 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1104 0 \
1105 -S "next record in same datagram" \
1106 -C "next record in same datagram"
1107
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001108# Tests for Truncated HMAC extension
1109
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001110run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001111 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001112 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001113 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001114 -s "dumping 'expected mac' (20 bytes)" \
1115 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001116
Hanno Becker32c55012017-11-10 08:42:54 +00001117requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001118run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001119 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001120 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001121 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001122 -s "dumping 'expected mac' (20 bytes)" \
1123 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001124
Hanno Becker32c55012017-11-10 08:42:54 +00001125requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001126run_test "Truncated HMAC: client enabled, server default" \
1127 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001128 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001129 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001130 -s "dumping 'expected mac' (20 bytes)" \
1131 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001132
Hanno Becker32c55012017-11-10 08:42:54 +00001133requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001134run_test "Truncated HMAC: client enabled, server disabled" \
1135 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001136 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001137 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001138 -s "dumping 'expected mac' (20 bytes)" \
1139 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001140
Hanno Becker32c55012017-11-10 08:42:54 +00001141requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001142run_test "Truncated HMAC: client disabled, server enabled" \
1143 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001144 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001145 0 \
1146 -s "dumping 'expected mac' (20 bytes)" \
1147 -S "dumping 'expected mac' (10 bytes)"
1148
1149requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001150run_test "Truncated HMAC: client enabled, server enabled" \
1151 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001152 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001153 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001154 -S "dumping 'expected mac' (20 bytes)" \
1155 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001156
Hanno Becker4c4f4102017-11-10 09:16:05 +00001157run_test "Truncated HMAC, DTLS: client default, server default" \
1158 "$P_SRV dtls=1 debug_level=4" \
1159 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1160 0 \
1161 -s "dumping 'expected mac' (20 bytes)" \
1162 -S "dumping 'expected mac' (10 bytes)"
1163
1164requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1165run_test "Truncated HMAC, DTLS: client disabled, server default" \
1166 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001167 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001168 0 \
1169 -s "dumping 'expected mac' (20 bytes)" \
1170 -S "dumping 'expected mac' (10 bytes)"
1171
1172requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1173run_test "Truncated HMAC, DTLS: client enabled, server default" \
1174 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001175 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001176 0 \
1177 -s "dumping 'expected mac' (20 bytes)" \
1178 -S "dumping 'expected mac' (10 bytes)"
1179
1180requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1181run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1182 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001183 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001184 0 \
1185 -s "dumping 'expected mac' (20 bytes)" \
1186 -S "dumping 'expected mac' (10 bytes)"
1187
1188requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1189run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1190 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001191 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001192 0 \
1193 -s "dumping 'expected mac' (20 bytes)" \
1194 -S "dumping 'expected mac' (10 bytes)"
1195
1196requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1197run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1198 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001199 "$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 +01001200 0 \
1201 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001202 -s "dumping 'expected mac' (10 bytes)"
1203
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001204# Tests for Encrypt-then-MAC extension
1205
1206run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001207 "$P_SRV debug_level=3 \
1208 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001209 "$P_CLI debug_level=3" \
1210 0 \
1211 -c "client hello, adding encrypt_then_mac extension" \
1212 -s "found encrypt then mac extension" \
1213 -s "server hello, adding encrypt then mac extension" \
1214 -c "found encrypt_then_mac extension" \
1215 -c "using encrypt then mac" \
1216 -s "using encrypt then mac"
1217
1218run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001219 "$P_SRV debug_level=3 etm=0 \
1220 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001221 "$P_CLI debug_level=3 etm=1" \
1222 0 \
1223 -c "client hello, adding encrypt_then_mac extension" \
1224 -s "found encrypt then mac extension" \
1225 -S "server hello, adding encrypt then mac extension" \
1226 -C "found encrypt_then_mac extension" \
1227 -C "using encrypt then mac" \
1228 -S "using encrypt then mac"
1229
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001230run_test "Encrypt then MAC: client enabled, aead cipher" \
1231 "$P_SRV debug_level=3 etm=1 \
1232 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1233 "$P_CLI debug_level=3 etm=1" \
1234 0 \
1235 -c "client hello, adding encrypt_then_mac extension" \
1236 -s "found encrypt then mac extension" \
1237 -S "server hello, adding encrypt then mac extension" \
1238 -C "found encrypt_then_mac extension" \
1239 -C "using encrypt then mac" \
1240 -S "using encrypt then mac"
1241
1242run_test "Encrypt then MAC: client enabled, stream cipher" \
1243 "$P_SRV debug_level=3 etm=1 \
1244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001245 "$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 +01001246 0 \
1247 -c "client hello, adding encrypt_then_mac extension" \
1248 -s "found encrypt then mac extension" \
1249 -S "server hello, adding encrypt then mac extension" \
1250 -C "found encrypt_then_mac extension" \
1251 -C "using encrypt then mac" \
1252 -S "using encrypt then mac"
1253
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001254run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001255 "$P_SRV debug_level=3 etm=1 \
1256 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001257 "$P_CLI debug_level=3 etm=0" \
1258 0 \
1259 -C "client hello, adding encrypt_then_mac extension" \
1260 -S "found encrypt then mac extension" \
1261 -S "server hello, adding encrypt then mac extension" \
1262 -C "found encrypt_then_mac extension" \
1263 -C "using encrypt then mac" \
1264 -S "using encrypt then mac"
1265
Janos Follathe2681a42016-03-07 15:57:05 +00001266requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001267run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001268 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001269 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001270 "$P_CLI debug_level=3 force_version=ssl3" \
1271 0 \
1272 -C "client hello, adding encrypt_then_mac extension" \
1273 -S "found encrypt then mac extension" \
1274 -S "server hello, adding encrypt then mac extension" \
1275 -C "found encrypt_then_mac extension" \
1276 -C "using encrypt then mac" \
1277 -S "using encrypt then mac"
1278
Janos Follathe2681a42016-03-07 15:57:05 +00001279requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001280run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001281 "$P_SRV debug_level=3 force_version=ssl3 \
1282 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001283 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001284 0 \
1285 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001286 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001287 -S "server hello, adding encrypt then mac extension" \
1288 -C "found encrypt_then_mac extension" \
1289 -C "using encrypt then mac" \
1290 -S "using encrypt then mac"
1291
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001292# Tests for Extended Master Secret extension
1293
1294run_test "Extended Master Secret: default" \
1295 "$P_SRV debug_level=3" \
1296 "$P_CLI debug_level=3" \
1297 0 \
1298 -c "client hello, adding extended_master_secret extension" \
1299 -s "found extended master secret extension" \
1300 -s "server hello, adding extended master secret extension" \
1301 -c "found extended_master_secret extension" \
1302 -c "using extended master secret" \
1303 -s "using extended master secret"
1304
1305run_test "Extended Master Secret: client enabled, server disabled" \
1306 "$P_SRV debug_level=3 extended_ms=0" \
1307 "$P_CLI debug_level=3 extended_ms=1" \
1308 0 \
1309 -c "client hello, adding extended_master_secret extension" \
1310 -s "found extended master secret extension" \
1311 -S "server hello, adding extended master secret extension" \
1312 -C "found extended_master_secret extension" \
1313 -C "using extended master secret" \
1314 -S "using extended master secret"
1315
1316run_test "Extended Master Secret: client disabled, server enabled" \
1317 "$P_SRV debug_level=3 extended_ms=1" \
1318 "$P_CLI debug_level=3 extended_ms=0" \
1319 0 \
1320 -C "client hello, adding extended_master_secret extension" \
1321 -S "found extended master secret extension" \
1322 -S "server hello, adding extended master secret extension" \
1323 -C "found extended_master_secret extension" \
1324 -C "using extended master secret" \
1325 -S "using extended master secret"
1326
Janos Follathe2681a42016-03-07 15:57:05 +00001327requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001328run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001329 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001330 "$P_CLI debug_level=3 force_version=ssl3" \
1331 0 \
1332 -C "client hello, adding extended_master_secret extension" \
1333 -S "found extended master secret extension" \
1334 -S "server hello, adding extended master secret extension" \
1335 -C "found extended_master_secret extension" \
1336 -C "using extended master secret" \
1337 -S "using extended master secret"
1338
Janos Follathe2681a42016-03-07 15:57:05 +00001339requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001340run_test "Extended Master Secret: client enabled, server SSLv3" \
1341 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001342 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001343 0 \
1344 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001345 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001346 -S "server hello, adding extended master secret extension" \
1347 -C "found extended_master_secret extension" \
1348 -C "using extended master secret" \
1349 -S "using extended master secret"
1350
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001351# Tests for FALLBACK_SCSV
1352
1353run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001354 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001355 "$P_CLI debug_level=3 force_version=tls1_1" \
1356 0 \
1357 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001358 -S "received FALLBACK_SCSV" \
1359 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001360 -C "is a fatal alert message (msg 86)"
1361
1362run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001363 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001364 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1365 0 \
1366 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001367 -S "received FALLBACK_SCSV" \
1368 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001369 -C "is a fatal alert message (msg 86)"
1370
1371run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001372 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001373 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001374 1 \
1375 -c "adding FALLBACK_SCSV" \
1376 -s "received FALLBACK_SCSV" \
1377 -s "inapropriate fallback" \
1378 -c "is a fatal alert message (msg 86)"
1379
1380run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001381 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001382 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001383 0 \
1384 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001385 -s "received FALLBACK_SCSV" \
1386 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001387 -C "is a fatal alert message (msg 86)"
1388
1389requires_openssl_with_fallback_scsv
1390run_test "Fallback SCSV: default, openssl server" \
1391 "$O_SRV" \
1392 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1393 0 \
1394 -C "adding FALLBACK_SCSV" \
1395 -C "is a fatal alert message (msg 86)"
1396
1397requires_openssl_with_fallback_scsv
1398run_test "Fallback SCSV: enabled, openssl server" \
1399 "$O_SRV" \
1400 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1401 1 \
1402 -c "adding FALLBACK_SCSV" \
1403 -c "is a fatal alert message (msg 86)"
1404
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001405requires_openssl_with_fallback_scsv
1406run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001407 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001408 "$O_CLI -tls1_1" \
1409 0 \
1410 -S "received FALLBACK_SCSV" \
1411 -S "inapropriate fallback"
1412
1413requires_openssl_with_fallback_scsv
1414run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001415 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001416 "$O_CLI -tls1_1 -fallback_scsv" \
1417 1 \
1418 -s "received FALLBACK_SCSV" \
1419 -s "inapropriate fallback"
1420
1421requires_openssl_with_fallback_scsv
1422run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001423 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001424 "$O_CLI -fallback_scsv" \
1425 0 \
1426 -s "received FALLBACK_SCSV" \
1427 -S "inapropriate fallback"
1428
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001429# Test sending and receiving empty application data records
1430
1431run_test "Encrypt then MAC: empty application data record" \
1432 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1433 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1434 0 \
1435 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1436 -s "dumping 'input payload after decrypt' (0 bytes)" \
1437 -c "0 bytes written in 1 fragments"
1438
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001439run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001440 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1441 "$P_CLI auth_mode=none etm=0 request_size=0" \
1442 0 \
1443 -s "dumping 'input payload after decrypt' (0 bytes)" \
1444 -c "0 bytes written in 1 fragments"
1445
1446run_test "Encrypt then MAC, DTLS: empty application data record" \
1447 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1448 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1449 0 \
1450 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1451 -s "dumping 'input payload after decrypt' (0 bytes)" \
1452 -c "0 bytes written in 1 fragments"
1453
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001454run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001455 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1456 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1457 0 \
1458 -s "dumping 'input payload after decrypt' (0 bytes)" \
1459 -c "0 bytes written in 1 fragments"
1460
Gilles Peskined50177f2017-05-16 17:53:03 +02001461## ClientHello generated with
1462## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1463## then manually twiddling the ciphersuite list.
1464## The ClientHello content is spelled out below as a hex string as
1465## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1466## The expected response is an inappropriate_fallback alert.
1467requires_openssl_with_fallback_scsv
1468run_test "Fallback SCSV: beginning of list" \
1469 "$P_SRV debug_level=2" \
1470 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1471 0 \
1472 -s "received FALLBACK_SCSV" \
1473 -s "inapropriate fallback"
1474
1475requires_openssl_with_fallback_scsv
1476run_test "Fallback SCSV: end of list" \
1477 "$P_SRV debug_level=2" \
1478 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1479 0 \
1480 -s "received FALLBACK_SCSV" \
1481 -s "inapropriate fallback"
1482
1483## Here the expected response is a valid ServerHello prefix, up to the random.
1484requires_openssl_with_fallback_scsv
1485run_test "Fallback SCSV: not in list" \
1486 "$P_SRV debug_level=2" \
1487 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1488 0 \
1489 -S "received FALLBACK_SCSV" \
1490 -S "inapropriate fallback"
1491
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001492# Tests for CBC 1/n-1 record splitting
1493
1494run_test "CBC Record splitting: TLS 1.2, no splitting" \
1495 "$P_SRV" \
1496 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1497 request_size=123 force_version=tls1_2" \
1498 0 \
1499 -s "Read from client: 123 bytes read" \
1500 -S "Read from client: 1 bytes read" \
1501 -S "122 bytes read"
1502
1503run_test "CBC Record splitting: TLS 1.1, no splitting" \
1504 "$P_SRV" \
1505 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1506 request_size=123 force_version=tls1_1" \
1507 0 \
1508 -s "Read from client: 123 bytes read" \
1509 -S "Read from client: 1 bytes read" \
1510 -S "122 bytes read"
1511
1512run_test "CBC Record splitting: TLS 1.0, splitting" \
1513 "$P_SRV" \
1514 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1515 request_size=123 force_version=tls1" \
1516 0 \
1517 -S "Read from client: 123 bytes read" \
1518 -s "Read from client: 1 bytes read" \
1519 -s "122 bytes read"
1520
Janos Follathe2681a42016-03-07 15:57:05 +00001521requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001522run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001523 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001524 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1525 request_size=123 force_version=ssl3" \
1526 0 \
1527 -S "Read from client: 123 bytes read" \
1528 -s "Read from client: 1 bytes read" \
1529 -s "122 bytes read"
1530
1531run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001532 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001533 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1534 request_size=123 force_version=tls1" \
1535 0 \
1536 -s "Read from client: 123 bytes read" \
1537 -S "Read from client: 1 bytes read" \
1538 -S "122 bytes read"
1539
1540run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1541 "$P_SRV" \
1542 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1543 request_size=123 force_version=tls1 recsplit=0" \
1544 0 \
1545 -s "Read from client: 123 bytes read" \
1546 -S "Read from client: 1 bytes read" \
1547 -S "122 bytes read"
1548
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001549run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1550 "$P_SRV nbio=2" \
1551 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1552 request_size=123 force_version=tls1" \
1553 0 \
1554 -S "Read from client: 123 bytes read" \
1555 -s "Read from client: 1 bytes read" \
1556 -s "122 bytes read"
1557
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001558# Tests for Session Tickets
1559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001560run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001561 "$P_SRV debug_level=3 tickets=1" \
1562 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001563 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001564 -c "client hello, adding session ticket extension" \
1565 -s "found session ticket extension" \
1566 -s "server hello, adding session ticket extension" \
1567 -c "found session_ticket extension" \
1568 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001569 -S "session successfully restored from cache" \
1570 -s "session successfully restored from ticket" \
1571 -s "a session has been resumed" \
1572 -c "a session has been resumed"
1573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001574run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001575 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1576 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001577 0 \
1578 -c "client hello, adding session ticket extension" \
1579 -s "found session ticket extension" \
1580 -s "server hello, adding session ticket extension" \
1581 -c "found session_ticket extension" \
1582 -c "parse new session ticket" \
1583 -S "session successfully restored from cache" \
1584 -s "session successfully restored from ticket" \
1585 -s "a session has been resumed" \
1586 -c "a session has been resumed"
1587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001588run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001589 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1590 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001591 0 \
1592 -c "client hello, adding session ticket extension" \
1593 -s "found session ticket extension" \
1594 -s "server hello, adding session ticket extension" \
1595 -c "found session_ticket extension" \
1596 -c "parse new session ticket" \
1597 -S "session successfully restored from cache" \
1598 -S "session successfully restored from ticket" \
1599 -S "a session has been resumed" \
1600 -C "a session has been resumed"
1601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001603 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001604 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001605 0 \
1606 -c "client hello, adding session ticket extension" \
1607 -c "found session_ticket extension" \
1608 -c "parse new session ticket" \
1609 -c "a session has been resumed"
1610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001611run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001612 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001613 "( $O_CLI -sess_out $SESSION; \
1614 $O_CLI -sess_in $SESSION; \
1615 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001616 0 \
1617 -s "found session ticket extension" \
1618 -s "server hello, adding session ticket extension" \
1619 -S "session successfully restored from cache" \
1620 -s "session successfully restored from ticket" \
1621 -s "a session has been resumed"
1622
Hanno Becker1d739932018-08-21 13:55:22 +01001623# Tests for Session Tickets with DTLS
1624
1625run_test "Session resume using tickets, DTLS: basic" \
1626 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001627 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001628 0 \
1629 -c "client hello, adding session ticket extension" \
1630 -s "found session ticket extension" \
1631 -s "server hello, adding session ticket extension" \
1632 -c "found session_ticket extension" \
1633 -c "parse new session ticket" \
1634 -S "session successfully restored from cache" \
1635 -s "session successfully restored from ticket" \
1636 -s "a session has been resumed" \
1637 -c "a session has been resumed"
1638
1639run_test "Session resume using tickets, DTLS: cache disabled" \
1640 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001641 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001642 0 \
1643 -c "client hello, adding session ticket extension" \
1644 -s "found session ticket extension" \
1645 -s "server hello, adding session ticket extension" \
1646 -c "found session_ticket extension" \
1647 -c "parse new session ticket" \
1648 -S "session successfully restored from cache" \
1649 -s "session successfully restored from ticket" \
1650 -s "a session has been resumed" \
1651 -c "a session has been resumed"
1652
1653run_test "Session resume using tickets, DTLS: timeout" \
1654 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001655 "$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 +01001656 0 \
1657 -c "client hello, adding session ticket extension" \
1658 -s "found session ticket extension" \
1659 -s "server hello, adding session ticket extension" \
1660 -c "found session_ticket extension" \
1661 -c "parse new session ticket" \
1662 -S "session successfully restored from cache" \
1663 -S "session successfully restored from ticket" \
1664 -S "a session has been resumed" \
1665 -C "a session has been resumed"
1666
1667run_test "Session resume using tickets, DTLS: openssl server" \
1668 "$O_SRV -dtls1" \
1669 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1670 0 \
1671 -c "client hello, adding session ticket extension" \
1672 -c "found session_ticket extension" \
1673 -c "parse new session ticket" \
1674 -c "a session has been resumed"
1675
1676run_test "Session resume using tickets, DTLS: openssl client" \
1677 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1678 "( $O_CLI -dtls1 -sess_out $SESSION; \
1679 $O_CLI -dtls1 -sess_in $SESSION; \
1680 rm -f $SESSION )" \
1681 0 \
1682 -s "found session ticket extension" \
1683 -s "server hello, adding session ticket extension" \
1684 -S "session successfully restored from cache" \
1685 -s "session successfully restored from ticket" \
1686 -s "a session has been resumed"
1687
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001688# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001689
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001690run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001691 "$P_SRV debug_level=3 tickets=0" \
1692 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001693 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001694 -c "client hello, adding session ticket extension" \
1695 -s "found session ticket extension" \
1696 -S "server hello, adding session ticket extension" \
1697 -C "found session_ticket extension" \
1698 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001699 -s "session successfully restored from cache" \
1700 -S "session successfully restored from ticket" \
1701 -s "a session has been resumed" \
1702 -c "a session has been resumed"
1703
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001704run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001705 "$P_SRV debug_level=3 tickets=1" \
1706 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001707 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001708 -C "client hello, adding session ticket extension" \
1709 -S "found session ticket extension" \
1710 -S "server hello, adding session ticket extension" \
1711 -C "found session_ticket extension" \
1712 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001713 -s "session successfully restored from cache" \
1714 -S "session successfully restored from ticket" \
1715 -s "a session has been resumed" \
1716 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001719 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1720 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001721 0 \
1722 -S "session successfully restored from cache" \
1723 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001724 -S "a session has been resumed" \
1725 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001727run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001728 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1729 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001730 0 \
1731 -s "session successfully restored from cache" \
1732 -S "session successfully restored from ticket" \
1733 -s "a session has been resumed" \
1734 -c "a session has been resumed"
1735
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001736run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001737 "$P_SRV debug_level=3 tickets=0" \
1738 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001739 0 \
1740 -s "session successfully restored from cache" \
1741 -S "session successfully restored from ticket" \
1742 -s "a session has been resumed" \
1743 -c "a session has been resumed"
1744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1747 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001748 0 \
1749 -S "session successfully restored from cache" \
1750 -S "session successfully restored from ticket" \
1751 -S "a session has been resumed" \
1752 -C "a session has been resumed"
1753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001754run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001755 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1756 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001757 0 \
1758 -s "session successfully restored from cache" \
1759 -S "session successfully restored from ticket" \
1760 -s "a session has been resumed" \
1761 -c "a session has been resumed"
1762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001763run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001764 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001765 "( $O_CLI -sess_out $SESSION; \
1766 $O_CLI -sess_in $SESSION; \
1767 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001768 0 \
1769 -s "found session ticket extension" \
1770 -S "server hello, adding session ticket extension" \
1771 -s "session successfully restored from cache" \
1772 -S "session successfully restored from ticket" \
1773 -s "a session has been resumed"
1774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001775run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001776 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001778 0 \
1779 -C "found session_ticket extension" \
1780 -C "parse new session ticket" \
1781 -c "a session has been resumed"
1782
Hanno Becker1d739932018-08-21 13:55:22 +01001783# Tests for Session Resume based on session-ID and cache, DTLS
1784
1785run_test "Session resume using cache, DTLS: tickets enabled on client" \
1786 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001787 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001788 0 \
1789 -c "client hello, adding session ticket extension" \
1790 -s "found session ticket extension" \
1791 -S "server hello, adding session ticket extension" \
1792 -C "found session_ticket extension" \
1793 -C "parse new session ticket" \
1794 -s "session successfully restored from cache" \
1795 -S "session successfully restored from ticket" \
1796 -s "a session has been resumed" \
1797 -c "a session has been resumed"
1798
1799run_test "Session resume using cache, DTLS: tickets enabled on server" \
1800 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001801 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001802 0 \
1803 -C "client hello, adding session ticket extension" \
1804 -S "found session ticket extension" \
1805 -S "server hello, adding session ticket extension" \
1806 -C "found session_ticket extension" \
1807 -C "parse new session ticket" \
1808 -s "session successfully restored from cache" \
1809 -S "session successfully restored from ticket" \
1810 -s "a session has been resumed" \
1811 -c "a session has been resumed"
1812
1813run_test "Session resume using cache, DTLS: cache_max=0" \
1814 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001815 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001816 0 \
1817 -S "session successfully restored from cache" \
1818 -S "session successfully restored from ticket" \
1819 -S "a session has been resumed" \
1820 -C "a session has been resumed"
1821
1822run_test "Session resume using cache, DTLS: cache_max=1" \
1823 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001824 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001825 0 \
1826 -s "session successfully restored from cache" \
1827 -S "session successfully restored from ticket" \
1828 -s "a session has been resumed" \
1829 -c "a session has been resumed"
1830
1831run_test "Session resume using cache, DTLS: timeout > delay" \
1832 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001833 "$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 +01001834 0 \
1835 -s "session successfully restored from cache" \
1836 -S "session successfully restored from ticket" \
1837 -s "a session has been resumed" \
1838 -c "a session has been resumed"
1839
1840run_test "Session resume using cache, DTLS: timeout < delay" \
1841 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001842 "$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 +01001843 0 \
1844 -S "session successfully restored from cache" \
1845 -S "session successfully restored from ticket" \
1846 -S "a session has been resumed" \
1847 -C "a session has been resumed"
1848
1849run_test "Session resume using cache, DTLS: no timeout" \
1850 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001851 "$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 +01001852 0 \
1853 -s "session successfully restored from cache" \
1854 -S "session successfully restored from ticket" \
1855 -s "a session has been resumed" \
1856 -c "a session has been resumed"
1857
1858run_test "Session resume using cache, DTLS: openssl client" \
1859 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1860 "( $O_CLI -dtls1 -sess_out $SESSION; \
1861 $O_CLI -dtls1 -sess_in $SESSION; \
1862 rm -f $SESSION )" \
1863 0 \
1864 -s "found session ticket extension" \
1865 -S "server hello, adding session ticket extension" \
1866 -s "session successfully restored from cache" \
1867 -S "session successfully restored from ticket" \
1868 -s "a session has been resumed"
1869
1870run_test "Session resume using cache, DTLS: openssl server" \
1871 "$O_SRV -dtls1" \
1872 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1873 0 \
1874 -C "found session_ticket extension" \
1875 -C "parse new session ticket" \
1876 -c "a session has been resumed"
1877
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001878# Tests for Max Fragment Length extension
1879
Angus Grattonc4dd0732018-04-11 16:28:39 +10001880if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001881 printf '%s defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n' "${CONFIG_H}"
Hanno Becker6428f8d2017-09-22 16:58:50 +01001882 exit 1
1883fi
1884
Angus Grattonc4dd0732018-04-11 16:28:39 +10001885if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001886 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10001887fi
1888
Hanno Becker4aed27e2017-09-18 15:00:34 +01001889requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001890run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001891 "$P_SRV debug_level=3" \
1892 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001893 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001894 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1895 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001896 -C "client hello, adding max_fragment_length extension" \
1897 -S "found max fragment length extension" \
1898 -S "server hello, max_fragment_length extension" \
1899 -C "found max_fragment_length extension"
1900
Hanno Becker4aed27e2017-09-18 15:00:34 +01001901requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001902run_test "Max fragment length: enabled, default, larger message" \
1903 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001904 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001905 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001906 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1907 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001908 -C "client hello, adding max_fragment_length extension" \
1909 -S "found max fragment length extension" \
1910 -S "server hello, max_fragment_length extension" \
1911 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001912 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1913 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001914 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001915
1916requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1917run_test "Max fragment length, DTLS: enabled, default, larger message" \
1918 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001919 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001920 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001921 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1922 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001923 -C "client hello, adding max_fragment_length extension" \
1924 -S "found max fragment length extension" \
1925 -S "server hello, max_fragment_length extension" \
1926 -C "found max_fragment_length extension" \
1927 -c "fragment larger than.*maximum "
1928
Angus Grattonc4dd0732018-04-11 16:28:39 +10001929# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1930# (session fragment length will be 16384 regardless of mbedtls
1931# content length configuration.)
1932
Hanno Beckerc5266962017-09-18 15:01:50 +01001933requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1934run_test "Max fragment length: disabled, larger message" \
1935 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001936 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001937 0 \
1938 -C "Maximum fragment length is 16384" \
1939 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001940 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1941 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001942 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001943
1944requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1945run_test "Max fragment length DTLS: disabled, larger message" \
1946 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001947 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001948 1 \
1949 -C "Maximum fragment length is 16384" \
1950 -S "Maximum fragment length is 16384" \
1951 -c "fragment larger than.*maximum "
1952
1953requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001954run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001955 "$P_SRV debug_level=3" \
1956 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001957 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001958 -c "Maximum fragment length is 4096" \
1959 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001960 -c "client hello, adding max_fragment_length extension" \
1961 -s "found max fragment length extension" \
1962 -s "server hello, max_fragment_length extension" \
1963 -c "found max_fragment_length extension"
1964
Hanno Becker4aed27e2017-09-18 15:00:34 +01001965requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001966run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001967 "$P_SRV debug_level=3 max_frag_len=4096" \
1968 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001969 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001970 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001971 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001972 -C "client hello, adding max_fragment_length extension" \
1973 -S "found max fragment length extension" \
1974 -S "server hello, max_fragment_length extension" \
1975 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001976
Hanno Becker4aed27e2017-09-18 15:00:34 +01001977requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001978requires_gnutls
1979run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001980 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001981 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001982 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001983 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001984 -c "client hello, adding max_fragment_length extension" \
1985 -c "found max_fragment_length extension"
1986
Hanno Becker4aed27e2017-09-18 15:00:34 +01001987requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001988run_test "Max fragment length: client, message just fits" \
1989 "$P_SRV debug_level=3" \
1990 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1991 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001992 -c "Maximum fragment length is 2048" \
1993 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001994 -c "client hello, adding max_fragment_length extension" \
1995 -s "found max fragment length extension" \
1996 -s "server hello, max_fragment_length extension" \
1997 -c "found max_fragment_length extension" \
1998 -c "2048 bytes written in 1 fragments" \
1999 -s "2048 bytes read"
2000
Hanno Becker4aed27e2017-09-18 15:00:34 +01002001requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002002run_test "Max fragment length: client, larger message" \
2003 "$P_SRV debug_level=3" \
2004 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2005 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002006 -c "Maximum fragment length is 2048" \
2007 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002008 -c "client hello, adding max_fragment_length extension" \
2009 -s "found max fragment length extension" \
2010 -s "server hello, max_fragment_length extension" \
2011 -c "found max_fragment_length extension" \
2012 -c "2345 bytes written in 2 fragments" \
2013 -s "2048 bytes read" \
2014 -s "297 bytes read"
2015
Hanno Becker4aed27e2017-09-18 15:00:34 +01002016requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002017run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002018 "$P_SRV debug_level=3 dtls=1" \
2019 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2020 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002021 -c "Maximum fragment length is 2048" \
2022 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002023 -c "client hello, adding max_fragment_length extension" \
2024 -s "found max fragment length extension" \
2025 -s "server hello, max_fragment_length extension" \
2026 -c "found max_fragment_length extension" \
2027 -c "fragment larger than.*maximum"
2028
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002029# Tests for renegotiation
2030
Hanno Becker6a243642017-10-12 15:18:45 +01002031# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002033 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002034 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002035 0 \
2036 -C "client hello, adding renegotiation extension" \
2037 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2038 -S "found renegotiation extension" \
2039 -s "server hello, secure renegotiation extension" \
2040 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002041 -C "=> renegotiate" \
2042 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002043 -S "write hello request"
2044
Hanno Becker6a243642017-10-12 15:18:45 +01002045requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002046run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002047 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002048 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002049 0 \
2050 -c "client hello, adding renegotiation extension" \
2051 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2052 -s "found renegotiation extension" \
2053 -s "server hello, secure renegotiation extension" \
2054 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002055 -c "=> renegotiate" \
2056 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002057 -S "write hello request"
2058
Hanno Becker6a243642017-10-12 15:18:45 +01002059requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002060run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002061 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002062 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002063 0 \
2064 -c "client hello, adding renegotiation extension" \
2065 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2066 -s "found renegotiation extension" \
2067 -s "server hello, secure renegotiation extension" \
2068 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002069 -c "=> renegotiate" \
2070 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002071 -s "write hello request"
2072
Janos Follathb0f148c2017-10-05 12:29:42 +01002073# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2074# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2075# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002076requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002077run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2078 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2079 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2080 0 \
2081 -c "client hello, adding renegotiation extension" \
2082 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2083 -s "found renegotiation extension" \
2084 -s "server hello, secure renegotiation extension" \
2085 -c "found renegotiation extension" \
2086 -c "=> renegotiate" \
2087 -s "=> renegotiate" \
2088 -S "write hello request" \
2089 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2090
2091# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2092# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2093# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002094requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002095run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2096 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2097 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2098 0 \
2099 -c "client hello, adding renegotiation extension" \
2100 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2101 -s "found renegotiation extension" \
2102 -s "server hello, secure renegotiation extension" \
2103 -c "found renegotiation extension" \
2104 -c "=> renegotiate" \
2105 -s "=> renegotiate" \
2106 -s "write hello request" \
2107 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2108
Hanno Becker6a243642017-10-12 15:18:45 +01002109requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002110run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002111 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002112 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002113 0 \
2114 -c "client hello, adding renegotiation extension" \
2115 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2116 -s "found renegotiation extension" \
2117 -s "server hello, secure renegotiation extension" \
2118 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002119 -c "=> renegotiate" \
2120 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002121 -s "write hello request"
2122
Hanno Becker6a243642017-10-12 15:18:45 +01002123requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002124run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002125 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002126 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002127 1 \
2128 -c "client hello, adding renegotiation extension" \
2129 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2130 -S "found renegotiation extension" \
2131 -s "server hello, secure renegotiation extension" \
2132 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002133 -c "=> renegotiate" \
2134 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002135 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002136 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002137 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002138
Hanno Becker6a243642017-10-12 15:18:45 +01002139requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002140run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002141 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002142 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002143 0 \
2144 -C "client hello, adding renegotiation extension" \
2145 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2146 -S "found renegotiation extension" \
2147 -s "server hello, secure renegotiation extension" \
2148 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002149 -C "=> renegotiate" \
2150 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002151 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002152 -S "SSL - An unexpected message was received from our peer" \
2153 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002154
Hanno Becker6a243642017-10-12 15:18:45 +01002155requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002156run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002157 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002158 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002159 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002160 0 \
2161 -C "client hello, adding renegotiation extension" \
2162 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2163 -S "found renegotiation extension" \
2164 -s "server hello, secure renegotiation extension" \
2165 -c "found renegotiation extension" \
2166 -C "=> renegotiate" \
2167 -S "=> renegotiate" \
2168 -s "write hello request" \
2169 -S "SSL - An unexpected message was received from our peer" \
2170 -S "failed"
2171
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002172# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002173requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002174run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002176 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002177 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002178 0 \
2179 -C "client hello, adding renegotiation extension" \
2180 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2181 -S "found renegotiation extension" \
2182 -s "server hello, secure renegotiation extension" \
2183 -c "found renegotiation extension" \
2184 -C "=> renegotiate" \
2185 -S "=> renegotiate" \
2186 -s "write hello request" \
2187 -S "SSL - An unexpected message was received from our peer" \
2188 -S "failed"
2189
Hanno Becker6a243642017-10-12 15:18:45 +01002190requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002191run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002192 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002193 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002194 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002195 0 \
2196 -C "client hello, adding renegotiation extension" \
2197 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2198 -S "found renegotiation extension" \
2199 -s "server hello, secure renegotiation extension" \
2200 -c "found renegotiation extension" \
2201 -C "=> renegotiate" \
2202 -S "=> renegotiate" \
2203 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002204 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002205
Hanno Becker6a243642017-10-12 15:18:45 +01002206requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002207run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002208 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002209 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002210 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002211 0 \
2212 -c "client hello, adding renegotiation extension" \
2213 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2214 -s "found renegotiation extension" \
2215 -s "server hello, secure renegotiation extension" \
2216 -c "found renegotiation extension" \
2217 -c "=> renegotiate" \
2218 -s "=> renegotiate" \
2219 -s "write hello request" \
2220 -S "SSL - An unexpected message was received from our peer" \
2221 -S "failed"
2222
Hanno Becker6a243642017-10-12 15:18:45 +01002223requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002224run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002225 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002226 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2227 0 \
2228 -C "client hello, adding renegotiation extension" \
2229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2230 -S "found renegotiation extension" \
2231 -s "server hello, secure renegotiation extension" \
2232 -c "found renegotiation extension" \
2233 -S "record counter limit reached: renegotiate" \
2234 -C "=> renegotiate" \
2235 -S "=> renegotiate" \
2236 -S "write hello request" \
2237 -S "SSL - An unexpected message was received from our peer" \
2238 -S "failed"
2239
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002240# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002241requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002242run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002243 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002244 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002245 0 \
2246 -c "client hello, adding renegotiation extension" \
2247 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2248 -s "found renegotiation extension" \
2249 -s "server hello, secure renegotiation extension" \
2250 -c "found renegotiation extension" \
2251 -s "record counter limit reached: renegotiate" \
2252 -c "=> renegotiate" \
2253 -s "=> renegotiate" \
2254 -s "write hello request" \
2255 -S "SSL - An unexpected message was received from our peer" \
2256 -S "failed"
2257
Hanno Becker6a243642017-10-12 15:18:45 +01002258requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002259run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002260 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002261 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002262 0 \
2263 -c "client hello, adding renegotiation extension" \
2264 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2265 -s "found renegotiation extension" \
2266 -s "server hello, secure renegotiation extension" \
2267 -c "found renegotiation extension" \
2268 -s "record counter limit reached: renegotiate" \
2269 -c "=> renegotiate" \
2270 -s "=> renegotiate" \
2271 -s "write hello request" \
2272 -S "SSL - An unexpected message was received from our peer" \
2273 -S "failed"
2274
Hanno Becker6a243642017-10-12 15:18:45 +01002275requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002276run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002277 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002278 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2279 0 \
2280 -C "client hello, adding renegotiation extension" \
2281 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2282 -S "found renegotiation extension" \
2283 -s "server hello, secure renegotiation extension" \
2284 -c "found renegotiation extension" \
2285 -S "record counter limit reached: renegotiate" \
2286 -C "=> renegotiate" \
2287 -S "=> renegotiate" \
2288 -S "write hello request" \
2289 -S "SSL - An unexpected message was received from our peer" \
2290 -S "failed"
2291
Hanno Becker6a243642017-10-12 15:18:45 +01002292requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002293run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002294 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002295 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002296 0 \
2297 -c "client hello, adding renegotiation extension" \
2298 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2299 -s "found renegotiation extension" \
2300 -s "server hello, secure renegotiation extension" \
2301 -c "found renegotiation extension" \
2302 -c "=> renegotiate" \
2303 -s "=> renegotiate" \
2304 -S "write hello request"
2305
Hanno Becker6a243642017-10-12 15:18:45 +01002306requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002307run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002308 "$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 +02002309 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002310 0 \
2311 -c "client hello, adding renegotiation extension" \
2312 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2313 -s "found renegotiation extension" \
2314 -s "server hello, secure renegotiation extension" \
2315 -c "found renegotiation extension" \
2316 -c "=> renegotiate" \
2317 -s "=> renegotiate" \
2318 -s "write hello request"
2319
Hanno Becker6a243642017-10-12 15:18:45 +01002320requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002321run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002322 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002323 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002324 0 \
2325 -c "client hello, adding renegotiation extension" \
2326 -c "found renegotiation extension" \
2327 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002328 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002329 -C "error" \
2330 -c "HTTP/1.0 200 [Oo][Kk]"
2331
Paul Bakker539d9722015-02-08 16:18:35 +01002332requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002333requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002334run_test "Renegotiation: gnutls server strict, client-initiated" \
2335 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002336 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002337 0 \
2338 -c "client hello, adding renegotiation extension" \
2339 -c "found renegotiation extension" \
2340 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002341 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002342 -C "error" \
2343 -c "HTTP/1.0 200 [Oo][Kk]"
2344
Paul Bakker539d9722015-02-08 16:18:35 +01002345requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002346requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002347run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2348 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2349 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2350 1 \
2351 -c "client hello, adding renegotiation extension" \
2352 -C "found renegotiation extension" \
2353 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002354 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002355 -c "error" \
2356 -C "HTTP/1.0 200 [Oo][Kk]"
2357
Paul Bakker539d9722015-02-08 16:18:35 +01002358requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002359requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002360run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2361 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2362 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2363 allow_legacy=0" \
2364 1 \
2365 -c "client hello, adding renegotiation extension" \
2366 -C "found renegotiation extension" \
2367 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002368 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002369 -c "error" \
2370 -C "HTTP/1.0 200 [Oo][Kk]"
2371
Paul Bakker539d9722015-02-08 16:18:35 +01002372requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002373requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002374run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2375 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2376 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2377 allow_legacy=1" \
2378 0 \
2379 -c "client hello, adding renegotiation extension" \
2380 -C "found renegotiation extension" \
2381 -c "=> renegotiate" \
2382 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002383 -C "error" \
2384 -c "HTTP/1.0 200 [Oo][Kk]"
2385
Hanno Becker6a243642017-10-12 15:18:45 +01002386requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002387run_test "Renegotiation: DTLS, client-initiated" \
2388 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2389 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2390 0 \
2391 -c "client hello, adding renegotiation extension" \
2392 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2393 -s "found renegotiation extension" \
2394 -s "server hello, secure renegotiation extension" \
2395 -c "found renegotiation extension" \
2396 -c "=> renegotiate" \
2397 -s "=> renegotiate" \
2398 -S "write hello request"
2399
Hanno Becker6a243642017-10-12 15:18:45 +01002400requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002401run_test "Renegotiation: DTLS, server-initiated" \
2402 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002403 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2404 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002405 0 \
2406 -c "client hello, adding renegotiation extension" \
2407 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2408 -s "found renegotiation extension" \
2409 -s "server hello, secure renegotiation extension" \
2410 -c "found renegotiation extension" \
2411 -c "=> renegotiate" \
2412 -s "=> renegotiate" \
2413 -s "write hello request"
2414
Hanno Becker6a243642017-10-12 15:18:45 +01002415requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002416run_test "Renegotiation: DTLS, renego_period overflow" \
2417 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2418 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2419 0 \
2420 -c "client hello, adding renegotiation extension" \
2421 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2422 -s "found renegotiation extension" \
2423 -s "server hello, secure renegotiation extension" \
2424 -s "record counter limit reached: renegotiate" \
2425 -c "=> renegotiate" \
2426 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002427 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002428
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002429requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002430requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002431run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2432 "$G_SRV -u --mtu 4096" \
2433 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2434 0 \
2435 -c "client hello, adding renegotiation extension" \
2436 -c "found renegotiation extension" \
2437 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002438 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002439 -C "error" \
2440 -s "Extra-header:"
2441
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002442# Test for the "secure renegotation" extension only (no actual renegotiation)
2443
Paul Bakker539d9722015-02-08 16:18:35 +01002444requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002445run_test "Renego ext: gnutls server strict, client default" \
2446 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2447 "$P_CLI debug_level=3" \
2448 0 \
2449 -c "found renegotiation extension" \
2450 -C "error" \
2451 -c "HTTP/1.0 200 [Oo][Kk]"
2452
Paul Bakker539d9722015-02-08 16:18:35 +01002453requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002454run_test "Renego ext: gnutls server unsafe, client default" \
2455 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2456 "$P_CLI debug_level=3" \
2457 0 \
2458 -C "found renegotiation extension" \
2459 -C "error" \
2460 -c "HTTP/1.0 200 [Oo][Kk]"
2461
Paul Bakker539d9722015-02-08 16:18:35 +01002462requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002463run_test "Renego ext: gnutls server unsafe, client break legacy" \
2464 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2465 "$P_CLI debug_level=3 allow_legacy=-1" \
2466 1 \
2467 -C "found renegotiation extension" \
2468 -c "error" \
2469 -C "HTTP/1.0 200 [Oo][Kk]"
2470
Paul Bakker539d9722015-02-08 16:18:35 +01002471requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002472run_test "Renego ext: gnutls client strict, server default" \
2473 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002474 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002475 0 \
2476 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2477 -s "server hello, secure renegotiation extension"
2478
Paul Bakker539d9722015-02-08 16:18:35 +01002479requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002480run_test "Renego ext: gnutls client unsafe, server default" \
2481 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002482 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002483 0 \
2484 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2485 -S "server hello, secure renegotiation extension"
2486
Paul Bakker539d9722015-02-08 16:18:35 +01002487requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002488run_test "Renego ext: gnutls client unsafe, server break legacy" \
2489 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002490 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002491 1 \
2492 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2493 -S "server hello, secure renegotiation extension"
2494
Janos Follath0b242342016-02-17 10:11:21 +00002495# Tests for silently dropping trailing extra bytes in .der certificates
2496
2497requires_gnutls
2498run_test "DER format: no trailing bytes" \
2499 "$P_SRV crt_file=data_files/server5-der0.crt \
2500 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002501 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002502 0 \
2503 -c "Handshake was completed" \
2504
2505requires_gnutls
2506run_test "DER format: with a trailing zero byte" \
2507 "$P_SRV crt_file=data_files/server5-der1a.crt \
2508 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002509 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002510 0 \
2511 -c "Handshake was completed" \
2512
2513requires_gnutls
2514run_test "DER format: with a trailing random byte" \
2515 "$P_SRV crt_file=data_files/server5-der1b.crt \
2516 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002517 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002518 0 \
2519 -c "Handshake was completed" \
2520
2521requires_gnutls
2522run_test "DER format: with 2 trailing random bytes" \
2523 "$P_SRV crt_file=data_files/server5-der2.crt \
2524 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002525 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002526 0 \
2527 -c "Handshake was completed" \
2528
2529requires_gnutls
2530run_test "DER format: with 4 trailing random bytes" \
2531 "$P_SRV crt_file=data_files/server5-der4.crt \
2532 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002533 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002534 0 \
2535 -c "Handshake was completed" \
2536
2537requires_gnutls
2538run_test "DER format: with 8 trailing random bytes" \
2539 "$P_SRV crt_file=data_files/server5-der8.crt \
2540 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002541 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002542 0 \
2543 -c "Handshake was completed" \
2544
2545requires_gnutls
2546run_test "DER format: with 9 trailing random bytes" \
2547 "$P_SRV crt_file=data_files/server5-der9.crt \
2548 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002549 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002550 0 \
2551 -c "Handshake was completed" \
2552
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002553# Tests for auth_mode
2554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002556 "$P_SRV crt_file=data_files/server5-badsign.crt \
2557 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002558 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002559 1 \
2560 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002561 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002562 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002563 -c "X509 - Certificate verification failed"
2564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002565run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002566 "$P_SRV crt_file=data_files/server5-badsign.crt \
2567 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002568 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002569 0 \
2570 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002571 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002572 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002573 -C "X509 - Certificate verification failed"
2574
Hanno Beckere6706e62017-05-15 16:05:15 +01002575run_test "Authentication: server goodcert, client optional, no trusted CA" \
2576 "$P_SRV" \
2577 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2578 0 \
2579 -c "x509_verify_cert() returned" \
2580 -c "! The certificate is not correctly signed by the trusted CA" \
2581 -c "! Certificate verification flags"\
2582 -C "! mbedtls_ssl_handshake returned" \
2583 -C "X509 - Certificate verification failed" \
2584 -C "SSL - No CA Chain is set, but required to operate"
2585
2586run_test "Authentication: server goodcert, client required, no trusted CA" \
2587 "$P_SRV" \
2588 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2589 1 \
2590 -c "x509_verify_cert() returned" \
2591 -c "! The certificate is not correctly signed by the trusted CA" \
2592 -c "! Certificate verification flags"\
2593 -c "! mbedtls_ssl_handshake returned" \
2594 -c "SSL - No CA Chain is set, but required to operate"
2595
2596# The purpose of the next two tests is to test the client's behaviour when receiving a server
2597# certificate with an unsupported elliptic curve. This should usually not happen because
2598# the client informs the server about the supported curves - it does, though, in the
2599# corner case of a static ECDH suite, because the server doesn't check the curve on that
2600# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2601# different means to have the server ignoring the client's supported curve list.
2602
2603requires_config_enabled MBEDTLS_ECP_C
2604run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2605 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2606 crt_file=data_files/server5.ku-ka.crt" \
2607 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2608 1 \
2609 -c "bad certificate (EC key curve)"\
2610 -c "! Certificate verification flags"\
2611 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2612
2613requires_config_enabled MBEDTLS_ECP_C
2614run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2615 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2616 crt_file=data_files/server5.ku-ka.crt" \
2617 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2618 1 \
2619 -c "bad certificate (EC key curve)"\
2620 -c "! Certificate verification flags"\
2621 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2622
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002623run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002624 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002625 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002626 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002627 0 \
2628 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002629 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002630 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002631 -C "X509 - Certificate verification failed"
2632
Simon Butcher99000142016-10-13 17:21:01 +01002633run_test "Authentication: client SHA256, server required" \
2634 "$P_SRV auth_mode=required" \
2635 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2636 key_file=data_files/server6.key \
2637 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2638 0 \
2639 -c "Supported Signature Algorithm found: 4," \
2640 -c "Supported Signature Algorithm found: 5,"
2641
2642run_test "Authentication: client SHA384, server required" \
2643 "$P_SRV auth_mode=required" \
2644 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2645 key_file=data_files/server6.key \
2646 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2647 0 \
2648 -c "Supported Signature Algorithm found: 4," \
2649 -c "Supported Signature Algorithm found: 5,"
2650
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002651requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2652run_test "Authentication: client has no cert, server required (SSLv3)" \
2653 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2654 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2655 key_file=data_files/server5.key" \
2656 1 \
2657 -S "skip write certificate request" \
2658 -C "skip parse certificate request" \
2659 -c "got a certificate request" \
2660 -c "got no certificate to send" \
2661 -S "x509_verify_cert() returned" \
2662 -s "client has no certificate" \
2663 -s "! mbedtls_ssl_handshake returned" \
2664 -c "! mbedtls_ssl_handshake returned" \
2665 -s "No client certification received from the client, but required by the authentication mode"
2666
2667run_test "Authentication: client has no cert, server required (TLS)" \
2668 "$P_SRV debug_level=3 auth_mode=required" \
2669 "$P_CLI debug_level=3 crt_file=none \
2670 key_file=data_files/server5.key" \
2671 1 \
2672 -S "skip write certificate request" \
2673 -C "skip parse certificate request" \
2674 -c "got a certificate request" \
2675 -c "= write certificate$" \
2676 -C "skip write certificate$" \
2677 -S "x509_verify_cert() returned" \
2678 -s "client has no certificate" \
2679 -s "! mbedtls_ssl_handshake returned" \
2680 -c "! mbedtls_ssl_handshake returned" \
2681 -s "No client certification received from the client, but required by the authentication mode"
2682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002683run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002684 "$P_SRV debug_level=3 auth_mode=required" \
2685 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002686 key_file=data_files/server5.key" \
2687 1 \
2688 -S "skip write certificate request" \
2689 -C "skip parse certificate request" \
2690 -c "got a certificate request" \
2691 -C "skip write certificate" \
2692 -C "skip write certificate verify" \
2693 -S "skip parse certificate verify" \
2694 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002695 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002696 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002697 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002698 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002699 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002700# We don't check that the client receives the alert because it might
2701# detect that its write end of the connection is closed and abort
2702# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002703
Janos Follath89baba22017-04-10 14:34:35 +01002704run_test "Authentication: client cert not trusted, server required" \
2705 "$P_SRV debug_level=3 auth_mode=required" \
2706 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2707 key_file=data_files/server5.key" \
2708 1 \
2709 -S "skip write certificate request" \
2710 -C "skip parse certificate request" \
2711 -c "got a certificate request" \
2712 -C "skip write certificate" \
2713 -C "skip write certificate verify" \
2714 -S "skip parse certificate verify" \
2715 -s "x509_verify_cert() returned" \
2716 -s "! The certificate is not correctly signed by the trusted CA" \
2717 -s "! mbedtls_ssl_handshake returned" \
2718 -c "! mbedtls_ssl_handshake returned" \
2719 -s "X509 - Certificate verification failed"
2720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002721run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002722 "$P_SRV debug_level=3 auth_mode=optional" \
2723 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002724 key_file=data_files/server5.key" \
2725 0 \
2726 -S "skip write certificate request" \
2727 -C "skip parse certificate request" \
2728 -c "got a certificate request" \
2729 -C "skip write certificate" \
2730 -C "skip write certificate verify" \
2731 -S "skip parse certificate verify" \
2732 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002733 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002734 -S "! mbedtls_ssl_handshake returned" \
2735 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002736 -S "X509 - Certificate verification failed"
2737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002738run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002739 "$P_SRV debug_level=3 auth_mode=none" \
2740 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002741 key_file=data_files/server5.key" \
2742 0 \
2743 -s "skip write certificate request" \
2744 -C "skip parse certificate request" \
2745 -c "got no certificate request" \
2746 -c "skip write certificate" \
2747 -c "skip write certificate verify" \
2748 -s "skip parse certificate verify" \
2749 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002750 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002751 -S "! mbedtls_ssl_handshake returned" \
2752 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002753 -S "X509 - Certificate verification failed"
2754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002755run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002756 "$P_SRV debug_level=3 auth_mode=optional" \
2757 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002758 0 \
2759 -S "skip write certificate request" \
2760 -C "skip parse certificate request" \
2761 -c "got a certificate request" \
2762 -C "skip write certificate$" \
2763 -C "got no certificate to send" \
2764 -S "SSLv3 client has no certificate" \
2765 -c "skip write certificate verify" \
2766 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002767 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002768 -S "! mbedtls_ssl_handshake returned" \
2769 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002770 -S "X509 - Certificate verification failed"
2771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002772run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002773 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002774 "$O_CLI" \
2775 0 \
2776 -S "skip write certificate request" \
2777 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002778 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002779 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002780 -S "X509 - Certificate verification failed"
2781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002782run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002783 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002784 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002785 0 \
2786 -C "skip parse certificate request" \
2787 -c "got a certificate request" \
2788 -C "skip write certificate$" \
2789 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002790 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002791
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002792run_test "Authentication: client no cert, openssl server required" \
2793 "$O_SRV -Verify 10" \
2794 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2795 1 \
2796 -C "skip parse certificate request" \
2797 -c "got a certificate request" \
2798 -C "skip write certificate$" \
2799 -c "skip write certificate verify" \
2800 -c "! mbedtls_ssl_handshake returned"
2801
Janos Follathe2681a42016-03-07 15:57:05 +00002802requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002803run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002804 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002805 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002806 0 \
2807 -S "skip write certificate request" \
2808 -C "skip parse certificate request" \
2809 -c "got a certificate request" \
2810 -C "skip write certificate$" \
2811 -c "skip write certificate verify" \
2812 -c "got no certificate to send" \
2813 -s "SSLv3 client has no certificate" \
2814 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002815 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002816 -S "! mbedtls_ssl_handshake returned" \
2817 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002818 -S "X509 - Certificate verification failed"
2819
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002820# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2821# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002822
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002823MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002824MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002825
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002826if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002827 cat <<EOF
2828${CONFIG_H} contains a value for the configuration of
2829MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2830test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002831
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002832The tests assume this value and if it changes, the tests in this
2833script should also be adjusted.
2834EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002835 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002836fi
2837
Angus Grattonc4dd0732018-04-11 16:28:39 +10002838requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002839run_test "Authentication: server max_int chain, client default" \
2840 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2841 key_file=data_files/dir-maxpath/09.key" \
2842 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2843 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002844 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002845
Angus Grattonc4dd0732018-04-11 16:28:39 +10002846requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002847run_test "Authentication: server max_int+1 chain, client default" \
2848 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2849 key_file=data_files/dir-maxpath/10.key" \
2850 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2851 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002852 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002853
Angus Grattonc4dd0732018-04-11 16:28:39 +10002854requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002855run_test "Authentication: server max_int+1 chain, client optional" \
2856 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2857 key_file=data_files/dir-maxpath/10.key" \
2858 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2859 auth_mode=optional" \
2860 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002861 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002862
Angus Grattonc4dd0732018-04-11 16:28:39 +10002863requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002864run_test "Authentication: server max_int+1 chain, client none" \
2865 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2866 key_file=data_files/dir-maxpath/10.key" \
2867 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2868 auth_mode=none" \
2869 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002870 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002871
Angus Grattonc4dd0732018-04-11 16:28:39 +10002872requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002873run_test "Authentication: client max_int+1 chain, server default" \
2874 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2875 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2876 key_file=data_files/dir-maxpath/10.key" \
2877 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002878 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002879
Angus Grattonc4dd0732018-04-11 16:28:39 +10002880requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002881run_test "Authentication: client max_int+1 chain, server optional" \
2882 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2883 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2884 key_file=data_files/dir-maxpath/10.key" \
2885 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002886 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002887
Angus Grattonc4dd0732018-04-11 16:28:39 +10002888requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002889run_test "Authentication: client max_int+1 chain, server required" \
2890 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2891 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2892 key_file=data_files/dir-maxpath/10.key" \
2893 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002894 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002895
Angus Grattonc4dd0732018-04-11 16:28:39 +10002896requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002897run_test "Authentication: client max_int chain, server required" \
2898 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2899 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2900 key_file=data_files/dir-maxpath/09.key" \
2901 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002902 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002903
Janos Follath89baba22017-04-10 14:34:35 +01002904# Tests for CA list in CertificateRequest messages
2905
2906run_test "Authentication: send CA list in CertificateRequest (default)" \
2907 "$P_SRV debug_level=3 auth_mode=required" \
2908 "$P_CLI crt_file=data_files/server6.crt \
2909 key_file=data_files/server6.key" \
2910 0 \
2911 -s "requested DN"
2912
2913run_test "Authentication: do not send CA list in CertificateRequest" \
2914 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2915 "$P_CLI crt_file=data_files/server6.crt \
2916 key_file=data_files/server6.key" \
2917 0 \
2918 -S "requested DN"
2919
2920run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2921 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2922 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2923 key_file=data_files/server5.key" \
2924 1 \
2925 -S "requested DN" \
2926 -s "x509_verify_cert() returned" \
2927 -s "! The certificate is not correctly signed by the trusted CA" \
2928 -s "! mbedtls_ssl_handshake returned" \
2929 -c "! mbedtls_ssl_handshake returned" \
2930 -s "X509 - Certificate verification failed"
2931
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002932# Tests for certificate selection based on SHA verson
2933
2934run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2935 "$P_SRV crt_file=data_files/server5.crt \
2936 key_file=data_files/server5.key \
2937 crt_file2=data_files/server5-sha1.crt \
2938 key_file2=data_files/server5.key" \
2939 "$P_CLI force_version=tls1_2" \
2940 0 \
2941 -c "signed using.*ECDSA with SHA256" \
2942 -C "signed using.*ECDSA with SHA1"
2943
2944run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2945 "$P_SRV crt_file=data_files/server5.crt \
2946 key_file=data_files/server5.key \
2947 crt_file2=data_files/server5-sha1.crt \
2948 key_file2=data_files/server5.key" \
2949 "$P_CLI force_version=tls1_1" \
2950 0 \
2951 -C "signed using.*ECDSA with SHA256" \
2952 -c "signed using.*ECDSA with SHA1"
2953
2954run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2955 "$P_SRV crt_file=data_files/server5.crt \
2956 key_file=data_files/server5.key \
2957 crt_file2=data_files/server5-sha1.crt \
2958 key_file2=data_files/server5.key" \
2959 "$P_CLI force_version=tls1" \
2960 0 \
2961 -C "signed using.*ECDSA with SHA256" \
2962 -c "signed using.*ECDSA with SHA1"
2963
2964run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2965 "$P_SRV crt_file=data_files/server5.crt \
2966 key_file=data_files/server5.key \
2967 crt_file2=data_files/server6.crt \
2968 key_file2=data_files/server6.key" \
2969 "$P_CLI force_version=tls1_1" \
2970 0 \
2971 -c "serial number.*09" \
2972 -c "signed using.*ECDSA with SHA256" \
2973 -C "signed using.*ECDSA with SHA1"
2974
2975run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2976 "$P_SRV crt_file=data_files/server6.crt \
2977 key_file=data_files/server6.key \
2978 crt_file2=data_files/server5.crt \
2979 key_file2=data_files/server5.key" \
2980 "$P_CLI force_version=tls1_1" \
2981 0 \
2982 -c "serial number.*0A" \
2983 -c "signed using.*ECDSA with SHA256" \
2984 -C "signed using.*ECDSA with SHA1"
2985
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002986# tests for SNI
2987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002988run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002989 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002990 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002991 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002992 0 \
2993 -S "parse ServerName extension" \
2994 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2995 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002996
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002997run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002998 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002999 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003000 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 +02003001 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003002 0 \
3003 -s "parse ServerName extension" \
3004 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3005 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003007run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003008 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003009 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003010 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 +02003011 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003012 0 \
3013 -s "parse ServerName extension" \
3014 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3015 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003016
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003017run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003018 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003019 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003020 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 +02003021 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003022 1 \
3023 -s "parse ServerName extension" \
3024 -s "ssl_sni_wrapper() returned" \
3025 -s "mbedtls_ssl_handshake returned" \
3026 -c "mbedtls_ssl_handshake returned" \
3027 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003028
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003029run_test "SNI: client auth no override: optional" \
3030 "$P_SRV debug_level=3 auth_mode=optional \
3031 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3032 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3033 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003034 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003035 -S "skip write certificate request" \
3036 -C "skip parse certificate request" \
3037 -c "got a certificate request" \
3038 -C "skip write certificate" \
3039 -C "skip write certificate verify" \
3040 -S "skip parse certificate verify"
3041
3042run_test "SNI: client auth override: none -> optional" \
3043 "$P_SRV debug_level=3 auth_mode=none \
3044 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3045 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3046 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003047 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003048 -S "skip write certificate request" \
3049 -C "skip parse certificate request" \
3050 -c "got a certificate request" \
3051 -C "skip write certificate" \
3052 -C "skip write certificate verify" \
3053 -S "skip parse certificate verify"
3054
3055run_test "SNI: client auth override: optional -> none" \
3056 "$P_SRV debug_level=3 auth_mode=optional \
3057 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3058 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3059 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003060 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003061 -s "skip write certificate request" \
3062 -C "skip parse certificate request" \
3063 -c "got no certificate request" \
3064 -c "skip write certificate" \
3065 -c "skip write certificate verify" \
3066 -s "skip parse certificate verify"
3067
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003068run_test "SNI: CA no override" \
3069 "$P_SRV debug_level=3 auth_mode=optional \
3070 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3071 ca_file=data_files/test-ca.crt \
3072 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3073 "$P_CLI debug_level=3 server_name=localhost \
3074 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3075 1 \
3076 -S "skip write certificate request" \
3077 -C "skip parse certificate request" \
3078 -c "got a certificate request" \
3079 -C "skip write certificate" \
3080 -C "skip write certificate verify" \
3081 -S "skip parse certificate verify" \
3082 -s "x509_verify_cert() returned" \
3083 -s "! The certificate is not correctly signed by the trusted CA" \
3084 -S "The certificate has been revoked (is on a CRL)"
3085
3086run_test "SNI: CA override" \
3087 "$P_SRV debug_level=3 auth_mode=optional \
3088 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3089 ca_file=data_files/test-ca.crt \
3090 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3091 "$P_CLI debug_level=3 server_name=localhost \
3092 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3093 0 \
3094 -S "skip write certificate request" \
3095 -C "skip parse certificate request" \
3096 -c "got a certificate request" \
3097 -C "skip write certificate" \
3098 -C "skip write certificate verify" \
3099 -S "skip parse certificate verify" \
3100 -S "x509_verify_cert() returned" \
3101 -S "! The certificate is not correctly signed by the trusted CA" \
3102 -S "The certificate has been revoked (is on a CRL)"
3103
3104run_test "SNI: CA override with CRL" \
3105 "$P_SRV debug_level=3 auth_mode=optional \
3106 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3107 ca_file=data_files/test-ca.crt \
3108 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3109 "$P_CLI debug_level=3 server_name=localhost \
3110 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3111 1 \
3112 -S "skip write certificate request" \
3113 -C "skip parse certificate request" \
3114 -c "got a certificate request" \
3115 -C "skip write certificate" \
3116 -C "skip write certificate verify" \
3117 -S "skip parse certificate verify" \
3118 -s "x509_verify_cert() returned" \
3119 -S "! The certificate is not correctly signed by the trusted CA" \
3120 -s "The certificate has been revoked (is on a CRL)"
3121
Andres AG1a834452016-12-07 10:01:30 +00003122# Tests for SNI and DTLS
3123
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003124run_test "SNI: DTLS, no SNI callback" \
3125 "$P_SRV debug_level=3 dtls=1 \
3126 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3127 "$P_CLI server_name=localhost dtls=1" \
3128 0 \
3129 -S "parse ServerName extension" \
3130 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3131 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3132
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003133run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003134 "$P_SRV debug_level=3 dtls=1 \
3135 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3136 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3137 "$P_CLI server_name=localhost dtls=1" \
3138 0 \
3139 -s "parse ServerName extension" \
3140 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3141 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3142
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003143run_test "SNI: DTLS, matching cert 2" \
3144 "$P_SRV debug_level=3 dtls=1 \
3145 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3146 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3147 "$P_CLI server_name=polarssl.example dtls=1" \
3148 0 \
3149 -s "parse ServerName extension" \
3150 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3151 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3152
3153run_test "SNI: DTLS, no matching cert" \
3154 "$P_SRV debug_level=3 dtls=1 \
3155 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3156 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3157 "$P_CLI server_name=nonesuch.example dtls=1" \
3158 1 \
3159 -s "parse ServerName extension" \
3160 -s "ssl_sni_wrapper() returned" \
3161 -s "mbedtls_ssl_handshake returned" \
3162 -c "mbedtls_ssl_handshake returned" \
3163 -c "SSL - A fatal alert message was received from our peer"
3164
3165run_test "SNI: DTLS, client auth no override: optional" \
3166 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3167 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3168 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3169 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3170 0 \
3171 -S "skip write certificate request" \
3172 -C "skip parse certificate request" \
3173 -c "got a certificate request" \
3174 -C "skip write certificate" \
3175 -C "skip write certificate verify" \
3176 -S "skip parse certificate verify"
3177
3178run_test "SNI: DTLS, client auth override: none -> optional" \
3179 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3180 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3181 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3182 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3183 0 \
3184 -S "skip write certificate request" \
3185 -C "skip parse certificate request" \
3186 -c "got a certificate request" \
3187 -C "skip write certificate" \
3188 -C "skip write certificate verify" \
3189 -S "skip parse certificate verify"
3190
3191run_test "SNI: DTLS, client auth override: optional -> none" \
3192 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3193 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3194 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3195 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3196 0 \
3197 -s "skip write certificate request" \
3198 -C "skip parse certificate request" \
3199 -c "got no certificate request" \
3200 -c "skip write certificate" \
3201 -c "skip write certificate verify" \
3202 -s "skip parse certificate verify"
3203
3204run_test "SNI: DTLS, CA no override" \
3205 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3206 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3207 ca_file=data_files/test-ca.crt \
3208 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3209 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3210 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3211 1 \
3212 -S "skip write certificate request" \
3213 -C "skip parse certificate request" \
3214 -c "got a certificate request" \
3215 -C "skip write certificate" \
3216 -C "skip write certificate verify" \
3217 -S "skip parse certificate verify" \
3218 -s "x509_verify_cert() returned" \
3219 -s "! The certificate is not correctly signed by the trusted CA" \
3220 -S "The certificate has been revoked (is on a CRL)"
3221
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003222run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003223 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3224 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3225 ca_file=data_files/test-ca.crt \
3226 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3227 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3228 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3229 0 \
3230 -S "skip write certificate request" \
3231 -C "skip parse certificate request" \
3232 -c "got a certificate request" \
3233 -C "skip write certificate" \
3234 -C "skip write certificate verify" \
3235 -S "skip parse certificate verify" \
3236 -S "x509_verify_cert() returned" \
3237 -S "! The certificate is not correctly signed by the trusted CA" \
3238 -S "The certificate has been revoked (is on a CRL)"
3239
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003240run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003241 "$P_SRV debug_level=3 auth_mode=optional \
3242 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3243 ca_file=data_files/test-ca.crt \
3244 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3245 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3246 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3247 1 \
3248 -S "skip write certificate request" \
3249 -C "skip parse certificate request" \
3250 -c "got a certificate request" \
3251 -C "skip write certificate" \
3252 -C "skip write certificate verify" \
3253 -S "skip parse certificate verify" \
3254 -s "x509_verify_cert() returned" \
3255 -S "! The certificate is not correctly signed by the trusted CA" \
3256 -s "The certificate has been revoked (is on a CRL)"
3257
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003258# Tests for non-blocking I/O: exercise a variety of handshake flows
3259
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003260run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003261 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3262 "$P_CLI nbio=2 tickets=0" \
3263 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003264 -S "mbedtls_ssl_handshake returned" \
3265 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003266 -c "Read from server: .* bytes read"
3267
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003268run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003269 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3270 "$P_CLI nbio=2 tickets=0" \
3271 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003272 -S "mbedtls_ssl_handshake returned" \
3273 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003274 -c "Read from server: .* bytes read"
3275
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003276run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003277 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3278 "$P_CLI nbio=2 tickets=1" \
3279 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003280 -S "mbedtls_ssl_handshake returned" \
3281 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003282 -c "Read from server: .* bytes read"
3283
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003284run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003285 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3286 "$P_CLI nbio=2 tickets=1" \
3287 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003288 -S "mbedtls_ssl_handshake returned" \
3289 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003290 -c "Read from server: .* bytes read"
3291
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003292run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003293 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3294 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3295 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003296 -S "mbedtls_ssl_handshake returned" \
3297 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003298 -c "Read from server: .* bytes read"
3299
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003300run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003301 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3302 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3303 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003304 -S "mbedtls_ssl_handshake returned" \
3305 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003306 -c "Read from server: .* bytes read"
3307
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003308run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003309 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3310 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3311 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003312 -S "mbedtls_ssl_handshake returned" \
3313 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003314 -c "Read from server: .* bytes read"
3315
Hanno Becker00076712017-11-15 16:39:08 +00003316# Tests for event-driven I/O: exercise a variety of handshake flows
3317
3318run_test "Event-driven I/O: basic handshake" \
3319 "$P_SRV event=1 tickets=0 auth_mode=none" \
3320 "$P_CLI event=1 tickets=0" \
3321 0 \
3322 -S "mbedtls_ssl_handshake returned" \
3323 -C "mbedtls_ssl_handshake returned" \
3324 -c "Read from server: .* bytes read"
3325
3326run_test "Event-driven I/O: client auth" \
3327 "$P_SRV event=1 tickets=0 auth_mode=required" \
3328 "$P_CLI event=1 tickets=0" \
3329 0 \
3330 -S "mbedtls_ssl_handshake returned" \
3331 -C "mbedtls_ssl_handshake returned" \
3332 -c "Read from server: .* bytes read"
3333
3334run_test "Event-driven I/O: ticket" \
3335 "$P_SRV event=1 tickets=1 auth_mode=none" \
3336 "$P_CLI event=1 tickets=1" \
3337 0 \
3338 -S "mbedtls_ssl_handshake returned" \
3339 -C "mbedtls_ssl_handshake returned" \
3340 -c "Read from server: .* bytes read"
3341
3342run_test "Event-driven I/O: ticket + client auth" \
3343 "$P_SRV event=1 tickets=1 auth_mode=required" \
3344 "$P_CLI event=1 tickets=1" \
3345 0 \
3346 -S "mbedtls_ssl_handshake returned" \
3347 -C "mbedtls_ssl_handshake returned" \
3348 -c "Read from server: .* bytes read"
3349
3350run_test "Event-driven I/O: ticket + client auth + resume" \
3351 "$P_SRV event=1 tickets=1 auth_mode=required" \
3352 "$P_CLI event=1 tickets=1 reconnect=1" \
3353 0 \
3354 -S "mbedtls_ssl_handshake returned" \
3355 -C "mbedtls_ssl_handshake returned" \
3356 -c "Read from server: .* bytes read"
3357
3358run_test "Event-driven I/O: ticket + resume" \
3359 "$P_SRV event=1 tickets=1 auth_mode=none" \
3360 "$P_CLI event=1 tickets=1 reconnect=1" \
3361 0 \
3362 -S "mbedtls_ssl_handshake returned" \
3363 -C "mbedtls_ssl_handshake returned" \
3364 -c "Read from server: .* bytes read"
3365
3366run_test "Event-driven I/O: session-id resume" \
3367 "$P_SRV event=1 tickets=0 auth_mode=none" \
3368 "$P_CLI event=1 tickets=0 reconnect=1" \
3369 0 \
3370 -S "mbedtls_ssl_handshake returned" \
3371 -C "mbedtls_ssl_handshake returned" \
3372 -c "Read from server: .* bytes read"
3373
Hanno Becker6a33f592018-03-13 11:38:46 +00003374run_test "Event-driven I/O, DTLS: basic handshake" \
3375 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3376 "$P_CLI dtls=1 event=1 tickets=0" \
3377 0 \
3378 -c "Read from server: .* bytes read"
3379
3380run_test "Event-driven I/O, DTLS: client auth" \
3381 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3382 "$P_CLI dtls=1 event=1 tickets=0" \
3383 0 \
3384 -c "Read from server: .* bytes read"
3385
3386run_test "Event-driven I/O, DTLS: ticket" \
3387 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3388 "$P_CLI dtls=1 event=1 tickets=1" \
3389 0 \
3390 -c "Read from server: .* bytes read"
3391
3392run_test "Event-driven I/O, DTLS: ticket + client auth" \
3393 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3394 "$P_CLI dtls=1 event=1 tickets=1" \
3395 0 \
3396 -c "Read from server: .* bytes read"
3397
3398run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3399 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003400 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003401 0 \
3402 -c "Read from server: .* bytes read"
3403
3404run_test "Event-driven I/O, DTLS: ticket + resume" \
3405 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003406 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003407 0 \
3408 -c "Read from server: .* bytes read"
3409
3410run_test "Event-driven I/O, DTLS: session-id resume" \
3411 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003412 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003413 0 \
3414 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003415
3416# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3417# During session resumption, the client will send its ApplicationData record
3418# within the same datagram as the Finished messages. In this situation, the
3419# server MUST NOT idle on the underlying transport after handshake completion,
3420# because the ApplicationData request has already been queued internally.
3421run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003422 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003423 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003424 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003425 0 \
3426 -c "Read from server: .* bytes read"
3427
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003428# Tests for version negotiation
3429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003430run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003431 "$P_SRV" \
3432 "$P_CLI" \
3433 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003434 -S "mbedtls_ssl_handshake returned" \
3435 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003436 -s "Protocol is TLSv1.2" \
3437 -c "Protocol is TLSv1.2"
3438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003439run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003440 "$P_SRV" \
3441 "$P_CLI max_version=tls1_1" \
3442 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003443 -S "mbedtls_ssl_handshake returned" \
3444 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003445 -s "Protocol is TLSv1.1" \
3446 -c "Protocol is TLSv1.1"
3447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003448run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003449 "$P_SRV max_version=tls1_1" \
3450 "$P_CLI" \
3451 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003452 -S "mbedtls_ssl_handshake returned" \
3453 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003454 -s "Protocol is TLSv1.1" \
3455 -c "Protocol is TLSv1.1"
3456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003457run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003458 "$P_SRV max_version=tls1_1" \
3459 "$P_CLI max_version=tls1_1" \
3460 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003461 -S "mbedtls_ssl_handshake returned" \
3462 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003463 -s "Protocol is TLSv1.1" \
3464 -c "Protocol is TLSv1.1"
3465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003466run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003467 "$P_SRV min_version=tls1_1" \
3468 "$P_CLI max_version=tls1_1" \
3469 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003470 -S "mbedtls_ssl_handshake returned" \
3471 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003472 -s "Protocol is TLSv1.1" \
3473 -c "Protocol is TLSv1.1"
3474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003475run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003476 "$P_SRV max_version=tls1_1" \
3477 "$P_CLI min_version=tls1_1" \
3478 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003479 -S "mbedtls_ssl_handshake returned" \
3480 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003481 -s "Protocol is TLSv1.1" \
3482 -c "Protocol is TLSv1.1"
3483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003484run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003485 "$P_SRV max_version=tls1_1" \
3486 "$P_CLI min_version=tls1_2" \
3487 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003488 -s "mbedtls_ssl_handshake returned" \
3489 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003490 -c "SSL - Handshake protocol not within min/max boundaries"
3491
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003492run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003493 "$P_SRV min_version=tls1_2" \
3494 "$P_CLI max_version=tls1_1" \
3495 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003496 -s "mbedtls_ssl_handshake returned" \
3497 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003498 -s "SSL - Handshake protocol not within min/max boundaries"
3499
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003500# Tests for ALPN extension
3501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003502run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003503 "$P_SRV debug_level=3" \
3504 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003505 0 \
3506 -C "client hello, adding alpn extension" \
3507 -S "found alpn extension" \
3508 -C "got an alert message, type: \\[2:120]" \
3509 -S "server hello, adding alpn extension" \
3510 -C "found alpn extension " \
3511 -C "Application Layer Protocol is" \
3512 -S "Application Layer Protocol is"
3513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003514run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003515 "$P_SRV debug_level=3" \
3516 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003517 0 \
3518 -c "client hello, adding alpn extension" \
3519 -s "found alpn extension" \
3520 -C "got an alert message, type: \\[2:120]" \
3521 -S "server hello, adding alpn extension" \
3522 -C "found alpn extension " \
3523 -c "Application Layer Protocol is (none)" \
3524 -S "Application Layer Protocol is"
3525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003526run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003527 "$P_SRV debug_level=3 alpn=abc,1234" \
3528 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003529 0 \
3530 -C "client hello, adding alpn extension" \
3531 -S "found alpn extension" \
3532 -C "got an alert message, type: \\[2:120]" \
3533 -S "server hello, adding alpn extension" \
3534 -C "found alpn extension " \
3535 -C "Application Layer Protocol is" \
3536 -s "Application Layer Protocol is (none)"
3537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003538run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003539 "$P_SRV debug_level=3 alpn=abc,1234" \
3540 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003541 0 \
3542 -c "client hello, adding alpn extension" \
3543 -s "found alpn extension" \
3544 -C "got an alert message, type: \\[2:120]" \
3545 -s "server hello, adding alpn extension" \
3546 -c "found alpn extension" \
3547 -c "Application Layer Protocol is abc" \
3548 -s "Application Layer Protocol is abc"
3549
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003550run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003551 "$P_SRV debug_level=3 alpn=abc,1234" \
3552 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003553 0 \
3554 -c "client hello, adding alpn extension" \
3555 -s "found alpn extension" \
3556 -C "got an alert message, type: \\[2:120]" \
3557 -s "server hello, adding alpn extension" \
3558 -c "found alpn extension" \
3559 -c "Application Layer Protocol is abc" \
3560 -s "Application Layer Protocol is abc"
3561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003562run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003563 "$P_SRV debug_level=3 alpn=abc,1234" \
3564 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003565 0 \
3566 -c "client hello, adding alpn extension" \
3567 -s "found alpn extension" \
3568 -C "got an alert message, type: \\[2:120]" \
3569 -s "server hello, adding alpn extension" \
3570 -c "found alpn extension" \
3571 -c "Application Layer Protocol is 1234" \
3572 -s "Application Layer Protocol is 1234"
3573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003574run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003575 "$P_SRV debug_level=3 alpn=abc,123" \
3576 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003577 1 \
3578 -c "client hello, adding alpn extension" \
3579 -s "found alpn extension" \
3580 -c "got an alert message, type: \\[2:120]" \
3581 -S "server hello, adding alpn extension" \
3582 -C "found alpn extension" \
3583 -C "Application Layer Protocol is 1234" \
3584 -S "Application Layer Protocol is 1234"
3585
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003586
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003587# Tests for keyUsage in leaf certificates, part 1:
3588# server-side certificate/suite selection
3589
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003590run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003591 "$P_SRV key_file=data_files/server2.key \
3592 crt_file=data_files/server2.ku-ds.crt" \
3593 "$P_CLI" \
3594 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003595 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003596
3597
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003598run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003599 "$P_SRV key_file=data_files/server2.key \
3600 crt_file=data_files/server2.ku-ke.crt" \
3601 "$P_CLI" \
3602 0 \
3603 -c "Ciphersuite is TLS-RSA-WITH-"
3604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003605run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003606 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003607 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003608 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003609 1 \
3610 -C "Ciphersuite is "
3611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003612run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003613 "$P_SRV key_file=data_files/server5.key \
3614 crt_file=data_files/server5.ku-ds.crt" \
3615 "$P_CLI" \
3616 0 \
3617 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3618
3619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003620run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003621 "$P_SRV key_file=data_files/server5.key \
3622 crt_file=data_files/server5.ku-ka.crt" \
3623 "$P_CLI" \
3624 0 \
3625 -c "Ciphersuite is TLS-ECDH-"
3626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003627run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003628 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003629 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003630 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003631 1 \
3632 -C "Ciphersuite is "
3633
3634# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003635# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003636
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003637run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003638 "$O_SRV -key data_files/server2.key \
3639 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003640 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003641 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3642 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003643 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003644 -C "Processing of the Certificate handshake message failed" \
3645 -c "Ciphersuite is TLS-"
3646
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003647run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003648 "$O_SRV -key data_files/server2.key \
3649 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003650 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003651 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3652 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003653 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003654 -C "Processing of the Certificate handshake message failed" \
3655 -c "Ciphersuite is TLS-"
3656
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003657run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003658 "$O_SRV -key data_files/server2.key \
3659 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003660 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003661 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3662 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003663 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003664 -C "Processing of the Certificate handshake message failed" \
3665 -c "Ciphersuite is TLS-"
3666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003667run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003668 "$O_SRV -key data_files/server2.key \
3669 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003670 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003671 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3672 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003673 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003674 -c "Processing of the Certificate handshake message failed" \
3675 -C "Ciphersuite is TLS-"
3676
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003677run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3678 "$O_SRV -key data_files/server2.key \
3679 -cert data_files/server2.ku-ke.crt" \
3680 "$P_CLI debug_level=1 auth_mode=optional \
3681 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3682 0 \
3683 -c "bad certificate (usage extensions)" \
3684 -C "Processing of the Certificate handshake message failed" \
3685 -c "Ciphersuite is TLS-" \
3686 -c "! Usage does not match the keyUsage extension"
3687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003688run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003689 "$O_SRV -key data_files/server2.key \
3690 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003691 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003692 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3693 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003694 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003695 -C "Processing of the Certificate handshake message failed" \
3696 -c "Ciphersuite is TLS-"
3697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003698run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003699 "$O_SRV -key data_files/server2.key \
3700 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003701 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003702 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3703 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003704 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003705 -c "Processing of the Certificate handshake message failed" \
3706 -C "Ciphersuite is TLS-"
3707
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003708run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3709 "$O_SRV -key data_files/server2.key \
3710 -cert data_files/server2.ku-ds.crt" \
3711 "$P_CLI debug_level=1 auth_mode=optional \
3712 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3713 0 \
3714 -c "bad certificate (usage extensions)" \
3715 -C "Processing of the Certificate handshake message failed" \
3716 -c "Ciphersuite is TLS-" \
3717 -c "! Usage does not match the keyUsage extension"
3718
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003719# Tests for keyUsage in leaf certificates, part 3:
3720# server-side checking of client cert
3721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003722run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003723 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003724 "$O_CLI -key data_files/server2.key \
3725 -cert data_files/server2.ku-ds.crt" \
3726 0 \
3727 -S "bad certificate (usage extensions)" \
3728 -S "Processing of the Certificate handshake message failed"
3729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003730run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003731 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003732 "$O_CLI -key data_files/server2.key \
3733 -cert data_files/server2.ku-ke.crt" \
3734 0 \
3735 -s "bad certificate (usage extensions)" \
3736 -S "Processing of the Certificate handshake message failed"
3737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003738run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003739 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003740 "$O_CLI -key data_files/server2.key \
3741 -cert data_files/server2.ku-ke.crt" \
3742 1 \
3743 -s "bad certificate (usage extensions)" \
3744 -s "Processing of the Certificate handshake message failed"
3745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003746run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003747 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003748 "$O_CLI -key data_files/server5.key \
3749 -cert data_files/server5.ku-ds.crt" \
3750 0 \
3751 -S "bad certificate (usage extensions)" \
3752 -S "Processing of the Certificate handshake message failed"
3753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003754run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003755 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003756 "$O_CLI -key data_files/server5.key \
3757 -cert data_files/server5.ku-ka.crt" \
3758 0 \
3759 -s "bad certificate (usage extensions)" \
3760 -S "Processing of the Certificate handshake message failed"
3761
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003762# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003764run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003765 "$P_SRV key_file=data_files/server5.key \
3766 crt_file=data_files/server5.eku-srv.crt" \
3767 "$P_CLI" \
3768 0
3769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003770run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003771 "$P_SRV key_file=data_files/server5.key \
3772 crt_file=data_files/server5.eku-srv.crt" \
3773 "$P_CLI" \
3774 0
3775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003776run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003777 "$P_SRV key_file=data_files/server5.key \
3778 crt_file=data_files/server5.eku-cs_any.crt" \
3779 "$P_CLI" \
3780 0
3781
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003782run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003783 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003784 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003785 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003786 1
3787
3788# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003790run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003791 "$O_SRV -key data_files/server5.key \
3792 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003793 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003794 0 \
3795 -C "bad certificate (usage extensions)" \
3796 -C "Processing of the Certificate handshake message failed" \
3797 -c "Ciphersuite is TLS-"
3798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003799run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003800 "$O_SRV -key data_files/server5.key \
3801 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003802 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003803 0 \
3804 -C "bad certificate (usage extensions)" \
3805 -C "Processing of the Certificate handshake message failed" \
3806 -c "Ciphersuite is TLS-"
3807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003808run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003809 "$O_SRV -key data_files/server5.key \
3810 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003811 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003812 0 \
3813 -C "bad certificate (usage extensions)" \
3814 -C "Processing of the Certificate handshake message failed" \
3815 -c "Ciphersuite is TLS-"
3816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003817run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003818 "$O_SRV -key data_files/server5.key \
3819 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003820 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003821 1 \
3822 -c "bad certificate (usage extensions)" \
3823 -c "Processing of the Certificate handshake message failed" \
3824 -C "Ciphersuite is TLS-"
3825
3826# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003828run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003829 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003830 "$O_CLI -key data_files/server5.key \
3831 -cert data_files/server5.eku-cli.crt" \
3832 0 \
3833 -S "bad certificate (usage extensions)" \
3834 -S "Processing of the Certificate handshake message failed"
3835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003836run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003837 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003838 "$O_CLI -key data_files/server5.key \
3839 -cert data_files/server5.eku-srv_cli.crt" \
3840 0 \
3841 -S "bad certificate (usage extensions)" \
3842 -S "Processing of the Certificate handshake message failed"
3843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003844run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003845 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003846 "$O_CLI -key data_files/server5.key \
3847 -cert data_files/server5.eku-cs_any.crt" \
3848 0 \
3849 -S "bad certificate (usage extensions)" \
3850 -S "Processing of the Certificate handshake message failed"
3851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003852run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003853 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003854 "$O_CLI -key data_files/server5.key \
3855 -cert data_files/server5.eku-cs.crt" \
3856 0 \
3857 -s "bad certificate (usage extensions)" \
3858 -S "Processing of the Certificate handshake message failed"
3859
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003860run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003861 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003862 "$O_CLI -key data_files/server5.key \
3863 -cert data_files/server5.eku-cs.crt" \
3864 1 \
3865 -s "bad certificate (usage extensions)" \
3866 -s "Processing of the Certificate handshake message failed"
3867
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003868# Tests for DHM parameters loading
3869
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003870run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003871 "$P_SRV" \
3872 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3873 debug_level=3" \
3874 0 \
3875 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003876 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003878run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003879 "$P_SRV dhm_file=data_files/dhparams.pem" \
3880 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3881 debug_level=3" \
3882 0 \
3883 -c "value of 'DHM: P ' (1024 bits)" \
3884 -c "value of 'DHM: G ' (2 bits)"
3885
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003886# Tests for DHM client-side size checking
3887
3888run_test "DHM size: server default, client default, OK" \
3889 "$P_SRV" \
3890 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3891 debug_level=1" \
3892 0 \
3893 -C "DHM prime too short:"
3894
3895run_test "DHM size: server default, client 2048, OK" \
3896 "$P_SRV" \
3897 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3898 debug_level=1 dhmlen=2048" \
3899 0 \
3900 -C "DHM prime too short:"
3901
3902run_test "DHM size: server 1024, client default, OK" \
3903 "$P_SRV dhm_file=data_files/dhparams.pem" \
3904 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3905 debug_level=1" \
3906 0 \
3907 -C "DHM prime too short:"
3908
3909run_test "DHM size: server 1000, client default, rejected" \
3910 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3911 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3912 debug_level=1" \
3913 1 \
3914 -c "DHM prime too short:"
3915
3916run_test "DHM size: server default, client 2049, rejected" \
3917 "$P_SRV" \
3918 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3919 debug_level=1 dhmlen=2049" \
3920 1 \
3921 -c "DHM prime too short:"
3922
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003923# Tests for PSK callback
3924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003925run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003926 "$P_SRV psk=abc123 psk_identity=foo" \
3927 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3928 psk_identity=foo psk=abc123" \
3929 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003930 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003931 -S "SSL - Unknown identity received" \
3932 -S "SSL - Verification of the message MAC failed"
3933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003934run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003935 "$P_SRV" \
3936 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3937 psk_identity=foo psk=abc123" \
3938 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003939 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003940 -S "SSL - Unknown identity received" \
3941 -S "SSL - Verification of the message MAC failed"
3942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003943run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003944 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3945 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3946 psk_identity=foo psk=abc123" \
3947 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003948 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003949 -s "SSL - Unknown identity received" \
3950 -S "SSL - Verification of the message MAC failed"
3951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003952run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003953 "$P_SRV psk_list=abc,dead,def,beef" \
3954 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3955 psk_identity=abc psk=dead" \
3956 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003957 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003958 -S "SSL - Unknown identity received" \
3959 -S "SSL - Verification of the message MAC failed"
3960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003961run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003962 "$P_SRV psk_list=abc,dead,def,beef" \
3963 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3964 psk_identity=def psk=beef" \
3965 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003966 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003967 -S "SSL - Unknown identity received" \
3968 -S "SSL - Verification of the message MAC failed"
3969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003970run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003971 "$P_SRV psk_list=abc,dead,def,beef" \
3972 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3973 psk_identity=ghi psk=beef" \
3974 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003975 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003976 -s "SSL - Unknown identity received" \
3977 -S "SSL - Verification of the message MAC failed"
3978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003979run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003980 "$P_SRV psk_list=abc,dead,def,beef" \
3981 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3982 psk_identity=abc psk=beef" \
3983 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003984 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003985 -S "SSL - Unknown identity received" \
3986 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003987
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003988# Tests for EC J-PAKE
3989
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003990requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003991run_test "ECJPAKE: client not configured" \
3992 "$P_SRV debug_level=3" \
3993 "$P_CLI debug_level=3" \
3994 0 \
3995 -C "add ciphersuite: c0ff" \
3996 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003997 -S "found ecjpake kkpp extension" \
3998 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003999 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004000 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004001 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004002 -S "None of the common ciphersuites is usable"
4003
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004004requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004005run_test "ECJPAKE: server not configured" \
4006 "$P_SRV debug_level=3" \
4007 "$P_CLI debug_level=3 ecjpake_pw=bla \
4008 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4009 1 \
4010 -c "add ciphersuite: c0ff" \
4011 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004012 -s "found ecjpake kkpp extension" \
4013 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004014 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004015 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004016 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004017 -s "None of the common ciphersuites is usable"
4018
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004019requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004020run_test "ECJPAKE: working, TLS" \
4021 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4022 "$P_CLI debug_level=3 ecjpake_pw=bla \
4023 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004024 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004025 -c "add ciphersuite: c0ff" \
4026 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004027 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004028 -s "found ecjpake kkpp extension" \
4029 -S "skip ecjpake kkpp extension" \
4030 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004031 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004032 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004033 -S "None of the common ciphersuites is usable" \
4034 -S "SSL - Verification of the message MAC failed"
4035
Janos Follath74537a62016-09-02 13:45:28 +01004036server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004037requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004038run_test "ECJPAKE: password mismatch, TLS" \
4039 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4040 "$P_CLI debug_level=3 ecjpake_pw=bad \
4041 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4042 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004043 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004044 -s "SSL - Verification of the message MAC failed"
4045
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004046requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004047run_test "ECJPAKE: working, DTLS" \
4048 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4049 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4050 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4051 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004052 -c "re-using cached ecjpake parameters" \
4053 -S "SSL - Verification of the message MAC failed"
4054
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004055requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004056run_test "ECJPAKE: working, DTLS, no cookie" \
4057 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4058 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4059 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4060 0 \
4061 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004062 -S "SSL - Verification of the message MAC failed"
4063
Janos Follath74537a62016-09-02 13:45:28 +01004064server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004065requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004066run_test "ECJPAKE: password mismatch, DTLS" \
4067 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4068 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4069 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4070 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004071 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004072 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004073
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004074# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004075requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004076run_test "ECJPAKE: working, DTLS, nolog" \
4077 "$P_SRV dtls=1 ecjpake_pw=bla" \
4078 "$P_CLI dtls=1 ecjpake_pw=bla \
4079 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4080 0
4081
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004082# Tests for ciphersuites per version
4083
Janos Follathe2681a42016-03-07 15:57:05 +00004084requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004085requires_config_enabled MBEDTLS_CAMELLIA_C
4086requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004087run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004088 "$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 +02004089 "$P_CLI force_version=ssl3" \
4090 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004091 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004092
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004093requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4094requires_config_enabled MBEDTLS_CAMELLIA_C
4095requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004096run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004097 "$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 +01004098 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004099 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004100 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004101
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004102requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4103requires_config_enabled MBEDTLS_CAMELLIA_C
4104requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004105run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004106 "$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 +02004107 "$P_CLI force_version=tls1_1" \
4108 0 \
4109 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4110
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004111requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4112requires_config_enabled MBEDTLS_CAMELLIA_C
4113requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004114run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004115 "$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 +02004116 "$P_CLI force_version=tls1_2" \
4117 0 \
4118 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4119
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004120# Test for ClientHello without extensions
4121
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004122requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004123run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004124 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004125 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004126 0 \
4127 -s "dumping 'client hello extensions' (0 bytes)"
4128
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004129# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004130
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004131run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004132 "$P_SRV" \
4133 "$P_CLI request_size=100" \
4134 0 \
4135 -s "Read from client: 100 bytes read$"
4136
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004137run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004138 "$P_SRV" \
4139 "$P_CLI request_size=500" \
4140 0 \
4141 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004142
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004143# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004144
Janos Follathe2681a42016-03-07 15:57:05 +00004145requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004146run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004147 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004148 "$P_CLI request_size=1 force_version=ssl3 \
4149 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4150 0 \
4151 -s "Read from client: 1 bytes read"
4152
Janos Follathe2681a42016-03-07 15:57:05 +00004153requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004154run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004155 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004156 "$P_CLI request_size=1 force_version=ssl3 \
4157 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4158 0 \
4159 -s "Read from client: 1 bytes read"
4160
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004161run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004162 "$P_SRV" \
4163 "$P_CLI request_size=1 force_version=tls1 \
4164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4165 0 \
4166 -s "Read from client: 1 bytes read"
4167
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004168run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004169 "$P_SRV" \
4170 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4171 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4172 0 \
4173 -s "Read from client: 1 bytes read"
4174
Hanno Becker32c55012017-11-10 08:42:54 +00004175requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004176run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004177 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004178 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004179 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004180 0 \
4181 -s "Read from client: 1 bytes read"
4182
Hanno Becker32c55012017-11-10 08:42:54 +00004183requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004184run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004185 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004186 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004187 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004188 0 \
4189 -s "Read from client: 1 bytes read"
4190
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004191run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004192 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004193 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004194 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4195 0 \
4196 -s "Read from client: 1 bytes read"
4197
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004198run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004199 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4200 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004201 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004202 0 \
4203 -s "Read from client: 1 bytes read"
4204
4205requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004206run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004207 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004208 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004209 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004210 0 \
4211 -s "Read from client: 1 bytes read"
4212
Hanno Becker8501f982017-11-10 08:59:04 +00004213requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004214run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004215 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4216 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4217 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004218 0 \
4219 -s "Read from client: 1 bytes read"
4220
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004221run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004222 "$P_SRV" \
4223 "$P_CLI request_size=1 force_version=tls1_1 \
4224 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4225 0 \
4226 -s "Read from client: 1 bytes read"
4227
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004228run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004229 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004230 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004231 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004232 0 \
4233 -s "Read from client: 1 bytes read"
4234
4235requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004236run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004237 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004238 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004239 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004240 0 \
4241 -s "Read from client: 1 bytes read"
4242
4243requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004244run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004245 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004246 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004247 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004248 0 \
4249 -s "Read from client: 1 bytes read"
4250
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004251run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004252 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004253 "$P_CLI request_size=1 force_version=tls1_1 \
4254 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4255 0 \
4256 -s "Read from client: 1 bytes read"
4257
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004258run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004259 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004260 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004262 0 \
4263 -s "Read from client: 1 bytes read"
4264
Hanno Becker8501f982017-11-10 08:59:04 +00004265requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004266run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004267 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004268 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004269 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004270 0 \
4271 -s "Read from client: 1 bytes read"
4272
Hanno Becker32c55012017-11-10 08:42:54 +00004273requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004274run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004275 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004276 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004278 0 \
4279 -s "Read from client: 1 bytes read"
4280
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004281run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004282 "$P_SRV" \
4283 "$P_CLI request_size=1 force_version=tls1_2 \
4284 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4285 0 \
4286 -s "Read from client: 1 bytes read"
4287
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004288run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004289 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004290 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004291 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004292 0 \
4293 -s "Read from client: 1 bytes read"
4294
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004295run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004296 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004297 "$P_CLI request_size=1 force_version=tls1_2 \
4298 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004299 0 \
4300 -s "Read from client: 1 bytes read"
4301
Hanno Becker32c55012017-11-10 08:42:54 +00004302requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004303run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004304 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004305 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004306 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004307 0 \
4308 -s "Read from client: 1 bytes read"
4309
Hanno Becker8501f982017-11-10 08:59:04 +00004310requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004311run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004312 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004313 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004314 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004315 0 \
4316 -s "Read from client: 1 bytes read"
4317
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004318run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004319 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004320 "$P_CLI request_size=1 force_version=tls1_2 \
4321 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4322 0 \
4323 -s "Read from client: 1 bytes read"
4324
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004325run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004326 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004327 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004329 0 \
4330 -s "Read from client: 1 bytes read"
4331
Hanno Becker32c55012017-11-10 08:42:54 +00004332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004333run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004334 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004335 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004336 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004337 0 \
4338 -s "Read from client: 1 bytes read"
4339
Hanno Becker8501f982017-11-10 08:59:04 +00004340requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004341run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004342 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004343 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004345 0 \
4346 -s "Read from client: 1 bytes read"
4347
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004348run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004349 "$P_SRV" \
4350 "$P_CLI request_size=1 force_version=tls1_2 \
4351 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4352 0 \
4353 -s "Read from client: 1 bytes read"
4354
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004355run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004356 "$P_SRV" \
4357 "$P_CLI request_size=1 force_version=tls1_2 \
4358 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4359 0 \
4360 -s "Read from client: 1 bytes read"
4361
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004362# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004363
4364requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004365run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004366 "$P_SRV dtls=1 force_version=dtls1" \
4367 "$P_CLI dtls=1 request_size=1 \
4368 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4369 0 \
4370 -s "Read from client: 1 bytes read"
4371
4372requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004373run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004374 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4375 "$P_CLI dtls=1 request_size=1 \
4376 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4377 0 \
4378 -s "Read from client: 1 bytes read"
4379
4380requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4381requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004382run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004383 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4384 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4386 0 \
4387 -s "Read from client: 1 bytes read"
4388
4389requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4390requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004391run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004392 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004393 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004394 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004395 0 \
4396 -s "Read from client: 1 bytes read"
4397
4398requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004399run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004400 "$P_SRV dtls=1 force_version=dtls1_2" \
4401 "$P_CLI dtls=1 request_size=1 \
4402 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4403 0 \
4404 -s "Read from client: 1 bytes read"
4405
4406requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004407run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004408 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004409 "$P_CLI dtls=1 request_size=1 \
4410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4411 0 \
4412 -s "Read from client: 1 bytes read"
4413
4414requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4415requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004416run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004417 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004418 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004420 0 \
4421 -s "Read from client: 1 bytes read"
4422
4423requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4424requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004425run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004426 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004427 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004428 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004429 0 \
4430 -s "Read from client: 1 bytes read"
4431
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004432# Tests for small server packets
4433
4434requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4435run_test "Small server packet SSLv3 BlockCipher" \
4436 "$P_SRV response_size=1 min_version=ssl3" \
4437 "$P_CLI force_version=ssl3 \
4438 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4439 0 \
4440 -c "Read from server: 1 bytes read"
4441
4442requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4443run_test "Small server packet SSLv3 StreamCipher" \
4444 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4445 "$P_CLI force_version=ssl3 \
4446 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4447 0 \
4448 -c "Read from server: 1 bytes read"
4449
4450run_test "Small server packet TLS 1.0 BlockCipher" \
4451 "$P_SRV response_size=1" \
4452 "$P_CLI force_version=tls1 \
4453 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4454 0 \
4455 -c "Read from server: 1 bytes read"
4456
4457run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4458 "$P_SRV response_size=1" \
4459 "$P_CLI force_version=tls1 etm=0 \
4460 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4461 0 \
4462 -c "Read from server: 1 bytes read"
4463
4464requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4465run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4466 "$P_SRV response_size=1 trunc_hmac=1" \
4467 "$P_CLI force_version=tls1 \
4468 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4469 0 \
4470 -c "Read from server: 1 bytes read"
4471
4472requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4473run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4474 "$P_SRV response_size=1 trunc_hmac=1" \
4475 "$P_CLI force_version=tls1 \
4476 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4477 0 \
4478 -c "Read from server: 1 bytes read"
4479
4480run_test "Small server packet TLS 1.0 StreamCipher" \
4481 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4482 "$P_CLI force_version=tls1 \
4483 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4484 0 \
4485 -c "Read from server: 1 bytes read"
4486
4487run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4488 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4489 "$P_CLI force_version=tls1 \
4490 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4491 0 \
4492 -c "Read from server: 1 bytes read"
4493
4494requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4495run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4496 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4497 "$P_CLI force_version=tls1 \
4498 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4499 0 \
4500 -c "Read from server: 1 bytes read"
4501
4502requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4503run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4504 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4505 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4506 trunc_hmac=1 etm=0" \
4507 0 \
4508 -c "Read from server: 1 bytes read"
4509
4510run_test "Small server packet TLS 1.1 BlockCipher" \
4511 "$P_SRV response_size=1" \
4512 "$P_CLI force_version=tls1_1 \
4513 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4514 0 \
4515 -c "Read from server: 1 bytes read"
4516
4517run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4518 "$P_SRV response_size=1" \
4519 "$P_CLI force_version=tls1_1 \
4520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4521 0 \
4522 -c "Read from server: 1 bytes read"
4523
4524requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4525run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4526 "$P_SRV response_size=1 trunc_hmac=1" \
4527 "$P_CLI force_version=tls1_1 \
4528 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4529 0 \
4530 -c "Read from server: 1 bytes read"
4531
4532requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4533run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4534 "$P_SRV response_size=1 trunc_hmac=1" \
4535 "$P_CLI force_version=tls1_1 \
4536 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4537 0 \
4538 -c "Read from server: 1 bytes read"
4539
4540run_test "Small server packet TLS 1.1 StreamCipher" \
4541 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4542 "$P_CLI force_version=tls1_1 \
4543 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4544 0 \
4545 -c "Read from server: 1 bytes read"
4546
4547run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4548 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4549 "$P_CLI force_version=tls1_1 \
4550 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4551 0 \
4552 -c "Read from server: 1 bytes read"
4553
4554requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4555run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4556 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4557 "$P_CLI force_version=tls1_1 \
4558 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4559 0 \
4560 -c "Read from server: 1 bytes read"
4561
4562requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4563run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4564 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4565 "$P_CLI force_version=tls1_1 \
4566 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4567 0 \
4568 -c "Read from server: 1 bytes read"
4569
4570run_test "Small server packet TLS 1.2 BlockCipher" \
4571 "$P_SRV response_size=1" \
4572 "$P_CLI force_version=tls1_2 \
4573 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4574 0 \
4575 -c "Read from server: 1 bytes read"
4576
4577run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4578 "$P_SRV response_size=1" \
4579 "$P_CLI force_version=tls1_2 \
4580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4581 0 \
4582 -c "Read from server: 1 bytes read"
4583
4584run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4585 "$P_SRV response_size=1" \
4586 "$P_CLI force_version=tls1_2 \
4587 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4588 0 \
4589 -c "Read from server: 1 bytes read"
4590
4591requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4592run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4593 "$P_SRV response_size=1 trunc_hmac=1" \
4594 "$P_CLI force_version=tls1_2 \
4595 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4596 0 \
4597 -c "Read from server: 1 bytes read"
4598
4599requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4600run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4601 "$P_SRV response_size=1 trunc_hmac=1" \
4602 "$P_CLI force_version=tls1_2 \
4603 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4604 0 \
4605 -c "Read from server: 1 bytes read"
4606
4607run_test "Small server packet TLS 1.2 StreamCipher" \
4608 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4609 "$P_CLI force_version=tls1_2 \
4610 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4611 0 \
4612 -c "Read from server: 1 bytes read"
4613
4614run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4615 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4616 "$P_CLI force_version=tls1_2 \
4617 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4618 0 \
4619 -c "Read from server: 1 bytes read"
4620
4621requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4622run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4623 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4624 "$P_CLI force_version=tls1_2 \
4625 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4626 0 \
4627 -c "Read from server: 1 bytes read"
4628
4629requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4630run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4631 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4632 "$P_CLI force_version=tls1_2 \
4633 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4634 0 \
4635 -c "Read from server: 1 bytes read"
4636
4637run_test "Small server packet TLS 1.2 AEAD" \
4638 "$P_SRV response_size=1" \
4639 "$P_CLI force_version=tls1_2 \
4640 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4641 0 \
4642 -c "Read from server: 1 bytes read"
4643
4644run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4645 "$P_SRV response_size=1" \
4646 "$P_CLI force_version=tls1_2 \
4647 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4648 0 \
4649 -c "Read from server: 1 bytes read"
4650
4651# Tests for small server packets in DTLS
4652
4653requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4654run_test "Small server packet DTLS 1.0" \
4655 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4656 "$P_CLI dtls=1 \
4657 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4658 0 \
4659 -c "Read from server: 1 bytes read"
4660
4661requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4662run_test "Small server packet DTLS 1.0, without EtM" \
4663 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4664 "$P_CLI dtls=1 \
4665 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4666 0 \
4667 -c "Read from server: 1 bytes read"
4668
4669requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4670requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4671run_test "Small server packet DTLS 1.0, truncated hmac" \
4672 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4673 "$P_CLI dtls=1 trunc_hmac=1 \
4674 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4675 0 \
4676 -c "Read from server: 1 bytes read"
4677
4678requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4679requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4680run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4681 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4682 "$P_CLI dtls=1 \
4683 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4684 0 \
4685 -c "Read from server: 1 bytes read"
4686
4687requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4688run_test "Small server packet DTLS 1.2" \
4689 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4690 "$P_CLI dtls=1 \
4691 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4692 0 \
4693 -c "Read from server: 1 bytes read"
4694
4695requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4696run_test "Small server packet DTLS 1.2, without EtM" \
4697 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4698 "$P_CLI dtls=1 \
4699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4700 0 \
4701 -c "Read from server: 1 bytes read"
4702
4703requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4704requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4705run_test "Small server packet DTLS 1.2, truncated hmac" \
4706 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4707 "$P_CLI dtls=1 \
4708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4709 0 \
4710 -c "Read from server: 1 bytes read"
4711
4712requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4713requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4714run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4715 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4716 "$P_CLI dtls=1 \
4717 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4718 0 \
4719 -c "Read from server: 1 bytes read"
4720
Janos Follath00efff72016-05-06 13:48:23 +01004721# A test for extensions in SSLv3
4722
4723requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4724run_test "SSLv3 with extensions, server side" \
4725 "$P_SRV min_version=ssl3 debug_level=3" \
4726 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4727 0 \
4728 -S "dumping 'client hello extensions'" \
4729 -S "server hello, total extension length:"
4730
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004731# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004732
Angus Grattonc4dd0732018-04-11 16:28:39 +10004733# How many fragments do we expect to write $1 bytes?
4734fragments_for_write() {
4735 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4736}
4737
Janos Follathe2681a42016-03-07 15:57:05 +00004738requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004739run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004740 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004741 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004742 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4743 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004744 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4745 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004746
Janos Follathe2681a42016-03-07 15:57:05 +00004747requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004748run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004749 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004750 "$P_CLI request_size=16384 force_version=ssl3 \
4751 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4752 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004753 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4754 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004755
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004756run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004757 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004758 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004759 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4760 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004761 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4762 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004763
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004764run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004765 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004766 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4767 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4768 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004769 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004770
Hanno Becker32c55012017-11-10 08:42:54 +00004771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004772run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004773 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004774 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004776 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004777 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4778 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004779
Hanno Becker32c55012017-11-10 08:42:54 +00004780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004781run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004782 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004783 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004785 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004786 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004787
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004788run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004789 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004790 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004791 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4792 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004793 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004794
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004795run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004796 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4797 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004798 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004799 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004800 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004801
4802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004803run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004804 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004805 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004806 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004807 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004808 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004809
Hanno Becker278fc7a2017-11-10 09:16:28 +00004810requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004811run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004812 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004813 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004814 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004815 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004816 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4817 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004818
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004819run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004820 "$P_SRV" \
4821 "$P_CLI request_size=16384 force_version=tls1_1 \
4822 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4823 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004824 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4825 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004826
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004827run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004828 "$P_SRV" \
4829 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004831 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004832 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004833
Hanno Becker32c55012017-11-10 08:42:54 +00004834requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004835run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004836 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004837 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004838 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004839 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004840 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004841
Hanno Becker32c55012017-11-10 08:42:54 +00004842requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004843run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004844 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004845 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004847 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004848 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004849
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004850run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004851 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4852 "$P_CLI request_size=16384 force_version=tls1_1 \
4853 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4854 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004855 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4856 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004857
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004858run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004859 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004860 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004862 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004863 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4864 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004865
Hanno Becker278fc7a2017-11-10 09:16:28 +00004866requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004867run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004868 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004869 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004870 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004871 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004872 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004873
Hanno Becker278fc7a2017-11-10 09:16:28 +00004874requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004875run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004876 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004877 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004878 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004879 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004880 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4881 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004882
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004883run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004884 "$P_SRV" \
4885 "$P_CLI request_size=16384 force_version=tls1_2 \
4886 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4887 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004888 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4889 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004890
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004891run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004892 "$P_SRV" \
4893 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4894 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4895 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004896 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004897
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004898run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004899 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004900 "$P_CLI request_size=16384 force_version=tls1_2 \
4901 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004902 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004903 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4904 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004905
Hanno Becker32c55012017-11-10 08:42:54 +00004906requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004907run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004908 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004909 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004910 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004912 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004913
Hanno Becker278fc7a2017-11-10 09:16:28 +00004914requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004915run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004916 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004917 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004918 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004919 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004920 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4921 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004922
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004923run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004924 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004925 "$P_CLI request_size=16384 force_version=tls1_2 \
4926 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4927 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004928 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4929 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004930
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004931run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004932 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004933 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004934 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4935 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004936 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004937
Hanno Becker32c55012017-11-10 08:42:54 +00004938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004939run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004940 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004941 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004942 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004943 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004944 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004945
Hanno Becker278fc7a2017-11-10 09:16:28 +00004946requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004947run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004948 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004949 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004950 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004951 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004952 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4953 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004954
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004955run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004956 "$P_SRV" \
4957 "$P_CLI request_size=16384 force_version=tls1_2 \
4958 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4959 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004960 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4961 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004962
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004963run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004964 "$P_SRV" \
4965 "$P_CLI request_size=16384 force_version=tls1_2 \
4966 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4967 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004968 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4969 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004970
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004971# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004972requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4973run_test "Large server packet SSLv3 StreamCipher" \
4974 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4975 "$P_CLI force_version=ssl3 \
4976 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4977 0 \
4978 -c "Read from server: 16384 bytes read"
4979
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004980# Checking next 4 tests logs for 1n-1 split against BEAST too
4981requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4982run_test "Large server packet SSLv3 BlockCipher" \
4983 "$P_SRV response_size=16384 min_version=ssl3" \
4984 "$P_CLI force_version=ssl3 recsplit=0 \
4985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4986 0 \
4987 -c "Read from server: 1 bytes read"\
4988 -c "16383 bytes read"\
4989 -C "Read from server: 16384 bytes read"
4990
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004991run_test "Large server packet TLS 1.0 BlockCipher" \
4992 "$P_SRV response_size=16384" \
4993 "$P_CLI force_version=tls1 recsplit=0 \
4994 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4995 0 \
4996 -c "Read from server: 1 bytes read"\
4997 -c "16383 bytes read"\
4998 -C "Read from server: 16384 bytes read"
4999
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005000run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5001 "$P_SRV response_size=16384" \
5002 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5003 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5004 0 \
5005 -c "Read from server: 1 bytes read"\
5006 -c "16383 bytes read"\
5007 -C "Read from server: 16384 bytes read"
5008
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005009requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5010run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5011 "$P_SRV response_size=16384" \
5012 "$P_CLI force_version=tls1 recsplit=0 \
5013 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5014 trunc_hmac=1" \
5015 0 \
5016 -c "Read from server: 1 bytes read"\
5017 -c "16383 bytes read"\
5018 -C "Read from server: 16384 bytes read"
5019
5020requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5021run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5022 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5023 "$P_CLI force_version=tls1 \
5024 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5025 trunc_hmac=1" \
5026 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005027 -s "16384 bytes written in 1 fragments" \
5028 -c "Read from server: 16384 bytes read"
5029
5030run_test "Large server packet TLS 1.0 StreamCipher" \
5031 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5032 "$P_CLI force_version=tls1 \
5033 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5034 0 \
5035 -s "16384 bytes written in 1 fragments" \
5036 -c "Read from server: 16384 bytes read"
5037
5038run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5039 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5040 "$P_CLI force_version=tls1 \
5041 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5042 0 \
5043 -s "16384 bytes written in 1 fragments" \
5044 -c "Read from server: 16384 bytes read"
5045
5046requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5047run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5048 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5049 "$P_CLI force_version=tls1 \
5050 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5051 0 \
5052 -s "16384 bytes written in 1 fragments" \
5053 -c "Read from server: 16384 bytes read"
5054
5055requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5056run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5057 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5058 "$P_CLI force_version=tls1 \
5059 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5060 0 \
5061 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005062 -c "Read from server: 16384 bytes read"
5063
5064run_test "Large server packet TLS 1.1 BlockCipher" \
5065 "$P_SRV response_size=16384" \
5066 "$P_CLI force_version=tls1_1 \
5067 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5068 0 \
5069 -c "Read from server: 16384 bytes read"
5070
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005071run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5072 "$P_SRV response_size=16384" \
5073 "$P_CLI force_version=tls1_1 etm=0 \
5074 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005075 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005076 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005077 -c "Read from server: 16384 bytes read"
5078
5079requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5080run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5081 "$P_SRV response_size=16384" \
5082 "$P_CLI force_version=tls1_1 \
5083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5084 trunc_hmac=1" \
5085 0 \
5086 -c "Read from server: 16384 bytes read"
5087
5088requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005089run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5090 "$P_SRV response_size=16384 trunc_hmac=1" \
5091 "$P_CLI force_version=tls1_1 \
5092 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5093 0 \
5094 -s "16384 bytes written in 1 fragments" \
5095 -c "Read from server: 16384 bytes read"
5096
5097run_test "Large server packet TLS 1.1 StreamCipher" \
5098 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5099 "$P_CLI force_version=tls1_1 \
5100 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5101 0 \
5102 -c "Read from server: 16384 bytes read"
5103
5104run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5105 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5106 "$P_CLI force_version=tls1_1 \
5107 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5108 0 \
5109 -s "16384 bytes written in 1 fragments" \
5110 -c "Read from server: 16384 bytes read"
5111
5112requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005113run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5114 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5115 "$P_CLI force_version=tls1_1 \
5116 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5117 trunc_hmac=1" \
5118 0 \
5119 -c "Read from server: 16384 bytes read"
5120
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005121run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5122 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5123 "$P_CLI force_version=tls1_1 \
5124 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5125 0 \
5126 -s "16384 bytes written in 1 fragments" \
5127 -c "Read from server: 16384 bytes read"
5128
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005129run_test "Large server packet TLS 1.2 BlockCipher" \
5130 "$P_SRV response_size=16384" \
5131 "$P_CLI force_version=tls1_2 \
5132 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5133 0 \
5134 -c "Read from server: 16384 bytes read"
5135
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005136run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5137 "$P_SRV response_size=16384" \
5138 "$P_CLI force_version=tls1_2 etm=0 \
5139 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5140 0 \
5141 -s "16384 bytes written in 1 fragments" \
5142 -c "Read from server: 16384 bytes read"
5143
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005144run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5145 "$P_SRV response_size=16384" \
5146 "$P_CLI force_version=tls1_2 \
5147 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5148 0 \
5149 -c "Read from server: 16384 bytes read"
5150
5151requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5152run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5153 "$P_SRV response_size=16384" \
5154 "$P_CLI force_version=tls1_2 \
5155 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5156 trunc_hmac=1" \
5157 0 \
5158 -c "Read from server: 16384 bytes read"
5159
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005160run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5161 "$P_SRV response_size=16384 trunc_hmac=1" \
5162 "$P_CLI force_version=tls1_2 \
5163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5164 0 \
5165 -s "16384 bytes written in 1 fragments" \
5166 -c "Read from server: 16384 bytes read"
5167
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005168run_test "Large server packet TLS 1.2 StreamCipher" \
5169 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5170 "$P_CLI force_version=tls1_2 \
5171 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5172 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005173 -s "16384 bytes written in 1 fragments" \
5174 -c "Read from server: 16384 bytes read"
5175
5176run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5177 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5178 "$P_CLI force_version=tls1_2 \
5179 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5180 0 \
5181 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005182 -c "Read from server: 16384 bytes read"
5183
5184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5185run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5186 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5187 "$P_CLI force_version=tls1_2 \
5188 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5189 trunc_hmac=1" \
5190 0 \
5191 -c "Read from server: 16384 bytes read"
5192
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005193requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5194run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5195 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5196 "$P_CLI force_version=tls1_2 \
5197 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5198 0 \
5199 -s "16384 bytes written in 1 fragments" \
5200 -c "Read from server: 16384 bytes read"
5201
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005202run_test "Large server packet TLS 1.2 AEAD" \
5203 "$P_SRV response_size=16384" \
5204 "$P_CLI force_version=tls1_2 \
5205 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5206 0 \
5207 -c "Read from server: 16384 bytes read"
5208
5209run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5210 "$P_SRV response_size=16384" \
5211 "$P_CLI force_version=tls1_2 \
5212 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5213 0 \
5214 -c "Read from server: 16384 bytes read"
5215
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005216# Tests for restartable ECC
5217
5218requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5219run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005220 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005221 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005222 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005223 debug_level=1" \
5224 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005225 -C "x509_verify_cert.*4b00" \
5226 -C "mbedtls_pk_verify.*4b00" \
5227 -C "mbedtls_ecdh_make_public.*4b00" \
5228 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005229
5230requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5231run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005232 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005233 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005234 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005235 debug_level=1 ec_max_ops=0" \
5236 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005237 -C "x509_verify_cert.*4b00" \
5238 -C "mbedtls_pk_verify.*4b00" \
5239 -C "mbedtls_ecdh_make_public.*4b00" \
5240 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005241
5242requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5243run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005244 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005245 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005246 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005247 debug_level=1 ec_max_ops=65535" \
5248 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005249 -C "x509_verify_cert.*4b00" \
5250 -C "mbedtls_pk_verify.*4b00" \
5251 -C "mbedtls_ecdh_make_public.*4b00" \
5252 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005253
5254requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5255run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005256 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005257 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005258 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005259 debug_level=1 ec_max_ops=1000" \
5260 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005261 -c "x509_verify_cert.*4b00" \
5262 -c "mbedtls_pk_verify.*4b00" \
5263 -c "mbedtls_ecdh_make_public.*4b00" \
5264 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005265
5266requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005267run_test "EC restart: TLS, max_ops=1000, badsign" \
5268 "$P_SRV auth_mode=required \
5269 crt_file=data_files/server5-badsign.crt \
5270 key_file=data_files/server5.key" \
5271 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5272 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5273 debug_level=1 ec_max_ops=1000" \
5274 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005275 -c "x509_verify_cert.*4b00" \
5276 -C "mbedtls_pk_verify.*4b00" \
5277 -C "mbedtls_ecdh_make_public.*4b00" \
5278 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005279 -c "! The certificate is not correctly signed by the trusted CA" \
5280 -c "! mbedtls_ssl_handshake returned" \
5281 -c "X509 - Certificate verification failed"
5282
5283requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5284run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5285 "$P_SRV auth_mode=required \
5286 crt_file=data_files/server5-badsign.crt \
5287 key_file=data_files/server5.key" \
5288 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5289 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5290 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5291 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005292 -c "x509_verify_cert.*4b00" \
5293 -c "mbedtls_pk_verify.*4b00" \
5294 -c "mbedtls_ecdh_make_public.*4b00" \
5295 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005296 -c "! The certificate is not correctly signed by the trusted CA" \
5297 -C "! mbedtls_ssl_handshake returned" \
5298 -C "X509 - Certificate verification failed"
5299
5300requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5301run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5302 "$P_SRV auth_mode=required \
5303 crt_file=data_files/server5-badsign.crt \
5304 key_file=data_files/server5.key" \
5305 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5306 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5307 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5308 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005309 -C "x509_verify_cert.*4b00" \
5310 -c "mbedtls_pk_verify.*4b00" \
5311 -c "mbedtls_ecdh_make_public.*4b00" \
5312 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005313 -C "! The certificate is not correctly signed by the trusted CA" \
5314 -C "! mbedtls_ssl_handshake returned" \
5315 -C "X509 - Certificate verification failed"
5316
5317requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005318run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005319 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005320 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005321 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005322 dtls=1 debug_level=1 ec_max_ops=1000" \
5323 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005324 -c "x509_verify_cert.*4b00" \
5325 -c "mbedtls_pk_verify.*4b00" \
5326 -c "mbedtls_ecdh_make_public.*4b00" \
5327 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005328
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005329requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5330run_test "EC restart: TLS, max_ops=1000 no client auth" \
5331 "$P_SRV" \
5332 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5333 debug_level=1 ec_max_ops=1000" \
5334 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005335 -c "x509_verify_cert.*4b00" \
5336 -c "mbedtls_pk_verify.*4b00" \
5337 -c "mbedtls_ecdh_make_public.*4b00" \
5338 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005339
5340requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5341run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5342 "$P_SRV psk=abc123" \
5343 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5344 psk=abc123 debug_level=1 ec_max_ops=1000" \
5345 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005346 -C "x509_verify_cert.*4b00" \
5347 -C "mbedtls_pk_verify.*4b00" \
5348 -C "mbedtls_ecdh_make_public.*4b00" \
5349 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005350
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005351# Tests of asynchronous private key support in SSL
5352
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005353requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005354run_test "SSL async private: sign, delay=0" \
5355 "$P_SRV \
5356 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005357 "$P_CLI" \
5358 0 \
5359 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005360 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005361
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005362requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005363run_test "SSL async private: sign, delay=1" \
5364 "$P_SRV \
5365 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005366 "$P_CLI" \
5367 0 \
5368 -s "Async sign callback: using key slot " \
5369 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005370 -s "Async resume (slot [0-9]): sign done, status=0"
5371
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005372requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5373run_test "SSL async private: sign, delay=2" \
5374 "$P_SRV \
5375 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5376 "$P_CLI" \
5377 0 \
5378 -s "Async sign callback: using key slot " \
5379 -U "Async sign callback: using key slot " \
5380 -s "Async resume (slot [0-9]): call 1 more times." \
5381 -s "Async resume (slot [0-9]): call 0 more times." \
5382 -s "Async resume (slot [0-9]): sign done, status=0"
5383
Gilles Peskined3268832018-04-26 06:23:59 +02005384# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5385# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5386requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5387requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5388run_test "SSL async private: sign, RSA, TLS 1.1" \
5389 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5390 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5391 "$P_CLI force_version=tls1_1" \
5392 0 \
5393 -s "Async sign callback: using key slot " \
5394 -s "Async resume (slot [0-9]): sign done, status=0"
5395
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005396requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005397run_test "SSL async private: sign, SNI" \
5398 "$P_SRV debug_level=3 \
5399 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5400 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5401 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5402 "$P_CLI server_name=polarssl.example" \
5403 0 \
5404 -s "Async sign callback: using key slot " \
5405 -s "Async resume (slot [0-9]): sign done, status=0" \
5406 -s "parse ServerName extension" \
5407 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5408 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5409
5410requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005411run_test "SSL async private: decrypt, delay=0" \
5412 "$P_SRV \
5413 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5414 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5415 0 \
5416 -s "Async decrypt callback: using key slot " \
5417 -s "Async resume (slot [0-9]): decrypt done, status=0"
5418
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005419requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005420run_test "SSL async private: decrypt, delay=1" \
5421 "$P_SRV \
5422 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5423 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5424 0 \
5425 -s "Async decrypt callback: using key slot " \
5426 -s "Async resume (slot [0-9]): call 0 more times." \
5427 -s "Async resume (slot [0-9]): decrypt done, status=0"
5428
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005429requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005430run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5431 "$P_SRV psk=abc123 \
5432 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5433 "$P_CLI psk=abc123 \
5434 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5435 0 \
5436 -s "Async decrypt callback: using key slot " \
5437 -s "Async resume (slot [0-9]): decrypt done, status=0"
5438
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005439requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005440run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5441 "$P_SRV psk=abc123 \
5442 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5443 "$P_CLI psk=abc123 \
5444 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5445 0 \
5446 -s "Async decrypt callback: using key slot " \
5447 -s "Async resume (slot [0-9]): call 0 more times." \
5448 -s "Async resume (slot [0-9]): decrypt done, status=0"
5449
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005450requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005451run_test "SSL async private: sign callback not present" \
5452 "$P_SRV \
5453 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5454 "$P_CLI; [ \$? -eq 1 ] &&
5455 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5456 0 \
5457 -S "Async sign callback" \
5458 -s "! mbedtls_ssl_handshake returned" \
5459 -s "The own private key or pre-shared key is not set, but needed" \
5460 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5461 -s "Successful connection"
5462
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005463requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005464run_test "SSL async private: decrypt callback not present" \
5465 "$P_SRV debug_level=1 \
5466 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5467 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5468 [ \$? -eq 1 ] && $P_CLI" \
5469 0 \
5470 -S "Async decrypt callback" \
5471 -s "! mbedtls_ssl_handshake returned" \
5472 -s "got no RSA private key" \
5473 -s "Async resume (slot [0-9]): sign done, status=0" \
5474 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005475
5476# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005477requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005478run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005479 "$P_SRV \
5480 async_operations=s async_private_delay1=1 \
5481 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5482 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005483 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5484 0 \
5485 -s "Async sign callback: using key slot 0," \
5486 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005487 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005488
5489# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005490requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005491run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005492 "$P_SRV \
5493 async_operations=s async_private_delay2=1 \
5494 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5495 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005496 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5497 0 \
5498 -s "Async sign callback: using key slot 0," \
5499 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005500 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005501
5502# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005503requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005504run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005505 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005506 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005507 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5508 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005509 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5510 0 \
5511 -s "Async sign callback: using key slot 1," \
5512 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005513 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005514
5515# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005516requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005517run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005518 "$P_SRV \
5519 async_operations=s async_private_delay1=1 \
5520 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5521 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005522 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5523 0 \
5524 -s "Async sign callback: no key matches this certificate."
5525
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005526requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005527run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005528 "$P_SRV \
5529 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5530 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005531 "$P_CLI" \
5532 1 \
5533 -s "Async sign callback: injected error" \
5534 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005535 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005536 -s "! mbedtls_ssl_handshake returned"
5537
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005538requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005539run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005540 "$P_SRV \
5541 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5542 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005543 "$P_CLI" \
5544 1 \
5545 -s "Async sign callback: using key slot " \
5546 -S "Async resume" \
5547 -s "Async cancel"
5548
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005549requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005550run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005551 "$P_SRV \
5552 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5553 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005554 "$P_CLI" \
5555 1 \
5556 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005557 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005558 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005559 -s "! mbedtls_ssl_handshake returned"
5560
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005561requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005562run_test "SSL async private: decrypt, error in start" \
5563 "$P_SRV \
5564 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5565 async_private_error=1" \
5566 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5567 1 \
5568 -s "Async decrypt callback: injected error" \
5569 -S "Async resume" \
5570 -S "Async cancel" \
5571 -s "! mbedtls_ssl_handshake returned"
5572
5573requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5574run_test "SSL async private: decrypt, cancel after start" \
5575 "$P_SRV \
5576 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5577 async_private_error=2" \
5578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5579 1 \
5580 -s "Async decrypt callback: using key slot " \
5581 -S "Async resume" \
5582 -s "Async cancel"
5583
5584requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5585run_test "SSL async private: decrypt, error in resume" \
5586 "$P_SRV \
5587 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5588 async_private_error=3" \
5589 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5590 1 \
5591 -s "Async decrypt callback: using key slot " \
5592 -s "Async resume callback: decrypt done but injected error" \
5593 -S "Async cancel" \
5594 -s "! mbedtls_ssl_handshake returned"
5595
5596requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005597run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005598 "$P_SRV \
5599 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5600 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005601 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5602 0 \
5603 -s "Async cancel" \
5604 -s "! mbedtls_ssl_handshake returned" \
5605 -s "Async resume" \
5606 -s "Successful connection"
5607
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005608requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005609run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005610 "$P_SRV \
5611 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5612 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005613 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5614 0 \
5615 -s "! mbedtls_ssl_handshake returned" \
5616 -s "Async resume" \
5617 -s "Successful connection"
5618
5619# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005620requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005621run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005622 "$P_SRV \
5623 async_operations=s async_private_delay1=1 async_private_error=-2 \
5624 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5625 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005626 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5627 [ \$? -eq 1 ] &&
5628 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5629 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005630 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005631 -S "Async resume" \
5632 -s "Async cancel" \
5633 -s "! mbedtls_ssl_handshake returned" \
5634 -s "Async sign callback: no key matches this certificate." \
5635 -s "Successful connection"
5636
5637# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005638requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005639run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005640 "$P_SRV \
5641 async_operations=s async_private_delay1=1 async_private_error=-3 \
5642 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5643 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005644 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5645 [ \$? -eq 1 ] &&
5646 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5647 0 \
5648 -s "Async resume" \
5649 -s "! mbedtls_ssl_handshake returned" \
5650 -s "Async sign callback: no key matches this certificate." \
5651 -s "Successful connection"
5652
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005653requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005654requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005655run_test "SSL async private: renegotiation: client-initiated; sign" \
5656 "$P_SRV \
5657 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005658 exchanges=2 renegotiation=1" \
5659 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5660 0 \
5661 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005662 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005663
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005664requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005665requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005666run_test "SSL async private: renegotiation: server-initiated; sign" \
5667 "$P_SRV \
5668 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005669 exchanges=2 renegotiation=1 renegotiate=1" \
5670 "$P_CLI exchanges=2 renegotiation=1" \
5671 0 \
5672 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005673 -s "Async resume (slot [0-9]): sign done, status=0"
5674
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005675requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005676requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5677run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5678 "$P_SRV \
5679 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5680 exchanges=2 renegotiation=1" \
5681 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5682 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5683 0 \
5684 -s "Async decrypt callback: using key slot " \
5685 -s "Async resume (slot [0-9]): decrypt done, status=0"
5686
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005687requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005688requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5689run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5690 "$P_SRV \
5691 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5692 exchanges=2 renegotiation=1 renegotiate=1" \
5693 "$P_CLI exchanges=2 renegotiation=1 \
5694 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5695 0 \
5696 -s "Async decrypt callback: using key slot " \
5697 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005698
Ron Eldor58093c82018-06-28 13:22:05 +03005699# Tests for ECC extensions (rfc 4492)
5700
Ron Eldor643df7c2018-06-28 16:17:00 +03005701requires_config_enabled MBEDTLS_AES_C
5702requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5703requires_config_enabled MBEDTLS_SHA256_C
5704requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005705run_test "Force a non ECC ciphersuite in the client side" \
5706 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005707 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005708 0 \
5709 -C "client hello, adding supported_elliptic_curves extension" \
5710 -C "client hello, adding supported_point_formats extension" \
5711 -S "found supported elliptic curves extension" \
5712 -S "found supported point formats extension"
5713
Ron Eldor643df7c2018-06-28 16:17:00 +03005714requires_config_enabled MBEDTLS_AES_C
5715requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5716requires_config_enabled MBEDTLS_SHA256_C
5717requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005718run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005719 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005720 "$P_CLI debug_level=3" \
5721 0 \
5722 -C "found supported_point_formats extension" \
5723 -S "server hello, supported_point_formats extension"
5724
Ron Eldor643df7c2018-06-28 16:17:00 +03005725requires_config_enabled MBEDTLS_AES_C
5726requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5727requires_config_enabled MBEDTLS_SHA256_C
5728requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005729run_test "Force an ECC ciphersuite in the client side" \
5730 "$P_SRV debug_level=3" \
5731 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5732 0 \
5733 -c "client hello, adding supported_elliptic_curves extension" \
5734 -c "client hello, adding supported_point_formats extension" \
5735 -s "found supported elliptic curves extension" \
5736 -s "found supported point formats extension"
5737
Ron Eldor643df7c2018-06-28 16:17:00 +03005738requires_config_enabled MBEDTLS_AES_C
5739requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5740requires_config_enabled MBEDTLS_SHA256_C
5741requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005742run_test "Force an ECC ciphersuite in the server side" \
5743 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5744 "$P_CLI debug_level=3" \
5745 0 \
5746 -c "found supported_point_formats extension" \
5747 -s "server hello, supported_point_formats extension"
5748
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005749# Tests for DTLS HelloVerifyRequest
5750
5751run_test "DTLS cookie: enabled" \
5752 "$P_SRV dtls=1 debug_level=2" \
5753 "$P_CLI dtls=1 debug_level=2" \
5754 0 \
5755 -s "cookie verification failed" \
5756 -s "cookie verification passed" \
5757 -S "cookie verification skipped" \
5758 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005759 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005760 -S "SSL - The requested feature is not available"
5761
5762run_test "DTLS cookie: disabled" \
5763 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5764 "$P_CLI dtls=1 debug_level=2" \
5765 0 \
5766 -S "cookie verification failed" \
5767 -S "cookie verification passed" \
5768 -s "cookie verification skipped" \
5769 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005770 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005771 -S "SSL - The requested feature is not available"
5772
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005773run_test "DTLS cookie: default (failing)" \
5774 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5775 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5776 1 \
5777 -s "cookie verification failed" \
5778 -S "cookie verification passed" \
5779 -S "cookie verification skipped" \
5780 -C "received hello verify request" \
5781 -S "hello verification requested" \
5782 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005783
5784requires_ipv6
5785run_test "DTLS cookie: enabled, IPv6" \
5786 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5787 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5788 0 \
5789 -s "cookie verification failed" \
5790 -s "cookie verification passed" \
5791 -S "cookie verification skipped" \
5792 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005793 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005794 -S "SSL - The requested feature is not available"
5795
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005796run_test "DTLS cookie: enabled, nbio" \
5797 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5798 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5799 0 \
5800 -s "cookie verification failed" \
5801 -s "cookie verification passed" \
5802 -S "cookie verification skipped" \
5803 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005804 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005805 -S "SSL - The requested feature is not available"
5806
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005807# Tests for client reconnecting from the same port with DTLS
5808
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005809not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005810run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005811 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5812 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005813 0 \
5814 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005815 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005816 -S "Client initiated reconnection from same port"
5817
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005818not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005819run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005820 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5821 "$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 +02005822 0 \
5823 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005824 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005825 -s "Client initiated reconnection from same port"
5826
Paul Bakker362689d2016-05-13 10:33:25 +01005827not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5828run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005829 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5830 "$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 +02005831 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005832 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005833 -s "Client initiated reconnection from same port"
5834
Paul Bakker362689d2016-05-13 10:33:25 +01005835only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5836run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5837 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5838 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5839 0 \
5840 -S "The operation timed out" \
5841 -s "Client initiated reconnection from same port"
5842
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005843run_test "DTLS client reconnect from same port: no cookies" \
5844 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005845 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5846 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005847 -s "The operation timed out" \
5848 -S "Client initiated reconnection from same port"
5849
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005850run_test "DTLS client reconnect from same port: attacker-injected" \
5851 -p "$P_PXY inject_clihlo=1" \
5852 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5853 "$P_CLI dtls=1 exchanges=2" \
5854 0 \
5855 -s "possible client reconnect from the same port" \
5856 -S "Client initiated reconnection from same port"
5857
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005858# Tests for various cases of client authentication with DTLS
5859# (focused on handshake flows and message parsing)
5860
5861run_test "DTLS client auth: required" \
5862 "$P_SRV dtls=1 auth_mode=required" \
5863 "$P_CLI dtls=1" \
5864 0 \
5865 -s "Verifying peer X.509 certificate... ok"
5866
5867run_test "DTLS client auth: optional, client has no cert" \
5868 "$P_SRV dtls=1 auth_mode=optional" \
5869 "$P_CLI dtls=1 crt_file=none key_file=none" \
5870 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005871 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005872
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005873run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005874 "$P_SRV dtls=1 auth_mode=none" \
5875 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5876 0 \
5877 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005878 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005879
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005880run_test "DTLS wrong PSK: badmac alert" \
5881 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5882 "$P_CLI dtls=1 psk=abc124" \
5883 1 \
5884 -s "SSL - Verification of the message MAC failed" \
5885 -c "SSL - A fatal alert message was received from our peer"
5886
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005887# Tests for receiving fragmented handshake messages with DTLS
5888
5889requires_gnutls
5890run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5891 "$G_SRV -u --mtu 2048 -a" \
5892 "$P_CLI dtls=1 debug_level=2" \
5893 0 \
5894 -C "found fragmented DTLS handshake message" \
5895 -C "error"
5896
5897requires_gnutls
5898run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5899 "$G_SRV -u --mtu 512" \
5900 "$P_CLI dtls=1 debug_level=2" \
5901 0 \
5902 -c "found fragmented DTLS handshake message" \
5903 -C "error"
5904
5905requires_gnutls
5906run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5907 "$G_SRV -u --mtu 128" \
5908 "$P_CLI dtls=1 debug_level=2" \
5909 0 \
5910 -c "found fragmented DTLS handshake message" \
5911 -C "error"
5912
5913requires_gnutls
5914run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5915 "$G_SRV -u --mtu 128" \
5916 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5917 0 \
5918 -c "found fragmented DTLS handshake message" \
5919 -C "error"
5920
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005921requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005922requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005923run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5924 "$G_SRV -u --mtu 256" \
5925 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5926 0 \
5927 -c "found fragmented DTLS handshake message" \
5928 -c "client hello, adding renegotiation extension" \
5929 -c "found renegotiation extension" \
5930 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005931 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005932 -C "error" \
5933 -s "Extra-header:"
5934
5935requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005936requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005937run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5938 "$G_SRV -u --mtu 256" \
5939 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5940 0 \
5941 -c "found fragmented DTLS handshake message" \
5942 -c "client hello, adding renegotiation extension" \
5943 -c "found renegotiation extension" \
5944 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005945 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005946 -C "error" \
5947 -s "Extra-header:"
5948
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005949run_test "DTLS reassembly: no fragmentation (openssl server)" \
5950 "$O_SRV -dtls1 -mtu 2048" \
5951 "$P_CLI dtls=1 debug_level=2" \
5952 0 \
5953 -C "found fragmented DTLS handshake message" \
5954 -C "error"
5955
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005956run_test "DTLS reassembly: some fragmentation (openssl server)" \
5957 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005958 "$P_CLI dtls=1 debug_level=2" \
5959 0 \
5960 -c "found fragmented DTLS handshake message" \
5961 -C "error"
5962
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005963run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005964 "$O_SRV -dtls1 -mtu 256" \
5965 "$P_CLI dtls=1 debug_level=2" \
5966 0 \
5967 -c "found fragmented DTLS handshake message" \
5968 -C "error"
5969
5970run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5971 "$O_SRV -dtls1 -mtu 256" \
5972 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5973 0 \
5974 -c "found fragmented DTLS handshake message" \
5975 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005976
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005977# Tests for sending fragmented handshake messages with DTLS
5978#
5979# Use client auth when we need the client to send large messages,
5980# and use large cert chains on both sides too (the long chains we have all use
5981# both RSA and ECDSA, but ideally we should have long chains with either).
5982# Sizes reached (UDP payload):
5983# - 2037B for server certificate
5984# - 1542B for client certificate
5985# - 1013B for newsessionticket
5986# - all others below 512B
5987# All those tests assume MAX_CONTENT_LEN is at least 2048
5988
5989requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5990requires_config_enabled MBEDTLS_RSA_C
5991requires_config_enabled MBEDTLS_ECDSA_C
5992requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
5993run_test "DTLS fragmenting: none (for reference)" \
5994 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5995 crt_file=data_files/server7_int-ca.crt \
5996 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005997 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005998 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005999 "$P_CLI dtls=1 debug_level=2 \
6000 crt_file=data_files/server8_int-ca2.crt \
6001 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006002 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006003 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006004 0 \
6005 -S "found fragmented DTLS handshake message" \
6006 -C "found fragmented DTLS handshake message" \
6007 -C "error"
6008
6009requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6010requires_config_enabled MBEDTLS_RSA_C
6011requires_config_enabled MBEDTLS_ECDSA_C
6012requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006013run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006014 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6015 crt_file=data_files/server7_int-ca.crt \
6016 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006017 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006018 max_frag_len=1024" \
6019 "$P_CLI dtls=1 debug_level=2 \
6020 crt_file=data_files/server8_int-ca2.crt \
6021 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006022 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006023 max_frag_len=2048" \
6024 0 \
6025 -S "found fragmented DTLS handshake message" \
6026 -c "found fragmented DTLS handshake message" \
6027 -C "error"
6028
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006029# With the MFL extension, the server has no way of forcing
6030# the client to not exceed a certain MTU; hence, the following
6031# test can't be replicated with an MTU proxy such as the one
6032# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006033requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6034requires_config_enabled MBEDTLS_RSA_C
6035requires_config_enabled MBEDTLS_ECDSA_C
6036requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006037run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006038 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6039 crt_file=data_files/server7_int-ca.crt \
6040 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006041 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006042 max_frag_len=512" \
6043 "$P_CLI dtls=1 debug_level=2 \
6044 crt_file=data_files/server8_int-ca2.crt \
6045 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006046 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006047 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006048 0 \
6049 -S "found fragmented DTLS handshake message" \
6050 -c "found fragmented DTLS handshake message" \
6051 -C "error"
6052
6053requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6054requires_config_enabled MBEDTLS_RSA_C
6055requires_config_enabled MBEDTLS_ECDSA_C
6056requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006057run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006058 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6059 crt_file=data_files/server7_int-ca.crt \
6060 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006061 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006062 max_frag_len=2048" \
6063 "$P_CLI dtls=1 debug_level=2 \
6064 crt_file=data_files/server8_int-ca2.crt \
6065 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006066 hs_timeout=2500-60000 \
6067 max_frag_len=1024" \
6068 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006069 -S "found fragmented DTLS handshake message" \
6070 -c "found fragmented DTLS handshake message" \
6071 -C "error"
6072
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006073# While not required by the standard defining the MFL extension
6074# (according to which it only applies to records, not to datagrams),
6075# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6076# as otherwise there wouldn't be any means to communicate MTU restrictions
6077# to the peer.
6078# The next test checks that no datagrams significantly larger than the
6079# negotiated MFL are sent.
6080requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6081requires_config_enabled MBEDTLS_RSA_C
6082requires_config_enabled MBEDTLS_ECDSA_C
6083requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6084run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006085 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006086 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6087 crt_file=data_files/server7_int-ca.crt \
6088 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006089 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006090 max_frag_len=2048" \
6091 "$P_CLI dtls=1 debug_level=2 \
6092 crt_file=data_files/server8_int-ca2.crt \
6093 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006094 hs_timeout=2500-60000 \
6095 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006096 0 \
6097 -S "found fragmented DTLS handshake message" \
6098 -c "found fragmented DTLS handshake message" \
6099 -C "error"
6100
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006101requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6102requires_config_enabled MBEDTLS_RSA_C
6103requires_config_enabled MBEDTLS_ECDSA_C
6104requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006105run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006106 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6107 crt_file=data_files/server7_int-ca.crt \
6108 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006109 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006110 max_frag_len=2048" \
6111 "$P_CLI dtls=1 debug_level=2 \
6112 crt_file=data_files/server8_int-ca2.crt \
6113 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006114 hs_timeout=2500-60000 \
6115 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006116 0 \
6117 -s "found fragmented DTLS handshake message" \
6118 -c "found fragmented DTLS handshake message" \
6119 -C "error"
6120
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006121# While not required by the standard defining the MFL extension
6122# (according to which it only applies to records, not to datagrams),
6123# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6124# as otherwise there wouldn't be any means to communicate MTU restrictions
6125# to the peer.
6126# The next test checks that no datagrams significantly larger than the
6127# negotiated MFL are sent.
6128requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6129requires_config_enabled MBEDTLS_RSA_C
6130requires_config_enabled MBEDTLS_ECDSA_C
6131requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6132run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006133 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006134 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6135 crt_file=data_files/server7_int-ca.crt \
6136 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006137 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006138 max_frag_len=2048" \
6139 "$P_CLI dtls=1 debug_level=2 \
6140 crt_file=data_files/server8_int-ca2.crt \
6141 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006142 hs_timeout=2500-60000 \
6143 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006144 0 \
6145 -s "found fragmented DTLS handshake message" \
6146 -c "found fragmented DTLS handshake message" \
6147 -C "error"
6148
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006149requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6150requires_config_enabled MBEDTLS_RSA_C
6151requires_config_enabled MBEDTLS_ECDSA_C
6152run_test "DTLS fragmenting: none (for reference) (MTU)" \
6153 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6154 crt_file=data_files/server7_int-ca.crt \
6155 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006156 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006157 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006158 "$P_CLI dtls=1 debug_level=2 \
6159 crt_file=data_files/server8_int-ca2.crt \
6160 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006161 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006162 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006163 0 \
6164 -S "found fragmented DTLS handshake message" \
6165 -C "found fragmented DTLS handshake message" \
6166 -C "error"
6167
6168requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6169requires_config_enabled MBEDTLS_RSA_C
6170requires_config_enabled MBEDTLS_ECDSA_C
6171run_test "DTLS fragmenting: client (MTU)" \
6172 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6173 crt_file=data_files/server7_int-ca.crt \
6174 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006175 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006176 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006177 "$P_CLI dtls=1 debug_level=2 \
6178 crt_file=data_files/server8_int-ca2.crt \
6179 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006180 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006181 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006182 0 \
6183 -s "found fragmented DTLS handshake message" \
6184 -C "found fragmented DTLS handshake message" \
6185 -C "error"
6186
6187requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6188requires_config_enabled MBEDTLS_RSA_C
6189requires_config_enabled MBEDTLS_ECDSA_C
6190run_test "DTLS fragmenting: server (MTU)" \
6191 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6192 crt_file=data_files/server7_int-ca.crt \
6193 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006194 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006195 mtu=512" \
6196 "$P_CLI dtls=1 debug_level=2 \
6197 crt_file=data_files/server8_int-ca2.crt \
6198 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006199 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006200 mtu=2048" \
6201 0 \
6202 -S "found fragmented DTLS handshake message" \
6203 -c "found fragmented DTLS handshake message" \
6204 -C "error"
6205
6206requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6207requires_config_enabled MBEDTLS_RSA_C
6208requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006209run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006210 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006211 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6212 crt_file=data_files/server7_int-ca.crt \
6213 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006214 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006215 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006216 "$P_CLI dtls=1 debug_level=2 \
6217 crt_file=data_files/server8_int-ca2.crt \
6218 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006219 hs_timeout=2500-60000 \
6220 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006221 0 \
6222 -s "found fragmented DTLS handshake message" \
6223 -c "found fragmented DTLS handshake message" \
6224 -C "error"
6225
Andrzej Kurek77826052018-10-11 07:34:08 -04006226# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006227requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6228requires_config_enabled MBEDTLS_RSA_C
6229requires_config_enabled MBEDTLS_ECDSA_C
6230requires_config_enabled MBEDTLS_SHA256_C
6231requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6232requires_config_enabled MBEDTLS_AES_C
6233requires_config_enabled MBEDTLS_GCM_C
6234run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006235 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006236 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6237 crt_file=data_files/server7_int-ca.crt \
6238 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006239 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006240 mtu=512" \
6241 "$P_CLI dtls=1 debug_level=2 \
6242 crt_file=data_files/server8_int-ca2.crt \
6243 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006244 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6245 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006246 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006247 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006248 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006249 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006250 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006251
Andrzej Kurek7311c782018-10-11 06:49:41 -04006252# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006253# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006254# The ratio of max/min timeout should ideally equal 4 to accept two
6255# retransmissions, but in some cases (like both the server and client using
6256# fragmentation and auto-reduction) an extra retransmission might occur,
6257# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006258not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006259requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6260requires_config_enabled MBEDTLS_RSA_C
6261requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006262requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6263requires_config_enabled MBEDTLS_AES_C
6264requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006265run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6266 -p "$P_PXY mtu=508" \
6267 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6268 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006269 key_file=data_files/server7.key \
6270 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006271 "$P_CLI dtls=1 debug_level=2 \
6272 crt_file=data_files/server8_int-ca2.crt \
6273 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006274 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6275 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006276 0 \
6277 -s "found fragmented DTLS handshake message" \
6278 -c "found fragmented DTLS handshake message" \
6279 -C "error"
6280
Andrzej Kurek77826052018-10-11 07:34:08 -04006281# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006282only_with_valgrind
6283requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6284requires_config_enabled MBEDTLS_RSA_C
6285requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006286requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6287requires_config_enabled MBEDTLS_AES_C
6288requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006289run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6290 -p "$P_PXY mtu=508" \
6291 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6292 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006293 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006294 hs_timeout=250-10000" \
6295 "$P_CLI dtls=1 debug_level=2 \
6296 crt_file=data_files/server8_int-ca2.crt \
6297 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006298 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006299 hs_timeout=250-10000" \
6300 0 \
6301 -s "found fragmented DTLS handshake message" \
6302 -c "found fragmented DTLS handshake message" \
6303 -C "error"
6304
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006305# 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 +02006306# OTOH the client might resend if the server is to slow to reset after sending
6307# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006308not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006309requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6310requires_config_enabled MBEDTLS_RSA_C
6311requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006312run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006313 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006314 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6315 crt_file=data_files/server7_int-ca.crt \
6316 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006317 hs_timeout=10000-60000 \
6318 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006319 "$P_CLI dtls=1 debug_level=2 \
6320 crt_file=data_files/server8_int-ca2.crt \
6321 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006322 hs_timeout=10000-60000 \
6323 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006324 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006325 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006326 -s "found fragmented DTLS handshake message" \
6327 -c "found fragmented DTLS handshake message" \
6328 -C "error"
6329
Andrzej Kurek77826052018-10-11 07:34:08 -04006330# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006331# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6332# OTOH the client might resend if the server is to slow to reset after sending
6333# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006334not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006335requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6336requires_config_enabled MBEDTLS_RSA_C
6337requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006338requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6339requires_config_enabled MBEDTLS_AES_C
6340requires_config_enabled MBEDTLS_GCM_C
6341run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006342 -p "$P_PXY mtu=512" \
6343 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6344 crt_file=data_files/server7_int-ca.crt \
6345 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006346 hs_timeout=10000-60000 \
6347 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006348 "$P_CLI dtls=1 debug_level=2 \
6349 crt_file=data_files/server8_int-ca2.crt \
6350 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006351 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6352 hs_timeout=10000-60000 \
6353 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006354 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006355 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006356 -s "found fragmented DTLS handshake message" \
6357 -c "found fragmented DTLS handshake message" \
6358 -C "error"
6359
Andrzej Kurek7311c782018-10-11 06:49:41 -04006360not_with_valgrind # spurious autoreduction due to timeout
6361requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6362requires_config_enabled MBEDTLS_RSA_C
6363requires_config_enabled MBEDTLS_ECDSA_C
6364run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006365 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006366 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6367 crt_file=data_files/server7_int-ca.crt \
6368 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006369 hs_timeout=10000-60000 \
6370 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006371 "$P_CLI dtls=1 debug_level=2 \
6372 crt_file=data_files/server8_int-ca2.crt \
6373 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006374 hs_timeout=10000-60000 \
6375 mtu=1024 nbio=2" \
6376 0 \
6377 -S "autoreduction" \
6378 -s "found fragmented DTLS handshake message" \
6379 -c "found fragmented DTLS handshake message" \
6380 -C "error"
6381
Andrzej Kurek77826052018-10-11 07:34:08 -04006382# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006383not_with_valgrind # spurious autoreduction due to timeout
6384requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6385requires_config_enabled MBEDTLS_RSA_C
6386requires_config_enabled MBEDTLS_ECDSA_C
6387requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6388requires_config_enabled MBEDTLS_AES_C
6389requires_config_enabled MBEDTLS_GCM_C
6390run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6391 -p "$P_PXY mtu=512" \
6392 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6393 crt_file=data_files/server7_int-ca.crt \
6394 key_file=data_files/server7.key \
6395 hs_timeout=10000-60000 \
6396 mtu=512 nbio=2" \
6397 "$P_CLI dtls=1 debug_level=2 \
6398 crt_file=data_files/server8_int-ca2.crt \
6399 key_file=data_files/server8.key \
6400 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6401 hs_timeout=10000-60000 \
6402 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006403 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006404 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006405 -s "found fragmented DTLS handshake message" \
6406 -c "found fragmented DTLS handshake message" \
6407 -C "error"
6408
Andrzej Kurek77826052018-10-11 07:34:08 -04006409# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006410# This ensures things still work after session_reset().
6411# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006412# Since we don't support reading fragmented ClientHello yet,
6413# up the MTU to 1450 (larger than ClientHello with session ticket,
6414# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006415# An autoreduction on the client-side might happen if the server is
6416# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006417# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006418# resumed listening, which would result in a spurious autoreduction.
6419not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006420requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6421requires_config_enabled MBEDTLS_RSA_C
6422requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006423requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6424requires_config_enabled MBEDTLS_AES_C
6425requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006426run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6427 -p "$P_PXY mtu=1450" \
6428 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6429 crt_file=data_files/server7_int-ca.crt \
6430 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006431 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006432 mtu=1450" \
6433 "$P_CLI dtls=1 debug_level=2 \
6434 crt_file=data_files/server8_int-ca2.crt \
6435 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006436 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006437 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006438 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006439 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006440 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006441 -s "found fragmented DTLS handshake message" \
6442 -c "found fragmented DTLS handshake message" \
6443 -C "error"
6444
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006445# An autoreduction on the client-side might happen if the server is
6446# slow to reset, therefore omitting '-C "autoreduction"' below.
6447not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006448requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6449requires_config_enabled MBEDTLS_RSA_C
6450requires_config_enabled MBEDTLS_ECDSA_C
6451requires_config_enabled MBEDTLS_SHA256_C
6452requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6453requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6454requires_config_enabled MBEDTLS_CHACHAPOLY_C
6455run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6456 -p "$P_PXY mtu=512" \
6457 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6458 crt_file=data_files/server7_int-ca.crt \
6459 key_file=data_files/server7.key \
6460 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006461 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006462 mtu=512" \
6463 "$P_CLI dtls=1 debug_level=2 \
6464 crt_file=data_files/server8_int-ca2.crt \
6465 key_file=data_files/server8.key \
6466 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006467 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006468 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006469 mtu=512" \
6470 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006471 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006472 -s "found fragmented DTLS handshake message" \
6473 -c "found fragmented DTLS handshake message" \
6474 -C "error"
6475
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006476# An autoreduction on the client-side might happen if the server is
6477# slow to reset, therefore omitting '-C "autoreduction"' below.
6478not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006479requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6480requires_config_enabled MBEDTLS_RSA_C
6481requires_config_enabled MBEDTLS_ECDSA_C
6482requires_config_enabled MBEDTLS_SHA256_C
6483requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6484requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6485requires_config_enabled MBEDTLS_AES_C
6486requires_config_enabled MBEDTLS_GCM_C
6487run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6488 -p "$P_PXY mtu=512" \
6489 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6490 crt_file=data_files/server7_int-ca.crt \
6491 key_file=data_files/server7.key \
6492 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006493 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006494 mtu=512" \
6495 "$P_CLI dtls=1 debug_level=2 \
6496 crt_file=data_files/server8_int-ca2.crt \
6497 key_file=data_files/server8.key \
6498 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006499 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006500 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006501 mtu=512" \
6502 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006503 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006504 -s "found fragmented DTLS handshake message" \
6505 -c "found fragmented DTLS handshake message" \
6506 -C "error"
6507
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006508# An autoreduction on the client-side might happen if the server is
6509# slow to reset, therefore omitting '-C "autoreduction"' below.
6510not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006511requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6512requires_config_enabled MBEDTLS_RSA_C
6513requires_config_enabled MBEDTLS_ECDSA_C
6514requires_config_enabled MBEDTLS_SHA256_C
6515requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6516requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6517requires_config_enabled MBEDTLS_AES_C
6518requires_config_enabled MBEDTLS_CCM_C
6519run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006520 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006521 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6522 crt_file=data_files/server7_int-ca.crt \
6523 key_file=data_files/server7.key \
6524 exchanges=2 renegotiation=1 \
6525 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006526 hs_timeout=10000-60000 \
6527 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006528 "$P_CLI dtls=1 debug_level=2 \
6529 crt_file=data_files/server8_int-ca2.crt \
6530 key_file=data_files/server8.key \
6531 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006532 hs_timeout=10000-60000 \
6533 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006534 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006535 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006536 -s "found fragmented DTLS handshake message" \
6537 -c "found fragmented DTLS handshake message" \
6538 -C "error"
6539
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006540# An autoreduction on the client-side might happen if the server is
6541# slow to reset, therefore omitting '-C "autoreduction"' below.
6542not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006543requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6544requires_config_enabled MBEDTLS_RSA_C
6545requires_config_enabled MBEDTLS_ECDSA_C
6546requires_config_enabled MBEDTLS_SHA256_C
6547requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6548requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6549requires_config_enabled MBEDTLS_AES_C
6550requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6551requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6552run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006553 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006554 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6555 crt_file=data_files/server7_int-ca.crt \
6556 key_file=data_files/server7.key \
6557 exchanges=2 renegotiation=1 \
6558 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006559 hs_timeout=10000-60000 \
6560 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006561 "$P_CLI dtls=1 debug_level=2 \
6562 crt_file=data_files/server8_int-ca2.crt \
6563 key_file=data_files/server8.key \
6564 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006565 hs_timeout=10000-60000 \
6566 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006567 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006568 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006569 -s "found fragmented DTLS handshake message" \
6570 -c "found fragmented DTLS handshake message" \
6571 -C "error"
6572
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006573# An autoreduction on the client-side might happen if the server is
6574# slow to reset, therefore omitting '-C "autoreduction"' below.
6575not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006576requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6577requires_config_enabled MBEDTLS_RSA_C
6578requires_config_enabled MBEDTLS_ECDSA_C
6579requires_config_enabled MBEDTLS_SHA256_C
6580requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6581requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6582requires_config_enabled MBEDTLS_AES_C
6583requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6584run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006585 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006586 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6587 crt_file=data_files/server7_int-ca.crt \
6588 key_file=data_files/server7.key \
6589 exchanges=2 renegotiation=1 \
6590 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006591 hs_timeout=10000-60000 \
6592 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006593 "$P_CLI dtls=1 debug_level=2 \
6594 crt_file=data_files/server8_int-ca2.crt \
6595 key_file=data_files/server8.key \
6596 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006597 hs_timeout=10000-60000 \
6598 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006599 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006600 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006601 -s "found fragmented DTLS handshake message" \
6602 -c "found fragmented DTLS handshake message" \
6603 -C "error"
6604
Andrzej Kurek77826052018-10-11 07:34:08 -04006605# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006606requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6607requires_config_enabled MBEDTLS_RSA_C
6608requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006609requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6610requires_config_enabled MBEDTLS_AES_C
6611requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006612client_needs_more_time 2
6613run_test "DTLS fragmenting: proxy MTU + 3d" \
6614 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006615 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006616 crt_file=data_files/server7_int-ca.crt \
6617 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006618 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006619 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006620 crt_file=data_files/server8_int-ca2.crt \
6621 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006622 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006623 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006624 0 \
6625 -s "found fragmented DTLS handshake message" \
6626 -c "found fragmented DTLS handshake message" \
6627 -C "error"
6628
Andrzej Kurek77826052018-10-11 07:34:08 -04006629# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006630requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6631requires_config_enabled MBEDTLS_RSA_C
6632requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006633requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6634requires_config_enabled MBEDTLS_AES_C
6635requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006636client_needs_more_time 2
6637run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6638 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6639 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6640 crt_file=data_files/server7_int-ca.crt \
6641 key_file=data_files/server7.key \
6642 hs_timeout=250-10000 mtu=512 nbio=2" \
6643 "$P_CLI dtls=1 debug_level=2 \
6644 crt_file=data_files/server8_int-ca2.crt \
6645 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006646 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006647 hs_timeout=250-10000 mtu=512 nbio=2" \
6648 0 \
6649 -s "found fragmented DTLS handshake message" \
6650 -c "found fragmented DTLS handshake message" \
6651 -C "error"
6652
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006653# interop tests for DTLS fragmentating with reliable connection
6654#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006655# here and below we just want to test that the we fragment in a way that
6656# pleases other implementations, so we don't need the peer to fragment
6657requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6658requires_config_enabled MBEDTLS_RSA_C
6659requires_config_enabled MBEDTLS_ECDSA_C
6660requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006661requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006662run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6663 "$G_SRV -u" \
6664 "$P_CLI dtls=1 debug_level=2 \
6665 crt_file=data_files/server8_int-ca2.crt \
6666 key_file=data_files/server8.key \
6667 mtu=512 force_version=dtls1_2" \
6668 0 \
6669 -c "fragmenting handshake message" \
6670 -C "error"
6671
6672requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6673requires_config_enabled MBEDTLS_RSA_C
6674requires_config_enabled MBEDTLS_ECDSA_C
6675requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006676requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006677run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6678 "$G_SRV -u" \
6679 "$P_CLI dtls=1 debug_level=2 \
6680 crt_file=data_files/server8_int-ca2.crt \
6681 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006682 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006683 0 \
6684 -c "fragmenting handshake message" \
6685 -C "error"
6686
Hanno Beckerb9a00862018-08-28 10:20:22 +01006687# We use --insecure for the GnuTLS client because it expects
6688# the hostname / IP it connects to to be the name used in the
6689# certificate obtained from the server. Here, however, it
6690# connects to 127.0.0.1 while our test certificates use 'localhost'
6691# as the server name in the certificate. This will make the
6692# certifiate validation fail, but passing --insecure makes
6693# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006694requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6695requires_config_enabled MBEDTLS_RSA_C
6696requires_config_enabled MBEDTLS_ECDSA_C
6697requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006698requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006699requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006700run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006701 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006702 crt_file=data_files/server7_int-ca.crt \
6703 key_file=data_files/server7.key \
6704 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006705 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006706 0 \
6707 -s "fragmenting handshake message"
6708
Hanno Beckerb9a00862018-08-28 10:20:22 +01006709# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006710requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6711requires_config_enabled MBEDTLS_RSA_C
6712requires_config_enabled MBEDTLS_ECDSA_C
6713requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006714requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006715requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006716run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006717 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006718 crt_file=data_files/server7_int-ca.crt \
6719 key_file=data_files/server7.key \
6720 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006721 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006722 0 \
6723 -s "fragmenting handshake message"
6724
6725requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6726requires_config_enabled MBEDTLS_RSA_C
6727requires_config_enabled MBEDTLS_ECDSA_C
6728requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6729run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6730 "$O_SRV -dtls1_2 -verify 10" \
6731 "$P_CLI dtls=1 debug_level=2 \
6732 crt_file=data_files/server8_int-ca2.crt \
6733 key_file=data_files/server8.key \
6734 mtu=512 force_version=dtls1_2" \
6735 0 \
6736 -c "fragmenting handshake message" \
6737 -C "error"
6738
6739requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6740requires_config_enabled MBEDTLS_RSA_C
6741requires_config_enabled MBEDTLS_ECDSA_C
6742requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6743run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6744 "$O_SRV -dtls1 -verify 10" \
6745 "$P_CLI dtls=1 debug_level=2 \
6746 crt_file=data_files/server8_int-ca2.crt \
6747 key_file=data_files/server8.key \
6748 mtu=512 force_version=dtls1" \
6749 0 \
6750 -c "fragmenting handshake message" \
6751 -C "error"
6752
6753requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6754requires_config_enabled MBEDTLS_RSA_C
6755requires_config_enabled MBEDTLS_ECDSA_C
6756requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6757run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6758 "$P_SRV dtls=1 debug_level=2 \
6759 crt_file=data_files/server7_int-ca.crt \
6760 key_file=data_files/server7.key \
6761 mtu=512 force_version=dtls1_2" \
6762 "$O_CLI -dtls1_2" \
6763 0 \
6764 -s "fragmenting handshake message"
6765
6766requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6767requires_config_enabled MBEDTLS_RSA_C
6768requires_config_enabled MBEDTLS_ECDSA_C
6769requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6770run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6771 "$P_SRV dtls=1 debug_level=2 \
6772 crt_file=data_files/server7_int-ca.crt \
6773 key_file=data_files/server7.key \
6774 mtu=512 force_version=dtls1" \
6775 "$O_CLI -dtls1" \
6776 0 \
6777 -s "fragmenting handshake message"
6778
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006779# interop tests for DTLS fragmentating with unreliable connection
6780#
6781# again we just want to test that the we fragment in a way that
6782# pleases other implementations, so we don't need the peer to fragment
6783requires_gnutls_next
6784requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6785requires_config_enabled MBEDTLS_RSA_C
6786requires_config_enabled MBEDTLS_ECDSA_C
6787requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006788client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006789run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6790 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6791 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006792 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006793 crt_file=data_files/server8_int-ca2.crt \
6794 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006795 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006796 0 \
6797 -c "fragmenting handshake message" \
6798 -C "error"
6799
6800requires_gnutls_next
6801requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6802requires_config_enabled MBEDTLS_RSA_C
6803requires_config_enabled MBEDTLS_ECDSA_C
6804requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006805client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006806run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6807 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6808 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006809 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006810 crt_file=data_files/server8_int-ca2.crt \
6811 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006812 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006813 0 \
6814 -c "fragmenting handshake message" \
6815 -C "error"
6816
k-stachowiakabb843e2019-02-18 16:14:03 +01006817requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006818requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6819requires_config_enabled MBEDTLS_RSA_C
6820requires_config_enabled MBEDTLS_ECDSA_C
6821requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6822client_needs_more_time 4
6823run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6824 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6825 "$P_SRV dtls=1 debug_level=2 \
6826 crt_file=data_files/server7_int-ca.crt \
6827 key_file=data_files/server7.key \
6828 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006829 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006830 0 \
6831 -s "fragmenting handshake message"
6832
k-stachowiakabb843e2019-02-18 16:14:03 +01006833requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006834requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6835requires_config_enabled MBEDTLS_RSA_C
6836requires_config_enabled MBEDTLS_ECDSA_C
6837requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6838client_needs_more_time 4
6839run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6840 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6841 "$P_SRV dtls=1 debug_level=2 \
6842 crt_file=data_files/server7_int-ca.crt \
6843 key_file=data_files/server7.key \
6844 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006845 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006846 0 \
6847 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006848
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006849## Interop test with OpenSSL might trigger a bug in recent versions (including
6850## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006851## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006852## They should be re-enabled once a fixed version of OpenSSL is available
6853## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006854skip_next_test
6855requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6856requires_config_enabled MBEDTLS_RSA_C
6857requires_config_enabled MBEDTLS_ECDSA_C
6858requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6859client_needs_more_time 4
6860run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6861 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6862 "$O_SRV -dtls1_2 -verify 10" \
6863 "$P_CLI dtls=1 debug_level=2 \
6864 crt_file=data_files/server8_int-ca2.crt \
6865 key_file=data_files/server8.key \
6866 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6867 0 \
6868 -c "fragmenting handshake message" \
6869 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006870
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006871skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006872requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6873requires_config_enabled MBEDTLS_RSA_C
6874requires_config_enabled MBEDTLS_ECDSA_C
6875requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006876client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006877run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6878 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006879 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006880 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006881 crt_file=data_files/server8_int-ca2.crt \
6882 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006883 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006884 0 \
6885 -c "fragmenting handshake message" \
6886 -C "error"
6887
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006888skip_next_test
6889requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6890requires_config_enabled MBEDTLS_RSA_C
6891requires_config_enabled MBEDTLS_ECDSA_C
6892requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6893client_needs_more_time 4
6894run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6895 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6896 "$P_SRV dtls=1 debug_level=2 \
6897 crt_file=data_files/server7_int-ca.crt \
6898 key_file=data_files/server7.key \
6899 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6900 "$O_CLI -dtls1_2" \
6901 0 \
6902 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006903
6904# -nbio is added to prevent s_client from blocking in case of duplicated
6905# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006906skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006907requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6908requires_config_enabled MBEDTLS_RSA_C
6909requires_config_enabled MBEDTLS_ECDSA_C
6910requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006911client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006912run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6913 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006914 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006915 crt_file=data_files/server7_int-ca.crt \
6916 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006917 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006918 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006919 0 \
6920 -s "fragmenting handshake message"
6921
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006922# Tests for specific things with "unreliable" UDP connection
6923
6924not_with_valgrind # spurious resend due to timeout
6925run_test "DTLS proxy: reference" \
6926 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006927 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6928 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006929 0 \
6930 -C "replayed record" \
6931 -S "replayed record" \
6932 -C "record from another epoch" \
6933 -S "record from another epoch" \
6934 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006935 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006936 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006937 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006938 -c "HTTP/1.0 200 OK"
6939
6940not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006941run_test "DTLS proxy: duplicate every packet" \
6942 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006943 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6944 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006945 0 \
6946 -c "replayed record" \
6947 -s "replayed record" \
6948 -c "record from another epoch" \
6949 -s "record from another epoch" \
6950 -S "resend" \
6951 -s "Extra-header:" \
6952 -c "HTTP/1.0 200 OK"
6953
6954run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6955 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006956 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6957 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006958 0 \
6959 -c "replayed record" \
6960 -S "replayed record" \
6961 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006962 -s "record from another epoch" \
6963 -c "resend" \
6964 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006965 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006966 -c "HTTP/1.0 200 OK"
6967
6968run_test "DTLS proxy: multiple records in same datagram" \
6969 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006970 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6971 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006972 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006973 -c "next record in same datagram" \
6974 -s "next record in same datagram"
6975
6976run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6977 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006978 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6979 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006980 0 \
6981 -c "next record in same datagram" \
6982 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006983
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006984run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6985 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006986 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6987 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006988 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006989 -c "discarding invalid record (mac)" \
6990 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006991 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006992 -c "HTTP/1.0 200 OK" \
6993 -S "too many records with bad MAC" \
6994 -S "Verification of the message MAC failed"
6995
6996run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
6997 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006998 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
6999 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007000 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007001 -C "discarding invalid record (mac)" \
7002 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007003 -S "Extra-header:" \
7004 -C "HTTP/1.0 200 OK" \
7005 -s "too many records with bad MAC" \
7006 -s "Verification of the message MAC failed"
7007
7008run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7009 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007010 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7011 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007012 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007013 -c "discarding invalid record (mac)" \
7014 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007015 -s "Extra-header:" \
7016 -c "HTTP/1.0 200 OK" \
7017 -S "too many records with bad MAC" \
7018 -S "Verification of the message MAC failed"
7019
7020run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7021 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007022 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7023 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007024 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007025 -c "discarding invalid record (mac)" \
7026 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007027 -s "Extra-header:" \
7028 -c "HTTP/1.0 200 OK" \
7029 -s "too many records with bad MAC" \
7030 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007031
7032run_test "DTLS proxy: delay ChangeCipherSpec" \
7033 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007034 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7035 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007036 0 \
7037 -c "record from another epoch" \
7038 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007039 -s "Extra-header:" \
7040 -c "HTTP/1.0 200 OK"
7041
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007042# Tests for reordering support with DTLS
7043
Hanno Becker56cdfd12018-08-17 13:42:15 +01007044run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7045 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007046 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7047 hs_timeout=2500-60000" \
7048 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7049 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007050 0 \
7051 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007052 -c "Next handshake message has been buffered - load"\
7053 -S "Buffering HS message" \
7054 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007055 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007056 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007057 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007058 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007059
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007060run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7061 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007062 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7063 hs_timeout=2500-60000" \
7064 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7065 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007066 0 \
7067 -c "Buffering HS message" \
7068 -c "found fragmented DTLS handshake message"\
7069 -c "Next handshake message 1 not or only partially bufffered" \
7070 -c "Next handshake message has been buffered - load"\
7071 -S "Buffering HS message" \
7072 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007073 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007074 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007075 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007076 -S "Remember CCS message"
7077
Hanno Beckera1adcca2018-08-24 14:41:07 +01007078# The client buffers the ServerKeyExchange before receiving the fragmented
7079# Certificate message; at the time of writing, together these are aroudn 1200b
7080# in size, so that the bound below ensures that the certificate can be reassembled
7081# while keeping the ServerKeyExchange.
7082requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7083run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007084 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007085 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7086 hs_timeout=2500-60000" \
7087 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7088 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007089 0 \
7090 -c "Buffering HS message" \
7091 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007092 -C "attempt to make space by freeing buffered messages" \
7093 -S "Buffering HS message" \
7094 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007095 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007096 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007097 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007098 -S "Remember CCS message"
7099
7100# The size constraints ensure that the delayed certificate message can't
7101# be reassembled while keeping the ServerKeyExchange message, but it can
7102# when dropping it first.
7103requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7104requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7105run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7106 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007107 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7108 hs_timeout=2500-60000" \
7109 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7110 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007111 0 \
7112 -c "Buffering HS message" \
7113 -c "attempt to make space by freeing buffered future messages" \
7114 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007115 -S "Buffering HS message" \
7116 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007117 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007118 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007119 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007120 -S "Remember CCS message"
7121
Hanno Becker56cdfd12018-08-17 13:42:15 +01007122run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7123 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007124 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7125 hs_timeout=2500-60000" \
7126 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7127 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007128 0 \
7129 -C "Buffering HS message" \
7130 -C "Next handshake message has been buffered - load"\
7131 -s "Buffering HS message" \
7132 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007133 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007134 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007135 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007136 -S "Remember CCS message"
7137
7138run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7139 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007140 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7141 hs_timeout=2500-60000" \
7142 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7143 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007144 0 \
7145 -C "Buffering HS message" \
7146 -C "Next handshake message has been buffered - load"\
7147 -S "Buffering HS message" \
7148 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007149 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007150 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007151 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007152 -S "Remember CCS message"
7153
7154run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7155 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007156 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7157 hs_timeout=2500-60000" \
7158 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7159 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007160 0 \
7161 -C "Buffering HS message" \
7162 -C "Next handshake message has been buffered - load"\
7163 -S "Buffering HS message" \
7164 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007165 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007166 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007167 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007168 -s "Remember CCS message"
7169
Hanno Beckera1adcca2018-08-24 14:41:07 +01007170run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007171 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007172 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7173 hs_timeout=2500-60000" \
7174 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7175 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007176 0 \
7177 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007178 -s "Found buffered record from current epoch - load" \
7179 -c "Buffer record from epoch 1" \
7180 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007181
Hanno Beckera1adcca2018-08-24 14:41:07 +01007182# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7183# from the server are delayed, so that the encrypted Finished message
7184# is received and buffered. When the fragmented NewSessionTicket comes
7185# in afterwards, the encrypted Finished message must be freed in order
7186# to make space for the NewSessionTicket to be reassembled.
7187# This works only in very particular circumstances:
7188# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7189# of the NewSessionTicket, but small enough to also allow buffering of
7190# the encrypted Finished message.
7191# - The MTU setting on the server must be so small that the NewSessionTicket
7192# needs to be fragmented.
7193# - All messages sent by the server must be small enough to be either sent
7194# without fragmentation or be reassembled within the bounds of
7195# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7196# handshake, omitting CRTs.
7197requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7198requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7199run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7200 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7201 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7202 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7203 0 \
7204 -s "Buffer record from epoch 1" \
7205 -s "Found buffered record from current epoch - load" \
7206 -c "Buffer record from epoch 1" \
7207 -C "Found buffered record from current epoch - load" \
7208 -c "Enough space available after freeing future epoch record"
7209
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007210# Tests for "randomly unreliable connection": try a variety of flows and peers
7211
7212client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007213run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7214 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007215 "$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 +02007216 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007217 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007218 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7219 0 \
7220 -s "Extra-header:" \
7221 -c "HTTP/1.0 200 OK"
7222
Janos Follath74537a62016-09-02 13:45:28 +01007223client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007224run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7225 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007226 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7227 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007228 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7229 0 \
7230 -s "Extra-header:" \
7231 -c "HTTP/1.0 200 OK"
7232
Janos Follath74537a62016-09-02 13:45:28 +01007233client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007234run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7235 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007236 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7237 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007238 0 \
7239 -s "Extra-header:" \
7240 -c "HTTP/1.0 200 OK"
7241
Janos Follath74537a62016-09-02 13:45:28 +01007242client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007243run_test "DTLS proxy: 3d, FS, client auth" \
7244 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007245 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7246 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007247 0 \
7248 -s "Extra-header:" \
7249 -c "HTTP/1.0 200 OK"
7250
Janos Follath74537a62016-09-02 13:45:28 +01007251client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007252run_test "DTLS proxy: 3d, FS, ticket" \
7253 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007254 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7255 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007256 0 \
7257 -s "Extra-header:" \
7258 -c "HTTP/1.0 200 OK"
7259
Janos Follath74537a62016-09-02 13:45:28 +01007260client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007261run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7262 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007263 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7264 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007265 0 \
7266 -s "Extra-header:" \
7267 -c "HTTP/1.0 200 OK"
7268
Janos Follath74537a62016-09-02 13:45:28 +01007269client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007270run_test "DTLS proxy: 3d, max handshake, nbio" \
7271 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007272 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007273 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007274 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007275 0 \
7276 -s "Extra-header:" \
7277 -c "HTTP/1.0 200 OK"
7278
Janos Follath74537a62016-09-02 13:45:28 +01007279client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007280run_test "DTLS proxy: 3d, min handshake, resumption" \
7281 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007282 "$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 +02007283 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007284 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007285 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007286 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7287 0 \
7288 -s "a session has been resumed" \
7289 -c "a session has been resumed" \
7290 -s "Extra-header:" \
7291 -c "HTTP/1.0 200 OK"
7292
Janos Follath74537a62016-09-02 13:45:28 +01007293client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007294run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7295 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007296 "$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 +02007297 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007298 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007299 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007300 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7301 0 \
7302 -s "a session has been resumed" \
7303 -c "a session has been resumed" \
7304 -s "Extra-header:" \
7305 -c "HTTP/1.0 200 OK"
7306
Janos Follath74537a62016-09-02 13:45:28 +01007307client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007308requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007309run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007310 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007311 "$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 +02007312 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007313 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007314 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007315 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7316 0 \
7317 -c "=> renegotiate" \
7318 -s "=> renegotiate" \
7319 -s "Extra-header:" \
7320 -c "HTTP/1.0 200 OK"
7321
Janos Follath74537a62016-09-02 13:45:28 +01007322client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007323requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007324run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7325 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007326 "$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 +02007327 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007328 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007329 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007330 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7331 0 \
7332 -c "=> renegotiate" \
7333 -s "=> renegotiate" \
7334 -s "Extra-header:" \
7335 -c "HTTP/1.0 200 OK"
7336
Janos Follath74537a62016-09-02 13:45:28 +01007337client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007338requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007339run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007340 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007341 "$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 +02007342 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007343 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007344 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007345 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007346 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7347 0 \
7348 -c "=> renegotiate" \
7349 -s "=> renegotiate" \
7350 -s "Extra-header:" \
7351 -c "HTTP/1.0 200 OK"
7352
Janos Follath74537a62016-09-02 13:45:28 +01007353client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007354requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007355run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007356 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007357 "$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 +02007358 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007359 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007360 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007361 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007362 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7363 0 \
7364 -c "=> renegotiate" \
7365 -s "=> renegotiate" \
7366 -s "Extra-header:" \
7367 -c "HTTP/1.0 200 OK"
7368
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007369## Interop tests with OpenSSL might trigger a bug in recent versions (including
7370## all versions installed on the CI machines), reported here:
7371## Bug report: https://github.com/openssl/openssl/issues/6902
7372## They should be re-enabled once a fixed version of OpenSSL is available
7373## (this should happen in some 1.1.1_ release according to the ticket).
7374skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007375client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007376not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007377run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007378 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7379 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007380 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007381 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007382 -c "HTTP/1.0 200 OK"
7383
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007384skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007385client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007386not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007387run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7388 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7389 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007390 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007391 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007392 -c "HTTP/1.0 200 OK"
7393
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007394skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007395client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007396not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007397run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7398 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7399 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007400 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007401 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007402 -c "HTTP/1.0 200 OK"
7403
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007404requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007405client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007406not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007407run_test "DTLS proxy: 3d, gnutls server" \
7408 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7409 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007410 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007411 0 \
7412 -s "Extra-header:" \
7413 -c "Extra-header:"
7414
k-stachowiakabb843e2019-02-18 16:14:03 +01007415requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007416client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007417not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007418run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7419 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007420 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007421 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007422 0 \
7423 -s "Extra-header:" \
7424 -c "Extra-header:"
7425
k-stachowiakabb843e2019-02-18 16:14:03 +01007426requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007427client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007428not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007429run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7430 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007431 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007432 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007433 0 \
7434 -s "Extra-header:" \
7435 -c "Extra-header:"
7436
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007437# Final report
7438
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007439echo "------------------------------------------------------------------------"
7440
7441if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007442 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007443else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007444 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007445fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007446PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007447echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007448
7449exit $FAILS