blob: 0b8707292523135ecb250e8a3f1673131484f70a [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 Peskineb7bb068b2020-08-26 22:35:46 +0200133 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
134 printf " -e|--exclude\tMatching tests are excluded (substring or 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
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200187# Read boolean configuration options from config.h for easy and quick
188# testing. Skip non-boolean options (with something other than spaces
189# and a comment after "#define SYMBOL"). The variable contains a
190# space-separated list of symbols.
191CONFIGS_ENABLED=" $(<"$CONFIG_H" \
192 sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
193 tr '\n' ' ')"
194
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100195# Skip next test; use this macro to skip tests which are legitimate
196# in theory and expected to be re-introduced at some point, but
197# aren't expected to succeed at the moment due to problems outside
198# our control (such as bugs in other TLS implementations).
199skip_next_test() {
200 SKIP_NEXT="YES"
201}
202
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100203# skip next test if the flag is not enabled in config.h
204requires_config_enabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200205 case $CONFIGS_ENABLED in
206 *" $1 "*) :;;
207 *) SKIP_NEXT="YES";;
208 esac
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100209}
210
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200211# skip next test if the flag is enabled in config.h
212requires_config_disabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200213 case $CONFIGS_ENABLED in
214 *" $1 "*) SKIP_NEXT="YES";;
215 esac
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200216}
217
Hanno Becker7c48dd12018-08-28 16:09:22 +0100218get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100219 # This function uses the query_config command line option to query the
220 # required Mbed TLS compile time configuration from the ssl_server2
221 # program. The command will always return a success value if the
222 # configuration is defined and the value will be printed to stdout.
223 #
224 # Note that if the configuration is not defined or is defined to nothing,
225 # the output of this function will be an empty string.
226 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100227}
228
229requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100230 VAL="$( get_config_value_or_default "$1" )"
231 if [ -z "$VAL" ]; then
232 # Should never happen
233 echo "Mbed TLS configuration $1 is not defined"
234 exit 1
235 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100236 SKIP_NEXT="YES"
237 fi
238}
239
240requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100241 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100242 if [ -z "$VAL" ]; then
243 # Should never happen
244 echo "Mbed TLS configuration $1 is not defined"
245 exit 1
246 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100247 SKIP_NEXT="YES"
248 fi
249}
250
Yuto Takanobc632c22021-07-02 13:10:41 +0100251requires_config_value_equals() {
252 VAL=$( get_config_value_or_default "$1" )
253 if [ -z "$VAL" ]; then
254 # Should never happen
255 echo "Mbed TLS configuration $1 is not defined"
256 exit 1
257 elif [ "$VAL" -ne "$2" ]; then
258 SKIP_NEXT="YES"
259 fi
260}
261
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200262# skip next test if OpenSSL doesn't support FALLBACK_SCSV
263requires_openssl_with_fallback_scsv() {
264 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
265 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
266 then
267 OPENSSL_HAS_FBSCSV="YES"
268 else
269 OPENSSL_HAS_FBSCSV="NO"
270 fi
271 fi
272 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
273 SKIP_NEXT="YES"
274 fi
275}
276
Yuto Takano0807e1d2021-07-02 10:10:49 +0100277# skip next test if either IN_CONTENT_LEN or MAX_CONTENT_LEN are below a value
278requires_max_content_len() {
279 requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" $1
280 requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" $1
281}
282
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200283# skip next test if GnuTLS isn't available
284requires_gnutls() {
285 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200286 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200287 GNUTLS_AVAILABLE="YES"
288 else
289 GNUTLS_AVAILABLE="NO"
290 fi
291 fi
292 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
293 SKIP_NEXT="YES"
294 fi
295}
296
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200297# skip next test if GnuTLS-next isn't available
298requires_gnutls_next() {
299 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
300 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
301 GNUTLS_NEXT_AVAILABLE="YES"
302 else
303 GNUTLS_NEXT_AVAILABLE="NO"
304 fi
305 fi
306 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
307 SKIP_NEXT="YES"
308 fi
309}
310
311# skip next test if OpenSSL-legacy isn't available
312requires_openssl_legacy() {
313 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
314 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
315 OPENSSL_LEGACY_AVAILABLE="YES"
316 else
317 OPENSSL_LEGACY_AVAILABLE="NO"
318 fi
319 fi
320 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
321 SKIP_NEXT="YES"
322 fi
323}
324
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200325# skip next test if IPv6 isn't available on this host
326requires_ipv6() {
327 if [ -z "${HAS_IPV6:-}" ]; then
328 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
329 SRV_PID=$!
330 sleep 1
331 kill $SRV_PID >/dev/null 2>&1
332 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
333 HAS_IPV6="NO"
334 else
335 HAS_IPV6="YES"
336 fi
337 rm -r $SRV_OUT
338 fi
339
340 if [ "$HAS_IPV6" = "NO" ]; then
341 SKIP_NEXT="YES"
342 fi
343}
344
Andrzej Kurekb4593462018-10-11 08:43:30 -0400345# skip next test if it's i686 or uname is not available
346requires_not_i686() {
347 if [ -z "${IS_I686:-}" ]; then
348 IS_I686="YES"
349 if which "uname" >/dev/null 2>&1; then
350 if [ -z "$(uname -a | grep i686)" ]; then
351 IS_I686="NO"
352 fi
353 fi
354 fi
355 if [ "$IS_I686" = "YES" ]; then
356 SKIP_NEXT="YES"
357 fi
358}
359
Angus Grattonc4dd0732018-04-11 16:28:39 +1000360# Calculate the input & output maximum content lengths set in the config
Yuto Takanobbf657a2021-06-22 07:16:40 +0100361MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_CONTENT_LEN" )
362MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" )
363MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" )
Angus Grattonc4dd0732018-04-11 16:28:39 +1000364
Yuto Takano2e580ce2021-06-21 19:43:33 +0100365# Calculate the maximum content length that fits both
Angus Grattonc4dd0732018-04-11 16:28:39 +1000366if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
367 MAX_CONTENT_LEN="$MAX_IN_LEN"
368fi
369if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
370 MAX_CONTENT_LEN="$MAX_OUT_LEN"
371fi
372
373# skip the next test if the SSL output buffer is less than 16KB
374requires_full_size_output_buffer() {
375 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
376 SKIP_NEXT="YES"
377 fi
378}
379
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200380# skip the next test if valgrind is in use
381not_with_valgrind() {
382 if [ "$MEMCHECK" -gt 0 ]; then
383 SKIP_NEXT="YES"
384 fi
385}
386
Paul Bakker362689d2016-05-13 10:33:25 +0100387# skip the next test if valgrind is NOT in use
388only_with_valgrind() {
389 if [ "$MEMCHECK" -eq 0 ]; then
390 SKIP_NEXT="YES"
391 fi
392}
393
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200394# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100395client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200396 CLI_DELAY_FACTOR=$1
397}
398
Janos Follath74537a62016-09-02 13:45:28 +0100399# wait for the given seconds after the client finished in the next test
400server_needs_more_time() {
401 SRV_DELAY_SECONDS=$1
402}
403
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100404# print_name <name>
405print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100406 TESTS=$(( $TESTS + 1 ))
407 LINE=""
408
409 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
410 LINE="$TESTS "
411 fi
412
413 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200414 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100415 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100416 for i in `seq 1 $LEN`; do printf '.'; done
417 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100418
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100419}
420
421# fail <message>
422fail() {
423 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100424 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100425
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200426 mv $SRV_OUT o-srv-${TESTS}.log
427 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200428 if [ -n "$PXY_CMD" ]; then
429 mv $PXY_OUT o-pxy-${TESTS}.log
430 fi
431 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100432
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200433 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200434 echo " ! server output:"
435 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200436 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200437 echo " ! client output:"
438 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200439 if [ -n "$PXY_CMD" ]; then
440 echo " ! ========================================================"
441 echo " ! proxy output:"
442 cat o-pxy-${TESTS}.log
443 fi
444 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200445 fi
446
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200447 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100448}
449
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100450# is_polar <cmd_line>
451is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200452 case "$1" in
453 *ssl_client2*) true;;
454 *ssl_server2*) true;;
455 *) false;;
456 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100457}
458
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200459# openssl s_server doesn't have -www with DTLS
460check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200461 case "$SRV_CMD" in
462 *s_server*-dtls*)
463 NEEDS_INPUT=1
464 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
465 *) NEEDS_INPUT=0;;
466 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200467}
468
469# provide input to commands that need it
470provide_input() {
471 if [ $NEEDS_INPUT -eq 0 ]; then
472 return
473 fi
474
475 while true; do
476 echo "HTTP/1.0 200 OK"
477 sleep 1
478 done
479}
480
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100481# has_mem_err <log_file_name>
482has_mem_err() {
483 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
484 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
485 then
486 return 1 # false: does not have errors
487 else
488 return 0 # true: has errors
489 fi
490}
491
Unknown43dc0d62019-09-02 10:42:57 -0400492# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100493if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400494 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100495 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200496 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100497 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200498 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100499 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200500 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100501 # Make a tight loop, server normally takes less than 1s to start.
502 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
503 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400504 echo "$3 START TIMEOUT"
505 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100506 break
507 fi
508 # Linux and *BSD support decimal arguments to sleep. On other
509 # OSes this may be a tight loop.
510 sleep 0.1 2>/dev/null || true
511 done
512 }
513else
Unknown43dc0d62019-09-02 10:42:57 -0400514 echo "Warning: lsof not available, wait_app_start = sleep"
515 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200516 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100517 }
518fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200519
Unknown43dc0d62019-09-02 10:42:57 -0400520# Wait for server process $2 to be listening on port $1.
521wait_server_start() {
522 wait_app_start $1 $2 "SERVER" $SRV_OUT
523}
524
525# Wait for proxy process $2 to be listening on port $1.
526wait_proxy_start() {
527 wait_app_start $1 $2 "PROXY" $PXY_OUT
528}
529
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100530# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100531# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100532# acceptable bounds
533check_server_hello_time() {
534 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100535 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100536 # Get the Unix timestamp for now
537 CUR_TIME=$(date +'%s')
538 THRESHOLD_IN_SECS=300
539
540 # Check if the ServerHello time was printed
541 if [ -z "$SERVER_HELLO_TIME" ]; then
542 return 1
543 fi
544
545 # Check the time in ServerHello is within acceptable bounds
546 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
547 # The time in ServerHello is at least 5 minutes before now
548 return 1
549 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100550 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100551 return 1
552 else
553 return 0
554 fi
555}
556
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200557# wait for client to terminate and set CLI_EXIT
558# must be called right after starting the client
559wait_client_done() {
560 CLI_PID=$!
561
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200562 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
563 CLI_DELAY_FACTOR=1
564
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200565 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200566 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200567
568 wait $CLI_PID
569 CLI_EXIT=$?
570
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200571 kill $DOG_PID >/dev/null 2>&1
572 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200573
574 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100575
576 sleep $SRV_DELAY_SECONDS
577 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200578}
579
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200580# check if the given command uses dtls and sets global variable DTLS
581detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200582 case "$1" in
583 *dtls=1*|-dtls|-u) DTLS=1;;
584 *) DTLS=0;;
585 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200586}
587
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200588# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100589# Options: -s pattern pattern that must be present in server output
590# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100591# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100592# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100593# -S pattern pattern that must be absent in server output
594# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100595# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100596# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100597run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100598 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200599 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100600
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200601 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200602 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100603 return
604 fi
605
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100606 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100607
Paul Bakkerb7584a52016-05-10 10:50:43 +0100608 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200609 if [ -n "$RUN_TEST_NUMBER" ]; then
610 case ",$RUN_TEST_NUMBER," in
611 *",$TESTS,"*) :;;
612 *) SKIP_NEXT="YES";;
613 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100614 fi
615
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200616 # should we skip?
617 if [ "X$SKIP_NEXT" = "XYES" ]; then
618 SKIP_NEXT="NO"
619 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200620 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200621 return
622 fi
623
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200624 # does this test use a proxy?
625 if [ "X$1" = "X-p" ]; then
626 PXY_CMD="$2"
627 shift 2
628 else
629 PXY_CMD=""
630 fi
631
632 # get commands and client output
633 SRV_CMD="$1"
634 CLI_CMD="$2"
635 CLI_EXPECT="$3"
636 shift 3
637
Hanno Becker7a11e722019-05-10 14:38:42 +0100638 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200639 case "$SRV_CMD $CLI_CMD" in
640 *data_files/*)
641 requires_config_enabled MBEDTLS_FS_IO;;
642 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100643
644 # should we skip?
645 if [ "X$SKIP_NEXT" = "XYES" ]; then
646 SKIP_NEXT="NO"
647 echo "SKIP"
648 SKIPS=$(( $SKIPS + 1 ))
649 return
650 fi
651
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200652 # update DTLS variable
653 detect_dtls "$SRV_CMD"
654
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200655 # if the test uses DTLS but no custom proxy, add a simple proxy
656 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200657 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200658 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200659 case " $SRV_CMD " in
660 *' server_addr=::1 '*)
661 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
662 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200663 fi
664
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200665 # fix client port
666 if [ -n "$PXY_CMD" ]; then
667 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
668 else
669 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
670 fi
671
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100672 # prepend valgrind to our commands if active
673 if [ "$MEMCHECK" -gt 0 ]; then
674 if is_polar "$SRV_CMD"; then
675 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
676 fi
677 if is_polar "$CLI_CMD"; then
678 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
679 fi
680 fi
681
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200682 TIMES_LEFT=2
683 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200684 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200685
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200686 # run the commands
687 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200688 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200689 $PXY_CMD >> $PXY_OUT 2>&1 &
690 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400691 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200692 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200693
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200694 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200695 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200696 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
697 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100698 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200699
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200700 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200701 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
702 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100703
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100704 sleep 0.05
705
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200706 # terminate the server (and the proxy)
707 kill $SRV_PID
708 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100709 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100710
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200711 if [ -n "$PXY_CMD" ]; then
712 kill $PXY_PID >/dev/null 2>&1
713 wait $PXY_PID
714 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100715
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200716 # retry only on timeouts
717 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
718 printf "RETRY "
719 else
720 TIMES_LEFT=0
721 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200722 done
723
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100724 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200725 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100726 # expected client exit to incorrectly succeed in case of catastrophic
727 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100728 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200729 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100730 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100731 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100732 return
733 fi
734 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100735 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200736 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100737 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100738 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100739 return
740 fi
741 fi
742
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100743 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
744 # exit with status 0 when interrupted by a signal, and we don't really
745 # care anyway), in case e.g. the server reports a memory leak.
746 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100747 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100748 return
749 fi
750
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100751 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100752 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
753 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100754 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200755 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100756 return
757 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100758
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100759 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200760 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100761 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100762 while [ $# -gt 0 ]
763 do
764 case $1 in
765 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100766 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 +0100767 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100768 return
769 fi
770 ;;
771
772 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100773 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 +0100774 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100775 return
776 fi
777 ;;
778
779 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100780 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 +0100781 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100782 return
783 fi
784 ;;
785
786 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100787 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 +0100788 fail "pattern '$2' MUST NOT be present in the Client output"
789 return
790 fi
791 ;;
792
793 # The filtering in the following two options (-u and -U) do the following
794 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100795 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100796 # - keep one of each non-unique line
797 # - count how many lines remain
798 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
799 # if there were no duplicates.
800 "-U")
801 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
802 fail "lines following pattern '$2' must be unique in Server output"
803 return
804 fi
805 ;;
806
807 "-u")
808 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
809 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100810 return
811 fi
812 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100813 "-F")
814 if ! $2 "$SRV_OUT"; then
815 fail "function call to '$2' failed on Server output"
816 return
817 fi
818 ;;
819 "-f")
820 if ! $2 "$CLI_OUT"; then
821 fail "function call to '$2' failed on Client output"
822 return
823 fi
824 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100825
826 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200827 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100828 exit 1
829 esac
830 shift 2
831 done
832
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100833 # check valgrind's results
834 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200835 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100836 fail "Server has memory errors"
837 return
838 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200839 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100840 fail "Client has memory errors"
841 return
842 fi
843 fi
844
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100845 # if we're here, everything is ok
846 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100847 if [ "$PRESERVE_LOGS" -gt 0 ]; then
848 mv $SRV_OUT o-srv-${TESTS}.log
849 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100850 if [ -n "$PXY_CMD" ]; then
851 mv $PXY_OUT o-pxy-${TESTS}.log
852 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100853 fi
854
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200855 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100856}
857
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100858cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200859 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200860 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
861 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
862 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
863 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100864 exit 1
865}
866
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100867#
868# MAIN
869#
870
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100871get_options "$@"
872
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200873# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
874# patterns rather than regular expressions, use a case statement instead
875# of calling grep. To keep the optimizer simple, it is incomplete and only
876# detects simple cases: plain substring, everything, nothing.
877#
878# As an exception, the character '.' is treated as an ordinary character
879# if it is the only special character in the string. This is because it's
880# rare to need "any one character", but needing a literal '.' is common
881# (e.g. '-f "DTLS 1.2"').
882need_grep=
883case "$FILTER" in
884 '^$') simple_filter=;;
885 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200886 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200887 need_grep=1;;
888 *) # No regexp or shell-pattern special character
889 simple_filter="*$FILTER*";;
890esac
891case "$EXCLUDE" in
892 '^$') simple_exclude=;;
893 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200894 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200895 need_grep=1;;
896 *) # No regexp or shell-pattern special character
897 simple_exclude="*$EXCLUDE*";;
898esac
899if [ -n "$need_grep" ]; then
900 is_excluded () {
901 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
902 }
903else
904 is_excluded () {
905 case "$1" in
906 $simple_exclude) true;;
907 $simple_filter) false;;
908 *) true;;
909 esac
910 }
911fi
912
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100913# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100914P_SRV_BIN="${P_SRV%%[ ]*}"
915P_CLI_BIN="${P_CLI%%[ ]*}"
916P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100917if [ ! -x "$P_SRV_BIN" ]; then
918 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100919 exit 1
920fi
Hanno Becker17c04932017-10-10 14:44:53 +0100921if [ ! -x "$P_CLI_BIN" ]; then
922 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100923 exit 1
924fi
Hanno Becker17c04932017-10-10 14:44:53 +0100925if [ ! -x "$P_PXY_BIN" ]; then
926 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200927 exit 1
928fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100929if [ "$MEMCHECK" -gt 0 ]; then
930 if which valgrind >/dev/null 2>&1; then :; else
931 echo "Memcheck not possible. Valgrind not found"
932 exit 1
933 fi
934fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100935if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
936 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100937 exit 1
938fi
939
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200940# used by watchdog
941MAIN_PID="$$"
942
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100943# We use somewhat arbitrary delays for tests:
944# - how long do we wait for the server to start (when lsof not available)?
945# - how long do we allow for the client to finish?
946# (not to check performance, just to avoid waiting indefinitely)
947# Things are slower with valgrind, so give extra time here.
948#
949# Note: without lsof, there is a trade-off between the running time of this
950# script and the risk of spurious errors because we didn't wait long enough.
951# The watchdog delay on the other hand doesn't affect normal running time of
952# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200953if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100954 START_DELAY=6
955 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200956else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100957 START_DELAY=2
958 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200959fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100960
961# some particular tests need more time:
962# - for the client, we multiply the usual watchdog limit by a factor
963# - for the server, we sleep for a number of seconds after the client exits
964# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200965CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100966SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200967
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200968# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000969# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200970P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
971P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100972P_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"}"
Gilles Peskine63a2b912021-04-01 14:00:11 +0200973O_SRV="$O_SRV -accept $SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200974O_CLI="$O_CLI -connect localhost:+SRV_PORT"
975G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200976G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200977
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200978if [ -n "${OPENSSL_LEGACY:-}" ]; then
979 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
980 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
981fi
982
Hanno Becker58e9dc32018-08-17 15:53:21 +0100983if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200984 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
985fi
986
Hanno Becker58e9dc32018-08-17 15:53:21 +0100987if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200988 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200989fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100990
Gilles Peskine62469d92017-05-10 10:13:59 +0200991# Allow SHA-1, because many of our test certificates use it
992P_SRV="$P_SRV allow_sha1=1"
993P_CLI="$P_CLI allow_sha1=1"
994
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200995# Also pick a unique name for intermediate files
996SRV_OUT="srv_out.$$"
997CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200998PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200999SESSION="session.$$"
1000
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001001SKIP_NEXT="NO"
1002
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001003trap cleanup INT TERM HUP
1004
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001005# Basic test
1006
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001007# Checks that:
1008# - things work with all ciphersuites active (used with config-full in all.sh)
1009# - the expected (highest security) parameters are selected
1010# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001011run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001012 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001013 "$P_CLI" \
1014 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001015 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001016 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001017 -s "client hello v3, signature_algorithm ext: 6" \
1018 -s "ECDHE curve: secp521r1" \
1019 -S "error" \
1020 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001021
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001022run_test "Default, DTLS" \
1023 "$P_SRV dtls=1" \
1024 "$P_CLI dtls=1" \
1025 0 \
1026 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001027 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001028
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001029requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1030run_test "Default (compression enabled)" \
1031 "$P_SRV debug_level=3" \
1032 "$P_CLI debug_level=3" \
1033 0 \
1034 -s "Allocating compression buffer" \
1035 -c "Allocating compression buffer" \
1036 -s "Record expansion is unknown (compression)" \
1037 -c "Record expansion is unknown (compression)" \
1038 -S "error" \
1039 -C "error"
1040
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001041# Test current time in ServerHello
1042requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001043run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001044 "$P_SRV debug_level=3" \
1045 "$P_CLI debug_level=3" \
1046 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001047 -f "check_server_hello_time" \
1048 -F "check_server_hello_time"
1049
Simon Butcher8e004102016-10-14 00:48:33 +01001050# Test for uniqueness of IVs in AEAD ciphersuites
1051run_test "Unique IV in GCM" \
1052 "$P_SRV exchanges=20 debug_level=4" \
1053 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1054 0 \
1055 -u "IV used" \
1056 -U "IV used"
1057
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001058# Tests for rc4 option
1059
Simon Butchera410af52016-05-19 22:12:18 +01001060requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001061run_test "RC4: server disabled, client enabled" \
1062 "$P_SRV" \
1063 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1064 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001065 -s "SSL - The server has no ciphersuites in common"
1066
Simon Butchera410af52016-05-19 22:12:18 +01001067requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001068run_test "RC4: server half, client enabled" \
1069 "$P_SRV arc4=1" \
1070 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1071 1 \
1072 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001073
1074run_test "RC4: server enabled, client disabled" \
1075 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1076 "$P_CLI" \
1077 1 \
1078 -s "SSL - The server has no ciphersuites in common"
1079
1080run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001081 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001082 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1083 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001084 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001085 -S "SSL - The server has no ciphersuites in common"
1086
Hanno Beckerd26bb202018-08-17 09:54:10 +01001087# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1088
1089requires_gnutls
1090requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1091run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1092 "$G_SRV"\
1093 "$P_CLI force_version=tls1_1" \
1094 0
1095
1096requires_gnutls
1097requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1098run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1099 "$G_SRV"\
1100 "$P_CLI force_version=tls1" \
1101 0
1102
Gilles Peskinebc70a182017-05-09 15:59:24 +02001103# Tests for SHA-1 support
1104
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001105requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001106run_test "SHA-1 forbidden by default in server certificate" \
1107 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1108 "$P_CLI debug_level=2 allow_sha1=0" \
1109 1 \
1110 -c "The certificate is signed with an unacceptable hash"
1111
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001112requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1113run_test "SHA-1 forbidden by default in server certificate" \
1114 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1115 "$P_CLI debug_level=2 allow_sha1=0" \
1116 0
1117
Gilles Peskinebc70a182017-05-09 15:59:24 +02001118run_test "SHA-1 explicitly allowed in server certificate" \
1119 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1120 "$P_CLI allow_sha1=1" \
1121 0
1122
1123run_test "SHA-256 allowed by default in server certificate" \
1124 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1125 "$P_CLI allow_sha1=0" \
1126 0
1127
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001128requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001129run_test "SHA-1 forbidden by default in client certificate" \
1130 "$P_SRV auth_mode=required allow_sha1=0" \
1131 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1132 1 \
1133 -s "The certificate is signed with an unacceptable hash"
1134
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001135requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1136run_test "SHA-1 forbidden by default in client certificate" \
1137 "$P_SRV auth_mode=required allow_sha1=0" \
1138 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1139 0
1140
Gilles Peskinebc70a182017-05-09 15:59:24 +02001141run_test "SHA-1 explicitly allowed in client certificate" \
1142 "$P_SRV auth_mode=required allow_sha1=1" \
1143 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1144 0
1145
1146run_test "SHA-256 allowed by default in client certificate" \
1147 "$P_SRV auth_mode=required allow_sha1=0" \
1148 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1149 0
1150
Hanno Becker7ae8a762018-08-14 15:43:35 +01001151# Tests for datagram packing
1152run_test "DTLS: multiple records in same datagram, client and server" \
1153 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1154 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1155 0 \
1156 -c "next record in same datagram" \
1157 -s "next record in same datagram"
1158
1159run_test "DTLS: multiple records in same datagram, client only" \
1160 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1161 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1162 0 \
1163 -s "next record in same datagram" \
1164 -C "next record in same datagram"
1165
1166run_test "DTLS: multiple records in same datagram, server only" \
1167 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1168 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1169 0 \
1170 -S "next record in same datagram" \
1171 -c "next record in same datagram"
1172
1173run_test "DTLS: multiple records in same datagram, neither client nor server" \
1174 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1175 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1176 0 \
1177 -S "next record in same datagram" \
1178 -C "next record in same datagram"
1179
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001180# Tests for Truncated HMAC extension
1181
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001182run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001183 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001184 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001185 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001186 -s "dumping 'expected mac' (20 bytes)" \
1187 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001188
Hanno Becker32c55012017-11-10 08:42:54 +00001189requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001190run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001191 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001192 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001193 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001194 -s "dumping 'expected mac' (20 bytes)" \
1195 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001196
Hanno Becker32c55012017-11-10 08:42:54 +00001197requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001198run_test "Truncated HMAC: client enabled, server default" \
1199 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001200 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001201 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001202 -s "dumping 'expected mac' (20 bytes)" \
1203 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001204
Hanno Becker32c55012017-11-10 08:42:54 +00001205requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001206run_test "Truncated HMAC: client enabled, server disabled" \
1207 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001208 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001209 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001210 -s "dumping 'expected mac' (20 bytes)" \
1211 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001212
Hanno Becker32c55012017-11-10 08:42:54 +00001213requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001214run_test "Truncated HMAC: client disabled, server enabled" \
1215 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001216 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001217 0 \
1218 -s "dumping 'expected mac' (20 bytes)" \
1219 -S "dumping 'expected mac' (10 bytes)"
1220
1221requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001222run_test "Truncated HMAC: client enabled, server enabled" \
1223 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001224 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001225 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001226 -S "dumping 'expected mac' (20 bytes)" \
1227 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001228
Hanno Becker4c4f4102017-11-10 09:16:05 +00001229run_test "Truncated HMAC, DTLS: client default, server default" \
1230 "$P_SRV dtls=1 debug_level=4" \
1231 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1232 0 \
1233 -s "dumping 'expected mac' (20 bytes)" \
1234 -S "dumping 'expected mac' (10 bytes)"
1235
1236requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1237run_test "Truncated HMAC, DTLS: client disabled, server default" \
1238 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001239 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001240 0 \
1241 -s "dumping 'expected mac' (20 bytes)" \
1242 -S "dumping 'expected mac' (10 bytes)"
1243
1244requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1245run_test "Truncated HMAC, DTLS: client enabled, server default" \
1246 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001247 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001248 0 \
1249 -s "dumping 'expected mac' (20 bytes)" \
1250 -S "dumping 'expected mac' (10 bytes)"
1251
1252requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1253run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1254 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001255 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001256 0 \
1257 -s "dumping 'expected mac' (20 bytes)" \
1258 -S "dumping 'expected mac' (10 bytes)"
1259
1260requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1261run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1262 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001263 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001264 0 \
1265 -s "dumping 'expected mac' (20 bytes)" \
1266 -S "dumping 'expected mac' (10 bytes)"
1267
1268requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1269run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1270 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001271 "$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 +01001272 0 \
1273 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001274 -s "dumping 'expected mac' (10 bytes)"
1275
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001276# Tests for Encrypt-then-MAC extension
1277
1278run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001279 "$P_SRV debug_level=3 \
1280 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001281 "$P_CLI debug_level=3" \
1282 0 \
1283 -c "client hello, adding encrypt_then_mac extension" \
1284 -s "found encrypt then mac extension" \
1285 -s "server hello, adding encrypt then mac extension" \
1286 -c "found encrypt_then_mac extension" \
1287 -c "using encrypt then mac" \
1288 -s "using encrypt then mac"
1289
1290run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001291 "$P_SRV debug_level=3 etm=0 \
1292 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001293 "$P_CLI debug_level=3 etm=1" \
1294 0 \
1295 -c "client hello, adding encrypt_then_mac extension" \
1296 -s "found encrypt then mac extension" \
1297 -S "server hello, adding encrypt then mac extension" \
1298 -C "found encrypt_then_mac extension" \
1299 -C "using encrypt then mac" \
1300 -S "using encrypt then mac"
1301
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001302run_test "Encrypt then MAC: client enabled, aead cipher" \
1303 "$P_SRV debug_level=3 etm=1 \
1304 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1305 "$P_CLI debug_level=3 etm=1" \
1306 0 \
1307 -c "client hello, adding encrypt_then_mac extension" \
1308 -s "found encrypt then mac extension" \
1309 -S "server hello, adding encrypt then mac extension" \
1310 -C "found encrypt_then_mac extension" \
1311 -C "using encrypt then mac" \
1312 -S "using encrypt then mac"
1313
1314run_test "Encrypt then MAC: client enabled, stream cipher" \
1315 "$P_SRV debug_level=3 etm=1 \
1316 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001317 "$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 +01001318 0 \
1319 -c "client hello, adding encrypt_then_mac extension" \
1320 -s "found encrypt then mac extension" \
1321 -S "server hello, adding encrypt then mac extension" \
1322 -C "found encrypt_then_mac extension" \
1323 -C "using encrypt then mac" \
1324 -S "using encrypt then mac"
1325
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001326run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001327 "$P_SRV debug_level=3 etm=1 \
1328 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001329 "$P_CLI debug_level=3 etm=0" \
1330 0 \
1331 -C "client hello, adding encrypt_then_mac extension" \
1332 -S "found encrypt then mac extension" \
1333 -S "server hello, adding encrypt then mac extension" \
1334 -C "found encrypt_then_mac extension" \
1335 -C "using encrypt then mac" \
1336 -S "using encrypt then mac"
1337
Janos Follathe2681a42016-03-07 15:57:05 +00001338requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001339run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001340 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001341 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001342 "$P_CLI debug_level=3 force_version=ssl3" \
1343 0 \
1344 -C "client hello, adding encrypt_then_mac extension" \
1345 -S "found encrypt then mac extension" \
1346 -S "server hello, adding encrypt then mac extension" \
1347 -C "found encrypt_then_mac extension" \
1348 -C "using encrypt then mac" \
1349 -S "using encrypt then mac"
1350
Janos Follathe2681a42016-03-07 15:57:05 +00001351requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001352run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001353 "$P_SRV debug_level=3 force_version=ssl3 \
1354 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001355 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001356 0 \
1357 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001358 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001359 -S "server hello, adding encrypt then mac extension" \
1360 -C "found encrypt_then_mac extension" \
1361 -C "using encrypt then mac" \
1362 -S "using encrypt then mac"
1363
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001364# Tests for Extended Master Secret extension
1365
1366run_test "Extended Master Secret: default" \
1367 "$P_SRV debug_level=3" \
1368 "$P_CLI debug_level=3" \
1369 0 \
1370 -c "client hello, adding extended_master_secret extension" \
1371 -s "found extended master secret extension" \
1372 -s "server hello, adding extended master secret extension" \
1373 -c "found extended_master_secret extension" \
1374 -c "using extended master secret" \
1375 -s "using extended master secret"
1376
1377run_test "Extended Master Secret: client enabled, server disabled" \
1378 "$P_SRV debug_level=3 extended_ms=0" \
1379 "$P_CLI debug_level=3 extended_ms=1" \
1380 0 \
1381 -c "client hello, adding extended_master_secret extension" \
1382 -s "found extended master secret extension" \
1383 -S "server hello, adding extended master secret extension" \
1384 -C "found extended_master_secret extension" \
1385 -C "using extended master secret" \
1386 -S "using extended master secret"
1387
1388run_test "Extended Master Secret: client disabled, server enabled" \
1389 "$P_SRV debug_level=3 extended_ms=1" \
1390 "$P_CLI debug_level=3 extended_ms=0" \
1391 0 \
1392 -C "client hello, adding extended_master_secret extension" \
1393 -S "found extended master secret extension" \
1394 -S "server hello, adding extended master secret extension" \
1395 -C "found extended_master_secret extension" \
1396 -C "using extended master secret" \
1397 -S "using extended master secret"
1398
Janos Follathe2681a42016-03-07 15:57:05 +00001399requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001400run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001401 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001402 "$P_CLI debug_level=3 force_version=ssl3" \
1403 0 \
1404 -C "client hello, adding extended_master_secret extension" \
1405 -S "found extended master secret extension" \
1406 -S "server hello, adding extended master secret extension" \
1407 -C "found extended_master_secret extension" \
1408 -C "using extended master secret" \
1409 -S "using extended master secret"
1410
Janos Follathe2681a42016-03-07 15:57:05 +00001411requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001412run_test "Extended Master Secret: client enabled, server SSLv3" \
1413 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001414 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001415 0 \
1416 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001417 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001418 -S "server hello, adding extended master secret extension" \
1419 -C "found extended_master_secret extension" \
1420 -C "using extended master secret" \
1421 -S "using extended master secret"
1422
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001423# Tests for FALLBACK_SCSV
1424
1425run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001426 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001427 "$P_CLI debug_level=3 force_version=tls1_1" \
1428 0 \
1429 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001430 -S "received FALLBACK_SCSV" \
1431 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001432 -C "is a fatal alert message (msg 86)"
1433
1434run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001435 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001436 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1437 0 \
1438 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001439 -S "received FALLBACK_SCSV" \
1440 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001441 -C "is a fatal alert message (msg 86)"
1442
1443run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001444 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001445 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001446 1 \
1447 -c "adding FALLBACK_SCSV" \
1448 -s "received FALLBACK_SCSV" \
1449 -s "inapropriate fallback" \
1450 -c "is a fatal alert message (msg 86)"
1451
1452run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001453 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001454 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001455 0 \
1456 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001457 -s "received FALLBACK_SCSV" \
1458 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001459 -C "is a fatal alert message (msg 86)"
1460
1461requires_openssl_with_fallback_scsv
1462run_test "Fallback SCSV: default, openssl server" \
1463 "$O_SRV" \
1464 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1465 0 \
1466 -C "adding FALLBACK_SCSV" \
1467 -C "is a fatal alert message (msg 86)"
1468
1469requires_openssl_with_fallback_scsv
1470run_test "Fallback SCSV: enabled, openssl server" \
1471 "$O_SRV" \
1472 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1473 1 \
1474 -c "adding FALLBACK_SCSV" \
1475 -c "is a fatal alert message (msg 86)"
1476
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001477requires_openssl_with_fallback_scsv
1478run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001479 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001480 "$O_CLI -tls1_1" \
1481 0 \
1482 -S "received FALLBACK_SCSV" \
1483 -S "inapropriate fallback"
1484
1485requires_openssl_with_fallback_scsv
1486run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001487 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001488 "$O_CLI -tls1_1 -fallback_scsv" \
1489 1 \
1490 -s "received FALLBACK_SCSV" \
1491 -s "inapropriate fallback"
1492
1493requires_openssl_with_fallback_scsv
1494run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001495 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001496 "$O_CLI -fallback_scsv" \
1497 0 \
1498 -s "received FALLBACK_SCSV" \
1499 -S "inapropriate fallback"
1500
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001501# Test sending and receiving empty application data records
1502
1503run_test "Encrypt then MAC: empty application data record" \
1504 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1505 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1506 0 \
1507 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1508 -s "dumping 'input payload after decrypt' (0 bytes)" \
1509 -c "0 bytes written in 1 fragments"
1510
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001511run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001512 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1513 "$P_CLI auth_mode=none etm=0 request_size=0" \
1514 0 \
1515 -s "dumping 'input payload after decrypt' (0 bytes)" \
1516 -c "0 bytes written in 1 fragments"
1517
1518run_test "Encrypt then MAC, DTLS: empty application data record" \
1519 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1520 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1521 0 \
1522 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1523 -s "dumping 'input payload after decrypt' (0 bytes)" \
1524 -c "0 bytes written in 1 fragments"
1525
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001526run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001527 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1528 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1529 0 \
1530 -s "dumping 'input payload after decrypt' (0 bytes)" \
1531 -c "0 bytes written in 1 fragments"
1532
Gilles Peskined50177f2017-05-16 17:53:03 +02001533## ClientHello generated with
1534## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1535## then manually twiddling the ciphersuite list.
1536## The ClientHello content is spelled out below as a hex string as
1537## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1538## The expected response is an inappropriate_fallback alert.
1539requires_openssl_with_fallback_scsv
1540run_test "Fallback SCSV: beginning of list" \
1541 "$P_SRV debug_level=2" \
1542 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1543 0 \
1544 -s "received FALLBACK_SCSV" \
1545 -s "inapropriate fallback"
1546
1547requires_openssl_with_fallback_scsv
1548run_test "Fallback SCSV: end of list" \
1549 "$P_SRV debug_level=2" \
1550 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1551 0 \
1552 -s "received FALLBACK_SCSV" \
1553 -s "inapropriate fallback"
1554
1555## Here the expected response is a valid ServerHello prefix, up to the random.
1556requires_openssl_with_fallback_scsv
1557run_test "Fallback SCSV: not in list" \
1558 "$P_SRV debug_level=2" \
1559 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1560 0 \
1561 -S "received FALLBACK_SCSV" \
1562 -S "inapropriate fallback"
1563
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001564# Tests for CBC 1/n-1 record splitting
1565
1566run_test "CBC Record splitting: TLS 1.2, no splitting" \
1567 "$P_SRV" \
1568 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1569 request_size=123 force_version=tls1_2" \
1570 0 \
1571 -s "Read from client: 123 bytes read" \
1572 -S "Read from client: 1 bytes read" \
1573 -S "122 bytes read"
1574
1575run_test "CBC Record splitting: TLS 1.1, no splitting" \
1576 "$P_SRV" \
1577 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1578 request_size=123 force_version=tls1_1" \
1579 0 \
1580 -s "Read from client: 123 bytes read" \
1581 -S "Read from client: 1 bytes read" \
1582 -S "122 bytes read"
1583
1584run_test "CBC Record splitting: TLS 1.0, splitting" \
1585 "$P_SRV" \
1586 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1587 request_size=123 force_version=tls1" \
1588 0 \
1589 -S "Read from client: 123 bytes read" \
1590 -s "Read from client: 1 bytes read" \
1591 -s "122 bytes read"
1592
Janos Follathe2681a42016-03-07 15:57:05 +00001593requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001594run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001595 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001596 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1597 request_size=123 force_version=ssl3" \
1598 0 \
1599 -S "Read from client: 123 bytes read" \
1600 -s "Read from client: 1 bytes read" \
1601 -s "122 bytes read"
1602
1603run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001604 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001605 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1606 request_size=123 force_version=tls1" \
1607 0 \
1608 -s "Read from client: 123 bytes read" \
1609 -S "Read from client: 1 bytes read" \
1610 -S "122 bytes read"
1611
1612run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1613 "$P_SRV" \
1614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1615 request_size=123 force_version=tls1 recsplit=0" \
1616 0 \
1617 -s "Read from client: 123 bytes read" \
1618 -S "Read from client: 1 bytes read" \
1619 -S "122 bytes read"
1620
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001621run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1622 "$P_SRV nbio=2" \
1623 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1624 request_size=123 force_version=tls1" \
1625 0 \
1626 -S "Read from client: 123 bytes read" \
1627 -s "Read from client: 1 bytes read" \
1628 -s "122 bytes read"
1629
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001630# Tests for Session Tickets
1631
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001632run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001633 "$P_SRV debug_level=3 tickets=1" \
1634 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001635 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001636 -c "client hello, adding session ticket extension" \
1637 -s "found session ticket extension" \
1638 -s "server hello, adding session ticket extension" \
1639 -c "found session_ticket extension" \
1640 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001641 -S "session successfully restored from cache" \
1642 -s "session successfully restored from ticket" \
1643 -s "a session has been resumed" \
1644 -c "a session has been resumed"
1645
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001646run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001647 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1648 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001649 0 \
1650 -c "client hello, adding session ticket extension" \
1651 -s "found session ticket extension" \
1652 -s "server hello, adding session ticket extension" \
1653 -c "found session_ticket extension" \
1654 -c "parse new session ticket" \
1655 -S "session successfully restored from cache" \
1656 -s "session successfully restored from ticket" \
1657 -s "a session has been resumed" \
1658 -c "a session has been resumed"
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1662 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001663 0 \
1664 -c "client hello, adding session ticket extension" \
1665 -s "found session ticket extension" \
1666 -s "server hello, adding session ticket extension" \
1667 -c "found session_ticket extension" \
1668 -c "parse new session ticket" \
1669 -S "session successfully restored from cache" \
1670 -S "session successfully restored from ticket" \
1671 -S "a session has been resumed" \
1672 -C "a session has been resumed"
1673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001674run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001675 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001676 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001677 0 \
1678 -c "client hello, adding session ticket extension" \
1679 -c "found session_ticket extension" \
1680 -c "parse new session ticket" \
1681 -c "a session has been resumed"
1682
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001683run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001684 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001685 "( $O_CLI -sess_out $SESSION; \
1686 $O_CLI -sess_in $SESSION; \
1687 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001688 0 \
1689 -s "found session ticket extension" \
1690 -s "server hello, adding session ticket extension" \
1691 -S "session successfully restored from cache" \
1692 -s "session successfully restored from ticket" \
1693 -s "a session has been resumed"
1694
Hanno Becker1d739932018-08-21 13:55:22 +01001695# Tests for Session Tickets with DTLS
1696
1697run_test "Session resume using tickets, DTLS: basic" \
1698 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001699 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001700 0 \
1701 -c "client hello, adding session ticket extension" \
1702 -s "found session ticket extension" \
1703 -s "server hello, adding session ticket extension" \
1704 -c "found session_ticket extension" \
1705 -c "parse new session ticket" \
1706 -S "session successfully restored from cache" \
1707 -s "session successfully restored from ticket" \
1708 -s "a session has been resumed" \
1709 -c "a session has been resumed"
1710
1711run_test "Session resume using tickets, DTLS: cache disabled" \
1712 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001713 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001714 0 \
1715 -c "client hello, adding session ticket extension" \
1716 -s "found session ticket extension" \
1717 -s "server hello, adding session ticket extension" \
1718 -c "found session_ticket extension" \
1719 -c "parse new session ticket" \
1720 -S "session successfully restored from cache" \
1721 -s "session successfully restored from ticket" \
1722 -s "a session has been resumed" \
1723 -c "a session has been resumed"
1724
1725run_test "Session resume using tickets, DTLS: timeout" \
1726 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001727 "$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 +01001728 0 \
1729 -c "client hello, adding session ticket extension" \
1730 -s "found session ticket extension" \
1731 -s "server hello, adding session ticket extension" \
1732 -c "found session_ticket extension" \
1733 -c "parse new session ticket" \
1734 -S "session successfully restored from cache" \
1735 -S "session successfully restored from ticket" \
1736 -S "a session has been resumed" \
1737 -C "a session has been resumed"
1738
1739run_test "Session resume using tickets, DTLS: openssl server" \
1740 "$O_SRV -dtls1" \
1741 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1742 0 \
1743 -c "client hello, adding session ticket extension" \
1744 -c "found session_ticket extension" \
1745 -c "parse new session ticket" \
1746 -c "a session has been resumed"
1747
1748run_test "Session resume using tickets, DTLS: openssl client" \
1749 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1750 "( $O_CLI -dtls1 -sess_out $SESSION; \
1751 $O_CLI -dtls1 -sess_in $SESSION; \
1752 rm -f $SESSION )" \
1753 0 \
1754 -s "found session ticket extension" \
1755 -s "server hello, adding session ticket extension" \
1756 -S "session successfully restored from cache" \
1757 -s "session successfully restored from ticket" \
1758 -s "a session has been resumed"
1759
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001760# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001761
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001762run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001763 "$P_SRV debug_level=3 tickets=0" \
1764 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001765 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001766 -c "client hello, adding session ticket extension" \
1767 -s "found session ticket extension" \
1768 -S "server hello, adding session ticket extension" \
1769 -C "found session_ticket extension" \
1770 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001771 -s "session successfully restored from cache" \
1772 -S "session successfully restored from ticket" \
1773 -s "a session has been resumed" \
1774 -c "a session has been resumed"
1775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001777 "$P_SRV debug_level=3 tickets=1" \
1778 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001779 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001780 -C "client hello, adding session ticket extension" \
1781 -S "found session ticket extension" \
1782 -S "server hello, adding session ticket extension" \
1783 -C "found session_ticket extension" \
1784 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001785 -s "session successfully restored from cache" \
1786 -S "session successfully restored from ticket" \
1787 -s "a session has been resumed" \
1788 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001790run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001791 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1792 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001793 0 \
1794 -S "session successfully restored from cache" \
1795 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001796 -S "a session has been resumed" \
1797 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001799run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001800 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1801 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001802 0 \
1803 -s "session successfully restored from cache" \
1804 -S "session successfully restored from ticket" \
1805 -s "a session has been resumed" \
1806 -c "a session has been resumed"
1807
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001808run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001809 "$P_SRV debug_level=3 tickets=0" \
1810 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001811 0 \
1812 -s "session successfully restored from cache" \
1813 -S "session successfully restored from ticket" \
1814 -s "a session has been resumed" \
1815 -c "a session has been resumed"
1816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001817run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001818 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1819 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001820 0 \
1821 -S "session successfully restored from cache" \
1822 -S "session successfully restored from ticket" \
1823 -S "a session has been resumed" \
1824 -C "a session has been resumed"
1825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001826run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001827 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1828 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001829 0 \
1830 -s "session successfully restored from cache" \
1831 -S "session successfully restored from ticket" \
1832 -s "a session has been resumed" \
1833 -c "a session has been resumed"
1834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001836 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001837 "( $O_CLI -sess_out $SESSION; \
1838 $O_CLI -sess_in $SESSION; \
1839 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001840 0 \
1841 -s "found session ticket extension" \
1842 -S "server hello, adding session ticket extension" \
1843 -s "session successfully restored from cache" \
1844 -S "session successfully restored from ticket" \
1845 -s "a session has been resumed"
1846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001847run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001848 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001849 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001850 0 \
1851 -C "found session_ticket extension" \
1852 -C "parse new session ticket" \
1853 -c "a session has been resumed"
1854
Hanno Becker1d739932018-08-21 13:55:22 +01001855# Tests for Session Resume based on session-ID and cache, DTLS
1856
1857run_test "Session resume using cache, DTLS: tickets enabled on client" \
1858 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001859 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001860 0 \
1861 -c "client hello, adding session ticket extension" \
1862 -s "found session ticket extension" \
1863 -S "server hello, adding session ticket extension" \
1864 -C "found session_ticket extension" \
1865 -C "parse new session ticket" \
1866 -s "session successfully restored from cache" \
1867 -S "session successfully restored from ticket" \
1868 -s "a session has been resumed" \
1869 -c "a session has been resumed"
1870
1871run_test "Session resume using cache, DTLS: tickets enabled on server" \
1872 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001873 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001874 0 \
1875 -C "client hello, adding session ticket extension" \
1876 -S "found session ticket extension" \
1877 -S "server hello, adding session ticket extension" \
1878 -C "found session_ticket extension" \
1879 -C "parse new session ticket" \
1880 -s "session successfully restored from cache" \
1881 -S "session successfully restored from ticket" \
1882 -s "a session has been resumed" \
1883 -c "a session has been resumed"
1884
1885run_test "Session resume using cache, DTLS: cache_max=0" \
1886 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001887 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001888 0 \
1889 -S "session successfully restored from cache" \
1890 -S "session successfully restored from ticket" \
1891 -S "a session has been resumed" \
1892 -C "a session has been resumed"
1893
1894run_test "Session resume using cache, DTLS: cache_max=1" \
1895 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001896 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001897 0 \
1898 -s "session successfully restored from cache" \
1899 -S "session successfully restored from ticket" \
1900 -s "a session has been resumed" \
1901 -c "a session has been resumed"
1902
1903run_test "Session resume using cache, DTLS: timeout > delay" \
1904 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001905 "$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 +01001906 0 \
1907 -s "session successfully restored from cache" \
1908 -S "session successfully restored from ticket" \
1909 -s "a session has been resumed" \
1910 -c "a session has been resumed"
1911
1912run_test "Session resume using cache, DTLS: timeout < delay" \
1913 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001914 "$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 +01001915 0 \
1916 -S "session successfully restored from cache" \
1917 -S "session successfully restored from ticket" \
1918 -S "a session has been resumed" \
1919 -C "a session has been resumed"
1920
1921run_test "Session resume using cache, DTLS: no timeout" \
1922 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001923 "$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 +01001924 0 \
1925 -s "session successfully restored from cache" \
1926 -S "session successfully restored from ticket" \
1927 -s "a session has been resumed" \
1928 -c "a session has been resumed"
1929
1930run_test "Session resume using cache, DTLS: openssl client" \
1931 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1932 "( $O_CLI -dtls1 -sess_out $SESSION; \
1933 $O_CLI -dtls1 -sess_in $SESSION; \
1934 rm -f $SESSION )" \
1935 0 \
1936 -s "found session ticket extension" \
1937 -S "server hello, adding session ticket extension" \
1938 -s "session successfully restored from cache" \
1939 -S "session successfully restored from ticket" \
1940 -s "a session has been resumed"
1941
1942run_test "Session resume using cache, DTLS: openssl server" \
1943 "$O_SRV -dtls1" \
1944 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1945 0 \
1946 -C "found session_ticket extension" \
1947 -C "parse new session ticket" \
1948 -c "a session has been resumed"
1949
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001950# Tests for Max Fragment Length extension
1951
Hanno Becker4aed27e2017-09-18 15:00:34 +01001952requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001953run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001954 "$P_SRV debug_level=3" \
1955 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001956 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001957 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1958 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001959 -C "client hello, adding max_fragment_length extension" \
1960 -S "found max fragment length extension" \
1961 -S "server hello, max_fragment_length extension" \
1962 -C "found max_fragment_length extension"
1963
Hanno Becker4aed27e2017-09-18 15:00:34 +01001964requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001965run_test "Max fragment length: enabled, default, larger message" \
1966 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001967 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001968 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001969 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1970 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001971 -C "client hello, adding max_fragment_length extension" \
1972 -S "found max fragment length extension" \
1973 -S "server hello, max_fragment_length extension" \
1974 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001975 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1976 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001977 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001978
1979requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1980run_test "Max fragment length, DTLS: enabled, default, larger message" \
1981 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001982 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001983 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001984 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1985 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001986 -C "client hello, adding max_fragment_length extension" \
1987 -S "found max fragment length extension" \
1988 -S "server hello, max_fragment_length extension" \
1989 -C "found max_fragment_length extension" \
1990 -c "fragment larger than.*maximum "
1991
Angus Grattonc4dd0732018-04-11 16:28:39 +10001992# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1993# (session fragment length will be 16384 regardless of mbedtls
1994# content length configuration.)
1995
Hanno Beckerc5266962017-09-18 15:01:50 +01001996requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1997run_test "Max fragment length: disabled, larger message" \
1998 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001999 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002000 0 \
2001 -C "Maximum fragment length is 16384" \
2002 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002003 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2004 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002005 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002006
2007requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takano2e580ce2021-06-21 19:43:33 +01002008run_test "Max fragment length, DTLS: disabled, larger message" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002009 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002010 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002011 1 \
2012 -C "Maximum fragment length is 16384" \
2013 -S "Maximum fragment length is 16384" \
2014 -c "fragment larger than.*maximum "
2015
Yuto Takano0807e1d2021-07-02 10:10:49 +01002016requires_max_content_len 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01002017requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002018run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002019 "$P_SRV debug_level=3" \
2020 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002021 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002022 -c "Maximum fragment length is 4096" \
2023 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002024 -c "client hello, adding max_fragment_length extension" \
2025 -s "found max fragment length extension" \
2026 -s "server hello, max_fragment_length extension" \
2027 -c "found max_fragment_length extension"
2028
Yuto Takano0807e1d2021-07-02 10:10:49 +01002029requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002030requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002031run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002032 "$P_SRV debug_level=3 max_frag_len=4096" \
2033 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002034 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002035 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002036 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002037 -C "client hello, adding max_fragment_length extension" \
2038 -S "found max fragment length extension" \
2039 -S "server hello, max_fragment_length extension" \
2040 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002041
Yuto Takano0807e1d2021-07-02 10:10:49 +01002042requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002043requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002044requires_gnutls
2045run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002046 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002047 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002048 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002049 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002050 -c "client hello, adding max_fragment_length extension" \
2051 -c "found max_fragment_length extension"
2052
Yuto Takano0807e1d2021-07-02 10:10:49 +01002053requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002054requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002055run_test "Max fragment length: client, message just fits" \
2056 "$P_SRV debug_level=3" \
2057 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2058 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002059 -c "Maximum fragment length is 2048" \
2060 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002061 -c "client hello, adding max_fragment_length extension" \
2062 -s "found max fragment length extension" \
2063 -s "server hello, max_fragment_length extension" \
2064 -c "found max_fragment_length extension" \
2065 -c "2048 bytes written in 1 fragments" \
2066 -s "2048 bytes read"
2067
Yuto Takano0807e1d2021-07-02 10:10:49 +01002068requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002069requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002070run_test "Max fragment length: client, larger message" \
2071 "$P_SRV debug_level=3" \
2072 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2073 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002074 -c "Maximum fragment length is 2048" \
2075 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002076 -c "client hello, adding max_fragment_length extension" \
2077 -s "found max fragment length extension" \
2078 -s "server hello, max_fragment_length extension" \
2079 -c "found max_fragment_length extension" \
2080 -c "2345 bytes written in 2 fragments" \
2081 -s "2048 bytes read" \
2082 -s "297 bytes read"
2083
Yuto Takano0807e1d2021-07-02 10:10:49 +01002084requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002085requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002086run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002087 "$P_SRV debug_level=3 dtls=1" \
2088 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2089 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002090 -c "Maximum fragment length is 2048" \
2091 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002092 -c "client hello, adding max_fragment_length extension" \
2093 -s "found max fragment length extension" \
2094 -s "server hello, max_fragment_length extension" \
2095 -c "found max_fragment_length extension" \
2096 -c "fragment larger than.*maximum"
2097
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002098# Tests for renegotiation
2099
Hanno Becker6a243642017-10-12 15:18:45 +01002100# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002102 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002103 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002104 0 \
2105 -C "client hello, adding renegotiation extension" \
2106 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2107 -S "found renegotiation extension" \
2108 -s "server hello, secure renegotiation extension" \
2109 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002110 -C "=> renegotiate" \
2111 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002112 -S "write hello request"
2113
Hanno Becker6a243642017-10-12 15:18:45 +01002114requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002115run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002116 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002118 0 \
2119 -c "client hello, adding renegotiation extension" \
2120 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2121 -s "found renegotiation extension" \
2122 -s "server hello, secure renegotiation extension" \
2123 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002124 -c "=> renegotiate" \
2125 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002126 -S "write hello request"
2127
Hanno Becker6a243642017-10-12 15:18:45 +01002128requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002129run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002130 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002131 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002132 0 \
2133 -c "client hello, adding renegotiation extension" \
2134 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2135 -s "found renegotiation extension" \
2136 -s "server hello, secure renegotiation extension" \
2137 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002138 -c "=> renegotiate" \
2139 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002140 -s "write hello request"
2141
Janos Follathb0f148c2017-10-05 12:29:42 +01002142# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2143# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2144# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002145requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002146run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2147 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2148 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2149 0 \
2150 -c "client hello, adding renegotiation extension" \
2151 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2152 -s "found renegotiation extension" \
2153 -s "server hello, secure renegotiation extension" \
2154 -c "found renegotiation extension" \
2155 -c "=> renegotiate" \
2156 -s "=> renegotiate" \
2157 -S "write hello request" \
2158 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2159
2160# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2161# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2162# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002163requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002164run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2165 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2166 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2167 0 \
2168 -c "client hello, adding renegotiation extension" \
2169 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2170 -s "found renegotiation extension" \
2171 -s "server hello, secure renegotiation extension" \
2172 -c "found renegotiation extension" \
2173 -c "=> renegotiate" \
2174 -s "=> renegotiate" \
2175 -s "write hello request" \
2176 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2177
Hanno Becker6a243642017-10-12 15:18:45 +01002178requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002179run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002180 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002181 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002182 0 \
2183 -c "client hello, adding renegotiation extension" \
2184 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2185 -s "found renegotiation extension" \
2186 -s "server hello, secure renegotiation extension" \
2187 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002188 -c "=> renegotiate" \
2189 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002190 -s "write hello request"
2191
Hanno Becker6a243642017-10-12 15:18:45 +01002192requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002193run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002194 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002195 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002196 1 \
2197 -c "client hello, adding renegotiation extension" \
2198 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2199 -S "found renegotiation extension" \
2200 -s "server hello, secure renegotiation extension" \
2201 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002202 -c "=> renegotiate" \
2203 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002204 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002205 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002206 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002207
Hanno Becker6a243642017-10-12 15:18:45 +01002208requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002209run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002210 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002211 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002212 0 \
2213 -C "client hello, adding renegotiation extension" \
2214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2215 -S "found renegotiation extension" \
2216 -s "server hello, secure renegotiation extension" \
2217 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002218 -C "=> renegotiate" \
2219 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002220 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002221 -S "SSL - An unexpected message was received from our peer" \
2222 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002223
Hanno Becker6a243642017-10-12 15:18:45 +01002224requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002226 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002227 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002228 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002229 0 \
2230 -C "client hello, adding renegotiation extension" \
2231 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2232 -S "found renegotiation extension" \
2233 -s "server hello, secure renegotiation extension" \
2234 -c "found renegotiation extension" \
2235 -C "=> renegotiate" \
2236 -S "=> renegotiate" \
2237 -s "write hello request" \
2238 -S "SSL - An unexpected message was received from our peer" \
2239 -S "failed"
2240
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002241# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002242requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002244 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002245 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002246 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002247 0 \
2248 -C "client hello, adding renegotiation extension" \
2249 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2250 -S "found renegotiation extension" \
2251 -s "server hello, secure renegotiation extension" \
2252 -c "found renegotiation extension" \
2253 -C "=> renegotiate" \
2254 -S "=> renegotiate" \
2255 -s "write hello request" \
2256 -S "SSL - An unexpected message was received from our peer" \
2257 -S "failed"
2258
Hanno Becker6a243642017-10-12 15:18:45 +01002259requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002260run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002261 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002262 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002263 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002264 0 \
2265 -C "client hello, adding renegotiation extension" \
2266 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2267 -S "found renegotiation extension" \
2268 -s "server hello, secure renegotiation extension" \
2269 -c "found renegotiation extension" \
2270 -C "=> renegotiate" \
2271 -S "=> renegotiate" \
2272 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002273 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002274
Hanno Becker6a243642017-10-12 15:18:45 +01002275requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002276run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002277 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002278 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002279 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002280 0 \
2281 -c "client hello, adding renegotiation extension" \
2282 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2283 -s "found renegotiation extension" \
2284 -s "server hello, secure renegotiation extension" \
2285 -c "found renegotiation extension" \
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é-Gonnard590f4162014-11-05 14:23:03 +01002293run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002294 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002295 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2296 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 -S "record counter limit reached: renegotiate" \
2303 -C "=> renegotiate" \
2304 -S "=> renegotiate" \
2305 -S "write hello request" \
2306 -S "SSL - An unexpected message was received from our peer" \
2307 -S "failed"
2308
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002309# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002310requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002311run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002312 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002313 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002314 0 \
2315 -c "client hello, adding renegotiation extension" \
2316 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2317 -s "found renegotiation extension" \
2318 -s "server hello, secure renegotiation extension" \
2319 -c "found renegotiation extension" \
2320 -s "record counter limit reached: renegotiate" \
2321 -c "=> renegotiate" \
2322 -s "=> renegotiate" \
2323 -s "write hello request" \
2324 -S "SSL - An unexpected message was received from our peer" \
2325 -S "failed"
2326
Hanno Becker6a243642017-10-12 15:18:45 +01002327requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002328run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002329 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002330 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002331 0 \
2332 -c "client hello, adding renegotiation extension" \
2333 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2334 -s "found renegotiation extension" \
2335 -s "server hello, secure renegotiation extension" \
2336 -c "found renegotiation extension" \
2337 -s "record counter limit reached: renegotiate" \
2338 -c "=> renegotiate" \
2339 -s "=> renegotiate" \
2340 -s "write hello request" \
2341 -S "SSL - An unexpected message was received from our peer" \
2342 -S "failed"
2343
Hanno Becker6a243642017-10-12 15:18:45 +01002344requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002345run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002346 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002347 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2348 0 \
2349 -C "client hello, adding renegotiation extension" \
2350 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2351 -S "found renegotiation extension" \
2352 -s "server hello, secure renegotiation extension" \
2353 -c "found renegotiation extension" \
2354 -S "record counter limit reached: renegotiate" \
2355 -C "=> renegotiate" \
2356 -S "=> renegotiate" \
2357 -S "write hello request" \
2358 -S "SSL - An unexpected message was received from our peer" \
2359 -S "failed"
2360
Hanno Becker6a243642017-10-12 15:18:45 +01002361requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002362run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002363 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002364 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002365 0 \
2366 -c "client hello, adding renegotiation extension" \
2367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2368 -s "found renegotiation extension" \
2369 -s "server hello, secure renegotiation extension" \
2370 -c "found renegotiation extension" \
2371 -c "=> renegotiate" \
2372 -s "=> renegotiate" \
2373 -S "write hello request"
2374
Hanno Becker6a243642017-10-12 15:18:45 +01002375requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002376run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002377 "$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 +02002378 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002379 0 \
2380 -c "client hello, adding renegotiation extension" \
2381 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2382 -s "found renegotiation extension" \
2383 -s "server hello, secure renegotiation extension" \
2384 -c "found renegotiation extension" \
2385 -c "=> renegotiate" \
2386 -s "=> renegotiate" \
2387 -s "write hello request"
2388
Hanno Becker6a243642017-10-12 15:18:45 +01002389requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002390run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002391 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002392 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002393 0 \
2394 -c "client hello, adding renegotiation extension" \
2395 -c "found renegotiation extension" \
2396 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002397 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002398 -C "error" \
2399 -c "HTTP/1.0 200 [Oo][Kk]"
2400
Paul Bakker539d9722015-02-08 16:18:35 +01002401requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002402requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002403run_test "Renegotiation: gnutls server strict, client-initiated" \
2404 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002405 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002406 0 \
2407 -c "client hello, adding renegotiation extension" \
2408 -c "found renegotiation extension" \
2409 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002410 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002411 -C "error" \
2412 -c "HTTP/1.0 200 [Oo][Kk]"
2413
Paul Bakker539d9722015-02-08 16:18:35 +01002414requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002415requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002416run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2417 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2418 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2419 1 \
2420 -c "client hello, adding renegotiation extension" \
2421 -C "found renegotiation extension" \
2422 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002423 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002424 -c "error" \
2425 -C "HTTP/1.0 200 [Oo][Kk]"
2426
Paul Bakker539d9722015-02-08 16:18:35 +01002427requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002428requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002429run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2430 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2431 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2432 allow_legacy=0" \
2433 1 \
2434 -c "client hello, adding renegotiation extension" \
2435 -C "found renegotiation extension" \
2436 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002437 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002438 -c "error" \
2439 -C "HTTP/1.0 200 [Oo][Kk]"
2440
Paul Bakker539d9722015-02-08 16:18:35 +01002441requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002442requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002443run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2444 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2445 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2446 allow_legacy=1" \
2447 0 \
2448 -c "client hello, adding renegotiation extension" \
2449 -C "found renegotiation extension" \
2450 -c "=> renegotiate" \
2451 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002452 -C "error" \
2453 -c "HTTP/1.0 200 [Oo][Kk]"
2454
Hanno Becker6a243642017-10-12 15:18:45 +01002455requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002456run_test "Renegotiation: DTLS, client-initiated" \
2457 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2458 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2459 0 \
2460 -c "client hello, adding renegotiation extension" \
2461 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2462 -s "found renegotiation extension" \
2463 -s "server hello, secure renegotiation extension" \
2464 -c "found renegotiation extension" \
2465 -c "=> renegotiate" \
2466 -s "=> renegotiate" \
2467 -S "write hello request"
2468
Hanno Becker6a243642017-10-12 15:18:45 +01002469requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002470run_test "Renegotiation: DTLS, server-initiated" \
2471 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002472 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2473 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002474 0 \
2475 -c "client hello, adding renegotiation extension" \
2476 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2477 -s "found renegotiation extension" \
2478 -s "server hello, secure renegotiation extension" \
2479 -c "found renegotiation extension" \
2480 -c "=> renegotiate" \
2481 -s "=> renegotiate" \
2482 -s "write hello request"
2483
Hanno Becker6a243642017-10-12 15:18:45 +01002484requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002485run_test "Renegotiation: DTLS, renego_period overflow" \
2486 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2487 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2488 0 \
2489 -c "client hello, adding renegotiation extension" \
2490 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2491 -s "found renegotiation extension" \
2492 -s "server hello, secure renegotiation extension" \
2493 -s "record counter limit reached: renegotiate" \
2494 -c "=> renegotiate" \
2495 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002496 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002497
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002498requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002499requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002500run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2501 "$G_SRV -u --mtu 4096" \
2502 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2503 0 \
2504 -c "client hello, adding renegotiation extension" \
2505 -c "found renegotiation extension" \
2506 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002507 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002508 -C "error" \
2509 -s "Extra-header:"
2510
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002511# Test for the "secure renegotation" extension only (no actual renegotiation)
2512
Paul Bakker539d9722015-02-08 16:18:35 +01002513requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002514run_test "Renego ext: gnutls server strict, client default" \
2515 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2516 "$P_CLI debug_level=3" \
2517 0 \
2518 -c "found renegotiation extension" \
2519 -C "error" \
2520 -c "HTTP/1.0 200 [Oo][Kk]"
2521
Paul Bakker539d9722015-02-08 16:18:35 +01002522requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002523run_test "Renego ext: gnutls server unsafe, client default" \
2524 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2525 "$P_CLI debug_level=3" \
2526 0 \
2527 -C "found renegotiation extension" \
2528 -C "error" \
2529 -c "HTTP/1.0 200 [Oo][Kk]"
2530
Paul Bakker539d9722015-02-08 16:18:35 +01002531requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002532run_test "Renego ext: gnutls server unsafe, client break legacy" \
2533 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2534 "$P_CLI debug_level=3 allow_legacy=-1" \
2535 1 \
2536 -C "found renegotiation extension" \
2537 -c "error" \
2538 -C "HTTP/1.0 200 [Oo][Kk]"
2539
Paul Bakker539d9722015-02-08 16:18:35 +01002540requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002541run_test "Renego ext: gnutls client strict, server default" \
2542 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002543 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002544 0 \
2545 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2546 -s "server hello, secure renegotiation extension"
2547
Paul Bakker539d9722015-02-08 16:18:35 +01002548requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002549run_test "Renego ext: gnutls client unsafe, server default" \
2550 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002551 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002552 0 \
2553 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2554 -S "server hello, secure renegotiation extension"
2555
Paul Bakker539d9722015-02-08 16:18:35 +01002556requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002557run_test "Renego ext: gnutls client unsafe, server break legacy" \
2558 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002559 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002560 1 \
2561 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2562 -S "server hello, secure renegotiation extension"
2563
Janos Follath0b242342016-02-17 10:11:21 +00002564# Tests for silently dropping trailing extra bytes in .der certificates
2565
2566requires_gnutls
2567run_test "DER format: no trailing bytes" \
2568 "$P_SRV crt_file=data_files/server5-der0.crt \
2569 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002570 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002571 0 \
2572 -c "Handshake was completed" \
2573
2574requires_gnutls
2575run_test "DER format: with a trailing zero byte" \
2576 "$P_SRV crt_file=data_files/server5-der1a.crt \
2577 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002578 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002579 0 \
2580 -c "Handshake was completed" \
2581
2582requires_gnutls
2583run_test "DER format: with a trailing random byte" \
2584 "$P_SRV crt_file=data_files/server5-der1b.crt \
2585 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002586 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002587 0 \
2588 -c "Handshake was completed" \
2589
2590requires_gnutls
2591run_test "DER format: with 2 trailing random bytes" \
2592 "$P_SRV crt_file=data_files/server5-der2.crt \
2593 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002594 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002595 0 \
2596 -c "Handshake was completed" \
2597
2598requires_gnutls
2599run_test "DER format: with 4 trailing random bytes" \
2600 "$P_SRV crt_file=data_files/server5-der4.crt \
2601 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002602 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002603 0 \
2604 -c "Handshake was completed" \
2605
2606requires_gnutls
2607run_test "DER format: with 8 trailing random bytes" \
2608 "$P_SRV crt_file=data_files/server5-der8.crt \
2609 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002610 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002611 0 \
2612 -c "Handshake was completed" \
2613
2614requires_gnutls
2615run_test "DER format: with 9 trailing random bytes" \
2616 "$P_SRV crt_file=data_files/server5-der9.crt \
2617 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002618 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002619 0 \
2620 -c "Handshake was completed" \
2621
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002622# Tests for auth_mode
2623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002624run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002625 "$P_SRV crt_file=data_files/server5-badsign.crt \
2626 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002627 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002628 1 \
2629 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002630 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002631 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002632 -c "X509 - Certificate verification failed"
2633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002634run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002635 "$P_SRV crt_file=data_files/server5-badsign.crt \
2636 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002637 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002638 0 \
2639 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002640 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002641 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002642 -C "X509 - Certificate verification failed"
2643
Hanno Beckere6706e62017-05-15 16:05:15 +01002644run_test "Authentication: server goodcert, client optional, no trusted CA" \
2645 "$P_SRV" \
2646 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2647 0 \
2648 -c "x509_verify_cert() returned" \
2649 -c "! The certificate is not correctly signed by the trusted CA" \
2650 -c "! Certificate verification flags"\
2651 -C "! mbedtls_ssl_handshake returned" \
2652 -C "X509 - Certificate verification failed" \
2653 -C "SSL - No CA Chain is set, but required to operate"
2654
2655run_test "Authentication: server goodcert, client required, no trusted CA" \
2656 "$P_SRV" \
2657 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2658 1 \
2659 -c "x509_verify_cert() returned" \
2660 -c "! The certificate is not correctly signed by the trusted CA" \
2661 -c "! Certificate verification flags"\
2662 -c "! mbedtls_ssl_handshake returned" \
2663 -c "SSL - No CA Chain is set, but required to operate"
2664
2665# The purpose of the next two tests is to test the client's behaviour when receiving a server
2666# certificate with an unsupported elliptic curve. This should usually not happen because
2667# the client informs the server about the supported curves - it does, though, in the
2668# corner case of a static ECDH suite, because the server doesn't check the curve on that
2669# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2670# different means to have the server ignoring the client's supported curve list.
2671
2672requires_config_enabled MBEDTLS_ECP_C
2673run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2674 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2675 crt_file=data_files/server5.ku-ka.crt" \
2676 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2677 1 \
2678 -c "bad certificate (EC key curve)"\
2679 -c "! Certificate verification flags"\
2680 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2681
2682requires_config_enabled MBEDTLS_ECP_C
2683run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2684 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2685 crt_file=data_files/server5.ku-ka.crt" \
2686 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2687 1 \
2688 -c "bad certificate (EC key curve)"\
2689 -c "! Certificate verification flags"\
2690 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002693 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002694 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002695 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002696 0 \
2697 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002698 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002699 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002700 -C "X509 - Certificate verification failed"
2701
Simon Butcher99000142016-10-13 17:21:01 +01002702run_test "Authentication: client SHA256, server required" \
2703 "$P_SRV auth_mode=required" \
2704 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2705 key_file=data_files/server6.key \
2706 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2707 0 \
2708 -c "Supported Signature Algorithm found: 4," \
2709 -c "Supported Signature Algorithm found: 5,"
2710
2711run_test "Authentication: client SHA384, server required" \
2712 "$P_SRV auth_mode=required" \
2713 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2714 key_file=data_files/server6.key \
2715 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2716 0 \
2717 -c "Supported Signature Algorithm found: 4," \
2718 -c "Supported Signature Algorithm found: 5,"
2719
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002720requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2721run_test "Authentication: client has no cert, server required (SSLv3)" \
2722 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2723 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2724 key_file=data_files/server5.key" \
2725 1 \
2726 -S "skip write certificate request" \
2727 -C "skip parse certificate request" \
2728 -c "got a certificate request" \
2729 -c "got no certificate to send" \
2730 -S "x509_verify_cert() returned" \
2731 -s "client has no certificate" \
2732 -s "! mbedtls_ssl_handshake returned" \
2733 -c "! mbedtls_ssl_handshake returned" \
2734 -s "No client certification received from the client, but required by the authentication mode"
2735
2736run_test "Authentication: client has no cert, server required (TLS)" \
2737 "$P_SRV debug_level=3 auth_mode=required" \
2738 "$P_CLI debug_level=3 crt_file=none \
2739 key_file=data_files/server5.key" \
2740 1 \
2741 -S "skip write certificate request" \
2742 -C "skip parse certificate request" \
2743 -c "got a certificate request" \
2744 -c "= write certificate$" \
2745 -C "skip write certificate$" \
2746 -S "x509_verify_cert() returned" \
2747 -s "client has no certificate" \
2748 -s "! mbedtls_ssl_handshake returned" \
2749 -c "! mbedtls_ssl_handshake returned" \
2750 -s "No client certification received from the client, but required by the authentication mode"
2751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002752run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002753 "$P_SRV debug_level=3 auth_mode=required" \
2754 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002755 key_file=data_files/server5.key" \
2756 1 \
2757 -S "skip write certificate request" \
2758 -C "skip parse certificate request" \
2759 -c "got a certificate request" \
2760 -C "skip write certificate" \
2761 -C "skip write certificate verify" \
2762 -S "skip parse certificate verify" \
2763 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002764 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002765 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002766 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002767 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002768 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002769# We don't check that the client receives the alert because it might
2770# detect that its write end of the connection is closed and abort
2771# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002772
Janos Follath89baba22017-04-10 14:34:35 +01002773run_test "Authentication: client cert not trusted, server required" \
2774 "$P_SRV debug_level=3 auth_mode=required" \
2775 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2776 key_file=data_files/server5.key" \
2777 1 \
2778 -S "skip write certificate request" \
2779 -C "skip parse certificate request" \
2780 -c "got a certificate request" \
2781 -C "skip write certificate" \
2782 -C "skip write certificate verify" \
2783 -S "skip parse certificate verify" \
2784 -s "x509_verify_cert() returned" \
2785 -s "! The certificate is not correctly signed by the trusted CA" \
2786 -s "! mbedtls_ssl_handshake returned" \
2787 -c "! mbedtls_ssl_handshake returned" \
2788 -s "X509 - Certificate verification failed"
2789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002790run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002791 "$P_SRV debug_level=3 auth_mode=optional" \
2792 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002793 key_file=data_files/server5.key" \
2794 0 \
2795 -S "skip write certificate request" \
2796 -C "skip parse certificate request" \
2797 -c "got a certificate request" \
2798 -C "skip write certificate" \
2799 -C "skip write certificate verify" \
2800 -S "skip parse certificate verify" \
2801 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002802 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002803 -S "! mbedtls_ssl_handshake returned" \
2804 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002805 -S "X509 - Certificate verification failed"
2806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002807run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002808 "$P_SRV debug_level=3 auth_mode=none" \
2809 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002810 key_file=data_files/server5.key" \
2811 0 \
2812 -s "skip write certificate request" \
2813 -C "skip parse certificate request" \
2814 -c "got no certificate request" \
2815 -c "skip write certificate" \
2816 -c "skip write certificate verify" \
2817 -s "skip parse certificate verify" \
2818 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002819 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002820 -S "! mbedtls_ssl_handshake returned" \
2821 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002822 -S "X509 - Certificate verification failed"
2823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002824run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002825 "$P_SRV debug_level=3 auth_mode=optional" \
2826 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002827 0 \
2828 -S "skip write certificate request" \
2829 -C "skip parse certificate request" \
2830 -c "got a certificate request" \
2831 -C "skip write certificate$" \
2832 -C "got no certificate to send" \
2833 -S "SSLv3 client has no certificate" \
2834 -c "skip write certificate verify" \
2835 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002836 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002837 -S "! mbedtls_ssl_handshake returned" \
2838 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002839 -S "X509 - Certificate verification failed"
2840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002841run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002842 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002843 "$O_CLI" \
2844 0 \
2845 -S "skip write certificate request" \
2846 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002847 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002848 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002849 -S "X509 - Certificate verification failed"
2850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002851run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002852 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002853 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002854 0 \
2855 -C "skip parse certificate request" \
2856 -c "got a certificate request" \
2857 -C "skip write certificate$" \
2858 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002859 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002860
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002861run_test "Authentication: client no cert, openssl server required" \
2862 "$O_SRV -Verify 10" \
2863 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2864 1 \
2865 -C "skip parse certificate request" \
2866 -c "got a certificate request" \
2867 -C "skip write certificate$" \
2868 -c "skip write certificate verify" \
2869 -c "! mbedtls_ssl_handshake returned"
2870
Janos Follathe2681a42016-03-07 15:57:05 +00002871requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002873 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002874 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002875 0 \
2876 -S "skip write certificate request" \
2877 -C "skip parse certificate request" \
2878 -c "got a certificate request" \
2879 -C "skip write certificate$" \
2880 -c "skip write certificate verify" \
2881 -c "got no certificate to send" \
2882 -s "SSLv3 client has no certificate" \
2883 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002884 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002885 -S "! mbedtls_ssl_handshake returned" \
2886 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002887 -S "X509 - Certificate verification failed"
2888
Yuto Takano8df2d252021-07-02 13:05:15 +01002889# This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default
2890# value, defined here as MAX_IM_CA. Some test cases will be skipped if the
2891# library is configured with a different value.
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002892
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002893MAX_IM_CA='8'
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002894
Yuto Takano8df2d252021-07-02 13:05:15 +01002895# The tests for the max_int tests can pass with any number higher than MAX_IM_CA
2896# because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1
2897# tests can pass with any number less than MAX_IM_CA. However, stricter preconditions
2898# are in place so that the semantics are consistent with the test description.
Yuto Takanobc632c22021-07-02 13:10:41 +01002899requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002900requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002901run_test "Authentication: server max_int chain, client default" \
2902 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2903 key_file=data_files/dir-maxpath/09.key" \
2904 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2905 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002906 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002907
Yuto Takanobc632c22021-07-02 13:10:41 +01002908requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002909requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002910run_test "Authentication: server max_int+1 chain, client default" \
2911 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2912 key_file=data_files/dir-maxpath/10.key" \
2913 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2914 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002915 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002916
Yuto Takanobc632c22021-07-02 13:10:41 +01002917requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002918requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002919run_test "Authentication: server max_int+1 chain, client optional" \
2920 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2921 key_file=data_files/dir-maxpath/10.key" \
2922 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2923 auth_mode=optional" \
2924 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002925 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002926
Yuto Takanobc632c22021-07-02 13:10:41 +01002927requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002928requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002929run_test "Authentication: server max_int+1 chain, client none" \
2930 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2931 key_file=data_files/dir-maxpath/10.key" \
2932 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2933 auth_mode=none" \
2934 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002935 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002936
Yuto Takanobc632c22021-07-02 13:10:41 +01002937requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002938requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002939run_test "Authentication: client max_int+1 chain, server default" \
2940 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2941 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2942 key_file=data_files/dir-maxpath/10.key" \
2943 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002944 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002945
Yuto Takanobc632c22021-07-02 13:10:41 +01002946requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002947requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002948run_test "Authentication: client max_int+1 chain, server optional" \
2949 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2950 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2951 key_file=data_files/dir-maxpath/10.key" \
2952 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002953 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002954
Yuto Takanobc632c22021-07-02 13:10:41 +01002955requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002956requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002957run_test "Authentication: client max_int+1 chain, server required" \
2958 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2959 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2960 key_file=data_files/dir-maxpath/10.key" \
2961 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002962 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002963
Yuto Takanobc632c22021-07-02 13:10:41 +01002964requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002965requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002966run_test "Authentication: client max_int chain, server required" \
2967 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2968 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2969 key_file=data_files/dir-maxpath/09.key" \
2970 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002971 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002972
Janos Follath89baba22017-04-10 14:34:35 +01002973# Tests for CA list in CertificateRequest messages
2974
2975run_test "Authentication: send CA list in CertificateRequest (default)" \
2976 "$P_SRV debug_level=3 auth_mode=required" \
2977 "$P_CLI crt_file=data_files/server6.crt \
2978 key_file=data_files/server6.key" \
2979 0 \
2980 -s "requested DN"
2981
2982run_test "Authentication: do not send CA list in CertificateRequest" \
2983 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2984 "$P_CLI crt_file=data_files/server6.crt \
2985 key_file=data_files/server6.key" \
2986 0 \
2987 -S "requested DN"
2988
2989run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2990 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2991 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2992 key_file=data_files/server5.key" \
2993 1 \
2994 -S "requested DN" \
2995 -s "x509_verify_cert() returned" \
2996 -s "! The certificate is not correctly signed by the trusted CA" \
2997 -s "! mbedtls_ssl_handshake returned" \
2998 -c "! mbedtls_ssl_handshake returned" \
2999 -s "X509 - Certificate verification failed"
3000
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01003001# Tests for certificate selection based on SHA verson
3002
3003run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3004 "$P_SRV crt_file=data_files/server5.crt \
3005 key_file=data_files/server5.key \
3006 crt_file2=data_files/server5-sha1.crt \
3007 key_file2=data_files/server5.key" \
3008 "$P_CLI force_version=tls1_2" \
3009 0 \
3010 -c "signed using.*ECDSA with SHA256" \
3011 -C "signed using.*ECDSA with SHA1"
3012
3013run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3014 "$P_SRV crt_file=data_files/server5.crt \
3015 key_file=data_files/server5.key \
3016 crt_file2=data_files/server5-sha1.crt \
3017 key_file2=data_files/server5.key" \
3018 "$P_CLI force_version=tls1_1" \
3019 0 \
3020 -C "signed using.*ECDSA with SHA256" \
3021 -c "signed using.*ECDSA with SHA1"
3022
3023run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3024 "$P_SRV crt_file=data_files/server5.crt \
3025 key_file=data_files/server5.key \
3026 crt_file2=data_files/server5-sha1.crt \
3027 key_file2=data_files/server5.key" \
3028 "$P_CLI force_version=tls1" \
3029 0 \
3030 -C "signed using.*ECDSA with SHA256" \
3031 -c "signed using.*ECDSA with SHA1"
3032
3033run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3034 "$P_SRV crt_file=data_files/server5.crt \
3035 key_file=data_files/server5.key \
3036 crt_file2=data_files/server6.crt \
3037 key_file2=data_files/server6.key" \
3038 "$P_CLI force_version=tls1_1" \
3039 0 \
3040 -c "serial number.*09" \
3041 -c "signed using.*ECDSA with SHA256" \
3042 -C "signed using.*ECDSA with SHA1"
3043
3044run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3045 "$P_SRV crt_file=data_files/server6.crt \
3046 key_file=data_files/server6.key \
3047 crt_file2=data_files/server5.crt \
3048 key_file2=data_files/server5.key" \
3049 "$P_CLI force_version=tls1_1" \
3050 0 \
3051 -c "serial number.*0A" \
3052 -c "signed using.*ECDSA with SHA256" \
3053 -C "signed using.*ECDSA with SHA1"
3054
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003055# tests for SNI
3056
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003057run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003058 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003059 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003060 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003061 0 \
3062 -S "parse ServerName extension" \
3063 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3064 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003065
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003066run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003067 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003068 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003069 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 +02003070 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003071 0 \
3072 -s "parse ServerName extension" \
3073 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3074 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003075
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003076run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003077 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003078 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003079 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 +02003080 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003081 0 \
3082 -s "parse ServerName extension" \
3083 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3084 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003086run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003087 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003088 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003089 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 +02003090 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003091 1 \
3092 -s "parse ServerName extension" \
3093 -s "ssl_sni_wrapper() returned" \
3094 -s "mbedtls_ssl_handshake returned" \
3095 -c "mbedtls_ssl_handshake returned" \
3096 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003097
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003098run_test "SNI: client auth no override: optional" \
3099 "$P_SRV debug_level=3 auth_mode=optional \
3100 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3101 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3102 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003103 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003104 -S "skip write certificate request" \
3105 -C "skip parse certificate request" \
3106 -c "got a certificate request" \
3107 -C "skip write certificate" \
3108 -C "skip write certificate verify" \
3109 -S "skip parse certificate verify"
3110
3111run_test "SNI: client auth override: none -> optional" \
3112 "$P_SRV debug_level=3 auth_mode=none \
3113 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3114 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3115 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003116 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003117 -S "skip write certificate request" \
3118 -C "skip parse certificate request" \
3119 -c "got a certificate request" \
3120 -C "skip write certificate" \
3121 -C "skip write certificate verify" \
3122 -S "skip parse certificate verify"
3123
3124run_test "SNI: client auth override: optional -> none" \
3125 "$P_SRV debug_level=3 auth_mode=optional \
3126 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3127 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3128 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003129 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003130 -s "skip write certificate request" \
3131 -C "skip parse certificate request" \
3132 -c "got no certificate request" \
3133 -c "skip write certificate" \
3134 -c "skip write certificate verify" \
3135 -s "skip parse certificate verify"
3136
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003137run_test "SNI: CA no override" \
3138 "$P_SRV debug_level=3 auth_mode=optional \
3139 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3140 ca_file=data_files/test-ca.crt \
3141 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3142 "$P_CLI debug_level=3 server_name=localhost \
3143 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3144 1 \
3145 -S "skip write certificate request" \
3146 -C "skip parse certificate request" \
3147 -c "got a certificate request" \
3148 -C "skip write certificate" \
3149 -C "skip write certificate verify" \
3150 -S "skip parse certificate verify" \
3151 -s "x509_verify_cert() returned" \
3152 -s "! The certificate is not correctly signed by the trusted CA" \
3153 -S "The certificate has been revoked (is on a CRL)"
3154
3155run_test "SNI: CA override" \
3156 "$P_SRV debug_level=3 auth_mode=optional \
3157 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3158 ca_file=data_files/test-ca.crt \
3159 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3160 "$P_CLI debug_level=3 server_name=localhost \
3161 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3162 0 \
3163 -S "skip write certificate request" \
3164 -C "skip parse certificate request" \
3165 -c "got a certificate request" \
3166 -C "skip write certificate" \
3167 -C "skip write certificate verify" \
3168 -S "skip parse certificate verify" \
3169 -S "x509_verify_cert() returned" \
3170 -S "! The certificate is not correctly signed by the trusted CA" \
3171 -S "The certificate has been revoked (is on a CRL)"
3172
3173run_test "SNI: CA override with CRL" \
3174 "$P_SRV debug_level=3 auth_mode=optional \
3175 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3176 ca_file=data_files/test-ca.crt \
3177 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3178 "$P_CLI debug_level=3 server_name=localhost \
3179 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3180 1 \
3181 -S "skip write certificate request" \
3182 -C "skip parse certificate request" \
3183 -c "got a certificate request" \
3184 -C "skip write certificate" \
3185 -C "skip write certificate verify" \
3186 -S "skip parse certificate verify" \
3187 -s "x509_verify_cert() returned" \
3188 -S "! The certificate is not correctly signed by the trusted CA" \
3189 -s "The certificate has been revoked (is on a CRL)"
3190
Andres AG1a834452016-12-07 10:01:30 +00003191# Tests for SNI and DTLS
3192
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003193run_test "SNI: DTLS, no SNI callback" \
3194 "$P_SRV debug_level=3 dtls=1 \
3195 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3196 "$P_CLI server_name=localhost dtls=1" \
3197 0 \
3198 -S "parse ServerName extension" \
3199 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3200 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3201
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003202run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003203 "$P_SRV debug_level=3 dtls=1 \
3204 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3205 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3206 "$P_CLI server_name=localhost dtls=1" \
3207 0 \
3208 -s "parse ServerName extension" \
3209 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3210 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3211
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003212run_test "SNI: DTLS, matching cert 2" \
3213 "$P_SRV debug_level=3 dtls=1 \
3214 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3215 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3216 "$P_CLI server_name=polarssl.example dtls=1" \
3217 0 \
3218 -s "parse ServerName extension" \
3219 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3220 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3221
3222run_test "SNI: DTLS, no matching cert" \
3223 "$P_SRV debug_level=3 dtls=1 \
3224 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3225 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3226 "$P_CLI server_name=nonesuch.example dtls=1" \
3227 1 \
3228 -s "parse ServerName extension" \
3229 -s "ssl_sni_wrapper() returned" \
3230 -s "mbedtls_ssl_handshake returned" \
3231 -c "mbedtls_ssl_handshake returned" \
3232 -c "SSL - A fatal alert message was received from our peer"
3233
3234run_test "SNI: DTLS, client auth no override: optional" \
3235 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3236 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3237 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3238 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3239 0 \
3240 -S "skip write certificate request" \
3241 -C "skip parse certificate request" \
3242 -c "got a certificate request" \
3243 -C "skip write certificate" \
3244 -C "skip write certificate verify" \
3245 -S "skip parse certificate verify"
3246
3247run_test "SNI: DTLS, client auth override: none -> optional" \
3248 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3249 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3250 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3251 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3252 0 \
3253 -S "skip write certificate request" \
3254 -C "skip parse certificate request" \
3255 -c "got a certificate request" \
3256 -C "skip write certificate" \
3257 -C "skip write certificate verify" \
3258 -S "skip parse certificate verify"
3259
3260run_test "SNI: DTLS, client auth override: optional -> none" \
3261 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3262 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3263 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3264 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3265 0 \
3266 -s "skip write certificate request" \
3267 -C "skip parse certificate request" \
3268 -c "got no certificate request" \
3269 -c "skip write certificate" \
3270 -c "skip write certificate verify" \
3271 -s "skip parse certificate verify"
3272
3273run_test "SNI: DTLS, CA no override" \
3274 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3275 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3276 ca_file=data_files/test-ca.crt \
3277 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3278 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3279 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3280 1 \
3281 -S "skip write certificate request" \
3282 -C "skip parse certificate request" \
3283 -c "got a certificate request" \
3284 -C "skip write certificate" \
3285 -C "skip write certificate verify" \
3286 -S "skip parse certificate verify" \
3287 -s "x509_verify_cert() returned" \
3288 -s "! The certificate is not correctly signed by the trusted CA" \
3289 -S "The certificate has been revoked (is on a CRL)"
3290
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003291run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003292 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3293 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3294 ca_file=data_files/test-ca.crt \
3295 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3296 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3297 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3298 0 \
3299 -S "skip write certificate request" \
3300 -C "skip parse certificate request" \
3301 -c "got a certificate request" \
3302 -C "skip write certificate" \
3303 -C "skip write certificate verify" \
3304 -S "skip parse certificate verify" \
3305 -S "x509_verify_cert() returned" \
3306 -S "! The certificate is not correctly signed by the trusted CA" \
3307 -S "The certificate has been revoked (is on a CRL)"
3308
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003309run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003310 "$P_SRV debug_level=3 auth_mode=optional \
3311 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3312 ca_file=data_files/test-ca.crt \
3313 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3314 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3315 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3316 1 \
3317 -S "skip write certificate request" \
3318 -C "skip parse certificate request" \
3319 -c "got a certificate request" \
3320 -C "skip write certificate" \
3321 -C "skip write certificate verify" \
3322 -S "skip parse certificate verify" \
3323 -s "x509_verify_cert() returned" \
3324 -S "! The certificate is not correctly signed by the trusted CA" \
3325 -s "The certificate has been revoked (is on a CRL)"
3326
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003327# Tests for non-blocking I/O: exercise a variety of handshake flows
3328
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003329run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003330 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3331 "$P_CLI nbio=2 tickets=0" \
3332 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003333 -S "mbedtls_ssl_handshake returned" \
3334 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003335 -c "Read from server: .* bytes read"
3336
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003337run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003338 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3339 "$P_CLI nbio=2 tickets=0" \
3340 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003341 -S "mbedtls_ssl_handshake returned" \
3342 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003343 -c "Read from server: .* bytes read"
3344
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003345run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003346 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3347 "$P_CLI nbio=2 tickets=1" \
3348 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003349 -S "mbedtls_ssl_handshake returned" \
3350 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003351 -c "Read from server: .* bytes read"
3352
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003353run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003354 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3355 "$P_CLI nbio=2 tickets=1" \
3356 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003357 -S "mbedtls_ssl_handshake returned" \
3358 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003359 -c "Read from server: .* bytes read"
3360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003361run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003362 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3363 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3364 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003365 -S "mbedtls_ssl_handshake returned" \
3366 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003367 -c "Read from server: .* bytes read"
3368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003369run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003370 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3371 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3372 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003373 -S "mbedtls_ssl_handshake returned" \
3374 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003375 -c "Read from server: .* bytes read"
3376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003377run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003378 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3379 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3380 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003381 -S "mbedtls_ssl_handshake returned" \
3382 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003383 -c "Read from server: .* bytes read"
3384
Hanno Becker00076712017-11-15 16:39:08 +00003385# Tests for event-driven I/O: exercise a variety of handshake flows
3386
3387run_test "Event-driven I/O: basic handshake" \
3388 "$P_SRV event=1 tickets=0 auth_mode=none" \
3389 "$P_CLI event=1 tickets=0" \
3390 0 \
3391 -S "mbedtls_ssl_handshake returned" \
3392 -C "mbedtls_ssl_handshake returned" \
3393 -c "Read from server: .* bytes read"
3394
3395run_test "Event-driven I/O: client auth" \
3396 "$P_SRV event=1 tickets=0 auth_mode=required" \
3397 "$P_CLI event=1 tickets=0" \
3398 0 \
3399 -S "mbedtls_ssl_handshake returned" \
3400 -C "mbedtls_ssl_handshake returned" \
3401 -c "Read from server: .* bytes read"
3402
3403run_test "Event-driven I/O: ticket" \
3404 "$P_SRV event=1 tickets=1 auth_mode=none" \
3405 "$P_CLI event=1 tickets=1" \
3406 0 \
3407 -S "mbedtls_ssl_handshake returned" \
3408 -C "mbedtls_ssl_handshake returned" \
3409 -c "Read from server: .* bytes read"
3410
3411run_test "Event-driven I/O: ticket + client auth" \
3412 "$P_SRV event=1 tickets=1 auth_mode=required" \
3413 "$P_CLI event=1 tickets=1" \
3414 0 \
3415 -S "mbedtls_ssl_handshake returned" \
3416 -C "mbedtls_ssl_handshake returned" \
3417 -c "Read from server: .* bytes read"
3418
3419run_test "Event-driven I/O: ticket + client auth + resume" \
3420 "$P_SRV event=1 tickets=1 auth_mode=required" \
3421 "$P_CLI event=1 tickets=1 reconnect=1" \
3422 0 \
3423 -S "mbedtls_ssl_handshake returned" \
3424 -C "mbedtls_ssl_handshake returned" \
3425 -c "Read from server: .* bytes read"
3426
3427run_test "Event-driven I/O: ticket + resume" \
3428 "$P_SRV event=1 tickets=1 auth_mode=none" \
3429 "$P_CLI event=1 tickets=1 reconnect=1" \
3430 0 \
3431 -S "mbedtls_ssl_handshake returned" \
3432 -C "mbedtls_ssl_handshake returned" \
3433 -c "Read from server: .* bytes read"
3434
3435run_test "Event-driven I/O: session-id resume" \
3436 "$P_SRV event=1 tickets=0 auth_mode=none" \
3437 "$P_CLI event=1 tickets=0 reconnect=1" \
3438 0 \
3439 -S "mbedtls_ssl_handshake returned" \
3440 -C "mbedtls_ssl_handshake returned" \
3441 -c "Read from server: .* bytes read"
3442
Hanno Becker6a33f592018-03-13 11:38:46 +00003443run_test "Event-driven I/O, DTLS: basic handshake" \
3444 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3445 "$P_CLI dtls=1 event=1 tickets=0" \
3446 0 \
3447 -c "Read from server: .* bytes read"
3448
3449run_test "Event-driven I/O, DTLS: client auth" \
3450 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3451 "$P_CLI dtls=1 event=1 tickets=0" \
3452 0 \
3453 -c "Read from server: .* bytes read"
3454
3455run_test "Event-driven I/O, DTLS: ticket" \
3456 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3457 "$P_CLI dtls=1 event=1 tickets=1" \
3458 0 \
3459 -c "Read from server: .* bytes read"
3460
3461run_test "Event-driven I/O, DTLS: ticket + client auth" \
3462 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3463 "$P_CLI dtls=1 event=1 tickets=1" \
3464 0 \
3465 -c "Read from server: .* bytes read"
3466
3467run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3468 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003469 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003470 0 \
3471 -c "Read from server: .* bytes read"
3472
3473run_test "Event-driven I/O, DTLS: ticket + resume" \
3474 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003475 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003476 0 \
3477 -c "Read from server: .* bytes read"
3478
3479run_test "Event-driven I/O, DTLS: session-id resume" \
3480 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003481 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003482 0 \
3483 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003484
3485# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3486# During session resumption, the client will send its ApplicationData record
3487# within the same datagram as the Finished messages. In this situation, the
3488# server MUST NOT idle on the underlying transport after handshake completion,
3489# because the ApplicationData request has already been queued internally.
3490run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003491 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003492 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003493 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003494 0 \
3495 -c "Read from server: .* bytes read"
3496
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003497# Tests for version negotiation
3498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003499run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003500 "$P_SRV" \
3501 "$P_CLI" \
3502 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003503 -S "mbedtls_ssl_handshake returned" \
3504 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003505 -s "Protocol is TLSv1.2" \
3506 -c "Protocol is TLSv1.2"
3507
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003508run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003509 "$P_SRV" \
3510 "$P_CLI max_version=tls1_1" \
3511 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003512 -S "mbedtls_ssl_handshake returned" \
3513 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003514 -s "Protocol is TLSv1.1" \
3515 -c "Protocol is TLSv1.1"
3516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003517run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003518 "$P_SRV max_version=tls1_1" \
3519 "$P_CLI" \
3520 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003521 -S "mbedtls_ssl_handshake returned" \
3522 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003523 -s "Protocol is TLSv1.1" \
3524 -c "Protocol is TLSv1.1"
3525
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003526run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003527 "$P_SRV max_version=tls1_1" \
3528 "$P_CLI max_version=tls1_1" \
3529 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003530 -S "mbedtls_ssl_handshake returned" \
3531 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003532 -s "Protocol is TLSv1.1" \
3533 -c "Protocol is TLSv1.1"
3534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003535run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003536 "$P_SRV min_version=tls1_1" \
3537 "$P_CLI max_version=tls1_1" \
3538 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003539 -S "mbedtls_ssl_handshake returned" \
3540 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003541 -s "Protocol is TLSv1.1" \
3542 -c "Protocol is TLSv1.1"
3543
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003544run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003545 "$P_SRV max_version=tls1_1" \
3546 "$P_CLI min_version=tls1_1" \
3547 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003548 -S "mbedtls_ssl_handshake returned" \
3549 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003550 -s "Protocol is TLSv1.1" \
3551 -c "Protocol is TLSv1.1"
3552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003553run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003554 "$P_SRV max_version=tls1_1" \
3555 "$P_CLI min_version=tls1_2" \
3556 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003557 -s "mbedtls_ssl_handshake returned" \
3558 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003559 -c "SSL - Handshake protocol not within min/max boundaries"
3560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003561run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003562 "$P_SRV min_version=tls1_2" \
3563 "$P_CLI max_version=tls1_1" \
3564 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003565 -s "mbedtls_ssl_handshake returned" \
3566 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003567 -s "SSL - Handshake protocol not within min/max boundaries"
3568
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003569# Tests for ALPN extension
3570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003571run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003572 "$P_SRV debug_level=3" \
3573 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003574 0 \
3575 -C "client hello, adding alpn extension" \
3576 -S "found alpn extension" \
3577 -C "got an alert message, type: \\[2:120]" \
3578 -S "server hello, adding alpn extension" \
3579 -C "found alpn extension " \
3580 -C "Application Layer Protocol is" \
3581 -S "Application Layer Protocol is"
3582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003583run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003584 "$P_SRV debug_level=3" \
3585 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003586 0 \
3587 -c "client hello, adding alpn extension" \
3588 -s "found alpn extension" \
3589 -C "got an alert message, type: \\[2:120]" \
3590 -S "server hello, adding alpn extension" \
3591 -C "found alpn extension " \
3592 -c "Application Layer Protocol is (none)" \
3593 -S "Application Layer Protocol is"
3594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003595run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003596 "$P_SRV debug_level=3 alpn=abc,1234" \
3597 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003598 0 \
3599 -C "client hello, adding alpn extension" \
3600 -S "found alpn extension" \
3601 -C "got an alert message, type: \\[2:120]" \
3602 -S "server hello, adding alpn extension" \
3603 -C "found alpn extension " \
3604 -C "Application Layer Protocol is" \
3605 -s "Application Layer Protocol is (none)"
3606
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003607run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003608 "$P_SRV debug_level=3 alpn=abc,1234" \
3609 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003610 0 \
3611 -c "client hello, adding alpn extension" \
3612 -s "found alpn extension" \
3613 -C "got an alert message, type: \\[2:120]" \
3614 -s "server hello, adding alpn extension" \
3615 -c "found alpn extension" \
3616 -c "Application Layer Protocol is abc" \
3617 -s "Application Layer Protocol is abc"
3618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003619run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003620 "$P_SRV debug_level=3 alpn=abc,1234" \
3621 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003622 0 \
3623 -c "client hello, adding alpn extension" \
3624 -s "found alpn extension" \
3625 -C "got an alert message, type: \\[2:120]" \
3626 -s "server hello, adding alpn extension" \
3627 -c "found alpn extension" \
3628 -c "Application Layer Protocol is abc" \
3629 -s "Application Layer Protocol is abc"
3630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003631run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003632 "$P_SRV debug_level=3 alpn=abc,1234" \
3633 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003634 0 \
3635 -c "client hello, adding alpn extension" \
3636 -s "found alpn extension" \
3637 -C "got an alert message, type: \\[2:120]" \
3638 -s "server hello, adding alpn extension" \
3639 -c "found alpn extension" \
3640 -c "Application Layer Protocol is 1234" \
3641 -s "Application Layer Protocol is 1234"
3642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003643run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003644 "$P_SRV debug_level=3 alpn=abc,123" \
3645 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003646 1 \
3647 -c "client hello, adding alpn extension" \
3648 -s "found alpn extension" \
3649 -c "got an alert message, type: \\[2:120]" \
3650 -S "server hello, adding alpn extension" \
3651 -C "found alpn extension" \
3652 -C "Application Layer Protocol is 1234" \
3653 -S "Application Layer Protocol is 1234"
3654
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003655
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003656# Tests for keyUsage in leaf certificates, part 1:
3657# server-side certificate/suite selection
3658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003659run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003660 "$P_SRV key_file=data_files/server2.key \
3661 crt_file=data_files/server2.ku-ds.crt" \
3662 "$P_CLI" \
3663 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003664 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003665
3666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003667run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003668 "$P_SRV key_file=data_files/server2.key \
3669 crt_file=data_files/server2.ku-ke.crt" \
3670 "$P_CLI" \
3671 0 \
3672 -c "Ciphersuite is TLS-RSA-WITH-"
3673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003674run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003675 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003676 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003677 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003678 1 \
3679 -C "Ciphersuite is "
3680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003681run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003682 "$P_SRV key_file=data_files/server5.key \
3683 crt_file=data_files/server5.ku-ds.crt" \
3684 "$P_CLI" \
3685 0 \
3686 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3687
3688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003689run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003690 "$P_SRV key_file=data_files/server5.key \
3691 crt_file=data_files/server5.ku-ka.crt" \
3692 "$P_CLI" \
3693 0 \
3694 -c "Ciphersuite is TLS-ECDH-"
3695
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003696run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003697 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003698 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003699 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003700 1 \
3701 -C "Ciphersuite is "
3702
3703# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003704# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003706run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003707 "$O_SRV -key data_files/server2.key \
3708 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003709 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003710 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3711 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003712 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003713 -C "Processing of the Certificate handshake message failed" \
3714 -c "Ciphersuite is TLS-"
3715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003716run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003717 "$O_SRV -key data_files/server2.key \
3718 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003719 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003720 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3721 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003722 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003723 -C "Processing of the Certificate handshake message failed" \
3724 -c "Ciphersuite is TLS-"
3725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003726run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003727 "$O_SRV -key data_files/server2.key \
3728 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003729 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003730 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3731 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003732 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003733 -C "Processing of the Certificate handshake message failed" \
3734 -c "Ciphersuite is TLS-"
3735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003736run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003737 "$O_SRV -key data_files/server2.key \
3738 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003739 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003740 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3741 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003742 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003743 -c "Processing of the Certificate handshake message failed" \
3744 -C "Ciphersuite is TLS-"
3745
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003746run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3747 "$O_SRV -key data_files/server2.key \
3748 -cert data_files/server2.ku-ke.crt" \
3749 "$P_CLI debug_level=1 auth_mode=optional \
3750 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3751 0 \
3752 -c "bad certificate (usage extensions)" \
3753 -C "Processing of the Certificate handshake message failed" \
3754 -c "Ciphersuite is TLS-" \
3755 -c "! Usage does not match the keyUsage extension"
3756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003757run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003758 "$O_SRV -key data_files/server2.key \
3759 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003760 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003761 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3762 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003763 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003764 -C "Processing of the Certificate handshake message failed" \
3765 -c "Ciphersuite is TLS-"
3766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003767run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003768 "$O_SRV -key data_files/server2.key \
3769 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003770 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003771 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3772 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003773 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003774 -c "Processing of the Certificate handshake message failed" \
3775 -C "Ciphersuite is TLS-"
3776
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003777run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3778 "$O_SRV -key data_files/server2.key \
3779 -cert data_files/server2.ku-ds.crt" \
3780 "$P_CLI debug_level=1 auth_mode=optional \
3781 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3782 0 \
3783 -c "bad certificate (usage extensions)" \
3784 -C "Processing of the Certificate handshake message failed" \
3785 -c "Ciphersuite is TLS-" \
3786 -c "! Usage does not match the keyUsage extension"
3787
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003788# Tests for keyUsage in leaf certificates, part 3:
3789# server-side checking of client cert
3790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003791run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003792 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003793 "$O_CLI -key data_files/server2.key \
3794 -cert data_files/server2.ku-ds.crt" \
3795 0 \
3796 -S "bad certificate (usage extensions)" \
3797 -S "Processing of the Certificate handshake message failed"
3798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003799run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003800 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003801 "$O_CLI -key data_files/server2.key \
3802 -cert data_files/server2.ku-ke.crt" \
3803 0 \
3804 -s "bad certificate (usage extensions)" \
3805 -S "Processing of the Certificate handshake message failed"
3806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003807run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003808 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003809 "$O_CLI -key data_files/server2.key \
3810 -cert data_files/server2.ku-ke.crt" \
3811 1 \
3812 -s "bad certificate (usage extensions)" \
3813 -s "Processing of the Certificate handshake message failed"
3814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003815run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003816 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003817 "$O_CLI -key data_files/server5.key \
3818 -cert data_files/server5.ku-ds.crt" \
3819 0 \
3820 -S "bad certificate (usage extensions)" \
3821 -S "Processing of the Certificate handshake message failed"
3822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003823run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003824 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003825 "$O_CLI -key data_files/server5.key \
3826 -cert data_files/server5.ku-ka.crt" \
3827 0 \
3828 -s "bad certificate (usage extensions)" \
3829 -S "Processing of the Certificate handshake message failed"
3830
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003831# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003833run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003834 "$P_SRV key_file=data_files/server5.key \
3835 crt_file=data_files/server5.eku-srv.crt" \
3836 "$P_CLI" \
3837 0
3838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003839run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003840 "$P_SRV key_file=data_files/server5.key \
3841 crt_file=data_files/server5.eku-srv.crt" \
3842 "$P_CLI" \
3843 0
3844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003845run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003846 "$P_SRV key_file=data_files/server5.key \
3847 crt_file=data_files/server5.eku-cs_any.crt" \
3848 "$P_CLI" \
3849 0
3850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003851run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003852 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003853 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003854 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003855 1
3856
3857# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003859run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003860 "$O_SRV -key data_files/server5.key \
3861 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003862 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003863 0 \
3864 -C "bad certificate (usage extensions)" \
3865 -C "Processing of the Certificate handshake message failed" \
3866 -c "Ciphersuite is TLS-"
3867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003868run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003869 "$O_SRV -key data_files/server5.key \
3870 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003871 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003872 0 \
3873 -C "bad certificate (usage extensions)" \
3874 -C "Processing of the Certificate handshake message failed" \
3875 -c "Ciphersuite is TLS-"
3876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003877run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003878 "$O_SRV -key data_files/server5.key \
3879 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003880 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003881 0 \
3882 -C "bad certificate (usage extensions)" \
3883 -C "Processing of the Certificate handshake message failed" \
3884 -c "Ciphersuite is TLS-"
3885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003886run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003887 "$O_SRV -key data_files/server5.key \
3888 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003889 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003890 1 \
3891 -c "bad certificate (usage extensions)" \
3892 -c "Processing of the Certificate handshake message failed" \
3893 -C "Ciphersuite is TLS-"
3894
3895# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3896
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003897run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003898 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003899 "$O_CLI -key data_files/server5.key \
3900 -cert data_files/server5.eku-cli.crt" \
3901 0 \
3902 -S "bad certificate (usage extensions)" \
3903 -S "Processing of the Certificate handshake message failed"
3904
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003905run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003906 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003907 "$O_CLI -key data_files/server5.key \
3908 -cert data_files/server5.eku-srv_cli.crt" \
3909 0 \
3910 -S "bad certificate (usage extensions)" \
3911 -S "Processing of the Certificate handshake message failed"
3912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003913run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003914 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003915 "$O_CLI -key data_files/server5.key \
3916 -cert data_files/server5.eku-cs_any.crt" \
3917 0 \
3918 -S "bad certificate (usage extensions)" \
3919 -S "Processing of the Certificate handshake message failed"
3920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003921run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003922 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003923 "$O_CLI -key data_files/server5.key \
3924 -cert data_files/server5.eku-cs.crt" \
3925 0 \
3926 -s "bad certificate (usage extensions)" \
3927 -S "Processing of the Certificate handshake message failed"
3928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003929run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003930 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003931 "$O_CLI -key data_files/server5.key \
3932 -cert data_files/server5.eku-cs.crt" \
3933 1 \
3934 -s "bad certificate (usage extensions)" \
3935 -s "Processing of the Certificate handshake message failed"
3936
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003937# Tests for DHM parameters loading
3938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003939run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003940 "$P_SRV" \
3941 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3942 debug_level=3" \
3943 0 \
3944 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003945 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003947run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003948 "$P_SRV dhm_file=data_files/dhparams.pem" \
3949 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3950 debug_level=3" \
3951 0 \
3952 -c "value of 'DHM: P ' (1024 bits)" \
3953 -c "value of 'DHM: G ' (2 bits)"
3954
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003955# Tests for DHM client-side size checking
3956
3957run_test "DHM size: server default, client default, OK" \
3958 "$P_SRV" \
3959 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3960 debug_level=1" \
3961 0 \
3962 -C "DHM prime too short:"
3963
3964run_test "DHM size: server default, client 2048, OK" \
3965 "$P_SRV" \
3966 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3967 debug_level=1 dhmlen=2048" \
3968 0 \
3969 -C "DHM prime too short:"
3970
3971run_test "DHM size: server 1024, client default, OK" \
3972 "$P_SRV dhm_file=data_files/dhparams.pem" \
3973 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3974 debug_level=1" \
3975 0 \
3976 -C "DHM prime too short:"
3977
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003978run_test "DHM size: server 999, client 999, OK" \
3979 "$P_SRV dhm_file=data_files/dh.999.pem" \
3980 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3981 debug_level=1 dhmlen=999" \
3982 0 \
3983 -C "DHM prime too short:"
3984
3985run_test "DHM size: server 1000, client 1000, OK" \
3986 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3987 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3988 debug_level=1 dhmlen=1000" \
3989 0 \
3990 -C "DHM prime too short:"
3991
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003992run_test "DHM size: server 1000, client default, rejected" \
3993 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3994 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3995 debug_level=1" \
3996 1 \
3997 -c "DHM prime too short:"
3998
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003999run_test "DHM size: server 1000, client 1001, rejected" \
4000 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4001 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4002 debug_level=1 dhmlen=1001" \
4003 1 \
4004 -c "DHM prime too short:"
4005
4006run_test "DHM size: server 999, client 1000, rejected" \
4007 "$P_SRV dhm_file=data_files/dh.999.pem" \
4008 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4009 debug_level=1 dhmlen=1000" \
4010 1 \
4011 -c "DHM prime too short:"
4012
4013run_test "DHM size: server 998, client 999, rejected" \
4014 "$P_SRV dhm_file=data_files/dh.998.pem" \
4015 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4016 debug_level=1 dhmlen=999" \
4017 1 \
4018 -c "DHM prime too short:"
4019
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004020run_test "DHM size: server default, client 2049, rejected" \
4021 "$P_SRV" \
4022 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4023 debug_level=1 dhmlen=2049" \
4024 1 \
4025 -c "DHM prime too short:"
4026
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004027# Tests for PSK callback
4028
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004029run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004030 "$P_SRV psk=abc123 psk_identity=foo" \
4031 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4032 psk_identity=foo psk=abc123" \
4033 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004034 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004035 -S "SSL - Unknown identity received" \
4036 -S "SSL - Verification of the message MAC failed"
4037
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004038run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004039 "$P_SRV" \
4040 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4041 psk_identity=foo psk=abc123" \
4042 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004043 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004044 -S "SSL - Unknown identity received" \
4045 -S "SSL - Verification of the message MAC failed"
4046
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004047run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004048 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4049 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4050 psk_identity=foo psk=abc123" \
4051 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004052 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004053 -s "SSL - Unknown identity received" \
4054 -S "SSL - Verification of the message MAC failed"
4055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004056run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004057 "$P_SRV psk_list=abc,dead,def,beef" \
4058 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4059 psk_identity=abc psk=dead" \
4060 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004061 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004062 -S "SSL - Unknown identity received" \
4063 -S "SSL - Verification of the message MAC failed"
4064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004065run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004066 "$P_SRV psk_list=abc,dead,def,beef" \
4067 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4068 psk_identity=def psk=beef" \
4069 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004070 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004071 -S "SSL - Unknown identity received" \
4072 -S "SSL - Verification of the message MAC failed"
4073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004074run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004075 "$P_SRV psk_list=abc,dead,def,beef" \
4076 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4077 psk_identity=ghi psk=beef" \
4078 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004079 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004080 -s "SSL - Unknown identity received" \
4081 -S "SSL - Verification of the message MAC failed"
4082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004083run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004084 "$P_SRV psk_list=abc,dead,def,beef" \
4085 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4086 psk_identity=abc psk=beef" \
4087 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004088 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004089 -S "SSL - Unknown identity received" \
4090 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004091
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004092# Tests for EC J-PAKE
4093
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004094requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004095run_test "ECJPAKE: client not configured" \
4096 "$P_SRV debug_level=3" \
4097 "$P_CLI debug_level=3" \
4098 0 \
4099 -C "add ciphersuite: c0ff" \
4100 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004101 -S "found ecjpake kkpp extension" \
4102 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004103 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004104 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004105 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004106 -S "None of the common ciphersuites is usable"
4107
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004108requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004109run_test "ECJPAKE: server not configured" \
4110 "$P_SRV debug_level=3" \
4111 "$P_CLI debug_level=3 ecjpake_pw=bla \
4112 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4113 1 \
4114 -c "add ciphersuite: c0ff" \
4115 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004116 -s "found ecjpake kkpp extension" \
4117 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004118 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004119 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004120 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004121 -s "None of the common ciphersuites is usable"
4122
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004123requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004124run_test "ECJPAKE: working, TLS" \
4125 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4126 "$P_CLI debug_level=3 ecjpake_pw=bla \
4127 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004128 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004129 -c "add ciphersuite: c0ff" \
4130 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004131 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004132 -s "found ecjpake kkpp extension" \
4133 -S "skip ecjpake kkpp extension" \
4134 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004135 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004136 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004137 -S "None of the common ciphersuites is usable" \
4138 -S "SSL - Verification of the message MAC failed"
4139
Janos Follath74537a62016-09-02 13:45:28 +01004140server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004141requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004142run_test "ECJPAKE: password mismatch, TLS" \
4143 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4144 "$P_CLI debug_level=3 ecjpake_pw=bad \
4145 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4146 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004147 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004148 -s "SSL - Verification of the message MAC failed"
4149
Dave Rodgmancee9e922021-06-29 19:05:34 +01004150requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004151run_test "ECJPAKE: working, DTLS" \
4152 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4153 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4154 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4155 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004156 -c "re-using cached ecjpake parameters" \
4157 -S "SSL - Verification of the message MAC failed"
4158
Dave Rodgmancee9e922021-06-29 19:05:34 +01004159requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004160run_test "ECJPAKE: working, DTLS, no cookie" \
4161 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4162 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4163 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4164 0 \
4165 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004166 -S "SSL - Verification of the message MAC failed"
4167
Janos Follath74537a62016-09-02 13:45:28 +01004168server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004169requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004170run_test "ECJPAKE: password mismatch, DTLS" \
4171 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4172 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4173 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4174 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004175 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004176 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004177
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004178# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004179requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004180run_test "ECJPAKE: working, DTLS, nolog" \
4181 "$P_SRV dtls=1 ecjpake_pw=bla" \
4182 "$P_CLI dtls=1 ecjpake_pw=bla \
4183 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4184 0
4185
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004186# Tests for ciphersuites per version
4187
Janos Follathe2681a42016-03-07 15:57:05 +00004188requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004189requires_config_enabled MBEDTLS_CAMELLIA_C
4190requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004191run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004192 "$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 +02004193 "$P_CLI force_version=ssl3" \
4194 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004195 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004196
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004197requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4198requires_config_enabled MBEDTLS_CAMELLIA_C
4199requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004200run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004201 "$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 +01004202 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004203 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004204 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004205
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004206requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4207requires_config_enabled MBEDTLS_CAMELLIA_C
4208requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004209run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004210 "$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 +02004211 "$P_CLI force_version=tls1_1" \
4212 0 \
4213 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4214
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004215requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4216requires_config_enabled MBEDTLS_CAMELLIA_C
4217requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004218run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004219 "$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 +02004220 "$P_CLI force_version=tls1_2" \
4221 0 \
4222 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4223
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004224# Test for ClientHello without extensions
4225
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004226requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004227run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004228 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004229 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004230 0 \
4231 -s "dumping 'client hello extensions' (0 bytes)"
4232
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004233# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004234
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004235run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004236 "$P_SRV" \
4237 "$P_CLI request_size=100" \
4238 0 \
4239 -s "Read from client: 100 bytes read$"
4240
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004241run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004242 "$P_SRV" \
4243 "$P_CLI request_size=500" \
4244 0 \
4245 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004246
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004247# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004248
Janos Follathe2681a42016-03-07 15:57:05 +00004249requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004250run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004251 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004252 "$P_CLI request_size=1 force_version=ssl3 \
4253 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4254 0 \
4255 -s "Read from client: 1 bytes read"
4256
Janos Follathe2681a42016-03-07 15:57:05 +00004257requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004258run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004259 "$P_SRV min_version=ssl3 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=ssl3 \
4261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4262 0 \
4263 -s "Read from client: 1 bytes read"
4264
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004265run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004266 "$P_SRV" \
4267 "$P_CLI request_size=1 force_version=tls1 \
4268 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4269 0 \
4270 -s "Read from client: 1 bytes read"
4271
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004272run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004273 "$P_SRV" \
4274 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4275 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4276 0 \
4277 -s "Read from client: 1 bytes read"
4278
Hanno Becker32c55012017-11-10 08:42:54 +00004279requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004280run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004281 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004282 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004283 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004284 0 \
4285 -s "Read from client: 1 bytes read"
4286
Hanno Becker32c55012017-11-10 08:42:54 +00004287requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004288run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004289 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004290 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004291 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004292 0 \
4293 -s "Read from client: 1 bytes read"
4294
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004295run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004296 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004297 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4299 0 \
4300 -s "Read from client: 1 bytes read"
4301
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004302run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004303 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4304 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004305 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004306 0 \
4307 -s "Read from client: 1 bytes read"
4308
4309requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004310run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004311 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004312 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004313 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004314 0 \
4315 -s "Read from client: 1 bytes read"
4316
Hanno Becker8501f982017-11-10 08:59:04 +00004317requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004318run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004319 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4320 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4321 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004322 0 \
4323 -s "Read from client: 1 bytes read"
4324
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004325run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004326 "$P_SRV" \
4327 "$P_CLI request_size=1 force_version=tls1_1 \
4328 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4329 0 \
4330 -s "Read from client: 1 bytes read"
4331
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004332run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004333 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004334 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004335 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004336 0 \
4337 -s "Read from client: 1 bytes read"
4338
4339requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004340run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004341 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004342 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004343 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004344 0 \
4345 -s "Read from client: 1 bytes read"
4346
4347requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004348run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004349 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004350 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004351 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004352 0 \
4353 -s "Read from client: 1 bytes read"
4354
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004355run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004356 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004357 "$P_CLI request_size=1 force_version=tls1_1 \
4358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4359 0 \
4360 -s "Read from client: 1 bytes read"
4361
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004362run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004363 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004364 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004365 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004366 0 \
4367 -s "Read from client: 1 bytes read"
4368
Hanno Becker8501f982017-11-10 08:59:04 +00004369requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004370run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004371 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004372 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004373 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004374 0 \
4375 -s "Read from client: 1 bytes read"
4376
Hanno Becker32c55012017-11-10 08:42:54 +00004377requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004378run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004379 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004380 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004381 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004382 0 \
4383 -s "Read from client: 1 bytes read"
4384
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004385run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004386 "$P_SRV" \
4387 "$P_CLI request_size=1 force_version=tls1_2 \
4388 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4389 0 \
4390 -s "Read from client: 1 bytes read"
4391
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004392run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004393 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004394 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004396 0 \
4397 -s "Read from client: 1 bytes read"
4398
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004399run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004400 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004401 "$P_CLI request_size=1 force_version=tls1_2 \
4402 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004403 0 \
4404 -s "Read from client: 1 bytes read"
4405
Hanno Becker32c55012017-11-10 08:42:54 +00004406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004407run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004408 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004409 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004411 0 \
4412 -s "Read from client: 1 bytes read"
4413
Hanno Becker8501f982017-11-10 08:59:04 +00004414requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004415run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004416 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004417 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004418 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004419 0 \
4420 -s "Read from client: 1 bytes read"
4421
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004422run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004423 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004424 "$P_CLI request_size=1 force_version=tls1_2 \
4425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4426 0 \
4427 -s "Read from client: 1 bytes read"
4428
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004429run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004430 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004431 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004432 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004433 0 \
4434 -s "Read from client: 1 bytes read"
4435
Hanno Becker32c55012017-11-10 08:42:54 +00004436requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004437run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004438 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004439 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004440 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004441 0 \
4442 -s "Read from client: 1 bytes read"
4443
Hanno Becker8501f982017-11-10 08:59:04 +00004444requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004445run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004446 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004447 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004448 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004449 0 \
4450 -s "Read from client: 1 bytes read"
4451
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004452run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004453 "$P_SRV" \
4454 "$P_CLI request_size=1 force_version=tls1_2 \
4455 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4456 0 \
4457 -s "Read from client: 1 bytes read"
4458
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004459run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004460 "$P_SRV" \
4461 "$P_CLI request_size=1 force_version=tls1_2 \
4462 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4463 0 \
4464 -s "Read from client: 1 bytes read"
4465
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004466# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004467
4468requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004469run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004470 "$P_SRV dtls=1 force_version=dtls1" \
4471 "$P_CLI dtls=1 request_size=1 \
4472 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4473 0 \
4474 -s "Read from client: 1 bytes read"
4475
4476requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004477run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004478 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4479 "$P_CLI dtls=1 request_size=1 \
4480 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4481 0 \
4482 -s "Read from client: 1 bytes read"
4483
4484requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4485requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004486run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004487 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4488 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004489 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4490 0 \
4491 -s "Read from client: 1 bytes read"
4492
4493requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4494requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004495run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004496 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004497 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004498 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004499 0 \
4500 -s "Read from client: 1 bytes read"
4501
4502requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004503run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004504 "$P_SRV dtls=1 force_version=dtls1_2" \
4505 "$P_CLI dtls=1 request_size=1 \
4506 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4507 0 \
4508 -s "Read from client: 1 bytes read"
4509
4510requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004511run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004512 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004513 "$P_CLI dtls=1 request_size=1 \
4514 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4515 0 \
4516 -s "Read from client: 1 bytes read"
4517
4518requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4519requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004520run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004521 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004522 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004523 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004524 0 \
4525 -s "Read from client: 1 bytes read"
4526
4527requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4528requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004529run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004530 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004531 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004533 0 \
4534 -s "Read from client: 1 bytes read"
4535
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004536# Tests for small server packets
4537
4538requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4539run_test "Small server packet SSLv3 BlockCipher" \
4540 "$P_SRV response_size=1 min_version=ssl3" \
4541 "$P_CLI force_version=ssl3 \
4542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4543 0 \
4544 -c "Read from server: 1 bytes read"
4545
4546requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4547run_test "Small server packet SSLv3 StreamCipher" \
4548 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4549 "$P_CLI force_version=ssl3 \
4550 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4551 0 \
4552 -c "Read from server: 1 bytes read"
4553
4554run_test "Small server packet TLS 1.0 BlockCipher" \
4555 "$P_SRV response_size=1" \
4556 "$P_CLI force_version=tls1 \
4557 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4558 0 \
4559 -c "Read from server: 1 bytes read"
4560
4561run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4562 "$P_SRV response_size=1" \
4563 "$P_CLI force_version=tls1 etm=0 \
4564 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4565 0 \
4566 -c "Read from server: 1 bytes read"
4567
4568requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4569run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4570 "$P_SRV response_size=1 trunc_hmac=1" \
4571 "$P_CLI force_version=tls1 \
4572 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4573 0 \
4574 -c "Read from server: 1 bytes read"
4575
4576requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4577run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4578 "$P_SRV response_size=1 trunc_hmac=1" \
4579 "$P_CLI force_version=tls1 \
4580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4581 0 \
4582 -c "Read from server: 1 bytes read"
4583
4584run_test "Small server packet TLS 1.0 StreamCipher" \
4585 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4586 "$P_CLI force_version=tls1 \
4587 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4588 0 \
4589 -c "Read from server: 1 bytes read"
4590
4591run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4592 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4593 "$P_CLI force_version=tls1 \
4594 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4595 0 \
4596 -c "Read from server: 1 bytes read"
4597
4598requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4599run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4600 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4601 "$P_CLI force_version=tls1 \
4602 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4603 0 \
4604 -c "Read from server: 1 bytes read"
4605
4606requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4607run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4608 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4609 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4610 trunc_hmac=1 etm=0" \
4611 0 \
4612 -c "Read from server: 1 bytes read"
4613
4614run_test "Small server packet TLS 1.1 BlockCipher" \
4615 "$P_SRV response_size=1" \
4616 "$P_CLI force_version=tls1_1 \
4617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4618 0 \
4619 -c "Read from server: 1 bytes read"
4620
4621run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4622 "$P_SRV response_size=1" \
4623 "$P_CLI force_version=tls1_1 \
4624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4625 0 \
4626 -c "Read from server: 1 bytes read"
4627
4628requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4629run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4630 "$P_SRV response_size=1 trunc_hmac=1" \
4631 "$P_CLI force_version=tls1_1 \
4632 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4633 0 \
4634 -c "Read from server: 1 bytes read"
4635
4636requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4637run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4638 "$P_SRV response_size=1 trunc_hmac=1" \
4639 "$P_CLI force_version=tls1_1 \
4640 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4641 0 \
4642 -c "Read from server: 1 bytes read"
4643
4644run_test "Small server packet TLS 1.1 StreamCipher" \
4645 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4646 "$P_CLI force_version=tls1_1 \
4647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4648 0 \
4649 -c "Read from server: 1 bytes read"
4650
4651run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4652 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4653 "$P_CLI force_version=tls1_1 \
4654 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4655 0 \
4656 -c "Read from server: 1 bytes read"
4657
4658requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4659run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4660 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4661 "$P_CLI force_version=tls1_1 \
4662 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4663 0 \
4664 -c "Read from server: 1 bytes read"
4665
4666requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4667run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4668 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4669 "$P_CLI force_version=tls1_1 \
4670 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4671 0 \
4672 -c "Read from server: 1 bytes read"
4673
4674run_test "Small server packet TLS 1.2 BlockCipher" \
4675 "$P_SRV response_size=1" \
4676 "$P_CLI force_version=tls1_2 \
4677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4678 0 \
4679 -c "Read from server: 1 bytes read"
4680
4681run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4682 "$P_SRV response_size=1" \
4683 "$P_CLI force_version=tls1_2 \
4684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4685 0 \
4686 -c "Read from server: 1 bytes read"
4687
4688run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4689 "$P_SRV response_size=1" \
4690 "$P_CLI force_version=tls1_2 \
4691 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4692 0 \
4693 -c "Read from server: 1 bytes read"
4694
4695requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4696run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4697 "$P_SRV response_size=1 trunc_hmac=1" \
4698 "$P_CLI force_version=tls1_2 \
4699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4700 0 \
4701 -c "Read from server: 1 bytes read"
4702
4703requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4704run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4705 "$P_SRV response_size=1 trunc_hmac=1" \
4706 "$P_CLI force_version=tls1_2 \
4707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4708 0 \
4709 -c "Read from server: 1 bytes read"
4710
4711run_test "Small server packet TLS 1.2 StreamCipher" \
4712 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4713 "$P_CLI force_version=tls1_2 \
4714 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4715 0 \
4716 -c "Read from server: 1 bytes read"
4717
4718run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4719 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4720 "$P_CLI force_version=tls1_2 \
4721 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4722 0 \
4723 -c "Read from server: 1 bytes read"
4724
4725requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4726run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4727 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4728 "$P_CLI force_version=tls1_2 \
4729 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4730 0 \
4731 -c "Read from server: 1 bytes read"
4732
4733requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4734run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4735 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4736 "$P_CLI force_version=tls1_2 \
4737 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4738 0 \
4739 -c "Read from server: 1 bytes read"
4740
4741run_test "Small server packet TLS 1.2 AEAD" \
4742 "$P_SRV response_size=1" \
4743 "$P_CLI force_version=tls1_2 \
4744 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4745 0 \
4746 -c "Read from server: 1 bytes read"
4747
4748run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4749 "$P_SRV response_size=1" \
4750 "$P_CLI force_version=tls1_2 \
4751 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4752 0 \
4753 -c "Read from server: 1 bytes read"
4754
4755# Tests for small server packets in DTLS
4756
4757requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4758run_test "Small server packet DTLS 1.0" \
4759 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4760 "$P_CLI dtls=1 \
4761 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4762 0 \
4763 -c "Read from server: 1 bytes read"
4764
4765requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4766run_test "Small server packet DTLS 1.0, without EtM" \
4767 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4768 "$P_CLI dtls=1 \
4769 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4770 0 \
4771 -c "Read from server: 1 bytes read"
4772
4773requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4774requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4775run_test "Small server packet DTLS 1.0, truncated hmac" \
4776 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4777 "$P_CLI dtls=1 trunc_hmac=1 \
4778 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4779 0 \
4780 -c "Read from server: 1 bytes read"
4781
4782requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4783requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4784run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4785 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4786 "$P_CLI dtls=1 \
4787 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4788 0 \
4789 -c "Read from server: 1 bytes read"
4790
4791requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4792run_test "Small server packet DTLS 1.2" \
4793 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4794 "$P_CLI dtls=1 \
4795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4796 0 \
4797 -c "Read from server: 1 bytes read"
4798
4799requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4800run_test "Small server packet DTLS 1.2, without EtM" \
4801 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4802 "$P_CLI dtls=1 \
4803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4804 0 \
4805 -c "Read from server: 1 bytes read"
4806
4807requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4808requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4809run_test "Small server packet DTLS 1.2, truncated hmac" \
4810 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4811 "$P_CLI dtls=1 \
4812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4813 0 \
4814 -c "Read from server: 1 bytes read"
4815
4816requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4817requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4818run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4819 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4820 "$P_CLI dtls=1 \
4821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4822 0 \
4823 -c "Read from server: 1 bytes read"
4824
Janos Follath00efff72016-05-06 13:48:23 +01004825# A test for extensions in SSLv3
4826
4827requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4828run_test "SSLv3 with extensions, server side" \
4829 "$P_SRV min_version=ssl3 debug_level=3" \
4830 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4831 0 \
4832 -S "dumping 'client hello extensions'" \
4833 -S "server hello, total extension length:"
4834
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004835# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004836
Angus Grattonc4dd0732018-04-11 16:28:39 +10004837# How many fragments do we expect to write $1 bytes?
4838fragments_for_write() {
4839 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4840}
4841
Janos Follathe2681a42016-03-07 15:57:05 +00004842requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004843run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004844 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004845 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4847 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004848 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4849 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004850
Janos Follathe2681a42016-03-07 15:57:05 +00004851requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004852run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004853 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004854 "$P_CLI request_size=16384 force_version=ssl3 \
4855 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4856 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004857 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4858 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004859
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004860run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004861 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004862 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004863 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4864 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004865 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4866 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004867
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004868run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004869 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004870 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4871 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4872 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004873 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004874
Hanno Becker32c55012017-11-10 08:42:54 +00004875requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004876run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004877 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004878 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004879 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004880 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004881 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4882 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004883
Hanno Becker32c55012017-11-10 08:42:54 +00004884requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004885run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004886 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004887 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004888 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004889 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004890 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004891
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004892run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004893 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004894 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4896 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004897 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004898
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004899run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004900 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4901 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004902 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004903 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004904 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004905
4906requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004907run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004908 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004909 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004910 force_ciphersuite=TLS-RSA-WITH-RC4-128-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.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004916 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004917 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004918 force_ciphersuite=TLS-RSA-WITH-RC4-128-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.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004924 "$P_SRV" \
4925 "$P_CLI request_size=16384 force_version=tls1_1 \
4926 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-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.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004932 "$P_SRV" \
4933 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4934 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004935 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004936 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004937
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.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004940 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004941 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004942 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-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 Becker32c55012017-11-10 08:42:54 +00004946requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004947run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004948 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004949 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004950 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004951 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004952 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004953
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004954run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004955 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4956 "$P_CLI request_size=16384 force_version=tls1_1 \
4957 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4958 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004959 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4960 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004961
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004962run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004963 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004964 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004965 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004966 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004967 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4968 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004969
Hanno Becker278fc7a2017-11-10 09:16:28 +00004970requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004971run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004972 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004973 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004974 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004975 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004976 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004977
Hanno Becker278fc7a2017-11-10 09:16:28 +00004978requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004979run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004980 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004981 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004982 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004983 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004984 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4985 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004986
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004987run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004988 "$P_SRV" \
4989 "$P_CLI request_size=16384 force_version=tls1_2 \
4990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4991 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004992 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4993 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004994
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004995run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004996 "$P_SRV" \
4997 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4998 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4999 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005000 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005001
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005002run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005003 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005004 "$P_CLI request_size=16384 force_version=tls1_2 \
5005 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005006 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005007 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5008 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005009
Hanno Becker32c55012017-11-10 08:42:54 +00005010requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005011run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005012 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005013 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005014 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005015 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005016 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005017
Hanno Becker278fc7a2017-11-10 09:16:28 +00005018requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005019run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005020 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005021 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005023 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005024 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5025 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005026
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005027run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005028 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005029 "$P_CLI request_size=16384 force_version=tls1_2 \
5030 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5031 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005032 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5033 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005034
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005035run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005036 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005037 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005038 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5039 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005040 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005041
Hanno Becker32c55012017-11-10 08:42:54 +00005042requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005043run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005044 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005045 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005046 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005047 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005048 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005049
Hanno Becker278fc7a2017-11-10 09:16:28 +00005050requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005051run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005052 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005053 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005054 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005055 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005056 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5057 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005058
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005059run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005060 "$P_SRV" \
5061 "$P_CLI request_size=16384 force_version=tls1_2 \
5062 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5063 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005064 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5065 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005066
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005067run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005068 "$P_SRV" \
5069 "$P_CLI request_size=16384 force_version=tls1_2 \
5070 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5071 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005072 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5073 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005074
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005075# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005076requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5077run_test "Large server packet SSLv3 StreamCipher" \
5078 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5079 "$P_CLI force_version=ssl3 \
5080 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5081 0 \
5082 -c "Read from server: 16384 bytes read"
5083
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005084# Checking next 4 tests logs for 1n-1 split against BEAST too
5085requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5086run_test "Large server packet SSLv3 BlockCipher" \
5087 "$P_SRV response_size=16384 min_version=ssl3" \
5088 "$P_CLI force_version=ssl3 recsplit=0 \
5089 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5090 0 \
5091 -c "Read from server: 1 bytes read"\
5092 -c "16383 bytes read"\
5093 -C "Read from server: 16384 bytes read"
5094
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005095run_test "Large server packet TLS 1.0 BlockCipher" \
5096 "$P_SRV response_size=16384" \
5097 "$P_CLI force_version=tls1 recsplit=0 \
5098 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5099 0 \
5100 -c "Read from server: 1 bytes read"\
5101 -c "16383 bytes read"\
5102 -C "Read from server: 16384 bytes read"
5103
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005104run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5105 "$P_SRV response_size=16384" \
5106 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5107 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5108 0 \
5109 -c "Read from server: 1 bytes read"\
5110 -c "16383 bytes read"\
5111 -C "Read from server: 16384 bytes read"
5112
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005113requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5114run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5115 "$P_SRV response_size=16384" \
5116 "$P_CLI force_version=tls1 recsplit=0 \
5117 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5118 trunc_hmac=1" \
5119 0 \
5120 -c "Read from server: 1 bytes read"\
5121 -c "16383 bytes read"\
5122 -C "Read from server: 16384 bytes read"
5123
5124requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5125run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5126 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5127 "$P_CLI force_version=tls1 \
5128 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5129 trunc_hmac=1" \
5130 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005131 -s "16384 bytes written in 1 fragments" \
5132 -c "Read from server: 16384 bytes read"
5133
5134run_test "Large server packet TLS 1.0 StreamCipher" \
5135 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5136 "$P_CLI force_version=tls1 \
5137 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5138 0 \
5139 -s "16384 bytes written in 1 fragments" \
5140 -c "Read from server: 16384 bytes read"
5141
5142run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5143 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5144 "$P_CLI force_version=tls1 \
5145 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5146 0 \
5147 -s "16384 bytes written in 1 fragments" \
5148 -c "Read from server: 16384 bytes read"
5149
5150requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5151run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5152 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5153 "$P_CLI force_version=tls1 \
5154 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5155 0 \
5156 -s "16384 bytes written in 1 fragments" \
5157 -c "Read from server: 16384 bytes read"
5158
5159requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5160run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5161 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5162 "$P_CLI force_version=tls1 \
5163 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5164 0 \
5165 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005166 -c "Read from server: 16384 bytes read"
5167
5168run_test "Large server packet TLS 1.1 BlockCipher" \
5169 "$P_SRV response_size=16384" \
5170 "$P_CLI force_version=tls1_1 \
5171 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5172 0 \
5173 -c "Read from server: 16384 bytes read"
5174
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005175run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5176 "$P_SRV response_size=16384" \
5177 "$P_CLI force_version=tls1_1 etm=0 \
5178 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005179 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005180 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005181 -c "Read from server: 16384 bytes read"
5182
5183requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5184run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5185 "$P_SRV response_size=16384" \
5186 "$P_CLI force_version=tls1_1 \
5187 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5188 trunc_hmac=1" \
5189 0 \
5190 -c "Read from server: 16384 bytes read"
5191
5192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005193run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5194 "$P_SRV response_size=16384 trunc_hmac=1" \
5195 "$P_CLI force_version=tls1_1 \
5196 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5197 0 \
5198 -s "16384 bytes written in 1 fragments" \
5199 -c "Read from server: 16384 bytes read"
5200
5201run_test "Large server packet TLS 1.1 StreamCipher" \
5202 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5203 "$P_CLI force_version=tls1_1 \
5204 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5205 0 \
5206 -c "Read from server: 16384 bytes read"
5207
5208run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5209 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5210 "$P_CLI force_version=tls1_1 \
5211 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5212 0 \
5213 -s "16384 bytes written in 1 fragments" \
5214 -c "Read from server: 16384 bytes read"
5215
5216requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005217run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5218 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5219 "$P_CLI force_version=tls1_1 \
5220 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5221 trunc_hmac=1" \
5222 0 \
5223 -c "Read from server: 16384 bytes read"
5224
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005225run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5226 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5227 "$P_CLI force_version=tls1_1 \
5228 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5229 0 \
5230 -s "16384 bytes written in 1 fragments" \
5231 -c "Read from server: 16384 bytes read"
5232
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005233run_test "Large server packet TLS 1.2 BlockCipher" \
5234 "$P_SRV response_size=16384" \
5235 "$P_CLI force_version=tls1_2 \
5236 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5237 0 \
5238 -c "Read from server: 16384 bytes read"
5239
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005240run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5241 "$P_SRV response_size=16384" \
5242 "$P_CLI force_version=tls1_2 etm=0 \
5243 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5244 0 \
5245 -s "16384 bytes written in 1 fragments" \
5246 -c "Read from server: 16384 bytes read"
5247
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005248run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5249 "$P_SRV response_size=16384" \
5250 "$P_CLI force_version=tls1_2 \
5251 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5252 0 \
5253 -c "Read from server: 16384 bytes read"
5254
5255requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5256run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5257 "$P_SRV response_size=16384" \
5258 "$P_CLI force_version=tls1_2 \
5259 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5260 trunc_hmac=1" \
5261 0 \
5262 -c "Read from server: 16384 bytes read"
5263
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005264run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5265 "$P_SRV response_size=16384 trunc_hmac=1" \
5266 "$P_CLI force_version=tls1_2 \
5267 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5268 0 \
5269 -s "16384 bytes written in 1 fragments" \
5270 -c "Read from server: 16384 bytes read"
5271
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005272run_test "Large server packet TLS 1.2 StreamCipher" \
5273 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5274 "$P_CLI force_version=tls1_2 \
5275 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5276 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005277 -s "16384 bytes written in 1 fragments" \
5278 -c "Read from server: 16384 bytes read"
5279
5280run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5281 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5282 "$P_CLI force_version=tls1_2 \
5283 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5284 0 \
5285 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005286 -c "Read from server: 16384 bytes read"
5287
5288requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5289run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5290 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5291 "$P_CLI force_version=tls1_2 \
5292 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5293 trunc_hmac=1" \
5294 0 \
5295 -c "Read from server: 16384 bytes read"
5296
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005297requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5298run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5299 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5300 "$P_CLI force_version=tls1_2 \
5301 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5302 0 \
5303 -s "16384 bytes written in 1 fragments" \
5304 -c "Read from server: 16384 bytes read"
5305
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005306run_test "Large server packet TLS 1.2 AEAD" \
5307 "$P_SRV response_size=16384" \
5308 "$P_CLI force_version=tls1_2 \
5309 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5310 0 \
5311 -c "Read from server: 16384 bytes read"
5312
5313run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5314 "$P_SRV response_size=16384" \
5315 "$P_CLI force_version=tls1_2 \
5316 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5317 0 \
5318 -c "Read from server: 16384 bytes read"
5319
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005320# Tests for restartable ECC
5321
5322requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5323run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005324 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005325 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005326 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005327 debug_level=1" \
5328 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005329 -C "x509_verify_cert.*4b00" \
5330 -C "mbedtls_pk_verify.*4b00" \
5331 -C "mbedtls_ecdh_make_public.*4b00" \
5332 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005333
5334requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5335run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005336 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005337 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005338 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005339 debug_level=1 ec_max_ops=0" \
5340 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005341 -C "x509_verify_cert.*4b00" \
5342 -C "mbedtls_pk_verify.*4b00" \
5343 -C "mbedtls_ecdh_make_public.*4b00" \
5344 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005345
5346requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5347run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005348 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005349 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005350 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005351 debug_level=1 ec_max_ops=65535" \
5352 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005353 -C "x509_verify_cert.*4b00" \
5354 -C "mbedtls_pk_verify.*4b00" \
5355 -C "mbedtls_ecdh_make_public.*4b00" \
5356 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005357
5358requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5359run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005360 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005361 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005362 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005363 debug_level=1 ec_max_ops=1000" \
5364 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005365 -c "x509_verify_cert.*4b00" \
5366 -c "mbedtls_pk_verify.*4b00" \
5367 -c "mbedtls_ecdh_make_public.*4b00" \
5368 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005369
5370requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005371run_test "EC restart: TLS, max_ops=1000, badsign" \
5372 "$P_SRV auth_mode=required \
5373 crt_file=data_files/server5-badsign.crt \
5374 key_file=data_files/server5.key" \
5375 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5376 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5377 debug_level=1 ec_max_ops=1000" \
5378 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005379 -c "x509_verify_cert.*4b00" \
5380 -C "mbedtls_pk_verify.*4b00" \
5381 -C "mbedtls_ecdh_make_public.*4b00" \
5382 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005383 -c "! The certificate is not correctly signed by the trusted CA" \
5384 -c "! mbedtls_ssl_handshake returned" \
5385 -c "X509 - Certificate verification failed"
5386
5387requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5388run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5389 "$P_SRV auth_mode=required \
5390 crt_file=data_files/server5-badsign.crt \
5391 key_file=data_files/server5.key" \
5392 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5393 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5394 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5395 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005396 -c "x509_verify_cert.*4b00" \
5397 -c "mbedtls_pk_verify.*4b00" \
5398 -c "mbedtls_ecdh_make_public.*4b00" \
5399 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005400 -c "! The certificate is not correctly signed by the trusted CA" \
5401 -C "! mbedtls_ssl_handshake returned" \
5402 -C "X509 - Certificate verification failed"
5403
5404requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5405run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5406 "$P_SRV auth_mode=required \
5407 crt_file=data_files/server5-badsign.crt \
5408 key_file=data_files/server5.key" \
5409 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5410 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5411 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5412 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005413 -C "x509_verify_cert.*4b00" \
5414 -c "mbedtls_pk_verify.*4b00" \
5415 -c "mbedtls_ecdh_make_public.*4b00" \
5416 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005417 -C "! The certificate is not correctly signed by the trusted CA" \
5418 -C "! mbedtls_ssl_handshake returned" \
5419 -C "X509 - Certificate verification failed"
5420
5421requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005422run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005423 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005424 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005425 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005426 dtls=1 debug_level=1 ec_max_ops=1000" \
5427 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005428 -c "x509_verify_cert.*4b00" \
5429 -c "mbedtls_pk_verify.*4b00" \
5430 -c "mbedtls_ecdh_make_public.*4b00" \
5431 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005432
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005433requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5434run_test "EC restart: TLS, max_ops=1000 no client auth" \
5435 "$P_SRV" \
5436 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5437 debug_level=1 ec_max_ops=1000" \
5438 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005439 -c "x509_verify_cert.*4b00" \
5440 -c "mbedtls_pk_verify.*4b00" \
5441 -c "mbedtls_ecdh_make_public.*4b00" \
5442 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005443
5444requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5445run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5446 "$P_SRV psk=abc123" \
5447 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5448 psk=abc123 debug_level=1 ec_max_ops=1000" \
5449 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005450 -C "x509_verify_cert.*4b00" \
5451 -C "mbedtls_pk_verify.*4b00" \
5452 -C "mbedtls_ecdh_make_public.*4b00" \
5453 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005454
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005455# Tests of asynchronous private key support in SSL
5456
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005457requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005458run_test "SSL async private: sign, delay=0" \
5459 "$P_SRV \
5460 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005461 "$P_CLI" \
5462 0 \
5463 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005464 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005465
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005466requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005467run_test "SSL async private: sign, delay=1" \
5468 "$P_SRV \
5469 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005470 "$P_CLI" \
5471 0 \
5472 -s "Async sign callback: using key slot " \
5473 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005474 -s "Async resume (slot [0-9]): sign done, status=0"
5475
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005476requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5477run_test "SSL async private: sign, delay=2" \
5478 "$P_SRV \
5479 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5480 "$P_CLI" \
5481 0 \
5482 -s "Async sign callback: using key slot " \
5483 -U "Async sign callback: using key slot " \
5484 -s "Async resume (slot [0-9]): call 1 more times." \
5485 -s "Async resume (slot [0-9]): call 0 more times." \
5486 -s "Async resume (slot [0-9]): sign done, status=0"
5487
Gilles Peskined3268832018-04-26 06:23:59 +02005488# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5489# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5490requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5491requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5492run_test "SSL async private: sign, RSA, TLS 1.1" \
5493 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5494 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5495 "$P_CLI force_version=tls1_1" \
5496 0 \
5497 -s "Async sign callback: using key slot " \
5498 -s "Async resume (slot [0-9]): sign done, status=0"
5499
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005500requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005501run_test "SSL async private: sign, SNI" \
5502 "$P_SRV debug_level=3 \
5503 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5504 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5505 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5506 "$P_CLI server_name=polarssl.example" \
5507 0 \
5508 -s "Async sign callback: using key slot " \
5509 -s "Async resume (slot [0-9]): sign done, status=0" \
5510 -s "parse ServerName extension" \
5511 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5512 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5513
5514requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005515run_test "SSL async private: decrypt, delay=0" \
5516 "$P_SRV \
5517 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5518 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5519 0 \
5520 -s "Async decrypt callback: using key slot " \
5521 -s "Async resume (slot [0-9]): decrypt done, status=0"
5522
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005523requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005524run_test "SSL async private: decrypt, delay=1" \
5525 "$P_SRV \
5526 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5527 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5528 0 \
5529 -s "Async decrypt callback: using key slot " \
5530 -s "Async resume (slot [0-9]): call 0 more times." \
5531 -s "Async resume (slot [0-9]): decrypt done, status=0"
5532
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005533requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005534run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5535 "$P_SRV psk=abc123 \
5536 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5537 "$P_CLI psk=abc123 \
5538 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5539 0 \
5540 -s "Async decrypt callback: using key slot " \
5541 -s "Async resume (slot [0-9]): decrypt done, status=0"
5542
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005543requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005544run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5545 "$P_SRV psk=abc123 \
5546 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5547 "$P_CLI psk=abc123 \
5548 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5549 0 \
5550 -s "Async decrypt callback: using key slot " \
5551 -s "Async resume (slot [0-9]): call 0 more times." \
5552 -s "Async resume (slot [0-9]): decrypt done, status=0"
5553
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005554requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005555run_test "SSL async private: sign callback not present" \
5556 "$P_SRV \
5557 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5558 "$P_CLI; [ \$? -eq 1 ] &&
5559 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5560 0 \
5561 -S "Async sign callback" \
5562 -s "! mbedtls_ssl_handshake returned" \
5563 -s "The own private key or pre-shared key is not set, but needed" \
5564 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5565 -s "Successful connection"
5566
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005567requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005568run_test "SSL async private: decrypt callback not present" \
5569 "$P_SRV debug_level=1 \
5570 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5571 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5572 [ \$? -eq 1 ] && $P_CLI" \
5573 0 \
5574 -S "Async decrypt callback" \
5575 -s "! mbedtls_ssl_handshake returned" \
5576 -s "got no RSA private key" \
5577 -s "Async resume (slot [0-9]): sign done, status=0" \
5578 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005579
5580# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005581requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005582run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005583 "$P_SRV \
5584 async_operations=s async_private_delay1=1 \
5585 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5586 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005587 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5588 0 \
5589 -s "Async sign callback: using key slot 0," \
5590 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005591 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005592
5593# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005594requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005595run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005596 "$P_SRV \
5597 async_operations=s async_private_delay2=1 \
5598 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5599 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005600 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5601 0 \
5602 -s "Async sign callback: using key slot 0," \
5603 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005604 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005605
5606# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005607requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005608run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005609 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005610 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005611 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5612 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005613 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5614 0 \
5615 -s "Async sign callback: using key slot 1," \
5616 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005617 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005618
5619# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005620requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005621run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005622 "$P_SRV \
5623 async_operations=s async_private_delay1=1 \
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 Peskine3665f1d2018-01-05 21:22:12 +01005626 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5627 0 \
5628 -s "Async sign callback: no key matches this certificate."
5629
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005630requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005631run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005632 "$P_SRV \
5633 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5634 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005635 "$P_CLI" \
5636 1 \
5637 -s "Async sign callback: injected error" \
5638 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005639 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005640 -s "! mbedtls_ssl_handshake returned"
5641
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005642requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005643run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005644 "$P_SRV \
5645 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5646 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005647 "$P_CLI" \
5648 1 \
5649 -s "Async sign callback: using key slot " \
5650 -S "Async resume" \
5651 -s "Async cancel"
5652
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005653requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005654run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005655 "$P_SRV \
5656 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5657 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005658 "$P_CLI" \
5659 1 \
5660 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005661 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005662 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005663 -s "! mbedtls_ssl_handshake returned"
5664
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005665requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005666run_test "SSL async private: decrypt, error in start" \
5667 "$P_SRV \
5668 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5669 async_private_error=1" \
5670 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5671 1 \
5672 -s "Async decrypt callback: injected error" \
5673 -S "Async resume" \
5674 -S "Async cancel" \
5675 -s "! mbedtls_ssl_handshake returned"
5676
5677requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5678run_test "SSL async private: decrypt, cancel after start" \
5679 "$P_SRV \
5680 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5681 async_private_error=2" \
5682 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5683 1 \
5684 -s "Async decrypt callback: using key slot " \
5685 -S "Async resume" \
5686 -s "Async cancel"
5687
5688requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5689run_test "SSL async private: decrypt, error in resume" \
5690 "$P_SRV \
5691 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5692 async_private_error=3" \
5693 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5694 1 \
5695 -s "Async decrypt callback: using key slot " \
5696 -s "Async resume callback: decrypt done but injected error" \
5697 -S "Async cancel" \
5698 -s "! mbedtls_ssl_handshake returned"
5699
5700requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005701run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005702 "$P_SRV \
5703 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5704 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005705 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5706 0 \
5707 -s "Async cancel" \
5708 -s "! mbedtls_ssl_handshake returned" \
5709 -s "Async resume" \
5710 -s "Successful connection"
5711
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005712requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005713run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005714 "$P_SRV \
5715 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5716 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005717 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5718 0 \
5719 -s "! mbedtls_ssl_handshake returned" \
5720 -s "Async resume" \
5721 -s "Successful connection"
5722
5723# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005724requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005725run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005726 "$P_SRV \
5727 async_operations=s async_private_delay1=1 async_private_error=-2 \
5728 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5729 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005730 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5731 [ \$? -eq 1 ] &&
5732 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5733 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005734 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005735 -S "Async resume" \
5736 -s "Async cancel" \
5737 -s "! mbedtls_ssl_handshake returned" \
5738 -s "Async sign callback: no key matches this certificate." \
5739 -s "Successful connection"
5740
5741# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005742requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005743run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005744 "$P_SRV \
5745 async_operations=s async_private_delay1=1 async_private_error=-3 \
5746 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5747 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005748 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5749 [ \$? -eq 1 ] &&
5750 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5751 0 \
5752 -s "Async resume" \
5753 -s "! mbedtls_ssl_handshake returned" \
5754 -s "Async sign callback: no key matches this certificate." \
5755 -s "Successful connection"
5756
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005757requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005758requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005759run_test "SSL async private: renegotiation: client-initiated; sign" \
5760 "$P_SRV \
5761 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005762 exchanges=2 renegotiation=1" \
5763 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5764 0 \
5765 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005766 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005767
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005768requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005769requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005770run_test "SSL async private: renegotiation: server-initiated; sign" \
5771 "$P_SRV \
5772 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005773 exchanges=2 renegotiation=1 renegotiate=1" \
5774 "$P_CLI exchanges=2 renegotiation=1" \
5775 0 \
5776 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005777 -s "Async resume (slot [0-9]): sign done, status=0"
5778
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005779requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005780requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5781run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5782 "$P_SRV \
5783 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5784 exchanges=2 renegotiation=1" \
5785 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5786 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5787 0 \
5788 -s "Async decrypt callback: using key slot " \
5789 -s "Async resume (slot [0-9]): decrypt done, status=0"
5790
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005791requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005792requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5793run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5794 "$P_SRV \
5795 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5796 exchanges=2 renegotiation=1 renegotiate=1" \
5797 "$P_CLI exchanges=2 renegotiation=1 \
5798 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5799 0 \
5800 -s "Async decrypt callback: using key slot " \
5801 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005802
Ron Eldor58093c82018-06-28 13:22:05 +03005803# Tests for ECC extensions (rfc 4492)
5804
Ron Eldor643df7c2018-06-28 16:17:00 +03005805requires_config_enabled MBEDTLS_AES_C
5806requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5807requires_config_enabled MBEDTLS_SHA256_C
5808requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005809run_test "Force a non ECC ciphersuite in the client side" \
5810 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005811 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005812 0 \
5813 -C "client hello, adding supported_elliptic_curves extension" \
5814 -C "client hello, adding supported_point_formats extension" \
5815 -S "found supported elliptic curves extension" \
5816 -S "found supported point formats extension"
5817
Ron Eldor643df7c2018-06-28 16:17:00 +03005818requires_config_enabled MBEDTLS_AES_C
5819requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5820requires_config_enabled MBEDTLS_SHA256_C
5821requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005822run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005823 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005824 "$P_CLI debug_level=3" \
5825 0 \
5826 -C "found supported_point_formats extension" \
5827 -S "server hello, supported_point_formats extension"
5828
Ron Eldor643df7c2018-06-28 16:17:00 +03005829requires_config_enabled MBEDTLS_AES_C
5830requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5831requires_config_enabled MBEDTLS_SHA256_C
5832requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005833run_test "Force an ECC ciphersuite in the client side" \
5834 "$P_SRV debug_level=3" \
5835 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5836 0 \
5837 -c "client hello, adding supported_elliptic_curves extension" \
5838 -c "client hello, adding supported_point_formats extension" \
5839 -s "found supported elliptic curves extension" \
5840 -s "found supported point formats extension"
5841
Ron Eldor643df7c2018-06-28 16:17:00 +03005842requires_config_enabled MBEDTLS_AES_C
5843requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5844requires_config_enabled MBEDTLS_SHA256_C
5845requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005846run_test "Force an ECC ciphersuite in the server side" \
5847 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5848 "$P_CLI debug_level=3" \
5849 0 \
5850 -c "found supported_point_formats extension" \
5851 -s "server hello, supported_point_formats extension"
5852
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005853# Tests for DTLS HelloVerifyRequest
5854
5855run_test "DTLS cookie: enabled" \
5856 "$P_SRV dtls=1 debug_level=2" \
5857 "$P_CLI dtls=1 debug_level=2" \
5858 0 \
5859 -s "cookie verification failed" \
5860 -s "cookie verification passed" \
5861 -S "cookie verification skipped" \
5862 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005863 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005864 -S "SSL - The requested feature is not available"
5865
5866run_test "DTLS cookie: disabled" \
5867 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5868 "$P_CLI dtls=1 debug_level=2" \
5869 0 \
5870 -S "cookie verification failed" \
5871 -S "cookie verification passed" \
5872 -s "cookie verification skipped" \
5873 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005874 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005875 -S "SSL - The requested feature is not available"
5876
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005877run_test "DTLS cookie: default (failing)" \
5878 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5879 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5880 1 \
5881 -s "cookie verification failed" \
5882 -S "cookie verification passed" \
5883 -S "cookie verification skipped" \
5884 -C "received hello verify request" \
5885 -S "hello verification requested" \
5886 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005887
5888requires_ipv6
5889run_test "DTLS cookie: enabled, IPv6" \
5890 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5891 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5892 0 \
5893 -s "cookie verification failed" \
5894 -s "cookie verification passed" \
5895 -S "cookie verification skipped" \
5896 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005897 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005898 -S "SSL - The requested feature is not available"
5899
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005900run_test "DTLS cookie: enabled, nbio" \
5901 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5902 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5903 0 \
5904 -s "cookie verification failed" \
5905 -s "cookie verification passed" \
5906 -S "cookie verification skipped" \
5907 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005908 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005909 -S "SSL - The requested feature is not available"
5910
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005911# Tests for client reconnecting from the same port with DTLS
5912
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005913not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005914run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005915 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5916 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005917 0 \
5918 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005919 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005920 -S "Client initiated reconnection from same port"
5921
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005922not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005923run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005924 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5925 "$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 +02005926 0 \
5927 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005928 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005929 -s "Client initiated reconnection from same port"
5930
Paul Bakker362689d2016-05-13 10:33:25 +01005931not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5932run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005933 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5934 "$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 +02005935 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005936 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005937 -s "Client initiated reconnection from same port"
5938
Paul Bakker362689d2016-05-13 10:33:25 +01005939only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5940run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5941 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5942 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5943 0 \
5944 -S "The operation timed out" \
5945 -s "Client initiated reconnection from same port"
5946
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005947run_test "DTLS client reconnect from same port: no cookies" \
5948 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005949 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5950 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005951 -s "The operation timed out" \
5952 -S "Client initiated reconnection from same port"
5953
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005954run_test "DTLS client reconnect from same port: attacker-injected" \
5955 -p "$P_PXY inject_clihlo=1" \
5956 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5957 "$P_CLI dtls=1 exchanges=2" \
5958 0 \
5959 -s "possible client reconnect from the same port" \
5960 -S "Client initiated reconnection from same port"
5961
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005962# Tests for various cases of client authentication with DTLS
5963# (focused on handshake flows and message parsing)
5964
5965run_test "DTLS client auth: required" \
5966 "$P_SRV dtls=1 auth_mode=required" \
5967 "$P_CLI dtls=1" \
5968 0 \
5969 -s "Verifying peer X.509 certificate... ok"
5970
5971run_test "DTLS client auth: optional, client has no cert" \
5972 "$P_SRV dtls=1 auth_mode=optional" \
5973 "$P_CLI dtls=1 crt_file=none key_file=none" \
5974 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005975 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005976
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005977run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005978 "$P_SRV dtls=1 auth_mode=none" \
5979 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5980 0 \
5981 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005982 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005983
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005984run_test "DTLS wrong PSK: badmac alert" \
5985 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5986 "$P_CLI dtls=1 psk=abc124" \
5987 1 \
5988 -s "SSL - Verification of the message MAC failed" \
5989 -c "SSL - A fatal alert message was received from our peer"
5990
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005991# Tests for receiving fragmented handshake messages with DTLS
5992
5993requires_gnutls
5994run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5995 "$G_SRV -u --mtu 2048 -a" \
5996 "$P_CLI dtls=1 debug_level=2" \
5997 0 \
5998 -C "found fragmented DTLS handshake message" \
5999 -C "error"
6000
6001requires_gnutls
6002run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6003 "$G_SRV -u --mtu 512" \
6004 "$P_CLI dtls=1 debug_level=2" \
6005 0 \
6006 -c "found fragmented DTLS handshake message" \
6007 -C "error"
6008
6009requires_gnutls
6010run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6011 "$G_SRV -u --mtu 128" \
6012 "$P_CLI dtls=1 debug_level=2" \
6013 0 \
6014 -c "found fragmented DTLS handshake message" \
6015 -C "error"
6016
6017requires_gnutls
6018run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6019 "$G_SRV -u --mtu 128" \
6020 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6021 0 \
6022 -c "found fragmented DTLS handshake message" \
6023 -C "error"
6024
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006025requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006026requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006027run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6028 "$G_SRV -u --mtu 256" \
6029 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6030 0 \
6031 -c "found fragmented DTLS handshake message" \
6032 -c "client hello, adding renegotiation extension" \
6033 -c "found renegotiation extension" \
6034 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006035 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006036 -C "error" \
6037 -s "Extra-header:"
6038
6039requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006040requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006041run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6042 "$G_SRV -u --mtu 256" \
6043 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6044 0 \
6045 -c "found fragmented DTLS handshake message" \
6046 -c "client hello, adding renegotiation extension" \
6047 -c "found renegotiation extension" \
6048 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006049 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006050 -C "error" \
6051 -s "Extra-header:"
6052
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006053run_test "DTLS reassembly: no fragmentation (openssl server)" \
6054 "$O_SRV -dtls1 -mtu 2048" \
6055 "$P_CLI dtls=1 debug_level=2" \
6056 0 \
6057 -C "found fragmented DTLS handshake message" \
6058 -C "error"
6059
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006060run_test "DTLS reassembly: some fragmentation (openssl server)" \
6061 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006062 "$P_CLI dtls=1 debug_level=2" \
6063 0 \
6064 -c "found fragmented DTLS handshake message" \
6065 -C "error"
6066
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006067run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006068 "$O_SRV -dtls1 -mtu 256" \
6069 "$P_CLI dtls=1 debug_level=2" \
6070 0 \
6071 -c "found fragmented DTLS handshake message" \
6072 -C "error"
6073
6074run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6075 "$O_SRV -dtls1 -mtu 256" \
6076 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6077 0 \
6078 -c "found fragmented DTLS handshake message" \
6079 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006080
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006081# Tests for sending fragmented handshake messages with DTLS
6082#
6083# Use client auth when we need the client to send large messages,
6084# and use large cert chains on both sides too (the long chains we have all use
6085# both RSA and ECDSA, but ideally we should have long chains with either).
6086# Sizes reached (UDP payload):
6087# - 2037B for server certificate
6088# - 1542B for client certificate
6089# - 1013B for newsessionticket
6090# - all others below 512B
6091# All those tests assume MAX_CONTENT_LEN is at least 2048
6092
6093requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6094requires_config_enabled MBEDTLS_RSA_C
6095requires_config_enabled MBEDTLS_ECDSA_C
6096requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6097run_test "DTLS fragmenting: none (for reference)" \
6098 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6099 crt_file=data_files/server7_int-ca.crt \
6100 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006101 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006102 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006103 "$P_CLI dtls=1 debug_level=2 \
6104 crt_file=data_files/server8_int-ca2.crt \
6105 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006106 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006107 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006108 0 \
6109 -S "found fragmented DTLS handshake message" \
6110 -C "found fragmented DTLS handshake message" \
6111 -C "error"
6112
6113requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6114requires_config_enabled MBEDTLS_RSA_C
6115requires_config_enabled MBEDTLS_ECDSA_C
6116requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006117run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006118 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6119 crt_file=data_files/server7_int-ca.crt \
6120 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006121 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006122 max_frag_len=1024" \
6123 "$P_CLI dtls=1 debug_level=2 \
6124 crt_file=data_files/server8_int-ca2.crt \
6125 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006126 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006127 max_frag_len=2048" \
6128 0 \
6129 -S "found fragmented DTLS handshake message" \
6130 -c "found fragmented DTLS handshake message" \
6131 -C "error"
6132
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006133# With the MFL extension, the server has no way of forcing
6134# the client to not exceed a certain MTU; hence, the following
6135# test can't be replicated with an MTU proxy such as the one
6136# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006137requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6138requires_config_enabled MBEDTLS_RSA_C
6139requires_config_enabled MBEDTLS_ECDSA_C
6140requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006141run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006142 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6143 crt_file=data_files/server7_int-ca.crt \
6144 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006145 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006146 max_frag_len=512" \
6147 "$P_CLI dtls=1 debug_level=2 \
6148 crt_file=data_files/server8_int-ca2.crt \
6149 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006150 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006151 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006152 0 \
6153 -S "found fragmented DTLS handshake message" \
6154 -c "found fragmented DTLS handshake message" \
6155 -C "error"
6156
6157requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6158requires_config_enabled MBEDTLS_RSA_C
6159requires_config_enabled MBEDTLS_ECDSA_C
6160requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006161run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006162 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6163 crt_file=data_files/server7_int-ca.crt \
6164 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006165 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006166 max_frag_len=2048" \
6167 "$P_CLI dtls=1 debug_level=2 \
6168 crt_file=data_files/server8_int-ca2.crt \
6169 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006170 hs_timeout=2500-60000 \
6171 max_frag_len=1024" \
6172 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006173 -S "found fragmented DTLS handshake message" \
6174 -c "found fragmented DTLS handshake message" \
6175 -C "error"
6176
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006177# While not required by the standard defining the MFL extension
6178# (according to which it only applies to records, not to datagrams),
6179# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6180# as otherwise there wouldn't be any means to communicate MTU restrictions
6181# to the peer.
6182# The next test checks that no datagrams significantly larger than the
6183# negotiated MFL are sent.
6184requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6185requires_config_enabled MBEDTLS_RSA_C
6186requires_config_enabled MBEDTLS_ECDSA_C
6187requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6188run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006189 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006190 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6191 crt_file=data_files/server7_int-ca.crt \
6192 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006193 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006194 max_frag_len=2048" \
6195 "$P_CLI dtls=1 debug_level=2 \
6196 crt_file=data_files/server8_int-ca2.crt \
6197 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006198 hs_timeout=2500-60000 \
6199 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006200 0 \
6201 -S "found fragmented DTLS handshake message" \
6202 -c "found fragmented DTLS handshake message" \
6203 -C "error"
6204
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006205requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6206requires_config_enabled MBEDTLS_RSA_C
6207requires_config_enabled MBEDTLS_ECDSA_C
6208requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006209run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006210 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6211 crt_file=data_files/server7_int-ca.crt \
6212 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006213 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006214 max_frag_len=2048" \
6215 "$P_CLI dtls=1 debug_level=2 \
6216 crt_file=data_files/server8_int-ca2.crt \
6217 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006218 hs_timeout=2500-60000 \
6219 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006220 0 \
6221 -s "found fragmented DTLS handshake message" \
6222 -c "found fragmented DTLS handshake message" \
6223 -C "error"
6224
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006225# While not required by the standard defining the MFL extension
6226# (according to which it only applies to records, not to datagrams),
6227# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6228# as otherwise there wouldn't be any means to communicate MTU restrictions
6229# to the peer.
6230# The next test checks that no datagrams significantly larger than the
6231# negotiated MFL are sent.
6232requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6233requires_config_enabled MBEDTLS_RSA_C
6234requires_config_enabled MBEDTLS_ECDSA_C
6235requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6236run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006237 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006238 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6239 crt_file=data_files/server7_int-ca.crt \
6240 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006241 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006242 max_frag_len=2048" \
6243 "$P_CLI dtls=1 debug_level=2 \
6244 crt_file=data_files/server8_int-ca2.crt \
6245 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006246 hs_timeout=2500-60000 \
6247 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006248 0 \
6249 -s "found fragmented DTLS handshake message" \
6250 -c "found fragmented DTLS handshake message" \
6251 -C "error"
6252
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006253requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6254requires_config_enabled MBEDTLS_RSA_C
6255requires_config_enabled MBEDTLS_ECDSA_C
6256run_test "DTLS fragmenting: none (for reference) (MTU)" \
6257 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6258 crt_file=data_files/server7_int-ca.crt \
6259 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006260 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006261 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006262 "$P_CLI dtls=1 debug_level=2 \
6263 crt_file=data_files/server8_int-ca2.crt \
6264 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006265 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006266 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006267 0 \
6268 -S "found fragmented DTLS handshake message" \
6269 -C "found fragmented DTLS handshake message" \
6270 -C "error"
6271
6272requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6273requires_config_enabled MBEDTLS_RSA_C
6274requires_config_enabled MBEDTLS_ECDSA_C
6275run_test "DTLS fragmenting: client (MTU)" \
6276 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6277 crt_file=data_files/server7_int-ca.crt \
6278 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006279 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006280 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006281 "$P_CLI dtls=1 debug_level=2 \
6282 crt_file=data_files/server8_int-ca2.crt \
6283 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006284 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006285 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006286 0 \
6287 -s "found fragmented DTLS handshake message" \
6288 -C "found fragmented DTLS handshake message" \
6289 -C "error"
6290
6291requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6292requires_config_enabled MBEDTLS_RSA_C
6293requires_config_enabled MBEDTLS_ECDSA_C
6294run_test "DTLS fragmenting: server (MTU)" \
6295 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6296 crt_file=data_files/server7_int-ca.crt \
6297 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006298 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006299 mtu=512" \
6300 "$P_CLI dtls=1 debug_level=2 \
6301 crt_file=data_files/server8_int-ca2.crt \
6302 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006303 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006304 mtu=2048" \
6305 0 \
6306 -S "found fragmented DTLS handshake message" \
6307 -c "found fragmented DTLS handshake message" \
6308 -C "error"
6309
6310requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6311requires_config_enabled MBEDTLS_RSA_C
6312requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006313run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006314 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006315 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6316 crt_file=data_files/server7_int-ca.crt \
6317 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006318 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006319 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006320 "$P_CLI dtls=1 debug_level=2 \
6321 crt_file=data_files/server8_int-ca2.crt \
6322 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006323 hs_timeout=2500-60000 \
6324 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006325 0 \
6326 -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 -04006331requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6332requires_config_enabled MBEDTLS_RSA_C
6333requires_config_enabled MBEDTLS_ECDSA_C
6334requires_config_enabled MBEDTLS_SHA256_C
6335requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6336requires_config_enabled MBEDTLS_AES_C
6337requires_config_enabled MBEDTLS_GCM_C
6338run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006339 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006340 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6341 crt_file=data_files/server7_int-ca.crt \
6342 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006343 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006344 mtu=512" \
6345 "$P_CLI dtls=1 debug_level=2 \
6346 crt_file=data_files/server8_int-ca2.crt \
6347 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006348 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6349 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006350 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006351 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006352 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006353 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006354 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006355
Andrzej Kurek7311c782018-10-11 06:49:41 -04006356# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006357# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006358# The ratio of max/min timeout should ideally equal 4 to accept two
6359# retransmissions, but in some cases (like both the server and client using
6360# fragmentation and auto-reduction) an extra retransmission might occur,
6361# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006362not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6364requires_config_enabled MBEDTLS_RSA_C
6365requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006366requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6367requires_config_enabled MBEDTLS_AES_C
6368requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006369run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6370 -p "$P_PXY mtu=508" \
6371 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6372 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006373 key_file=data_files/server7.key \
6374 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006375 "$P_CLI dtls=1 debug_level=2 \
6376 crt_file=data_files/server8_int-ca2.crt \
6377 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006378 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6379 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006380 0 \
6381 -s "found fragmented DTLS handshake message" \
6382 -c "found fragmented DTLS handshake message" \
6383 -C "error"
6384
Andrzej Kurek77826052018-10-11 07:34:08 -04006385# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006386only_with_valgrind
6387requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6388requires_config_enabled MBEDTLS_RSA_C
6389requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006390requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6391requires_config_enabled MBEDTLS_AES_C
6392requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006393run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6394 -p "$P_PXY mtu=508" \
6395 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6396 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006397 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006398 hs_timeout=250-10000" \
6399 "$P_CLI dtls=1 debug_level=2 \
6400 crt_file=data_files/server8_int-ca2.crt \
6401 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006402 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006403 hs_timeout=250-10000" \
6404 0 \
6405 -s "found fragmented DTLS handshake message" \
6406 -c "found fragmented DTLS handshake message" \
6407 -C "error"
6408
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006409# 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 +02006410# OTOH the client might resend if the server is to slow to reset after sending
6411# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006412not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006413requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6414requires_config_enabled MBEDTLS_RSA_C
6415requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006416run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006417 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006418 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6419 crt_file=data_files/server7_int-ca.crt \
6420 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006421 hs_timeout=10000-60000 \
6422 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006423 "$P_CLI dtls=1 debug_level=2 \
6424 crt_file=data_files/server8_int-ca2.crt \
6425 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006426 hs_timeout=10000-60000 \
6427 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006428 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006429 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006430 -s "found fragmented DTLS handshake message" \
6431 -c "found fragmented DTLS handshake message" \
6432 -C "error"
6433
Andrzej Kurek77826052018-10-11 07:34:08 -04006434# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006435# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6436# OTOH the client might resend if the server is to slow to reset after sending
6437# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006438not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006439requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6440requires_config_enabled MBEDTLS_RSA_C
6441requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006442requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6443requires_config_enabled MBEDTLS_AES_C
6444requires_config_enabled MBEDTLS_GCM_C
6445run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006446 -p "$P_PXY mtu=512" \
6447 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6448 crt_file=data_files/server7_int-ca.crt \
6449 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006450 hs_timeout=10000-60000 \
6451 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006452 "$P_CLI dtls=1 debug_level=2 \
6453 crt_file=data_files/server8_int-ca2.crt \
6454 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006455 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6456 hs_timeout=10000-60000 \
6457 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006458 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006459 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006460 -s "found fragmented DTLS handshake message" \
6461 -c "found fragmented DTLS handshake message" \
6462 -C "error"
6463
Andrzej Kurek7311c782018-10-11 06:49:41 -04006464not_with_valgrind # spurious autoreduction due to timeout
6465requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6466requires_config_enabled MBEDTLS_RSA_C
6467requires_config_enabled MBEDTLS_ECDSA_C
6468run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006469 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006470 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6471 crt_file=data_files/server7_int-ca.crt \
6472 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006473 hs_timeout=10000-60000 \
6474 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006475 "$P_CLI dtls=1 debug_level=2 \
6476 crt_file=data_files/server8_int-ca2.crt \
6477 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006478 hs_timeout=10000-60000 \
6479 mtu=1024 nbio=2" \
6480 0 \
6481 -S "autoreduction" \
6482 -s "found fragmented DTLS handshake message" \
6483 -c "found fragmented DTLS handshake message" \
6484 -C "error"
6485
Andrzej Kurek77826052018-10-11 07:34:08 -04006486# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006487not_with_valgrind # spurious autoreduction due to timeout
6488requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6489requires_config_enabled MBEDTLS_RSA_C
6490requires_config_enabled MBEDTLS_ECDSA_C
6491requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6492requires_config_enabled MBEDTLS_AES_C
6493requires_config_enabled MBEDTLS_GCM_C
6494run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6495 -p "$P_PXY mtu=512" \
6496 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6497 crt_file=data_files/server7_int-ca.crt \
6498 key_file=data_files/server7.key \
6499 hs_timeout=10000-60000 \
6500 mtu=512 nbio=2" \
6501 "$P_CLI dtls=1 debug_level=2 \
6502 crt_file=data_files/server8_int-ca2.crt \
6503 key_file=data_files/server8.key \
6504 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6505 hs_timeout=10000-60000 \
6506 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006507 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006508 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006509 -s "found fragmented DTLS handshake message" \
6510 -c "found fragmented DTLS handshake message" \
6511 -C "error"
6512
Andrzej Kurek77826052018-10-11 07:34:08 -04006513# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006514# This ensures things still work after session_reset().
6515# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006516# Since we don't support reading fragmented ClientHello yet,
6517# up the MTU to 1450 (larger than ClientHello with session ticket,
6518# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006519# An autoreduction on the client-side might happen if the server is
6520# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006521# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006522# resumed listening, which would result in a spurious autoreduction.
6523not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006524requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6525requires_config_enabled MBEDTLS_RSA_C
6526requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006527requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6528requires_config_enabled MBEDTLS_AES_C
6529requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006530run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6531 -p "$P_PXY mtu=1450" \
6532 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6533 crt_file=data_files/server7_int-ca.crt \
6534 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006535 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006536 mtu=1450" \
6537 "$P_CLI dtls=1 debug_level=2 \
6538 crt_file=data_files/server8_int-ca2.crt \
6539 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006540 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006541 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006542 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006543 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006544 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006545 -s "found fragmented DTLS handshake message" \
6546 -c "found fragmented DTLS handshake message" \
6547 -C "error"
6548
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006549# An autoreduction on the client-side might happen if the server is
6550# slow to reset, therefore omitting '-C "autoreduction"' below.
6551not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006552requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6553requires_config_enabled MBEDTLS_RSA_C
6554requires_config_enabled MBEDTLS_ECDSA_C
6555requires_config_enabled MBEDTLS_SHA256_C
6556requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6557requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6558requires_config_enabled MBEDTLS_CHACHAPOLY_C
6559run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6560 -p "$P_PXY mtu=512" \
6561 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6562 crt_file=data_files/server7_int-ca.crt \
6563 key_file=data_files/server7.key \
6564 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006565 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006566 mtu=512" \
6567 "$P_CLI dtls=1 debug_level=2 \
6568 crt_file=data_files/server8_int-ca2.crt \
6569 key_file=data_files/server8.key \
6570 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006571 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006572 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006573 mtu=512" \
6574 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006575 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006576 -s "found fragmented DTLS handshake message" \
6577 -c "found fragmented DTLS handshake message" \
6578 -C "error"
6579
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006580# An autoreduction on the client-side might happen if the server is
6581# slow to reset, therefore omitting '-C "autoreduction"' below.
6582not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006583requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6584requires_config_enabled MBEDTLS_RSA_C
6585requires_config_enabled MBEDTLS_ECDSA_C
6586requires_config_enabled MBEDTLS_SHA256_C
6587requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6588requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6589requires_config_enabled MBEDTLS_AES_C
6590requires_config_enabled MBEDTLS_GCM_C
6591run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6592 -p "$P_PXY mtu=512" \
6593 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6594 crt_file=data_files/server7_int-ca.crt \
6595 key_file=data_files/server7.key \
6596 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006597 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006598 mtu=512" \
6599 "$P_CLI dtls=1 debug_level=2 \
6600 crt_file=data_files/server8_int-ca2.crt \
6601 key_file=data_files/server8.key \
6602 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006603 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006604 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006605 mtu=512" \
6606 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006607 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006608 -s "found fragmented DTLS handshake message" \
6609 -c "found fragmented DTLS handshake message" \
6610 -C "error"
6611
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006612# An autoreduction on the client-side might happen if the server is
6613# slow to reset, therefore omitting '-C "autoreduction"' below.
6614not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006615requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6616requires_config_enabled MBEDTLS_RSA_C
6617requires_config_enabled MBEDTLS_ECDSA_C
6618requires_config_enabled MBEDTLS_SHA256_C
6619requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6620requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6621requires_config_enabled MBEDTLS_AES_C
6622requires_config_enabled MBEDTLS_CCM_C
6623run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006624 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006625 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6626 crt_file=data_files/server7_int-ca.crt \
6627 key_file=data_files/server7.key \
6628 exchanges=2 renegotiation=1 \
6629 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006630 hs_timeout=10000-60000 \
6631 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006632 "$P_CLI dtls=1 debug_level=2 \
6633 crt_file=data_files/server8_int-ca2.crt \
6634 key_file=data_files/server8.key \
6635 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006636 hs_timeout=10000-60000 \
6637 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006638 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006639 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006640 -s "found fragmented DTLS handshake message" \
6641 -c "found fragmented DTLS handshake message" \
6642 -C "error"
6643
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006644# An autoreduction on the client-side might happen if the server is
6645# slow to reset, therefore omitting '-C "autoreduction"' below.
6646not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006647requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6648requires_config_enabled MBEDTLS_RSA_C
6649requires_config_enabled MBEDTLS_ECDSA_C
6650requires_config_enabled MBEDTLS_SHA256_C
6651requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6652requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6653requires_config_enabled MBEDTLS_AES_C
6654requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6655requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6656run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006657 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006658 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6659 crt_file=data_files/server7_int-ca.crt \
6660 key_file=data_files/server7.key \
6661 exchanges=2 renegotiation=1 \
6662 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006663 hs_timeout=10000-60000 \
6664 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006665 "$P_CLI dtls=1 debug_level=2 \
6666 crt_file=data_files/server8_int-ca2.crt \
6667 key_file=data_files/server8.key \
6668 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006669 hs_timeout=10000-60000 \
6670 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006671 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006672 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006673 -s "found fragmented DTLS handshake message" \
6674 -c "found fragmented DTLS handshake message" \
6675 -C "error"
6676
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006677# An autoreduction on the client-side might happen if the server is
6678# slow to reset, therefore omitting '-C "autoreduction"' below.
6679not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006680requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6681requires_config_enabled MBEDTLS_RSA_C
6682requires_config_enabled MBEDTLS_ECDSA_C
6683requires_config_enabled MBEDTLS_SHA256_C
6684requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6685requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6686requires_config_enabled MBEDTLS_AES_C
6687requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6688run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006689 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006690 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6691 crt_file=data_files/server7_int-ca.crt \
6692 key_file=data_files/server7.key \
6693 exchanges=2 renegotiation=1 \
6694 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006695 hs_timeout=10000-60000 \
6696 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006697 "$P_CLI dtls=1 debug_level=2 \
6698 crt_file=data_files/server8_int-ca2.crt \
6699 key_file=data_files/server8.key \
6700 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006701 hs_timeout=10000-60000 \
6702 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006703 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006704 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006705 -s "found fragmented DTLS handshake message" \
6706 -c "found fragmented DTLS handshake message" \
6707 -C "error"
6708
Andrzej Kurek77826052018-10-11 07:34:08 -04006709# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006710requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6711requires_config_enabled MBEDTLS_RSA_C
6712requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006713requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6714requires_config_enabled MBEDTLS_AES_C
6715requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006716client_needs_more_time 2
6717run_test "DTLS fragmenting: proxy MTU + 3d" \
6718 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006719 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006720 crt_file=data_files/server7_int-ca.crt \
6721 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006722 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006723 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006724 crt_file=data_files/server8_int-ca2.crt \
6725 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006726 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006727 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006728 0 \
6729 -s "found fragmented DTLS handshake message" \
6730 -c "found fragmented DTLS handshake message" \
6731 -C "error"
6732
Andrzej Kurek77826052018-10-11 07:34:08 -04006733# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006734requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6735requires_config_enabled MBEDTLS_RSA_C
6736requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006737requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6738requires_config_enabled MBEDTLS_AES_C
6739requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006740client_needs_more_time 2
6741run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6742 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6743 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6744 crt_file=data_files/server7_int-ca.crt \
6745 key_file=data_files/server7.key \
6746 hs_timeout=250-10000 mtu=512 nbio=2" \
6747 "$P_CLI dtls=1 debug_level=2 \
6748 crt_file=data_files/server8_int-ca2.crt \
6749 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006750 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006751 hs_timeout=250-10000 mtu=512 nbio=2" \
6752 0 \
6753 -s "found fragmented DTLS handshake message" \
6754 -c "found fragmented DTLS handshake message" \
6755 -C "error"
6756
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006757# interop tests for DTLS fragmentating with reliable connection
6758#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006759# here and below we just want to test that the we fragment in a way that
6760# pleases other implementations, so we don't need the peer to fragment
6761requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6762requires_config_enabled MBEDTLS_RSA_C
6763requires_config_enabled MBEDTLS_ECDSA_C
6764requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006765requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006766run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6767 "$G_SRV -u" \
6768 "$P_CLI dtls=1 debug_level=2 \
6769 crt_file=data_files/server8_int-ca2.crt \
6770 key_file=data_files/server8.key \
6771 mtu=512 force_version=dtls1_2" \
6772 0 \
6773 -c "fragmenting handshake message" \
6774 -C "error"
6775
6776requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6777requires_config_enabled MBEDTLS_RSA_C
6778requires_config_enabled MBEDTLS_ECDSA_C
6779requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006780requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006781run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6782 "$G_SRV -u" \
6783 "$P_CLI dtls=1 debug_level=2 \
6784 crt_file=data_files/server8_int-ca2.crt \
6785 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006786 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006787 0 \
6788 -c "fragmenting handshake message" \
6789 -C "error"
6790
Hanno Beckerb9a00862018-08-28 10:20:22 +01006791# We use --insecure for the GnuTLS client because it expects
6792# the hostname / IP it connects to to be the name used in the
6793# certificate obtained from the server. Here, however, it
6794# connects to 127.0.0.1 while our test certificates use 'localhost'
6795# as the server name in the certificate. This will make the
6796# certifiate validation fail, but passing --insecure makes
6797# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006798requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6799requires_config_enabled MBEDTLS_RSA_C
6800requires_config_enabled MBEDTLS_ECDSA_C
6801requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006802requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006803requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006804run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006805 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006806 crt_file=data_files/server7_int-ca.crt \
6807 key_file=data_files/server7.key \
6808 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006809 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006810 0 \
6811 -s "fragmenting handshake message"
6812
Hanno Beckerb9a00862018-08-28 10:20:22 +01006813# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006814requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6815requires_config_enabled MBEDTLS_RSA_C
6816requires_config_enabled MBEDTLS_ECDSA_C
6817requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006818requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006819requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006820run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006821 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006822 crt_file=data_files/server7_int-ca.crt \
6823 key_file=data_files/server7.key \
6824 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006825 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006826 0 \
6827 -s "fragmenting handshake message"
6828
6829requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6830requires_config_enabled MBEDTLS_RSA_C
6831requires_config_enabled MBEDTLS_ECDSA_C
6832requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6833run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6834 "$O_SRV -dtls1_2 -verify 10" \
6835 "$P_CLI dtls=1 debug_level=2 \
6836 crt_file=data_files/server8_int-ca2.crt \
6837 key_file=data_files/server8.key \
6838 mtu=512 force_version=dtls1_2" \
6839 0 \
6840 -c "fragmenting handshake message" \
6841 -C "error"
6842
6843requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6844requires_config_enabled MBEDTLS_RSA_C
6845requires_config_enabled MBEDTLS_ECDSA_C
6846requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6847run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6848 "$O_SRV -dtls1 -verify 10" \
6849 "$P_CLI dtls=1 debug_level=2 \
6850 crt_file=data_files/server8_int-ca2.crt \
6851 key_file=data_files/server8.key \
6852 mtu=512 force_version=dtls1" \
6853 0 \
6854 -c "fragmenting handshake message" \
6855 -C "error"
6856
6857requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6858requires_config_enabled MBEDTLS_RSA_C
6859requires_config_enabled MBEDTLS_ECDSA_C
6860requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6861run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6862 "$P_SRV dtls=1 debug_level=2 \
6863 crt_file=data_files/server7_int-ca.crt \
6864 key_file=data_files/server7.key \
6865 mtu=512 force_version=dtls1_2" \
6866 "$O_CLI -dtls1_2" \
6867 0 \
6868 -s "fragmenting handshake message"
6869
6870requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6871requires_config_enabled MBEDTLS_RSA_C
6872requires_config_enabled MBEDTLS_ECDSA_C
6873requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6874run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6875 "$P_SRV dtls=1 debug_level=2 \
6876 crt_file=data_files/server7_int-ca.crt \
6877 key_file=data_files/server7.key \
6878 mtu=512 force_version=dtls1" \
6879 "$O_CLI -dtls1" \
6880 0 \
6881 -s "fragmenting handshake message"
6882
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006883# interop tests for DTLS fragmentating with unreliable connection
6884#
6885# again we just want to test that the we fragment in a way that
6886# pleases other implementations, so we don't need the peer to fragment
6887requires_gnutls_next
6888requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6889requires_config_enabled MBEDTLS_RSA_C
6890requires_config_enabled MBEDTLS_ECDSA_C
6891requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006892client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006893run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6894 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6895 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006896 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006897 crt_file=data_files/server8_int-ca2.crt \
6898 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006899 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006900 0 \
6901 -c "fragmenting handshake message" \
6902 -C "error"
6903
6904requires_gnutls_next
6905requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6906requires_config_enabled MBEDTLS_RSA_C
6907requires_config_enabled MBEDTLS_ECDSA_C
6908requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006909client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006910run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6911 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6912 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006913 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006914 crt_file=data_files/server8_int-ca2.crt \
6915 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006916 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006917 0 \
6918 -c "fragmenting handshake message" \
6919 -C "error"
6920
k-stachowiakabb843e2019-02-18 16:14:03 +01006921requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006922requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6923requires_config_enabled MBEDTLS_RSA_C
6924requires_config_enabled MBEDTLS_ECDSA_C
6925requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6926client_needs_more_time 4
6927run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6928 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6929 "$P_SRV dtls=1 debug_level=2 \
6930 crt_file=data_files/server7_int-ca.crt \
6931 key_file=data_files/server7.key \
6932 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006933 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006934 0 \
6935 -s "fragmenting handshake message"
6936
k-stachowiakabb843e2019-02-18 16:14:03 +01006937requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006938requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6939requires_config_enabled MBEDTLS_RSA_C
6940requires_config_enabled MBEDTLS_ECDSA_C
6941requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6942client_needs_more_time 4
6943run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6944 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6945 "$P_SRV dtls=1 debug_level=2 \
6946 crt_file=data_files/server7_int-ca.crt \
6947 key_file=data_files/server7.key \
6948 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006949 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006950 0 \
6951 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006952
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006953## Interop test with OpenSSL might trigger a bug in recent versions (including
6954## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006955## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006956## They should be re-enabled once a fixed version of OpenSSL is available
6957## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006958skip_next_test
6959requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6960requires_config_enabled MBEDTLS_RSA_C
6961requires_config_enabled MBEDTLS_ECDSA_C
6962requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6963client_needs_more_time 4
6964run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6965 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6966 "$O_SRV -dtls1_2 -verify 10" \
6967 "$P_CLI dtls=1 debug_level=2 \
6968 crt_file=data_files/server8_int-ca2.crt \
6969 key_file=data_files/server8.key \
6970 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6971 0 \
6972 -c "fragmenting handshake message" \
6973 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006974
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006975skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006976requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6977requires_config_enabled MBEDTLS_RSA_C
6978requires_config_enabled MBEDTLS_ECDSA_C
6979requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006980client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006981run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6982 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006983 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006984 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006985 crt_file=data_files/server8_int-ca2.crt \
6986 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006987 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006988 0 \
6989 -c "fragmenting handshake message" \
6990 -C "error"
6991
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006992skip_next_test
6993requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6994requires_config_enabled MBEDTLS_RSA_C
6995requires_config_enabled MBEDTLS_ECDSA_C
6996requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6997client_needs_more_time 4
6998run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6999 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7000 "$P_SRV dtls=1 debug_level=2 \
7001 crt_file=data_files/server7_int-ca.crt \
7002 key_file=data_files/server7.key \
7003 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7004 "$O_CLI -dtls1_2" \
7005 0 \
7006 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007007
7008# -nbio is added to prevent s_client from blocking in case of duplicated
7009# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007010skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007011requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7012requires_config_enabled MBEDTLS_RSA_C
7013requires_config_enabled MBEDTLS_ECDSA_C
7014requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007015client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007016run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7017 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007018 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007019 crt_file=data_files/server7_int-ca.crt \
7020 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007021 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007022 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007023 0 \
7024 -s "fragmenting handshake message"
7025
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007026# Tests for specific things with "unreliable" UDP connection
7027
7028not_with_valgrind # spurious resend due to timeout
7029run_test "DTLS proxy: reference" \
7030 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007031 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7032 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007033 0 \
7034 -C "replayed record" \
7035 -S "replayed record" \
7036 -C "record from another epoch" \
7037 -S "record from another epoch" \
7038 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007039 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007040 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007041 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007042 -c "HTTP/1.0 200 OK"
7043
7044not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007045run_test "DTLS proxy: duplicate every packet" \
7046 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007047 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7048 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007049 0 \
7050 -c "replayed record" \
7051 -s "replayed record" \
7052 -c "record from another epoch" \
7053 -s "record from another epoch" \
7054 -S "resend" \
7055 -s "Extra-header:" \
7056 -c "HTTP/1.0 200 OK"
7057
7058run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7059 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007060 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7061 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007062 0 \
7063 -c "replayed record" \
7064 -S "replayed record" \
7065 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007066 -s "record from another epoch" \
7067 -c "resend" \
7068 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007069 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007070 -c "HTTP/1.0 200 OK"
7071
7072run_test "DTLS proxy: multiple records in same datagram" \
7073 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007074 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7075 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007076 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007077 -c "next record in same datagram" \
7078 -s "next record in same datagram"
7079
7080run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7081 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007082 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7083 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007084 0 \
7085 -c "next record in same datagram" \
7086 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007087
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007088run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7089 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007090 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7091 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007092 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007093 -c "discarding invalid record (mac)" \
7094 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007095 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007096 -c "HTTP/1.0 200 OK" \
7097 -S "too many records with bad MAC" \
7098 -S "Verification of the message MAC failed"
7099
7100run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7101 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007102 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7103 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007104 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007105 -C "discarding invalid record (mac)" \
7106 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007107 -S "Extra-header:" \
7108 -C "HTTP/1.0 200 OK" \
7109 -s "too many records with bad MAC" \
7110 -s "Verification of the message MAC failed"
7111
7112run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7113 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007114 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7115 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007116 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007117 -c "discarding invalid record (mac)" \
7118 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007119 -s "Extra-header:" \
7120 -c "HTTP/1.0 200 OK" \
7121 -S "too many records with bad MAC" \
7122 -S "Verification of the message MAC failed"
7123
7124run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7125 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007126 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7127 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007128 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007129 -c "discarding invalid record (mac)" \
7130 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007131 -s "Extra-header:" \
7132 -c "HTTP/1.0 200 OK" \
7133 -s "too many records with bad MAC" \
7134 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007135
7136run_test "DTLS proxy: delay ChangeCipherSpec" \
7137 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007138 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7139 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007140 0 \
7141 -c "record from another epoch" \
7142 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007143 -s "Extra-header:" \
7144 -c "HTTP/1.0 200 OK"
7145
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007146# Tests for reordering support with DTLS
7147
Hanno Becker56cdfd12018-08-17 13:42:15 +01007148run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7149 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007150 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7151 hs_timeout=2500-60000" \
7152 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7153 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007154 0 \
7155 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007156 -c "Next handshake message has been buffered - load"\
7157 -S "Buffering HS message" \
7158 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007159 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007160 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007161 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007162 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007163
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007164run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7165 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007166 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7167 hs_timeout=2500-60000" \
7168 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7169 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007170 0 \
7171 -c "Buffering HS message" \
7172 -c "found fragmented DTLS handshake message"\
7173 -c "Next handshake message 1 not or only partially bufffered" \
7174 -c "Next handshake message has been buffered - load"\
7175 -S "Buffering HS message" \
7176 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007177 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007178 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007179 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007180 -S "Remember CCS message"
7181
Hanno Beckera1adcca2018-08-24 14:41:07 +01007182# The client buffers the ServerKeyExchange before receiving the fragmented
7183# Certificate message; at the time of writing, together these are aroudn 1200b
7184# in size, so that the bound below ensures that the certificate can be reassembled
7185# while keeping the ServerKeyExchange.
7186requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7187run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007188 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007189 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7190 hs_timeout=2500-60000" \
7191 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7192 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007193 0 \
7194 -c "Buffering HS message" \
7195 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007196 -C "attempt to make space by freeing buffered messages" \
7197 -S "Buffering HS message" \
7198 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007199 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007200 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007201 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007202 -S "Remember CCS message"
7203
7204# The size constraints ensure that the delayed certificate message can't
7205# be reassembled while keeping the ServerKeyExchange message, but it can
7206# when dropping it first.
7207requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7208requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7209run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7210 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007211 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7212 hs_timeout=2500-60000" \
7213 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7214 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007215 0 \
7216 -c "Buffering HS message" \
7217 -c "attempt to make space by freeing buffered future messages" \
7218 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007219 -S "Buffering HS message" \
7220 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007221 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007222 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007223 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007224 -S "Remember CCS message"
7225
Hanno Becker56cdfd12018-08-17 13:42:15 +01007226run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7227 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007228 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7229 hs_timeout=2500-60000" \
7230 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7231 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007232 0 \
7233 -C "Buffering HS message" \
7234 -C "Next handshake message has been buffered - load"\
7235 -s "Buffering HS message" \
7236 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007237 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007238 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007239 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007240 -S "Remember CCS message"
7241
7242run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7243 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007244 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7245 hs_timeout=2500-60000" \
7246 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7247 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007248 0 \
7249 -C "Buffering HS message" \
7250 -C "Next handshake message has been buffered - load"\
7251 -S "Buffering HS message" \
7252 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007253 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007254 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007255 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007256 -S "Remember CCS message"
7257
7258run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7259 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007260 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7261 hs_timeout=2500-60000" \
7262 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7263 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007264 0 \
7265 -C "Buffering HS message" \
7266 -C "Next handshake message has been buffered - load"\
7267 -S "Buffering HS message" \
7268 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007269 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007270 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007271 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007272 -s "Remember CCS message"
7273
Hanno Beckera1adcca2018-08-24 14:41:07 +01007274run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007275 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007276 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7277 hs_timeout=2500-60000" \
7278 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7279 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007280 0 \
7281 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007282 -s "Found buffered record from current epoch - load" \
7283 -c "Buffer record from epoch 1" \
7284 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007285
Hanno Beckera1adcca2018-08-24 14:41:07 +01007286# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7287# from the server are delayed, so that the encrypted Finished message
7288# is received and buffered. When the fragmented NewSessionTicket comes
7289# in afterwards, the encrypted Finished message must be freed in order
7290# to make space for the NewSessionTicket to be reassembled.
7291# This works only in very particular circumstances:
7292# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7293# of the NewSessionTicket, but small enough to also allow buffering of
7294# the encrypted Finished message.
7295# - The MTU setting on the server must be so small that the NewSessionTicket
7296# needs to be fragmented.
7297# - All messages sent by the server must be small enough to be either sent
7298# without fragmentation or be reassembled within the bounds of
7299# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7300# handshake, omitting CRTs.
7301requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7302requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7303run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7304 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7305 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7306 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7307 0 \
7308 -s "Buffer record from epoch 1" \
7309 -s "Found buffered record from current epoch - load" \
7310 -c "Buffer record from epoch 1" \
7311 -C "Found buffered record from current epoch - load" \
7312 -c "Enough space available after freeing future epoch record"
7313
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007314# Tests for "randomly unreliable connection": try a variety of flows and peers
7315
7316client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007317run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7318 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007319 "$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 +02007320 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007321 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007322 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7323 0 \
7324 -s "Extra-header:" \
7325 -c "HTTP/1.0 200 OK"
7326
Janos Follath74537a62016-09-02 13:45:28 +01007327client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007328run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7329 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007330 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7331 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007332 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7333 0 \
7334 -s "Extra-header:" \
7335 -c "HTTP/1.0 200 OK"
7336
Janos Follath74537a62016-09-02 13:45:28 +01007337client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007338run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7339 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007340 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7341 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007342 0 \
7343 -s "Extra-header:" \
7344 -c "HTTP/1.0 200 OK"
7345
Janos Follath74537a62016-09-02 13:45:28 +01007346client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007347run_test "DTLS proxy: 3d, FS, client auth" \
7348 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007349 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7350 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007351 0 \
7352 -s "Extra-header:" \
7353 -c "HTTP/1.0 200 OK"
7354
Janos Follath74537a62016-09-02 13:45:28 +01007355client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007356run_test "DTLS proxy: 3d, FS, ticket" \
7357 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007358 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7359 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007360 0 \
7361 -s "Extra-header:" \
7362 -c "HTTP/1.0 200 OK"
7363
Janos Follath74537a62016-09-02 13:45:28 +01007364client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007365run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7366 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007367 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7368 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007369 0 \
7370 -s "Extra-header:" \
7371 -c "HTTP/1.0 200 OK"
7372
Janos Follath74537a62016-09-02 13:45:28 +01007373client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007374run_test "DTLS proxy: 3d, max handshake, nbio" \
7375 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007376 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007377 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007378 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007379 0 \
7380 -s "Extra-header:" \
7381 -c "HTTP/1.0 200 OK"
7382
Janos Follath74537a62016-09-02 13:45:28 +01007383client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007384run_test "DTLS proxy: 3d, min handshake, resumption" \
7385 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007386 "$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 +02007387 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007388 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007389 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007390 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7391 0 \
7392 -s "a session has been resumed" \
7393 -c "a session has been resumed" \
7394 -s "Extra-header:" \
7395 -c "HTTP/1.0 200 OK"
7396
Janos Follath74537a62016-09-02 13:45:28 +01007397client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007398run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7399 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007400 "$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 +02007401 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007402 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007403 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007404 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7405 0 \
7406 -s "a session has been resumed" \
7407 -c "a session has been resumed" \
7408 -s "Extra-header:" \
7409 -c "HTTP/1.0 200 OK"
7410
Janos Follath74537a62016-09-02 13:45:28 +01007411client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007412requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007413run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007414 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007415 "$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 +02007416 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007417 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007418 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007419 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7420 0 \
7421 -c "=> renegotiate" \
7422 -s "=> renegotiate" \
7423 -s "Extra-header:" \
7424 -c "HTTP/1.0 200 OK"
7425
Janos Follath74537a62016-09-02 13:45:28 +01007426client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007428run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7429 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007430 "$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 +02007431 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007432 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007433 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007434 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7435 0 \
7436 -c "=> renegotiate" \
7437 -s "=> renegotiate" \
7438 -s "Extra-header:" \
7439 -c "HTTP/1.0 200 OK"
7440
Janos Follath74537a62016-09-02 13:45:28 +01007441client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007442requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007443run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007444 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007445 "$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 +02007446 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007447 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007448 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007449 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007450 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7451 0 \
7452 -c "=> renegotiate" \
7453 -s "=> renegotiate" \
7454 -s "Extra-header:" \
7455 -c "HTTP/1.0 200 OK"
7456
Janos Follath74537a62016-09-02 13:45:28 +01007457client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007458requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007459run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007460 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007461 "$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 +02007462 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007463 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007464 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007465 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007466 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7467 0 \
7468 -c "=> renegotiate" \
7469 -s "=> renegotiate" \
7470 -s "Extra-header:" \
7471 -c "HTTP/1.0 200 OK"
7472
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007473## Interop tests with OpenSSL might trigger a bug in recent versions (including
7474## all versions installed on the CI machines), reported here:
7475## Bug report: https://github.com/openssl/openssl/issues/6902
7476## They should be re-enabled once a fixed version of OpenSSL is available
7477## (this should happen in some 1.1.1_ release according to the ticket).
7478skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007479client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007480not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007481run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007482 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7483 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007484 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007485 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007486 -c "HTTP/1.0 200 OK"
7487
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007488skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007489client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007490not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007491run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7492 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7493 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007494 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007495 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007496 -c "HTTP/1.0 200 OK"
7497
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007498skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007499client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007500not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007501run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7502 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7503 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007504 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007505 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007506 -c "HTTP/1.0 200 OK"
7507
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007508requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007509client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007510not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007511run_test "DTLS proxy: 3d, gnutls server" \
7512 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7513 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007514 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007515 0 \
7516 -s "Extra-header:" \
7517 -c "Extra-header:"
7518
k-stachowiakabb843e2019-02-18 16:14:03 +01007519requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007520client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007521not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007522run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7523 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007524 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007525 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007526 0 \
7527 -s "Extra-header:" \
7528 -c "Extra-header:"
7529
k-stachowiakabb843e2019-02-18 16:14:03 +01007530requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007531client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007532not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007533run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7534 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007535 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007536 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007537 0 \
7538 -s "Extra-header:" \
7539 -c "Extra-header:"
7540
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007541# Final report
7542
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007543echo "------------------------------------------------------------------------"
7544
7545if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007546 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007547else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007548 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007549fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007550PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007551echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007552
7553exit $FAILS