blob: 8177e9bef2145517d176a9f9a421cc411ddabea9 [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
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200251# skip next test if OpenSSL doesn't support FALLBACK_SCSV
252requires_openssl_with_fallback_scsv() {
253 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
254 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
255 then
256 OPENSSL_HAS_FBSCSV="YES"
257 else
258 OPENSSL_HAS_FBSCSV="NO"
259 fi
260 fi
261 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
262 SKIP_NEXT="YES"
263 fi
264}
265
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200266# skip next test if GnuTLS isn't available
267requires_gnutls() {
268 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200269 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200270 GNUTLS_AVAILABLE="YES"
271 else
272 GNUTLS_AVAILABLE="NO"
273 fi
274 fi
275 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
276 SKIP_NEXT="YES"
277 fi
278}
279
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200280# skip next test if GnuTLS-next isn't available
281requires_gnutls_next() {
282 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
283 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
284 GNUTLS_NEXT_AVAILABLE="YES"
285 else
286 GNUTLS_NEXT_AVAILABLE="NO"
287 fi
288 fi
289 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
290 SKIP_NEXT="YES"
291 fi
292}
293
294# skip next test if OpenSSL-legacy isn't available
295requires_openssl_legacy() {
296 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
297 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
298 OPENSSL_LEGACY_AVAILABLE="YES"
299 else
300 OPENSSL_LEGACY_AVAILABLE="NO"
301 fi
302 fi
303 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
304 SKIP_NEXT="YES"
305 fi
306}
307
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200308# skip next test if IPv6 isn't available on this host
309requires_ipv6() {
310 if [ -z "${HAS_IPV6:-}" ]; then
311 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
312 SRV_PID=$!
313 sleep 1
314 kill $SRV_PID >/dev/null 2>&1
315 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
316 HAS_IPV6="NO"
317 else
318 HAS_IPV6="YES"
319 fi
320 rm -r $SRV_OUT
321 fi
322
323 if [ "$HAS_IPV6" = "NO" ]; then
324 SKIP_NEXT="YES"
325 fi
326}
327
Andrzej Kurekb4593462018-10-11 08:43:30 -0400328# skip next test if it's i686 or uname is not available
329requires_not_i686() {
330 if [ -z "${IS_I686:-}" ]; then
331 IS_I686="YES"
332 if which "uname" >/dev/null 2>&1; then
333 if [ -z "$(uname -a | grep i686)" ]; then
334 IS_I686="NO"
335 fi
336 fi
337 fi
338 if [ "$IS_I686" = "YES" ]; then
339 SKIP_NEXT="YES"
340 fi
341}
342
Angus Grattonc4dd0732018-04-11 16:28:39 +1000343# Calculate the input & output maximum content lengths set in the config
344MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
345MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
346MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
347
348if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
349 MAX_CONTENT_LEN="$MAX_IN_LEN"
350fi
351if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
352 MAX_CONTENT_LEN="$MAX_OUT_LEN"
353fi
354
355# skip the next test if the SSL output buffer is less than 16KB
356requires_full_size_output_buffer() {
357 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
358 SKIP_NEXT="YES"
359 fi
360}
361
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200362# skip the next test if valgrind is in use
363not_with_valgrind() {
364 if [ "$MEMCHECK" -gt 0 ]; then
365 SKIP_NEXT="YES"
366 fi
367}
368
Paul Bakker362689d2016-05-13 10:33:25 +0100369# skip the next test if valgrind is NOT in use
370only_with_valgrind() {
371 if [ "$MEMCHECK" -eq 0 ]; then
372 SKIP_NEXT="YES"
373 fi
374}
375
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200376# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100377client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200378 CLI_DELAY_FACTOR=$1
379}
380
Janos Follath74537a62016-09-02 13:45:28 +0100381# wait for the given seconds after the client finished in the next test
382server_needs_more_time() {
383 SRV_DELAY_SECONDS=$1
384}
385
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100386# print_name <name>
387print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100388 TESTS=$(( $TESTS + 1 ))
389 LINE=""
390
391 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
392 LINE="$TESTS "
393 fi
394
395 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200396 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100397 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100398 for i in `seq 1 $LEN`; do printf '.'; done
399 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100400
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100401}
402
403# fail <message>
404fail() {
405 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100406 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100407
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200408 mv $SRV_OUT o-srv-${TESTS}.log
409 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200410 if [ -n "$PXY_CMD" ]; then
411 mv $PXY_OUT o-pxy-${TESTS}.log
412 fi
413 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100414
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200415 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200416 echo " ! server output:"
417 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200418 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200419 echo " ! client output:"
420 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200421 if [ -n "$PXY_CMD" ]; then
422 echo " ! ========================================================"
423 echo " ! proxy output:"
424 cat o-pxy-${TESTS}.log
425 fi
426 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200427 fi
428
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200429 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100430}
431
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100432# is_polar <cmd_line>
433is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200434 case "$1" in
435 *ssl_client2*) true;;
436 *ssl_server2*) true;;
437 *) false;;
438 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100439}
440
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200441# openssl s_server doesn't have -www with DTLS
442check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200443 case "$SRV_CMD" in
444 *s_server*-dtls*)
445 NEEDS_INPUT=1
446 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
447 *) NEEDS_INPUT=0;;
448 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200449}
450
451# provide input to commands that need it
452provide_input() {
453 if [ $NEEDS_INPUT -eq 0 ]; then
454 return
455 fi
456
457 while true; do
458 echo "HTTP/1.0 200 OK"
459 sleep 1
460 done
461}
462
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100463# has_mem_err <log_file_name>
464has_mem_err() {
465 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
466 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
467 then
468 return 1 # false: does not have errors
469 else
470 return 0 # true: has errors
471 fi
472}
473
Unknown43dc0d62019-09-02 10:42:57 -0400474# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100475if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400476 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100477 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200478 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100479 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200480 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100481 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200482 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100483 # Make a tight loop, server normally takes less than 1s to start.
484 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
485 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400486 echo "$3 START TIMEOUT"
487 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100488 break
489 fi
490 # Linux and *BSD support decimal arguments to sleep. On other
491 # OSes this may be a tight loop.
492 sleep 0.1 2>/dev/null || true
493 done
494 }
495else
Unknown43dc0d62019-09-02 10:42:57 -0400496 echo "Warning: lsof not available, wait_app_start = sleep"
497 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200498 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100499 }
500fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200501
Unknown43dc0d62019-09-02 10:42:57 -0400502# Wait for server process $2 to be listening on port $1.
503wait_server_start() {
504 wait_app_start $1 $2 "SERVER" $SRV_OUT
505}
506
507# Wait for proxy process $2 to be listening on port $1.
508wait_proxy_start() {
509 wait_app_start $1 $2 "PROXY" $PXY_OUT
510}
511
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100512# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100513# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100514# acceptable bounds
515check_server_hello_time() {
516 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100517 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100518 # Get the Unix timestamp for now
519 CUR_TIME=$(date +'%s')
520 THRESHOLD_IN_SECS=300
521
522 # Check if the ServerHello time was printed
523 if [ -z "$SERVER_HELLO_TIME" ]; then
524 return 1
525 fi
526
527 # Check the time in ServerHello is within acceptable bounds
528 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
529 # The time in ServerHello is at least 5 minutes before now
530 return 1
531 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100532 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100533 return 1
534 else
535 return 0
536 fi
537}
538
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200539# wait for client to terminate and set CLI_EXIT
540# must be called right after starting the client
541wait_client_done() {
542 CLI_PID=$!
543
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200544 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
545 CLI_DELAY_FACTOR=1
546
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200547 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200548 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200549
550 wait $CLI_PID
551 CLI_EXIT=$?
552
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200553 kill $DOG_PID >/dev/null 2>&1
554 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200555
556 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100557
558 sleep $SRV_DELAY_SECONDS
559 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200560}
561
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200562# check if the given command uses dtls and sets global variable DTLS
563detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200564 case "$1" in
565 *dtls=1*|-dtls|-u) DTLS=1;;
566 *) DTLS=0;;
567 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200568}
569
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200570# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100571# Options: -s pattern pattern that must be present in server output
572# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100573# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100574# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100575# -S pattern pattern that must be absent in server output
576# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100577# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100578# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100579run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100580 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200581 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100582
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200583 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200584 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100585 return
586 fi
587
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100588 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100589
Paul Bakkerb7584a52016-05-10 10:50:43 +0100590 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200591 if [ -n "$RUN_TEST_NUMBER" ]; then
592 case ",$RUN_TEST_NUMBER," in
593 *",$TESTS,"*) :;;
594 *) SKIP_NEXT="YES";;
595 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100596 fi
597
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200598 # should we skip?
599 if [ "X$SKIP_NEXT" = "XYES" ]; then
600 SKIP_NEXT="NO"
601 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200602 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200603 return
604 fi
605
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200606 # does this test use a proxy?
607 if [ "X$1" = "X-p" ]; then
608 PXY_CMD="$2"
609 shift 2
610 else
611 PXY_CMD=""
612 fi
613
614 # get commands and client output
615 SRV_CMD="$1"
616 CLI_CMD="$2"
617 CLI_EXPECT="$3"
618 shift 3
619
Hanno Becker7a11e722019-05-10 14:38:42 +0100620 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200621 case "$SRV_CMD $CLI_CMD" in
622 *data_files/*)
623 requires_config_enabled MBEDTLS_FS_IO;;
624 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100625
626 # should we skip?
627 if [ "X$SKIP_NEXT" = "XYES" ]; then
628 SKIP_NEXT="NO"
629 echo "SKIP"
630 SKIPS=$(( $SKIPS + 1 ))
631 return
632 fi
633
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200634 # update DTLS variable
635 detect_dtls "$SRV_CMD"
636
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200637 # if the test uses DTLS but no custom proxy, add a simple proxy
638 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200639 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200640 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200641 case " $SRV_CMD " in
642 *' server_addr=::1 '*)
643 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
644 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200645 fi
646
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200647 # fix client port
648 if [ -n "$PXY_CMD" ]; then
649 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
650 else
651 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
652 fi
653
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100654 # prepend valgrind to our commands if active
655 if [ "$MEMCHECK" -gt 0 ]; then
656 if is_polar "$SRV_CMD"; then
657 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
658 fi
659 if is_polar "$CLI_CMD"; then
660 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
661 fi
662 fi
663
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200664 TIMES_LEFT=2
665 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200666 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200667
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200668 # run the commands
669 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200670 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200671 $PXY_CMD >> $PXY_OUT 2>&1 &
672 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400673 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200674 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200675
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200676 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200677 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200678 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
679 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100680 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200681
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200682 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200683 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
684 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100685
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100686 sleep 0.05
687
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200688 # terminate the server (and the proxy)
689 kill $SRV_PID
690 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100691 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100692
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200693 if [ -n "$PXY_CMD" ]; then
694 kill $PXY_PID >/dev/null 2>&1
695 wait $PXY_PID
696 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100697
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200698 # retry only on timeouts
699 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
700 printf "RETRY "
701 else
702 TIMES_LEFT=0
703 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200704 done
705
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100706 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200707 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100708 # expected client exit to incorrectly succeed in case of catastrophic
709 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100710 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200711 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100712 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100713 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100714 return
715 fi
716 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100717 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200718 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100719 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100720 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100721 return
722 fi
723 fi
724
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100725 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
726 # exit with status 0 when interrupted by a signal, and we don't really
727 # care anyway), in case e.g. the server reports a memory leak.
728 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100729 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100730 return
731 fi
732
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100733 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100734 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
735 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100736 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200737 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100738 return
739 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100740
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100741 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200742 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100743 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100744 while [ $# -gt 0 ]
745 do
746 case $1 in
747 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100748 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100749 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100750 return
751 fi
752 ;;
753
754 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100755 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100756 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100757 return
758 fi
759 ;;
760
761 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100762 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 +0100763 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100764 return
765 fi
766 ;;
767
768 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100769 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 +0100770 fail "pattern '$2' MUST NOT be present in the Client output"
771 return
772 fi
773 ;;
774
775 # The filtering in the following two options (-u and -U) do the following
776 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100777 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100778 # - keep one of each non-unique line
779 # - count how many lines remain
780 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
781 # if there were no duplicates.
782 "-U")
783 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
784 fail "lines following pattern '$2' must be unique in Server output"
785 return
786 fi
787 ;;
788
789 "-u")
790 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
791 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100792 return
793 fi
794 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100795 "-F")
796 if ! $2 "$SRV_OUT"; then
797 fail "function call to '$2' failed on Server output"
798 return
799 fi
800 ;;
801 "-f")
802 if ! $2 "$CLI_OUT"; then
803 fail "function call to '$2' failed on Client output"
804 return
805 fi
806 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100807
808 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200809 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100810 exit 1
811 esac
812 shift 2
813 done
814
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100815 # check valgrind's results
816 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200817 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100818 fail "Server has memory errors"
819 return
820 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200821 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100822 fail "Client has memory errors"
823 return
824 fi
825 fi
826
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100827 # if we're here, everything is ok
828 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100829 if [ "$PRESERVE_LOGS" -gt 0 ]; then
830 mv $SRV_OUT o-srv-${TESTS}.log
831 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100832 if [ -n "$PXY_CMD" ]; then
833 mv $PXY_OUT o-pxy-${TESTS}.log
834 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100835 fi
836
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200837 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100838}
839
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100840cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200841 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200842 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
843 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
844 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
845 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100846 exit 1
847}
848
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100849#
850# MAIN
851#
852
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100853get_options "$@"
854
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200855# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
856# patterns rather than regular expressions, use a case statement instead
857# of calling grep. To keep the optimizer simple, it is incomplete and only
858# detects simple cases: plain substring, everything, nothing.
859#
860# As an exception, the character '.' is treated as an ordinary character
861# if it is the only special character in the string. This is because it's
862# rare to need "any one character", but needing a literal '.' is common
863# (e.g. '-f "DTLS 1.2"').
864need_grep=
865case "$FILTER" in
866 '^$') simple_filter=;;
867 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200868 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200869 need_grep=1;;
870 *) # No regexp or shell-pattern special character
871 simple_filter="*$FILTER*";;
872esac
873case "$EXCLUDE" in
874 '^$') simple_exclude=;;
875 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200876 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200877 need_grep=1;;
878 *) # No regexp or shell-pattern special character
879 simple_exclude="*$EXCLUDE*";;
880esac
881if [ -n "$need_grep" ]; then
882 is_excluded () {
883 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
884 }
885else
886 is_excluded () {
887 case "$1" in
888 $simple_exclude) true;;
889 $simple_filter) false;;
890 *) true;;
891 esac
892 }
893fi
894
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100895# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100896P_SRV_BIN="${P_SRV%%[ ]*}"
897P_CLI_BIN="${P_CLI%%[ ]*}"
898P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100899if [ ! -x "$P_SRV_BIN" ]; then
900 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100901 exit 1
902fi
Hanno Becker17c04932017-10-10 14:44:53 +0100903if [ ! -x "$P_CLI_BIN" ]; then
904 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100905 exit 1
906fi
Hanno Becker17c04932017-10-10 14:44:53 +0100907if [ ! -x "$P_PXY_BIN" ]; then
908 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200909 exit 1
910fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100911if [ "$MEMCHECK" -gt 0 ]; then
912 if which valgrind >/dev/null 2>&1; then :; else
913 echo "Memcheck not possible. Valgrind not found"
914 exit 1
915 fi
916fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100917if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
918 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100919 exit 1
920fi
921
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200922# used by watchdog
923MAIN_PID="$$"
924
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100925# We use somewhat arbitrary delays for tests:
926# - how long do we wait for the server to start (when lsof not available)?
927# - how long do we allow for the client to finish?
928# (not to check performance, just to avoid waiting indefinitely)
929# Things are slower with valgrind, so give extra time here.
930#
931# Note: without lsof, there is a trade-off between the running time of this
932# script and the risk of spurious errors because we didn't wait long enough.
933# The watchdog delay on the other hand doesn't affect normal running time of
934# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200935if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100936 START_DELAY=6
937 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200938else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100939 START_DELAY=2
940 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200941fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100942
943# some particular tests need more time:
944# - for the client, we multiply the usual watchdog limit by a factor
945# - for the server, we sleep for a number of seconds after the client exits
946# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200947CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100948SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200949
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200950# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000951# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200952P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
953P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100954P_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 +0200955O_SRV="$O_SRV -accept $SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200956O_CLI="$O_CLI -connect localhost:+SRV_PORT"
957G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200958G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200959
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200960if [ -n "${OPENSSL_LEGACY:-}" ]; then
961 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
962 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
963fi
964
Hanno Becker58e9dc32018-08-17 15:53:21 +0100965if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200966 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
967fi
968
Hanno Becker58e9dc32018-08-17 15:53:21 +0100969if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200970 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200971fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100972
Gilles Peskine62469d92017-05-10 10:13:59 +0200973# Allow SHA-1, because many of our test certificates use it
974P_SRV="$P_SRV allow_sha1=1"
975P_CLI="$P_CLI allow_sha1=1"
976
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200977# Also pick a unique name for intermediate files
978SRV_OUT="srv_out.$$"
979CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200980PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200981SESSION="session.$$"
982
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200983SKIP_NEXT="NO"
984
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100985trap cleanup INT TERM HUP
986
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200987# Basic test
988
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200989# Checks that:
990# - things work with all ciphersuites active (used with config-full in all.sh)
991# - the expected (highest security) parameters are selected
992# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200993run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200994 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200995 "$P_CLI" \
996 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200997 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200998 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200999 -s "client hello v3, signature_algorithm ext: 6" \
1000 -s "ECDHE curve: secp521r1" \
1001 -S "error" \
1002 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001003
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001004run_test "Default, DTLS" \
1005 "$P_SRV dtls=1" \
1006 "$P_CLI dtls=1" \
1007 0 \
1008 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001009 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001010
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001011requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1012run_test "Default (compression enabled)" \
1013 "$P_SRV debug_level=3" \
1014 "$P_CLI debug_level=3" \
1015 0 \
1016 -s "Allocating compression buffer" \
1017 -c "Allocating compression buffer" \
1018 -s "Record expansion is unknown (compression)" \
1019 -c "Record expansion is unknown (compression)" \
1020 -S "error" \
1021 -C "error"
1022
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001023# Test current time in ServerHello
1024requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001025run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001026 "$P_SRV debug_level=3" \
1027 "$P_CLI debug_level=3" \
1028 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001029 -f "check_server_hello_time" \
1030 -F "check_server_hello_time"
1031
Simon Butcher8e004102016-10-14 00:48:33 +01001032# Test for uniqueness of IVs in AEAD ciphersuites
1033run_test "Unique IV in GCM" \
1034 "$P_SRV exchanges=20 debug_level=4" \
1035 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1036 0 \
1037 -u "IV used" \
1038 -U "IV used"
1039
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001040# Tests for rc4 option
1041
Simon Butchera410af52016-05-19 22:12:18 +01001042requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001043run_test "RC4: server disabled, client enabled" \
1044 "$P_SRV" \
1045 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1046 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001047 -s "SSL - The server has no ciphersuites in common"
1048
Simon Butchera410af52016-05-19 22:12:18 +01001049requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001050run_test "RC4: server half, client enabled" \
1051 "$P_SRV arc4=1" \
1052 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1053 1 \
1054 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001055
1056run_test "RC4: server enabled, client disabled" \
1057 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1058 "$P_CLI" \
1059 1 \
1060 -s "SSL - The server has no ciphersuites in common"
1061
1062run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001063 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001064 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1065 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001066 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001067 -S "SSL - The server has no ciphersuites in common"
1068
Hanno Beckerd26bb202018-08-17 09:54:10 +01001069# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1070
1071requires_gnutls
1072requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1073run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1074 "$G_SRV"\
1075 "$P_CLI force_version=tls1_1" \
1076 0
1077
1078requires_gnutls
1079requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1080run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1081 "$G_SRV"\
1082 "$P_CLI force_version=tls1" \
1083 0
1084
Gilles Peskinebc70a182017-05-09 15:59:24 +02001085# Tests for SHA-1 support
1086
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001087requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001088run_test "SHA-1 forbidden by default in server certificate" \
1089 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1090 "$P_CLI debug_level=2 allow_sha1=0" \
1091 1 \
1092 -c "The certificate is signed with an unacceptable hash"
1093
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001094requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1095run_test "SHA-1 forbidden by default in server certificate" \
1096 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1097 "$P_CLI debug_level=2 allow_sha1=0" \
1098 0
1099
Gilles Peskinebc70a182017-05-09 15:59:24 +02001100run_test "SHA-1 explicitly allowed in server certificate" \
1101 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1102 "$P_CLI allow_sha1=1" \
1103 0
1104
1105run_test "SHA-256 allowed by default in server certificate" \
1106 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1107 "$P_CLI allow_sha1=0" \
1108 0
1109
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001110requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001111run_test "SHA-1 forbidden by default in client certificate" \
1112 "$P_SRV auth_mode=required allow_sha1=0" \
1113 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1114 1 \
1115 -s "The certificate is signed with an unacceptable hash"
1116
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001117requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1118run_test "SHA-1 forbidden by default in client certificate" \
1119 "$P_SRV auth_mode=required allow_sha1=0" \
1120 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1121 0
1122
Gilles Peskinebc70a182017-05-09 15:59:24 +02001123run_test "SHA-1 explicitly allowed in client certificate" \
1124 "$P_SRV auth_mode=required allow_sha1=1" \
1125 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1126 0
1127
1128run_test "SHA-256 allowed by default in client certificate" \
1129 "$P_SRV auth_mode=required allow_sha1=0" \
1130 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1131 0
1132
Hanno Becker7ae8a762018-08-14 15:43:35 +01001133# Tests for datagram packing
1134run_test "DTLS: multiple records in same datagram, client and server" \
1135 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1136 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1137 0 \
1138 -c "next record in same datagram" \
1139 -s "next record in same datagram"
1140
1141run_test "DTLS: multiple records in same datagram, client only" \
1142 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1143 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1144 0 \
1145 -s "next record in same datagram" \
1146 -C "next record in same datagram"
1147
1148run_test "DTLS: multiple records in same datagram, server only" \
1149 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1150 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1151 0 \
1152 -S "next record in same datagram" \
1153 -c "next record in same datagram"
1154
1155run_test "DTLS: multiple records in same datagram, neither client nor server" \
1156 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1157 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1158 0 \
1159 -S "next record in same datagram" \
1160 -C "next record in same datagram"
1161
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001162# Tests for Truncated HMAC extension
1163
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001164run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001165 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001166 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001167 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001168 -s "dumping 'expected mac' (20 bytes)" \
1169 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001170
Hanno Becker32c55012017-11-10 08:42:54 +00001171requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001172run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001173 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001174 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001175 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001176 -s "dumping 'expected mac' (20 bytes)" \
1177 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001178
Hanno Becker32c55012017-11-10 08:42:54 +00001179requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001180run_test "Truncated HMAC: client enabled, server default" \
1181 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001182 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001183 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001184 -s "dumping 'expected mac' (20 bytes)" \
1185 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001186
Hanno Becker32c55012017-11-10 08:42:54 +00001187requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001188run_test "Truncated HMAC: client enabled, server disabled" \
1189 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001190 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001191 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001192 -s "dumping 'expected mac' (20 bytes)" \
1193 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001194
Hanno Becker32c55012017-11-10 08:42:54 +00001195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001196run_test "Truncated HMAC: client disabled, server enabled" \
1197 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001198 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001199 0 \
1200 -s "dumping 'expected mac' (20 bytes)" \
1201 -S "dumping 'expected mac' (10 bytes)"
1202
1203requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001204run_test "Truncated HMAC: client enabled, server enabled" \
1205 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001206 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001207 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001208 -S "dumping 'expected mac' (20 bytes)" \
1209 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001210
Hanno Becker4c4f4102017-11-10 09:16:05 +00001211run_test "Truncated HMAC, DTLS: client default, server default" \
1212 "$P_SRV dtls=1 debug_level=4" \
1213 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1214 0 \
1215 -s "dumping 'expected mac' (20 bytes)" \
1216 -S "dumping 'expected mac' (10 bytes)"
1217
1218requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1219run_test "Truncated HMAC, DTLS: client disabled, server default" \
1220 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001221 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001222 0 \
1223 -s "dumping 'expected mac' (20 bytes)" \
1224 -S "dumping 'expected mac' (10 bytes)"
1225
1226requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1227run_test "Truncated HMAC, DTLS: client enabled, server default" \
1228 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001229 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001230 0 \
1231 -s "dumping 'expected mac' (20 bytes)" \
1232 -S "dumping 'expected mac' (10 bytes)"
1233
1234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1235run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1236 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001237 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001238 0 \
1239 -s "dumping 'expected mac' (20 bytes)" \
1240 -S "dumping 'expected mac' (10 bytes)"
1241
1242requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1243run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1244 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001245 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001246 0 \
1247 -s "dumping 'expected mac' (20 bytes)" \
1248 -S "dumping 'expected mac' (10 bytes)"
1249
1250requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1251run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1252 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001253 "$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 +01001254 0 \
1255 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001256 -s "dumping 'expected mac' (10 bytes)"
1257
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001258# Tests for Encrypt-then-MAC extension
1259
1260run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001261 "$P_SRV debug_level=3 \
1262 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001263 "$P_CLI debug_level=3" \
1264 0 \
1265 -c "client hello, adding encrypt_then_mac extension" \
1266 -s "found encrypt then mac extension" \
1267 -s "server hello, adding encrypt then mac extension" \
1268 -c "found encrypt_then_mac extension" \
1269 -c "using encrypt then mac" \
1270 -s "using encrypt then mac"
1271
1272run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001273 "$P_SRV debug_level=3 etm=0 \
1274 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001275 "$P_CLI debug_level=3 etm=1" \
1276 0 \
1277 -c "client hello, adding encrypt_then_mac extension" \
1278 -s "found encrypt then mac extension" \
1279 -S "server hello, adding encrypt then mac extension" \
1280 -C "found encrypt_then_mac extension" \
1281 -C "using encrypt then mac" \
1282 -S "using encrypt then mac"
1283
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001284run_test "Encrypt then MAC: client enabled, aead cipher" \
1285 "$P_SRV debug_level=3 etm=1 \
1286 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1287 "$P_CLI debug_level=3 etm=1" \
1288 0 \
1289 -c "client hello, adding encrypt_then_mac extension" \
1290 -s "found encrypt then mac extension" \
1291 -S "server hello, adding encrypt then mac extension" \
1292 -C "found encrypt_then_mac extension" \
1293 -C "using encrypt then mac" \
1294 -S "using encrypt then mac"
1295
1296run_test "Encrypt then MAC: client enabled, stream cipher" \
1297 "$P_SRV debug_level=3 etm=1 \
1298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001299 "$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 +01001300 0 \
1301 -c "client hello, adding encrypt_then_mac extension" \
1302 -s "found encrypt then mac extension" \
1303 -S "server hello, adding encrypt then mac extension" \
1304 -C "found encrypt_then_mac extension" \
1305 -C "using encrypt then mac" \
1306 -S "using encrypt then mac"
1307
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001308run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001309 "$P_SRV debug_level=3 etm=1 \
1310 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001311 "$P_CLI debug_level=3 etm=0" \
1312 0 \
1313 -C "client hello, adding encrypt_then_mac extension" \
1314 -S "found encrypt then mac extension" \
1315 -S "server hello, adding encrypt then mac extension" \
1316 -C "found encrypt_then_mac extension" \
1317 -C "using encrypt then mac" \
1318 -S "using encrypt then mac"
1319
Janos Follathe2681a42016-03-07 15:57:05 +00001320requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001321run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001322 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001323 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001324 "$P_CLI debug_level=3 force_version=ssl3" \
1325 0 \
1326 -C "client hello, adding encrypt_then_mac extension" \
1327 -S "found encrypt then mac extension" \
1328 -S "server hello, adding encrypt then mac extension" \
1329 -C "found encrypt_then_mac extension" \
1330 -C "using encrypt then mac" \
1331 -S "using encrypt then mac"
1332
Janos Follathe2681a42016-03-07 15:57:05 +00001333requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001334run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001335 "$P_SRV debug_level=3 force_version=ssl3 \
1336 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001337 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001338 0 \
1339 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001340 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001341 -S "server hello, adding encrypt then mac extension" \
1342 -C "found encrypt_then_mac extension" \
1343 -C "using encrypt then mac" \
1344 -S "using encrypt then mac"
1345
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001346# Tests for Extended Master Secret extension
1347
1348run_test "Extended Master Secret: default" \
1349 "$P_SRV debug_level=3" \
1350 "$P_CLI debug_level=3" \
1351 0 \
1352 -c "client hello, adding extended_master_secret extension" \
1353 -s "found extended master secret extension" \
1354 -s "server hello, adding extended master secret extension" \
1355 -c "found extended_master_secret extension" \
1356 -c "using extended master secret" \
1357 -s "using extended master secret"
1358
1359run_test "Extended Master Secret: client enabled, server disabled" \
1360 "$P_SRV debug_level=3 extended_ms=0" \
1361 "$P_CLI debug_level=3 extended_ms=1" \
1362 0 \
1363 -c "client hello, adding extended_master_secret extension" \
1364 -s "found extended master secret extension" \
1365 -S "server hello, adding extended master secret extension" \
1366 -C "found extended_master_secret extension" \
1367 -C "using extended master secret" \
1368 -S "using extended master secret"
1369
1370run_test "Extended Master Secret: client disabled, server enabled" \
1371 "$P_SRV debug_level=3 extended_ms=1" \
1372 "$P_CLI debug_level=3 extended_ms=0" \
1373 0 \
1374 -C "client hello, adding extended_master_secret extension" \
1375 -S "found extended master secret extension" \
1376 -S "server hello, adding extended master secret extension" \
1377 -C "found extended_master_secret extension" \
1378 -C "using extended master secret" \
1379 -S "using extended master secret"
1380
Janos Follathe2681a42016-03-07 15:57:05 +00001381requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001382run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001383 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001384 "$P_CLI debug_level=3 force_version=ssl3" \
1385 0 \
1386 -C "client hello, adding extended_master_secret extension" \
1387 -S "found extended master secret extension" \
1388 -S "server hello, adding extended master secret extension" \
1389 -C "found extended_master_secret extension" \
1390 -C "using extended master secret" \
1391 -S "using extended master secret"
1392
Janos Follathe2681a42016-03-07 15:57:05 +00001393requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001394run_test "Extended Master Secret: client enabled, server SSLv3" \
1395 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001396 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001397 0 \
1398 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001399 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001400 -S "server hello, adding extended master secret extension" \
1401 -C "found extended_master_secret extension" \
1402 -C "using extended master secret" \
1403 -S "using extended master secret"
1404
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001405# Tests for FALLBACK_SCSV
1406
1407run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001408 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001409 "$P_CLI debug_level=3 force_version=tls1_1" \
1410 0 \
1411 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001412 -S "received FALLBACK_SCSV" \
1413 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001414 -C "is a fatal alert message (msg 86)"
1415
1416run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001417 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001418 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1419 0 \
1420 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001421 -S "received FALLBACK_SCSV" \
1422 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001423 -C "is a fatal alert message (msg 86)"
1424
1425run_test "Fallback SCSV: enabled" \
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 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001428 1 \
1429 -c "adding FALLBACK_SCSV" \
1430 -s "received FALLBACK_SCSV" \
1431 -s "inapropriate fallback" \
1432 -c "is a fatal alert message (msg 86)"
1433
1434run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001435 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001436 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001437 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
1443requires_openssl_with_fallback_scsv
1444run_test "Fallback SCSV: default, openssl server" \
1445 "$O_SRV" \
1446 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1447 0 \
1448 -C "adding FALLBACK_SCSV" \
1449 -C "is a fatal alert message (msg 86)"
1450
1451requires_openssl_with_fallback_scsv
1452run_test "Fallback SCSV: enabled, openssl server" \
1453 "$O_SRV" \
1454 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1455 1 \
1456 -c "adding FALLBACK_SCSV" \
1457 -c "is a fatal alert message (msg 86)"
1458
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001459requires_openssl_with_fallback_scsv
1460run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001461 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001462 "$O_CLI -tls1_1" \
1463 0 \
1464 -S "received FALLBACK_SCSV" \
1465 -S "inapropriate fallback"
1466
1467requires_openssl_with_fallback_scsv
1468run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001469 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001470 "$O_CLI -tls1_1 -fallback_scsv" \
1471 1 \
1472 -s "received FALLBACK_SCSV" \
1473 -s "inapropriate fallback"
1474
1475requires_openssl_with_fallback_scsv
1476run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001477 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001478 "$O_CLI -fallback_scsv" \
1479 0 \
1480 -s "received FALLBACK_SCSV" \
1481 -S "inapropriate fallback"
1482
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001483# Test sending and receiving empty application data records
1484
1485run_test "Encrypt then MAC: empty application data record" \
1486 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1487 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1488 0 \
1489 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1490 -s "dumping 'input payload after decrypt' (0 bytes)" \
1491 -c "0 bytes written in 1 fragments"
1492
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001493run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001494 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1495 "$P_CLI auth_mode=none etm=0 request_size=0" \
1496 0 \
1497 -s "dumping 'input payload after decrypt' (0 bytes)" \
1498 -c "0 bytes written in 1 fragments"
1499
1500run_test "Encrypt then MAC, DTLS: empty application data record" \
1501 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1502 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1503 0 \
1504 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1505 -s "dumping 'input payload after decrypt' (0 bytes)" \
1506 -c "0 bytes written in 1 fragments"
1507
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001508run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001509 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1510 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1511 0 \
1512 -s "dumping 'input payload after decrypt' (0 bytes)" \
1513 -c "0 bytes written in 1 fragments"
1514
Gilles Peskined50177f2017-05-16 17:53:03 +02001515## ClientHello generated with
1516## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1517## then manually twiddling the ciphersuite list.
1518## The ClientHello content is spelled out below as a hex string as
1519## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1520## The expected response is an inappropriate_fallback alert.
1521requires_openssl_with_fallback_scsv
1522run_test "Fallback SCSV: beginning of list" \
1523 "$P_SRV debug_level=2" \
1524 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1525 0 \
1526 -s "received FALLBACK_SCSV" \
1527 -s "inapropriate fallback"
1528
1529requires_openssl_with_fallback_scsv
1530run_test "Fallback SCSV: end of list" \
1531 "$P_SRV debug_level=2" \
1532 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1533 0 \
1534 -s "received FALLBACK_SCSV" \
1535 -s "inapropriate fallback"
1536
1537## Here the expected response is a valid ServerHello prefix, up to the random.
1538requires_openssl_with_fallback_scsv
1539run_test "Fallback SCSV: not in list" \
1540 "$P_SRV debug_level=2" \
1541 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1542 0 \
1543 -S "received FALLBACK_SCSV" \
1544 -S "inapropriate fallback"
1545
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001546# Tests for CBC 1/n-1 record splitting
1547
1548run_test "CBC Record splitting: TLS 1.2, no splitting" \
1549 "$P_SRV" \
1550 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1551 request_size=123 force_version=tls1_2" \
1552 0 \
1553 -s "Read from client: 123 bytes read" \
1554 -S "Read from client: 1 bytes read" \
1555 -S "122 bytes read"
1556
1557run_test "CBC Record splitting: TLS 1.1, no splitting" \
1558 "$P_SRV" \
1559 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1560 request_size=123 force_version=tls1_1" \
1561 0 \
1562 -s "Read from client: 123 bytes read" \
1563 -S "Read from client: 1 bytes read" \
1564 -S "122 bytes read"
1565
1566run_test "CBC Record splitting: TLS 1.0, splitting" \
1567 "$P_SRV" \
1568 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1569 request_size=123 force_version=tls1" \
1570 0 \
1571 -S "Read from client: 123 bytes read" \
1572 -s "Read from client: 1 bytes read" \
1573 -s "122 bytes read"
1574
Janos Follathe2681a42016-03-07 15:57:05 +00001575requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001576run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001577 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001578 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1579 request_size=123 force_version=ssl3" \
1580 0 \
1581 -S "Read from client: 123 bytes read" \
1582 -s "Read from client: 1 bytes read" \
1583 -s "122 bytes read"
1584
1585run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001586 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001587 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1588 request_size=123 force_version=tls1" \
1589 0 \
1590 -s "Read from client: 123 bytes read" \
1591 -S "Read from client: 1 bytes read" \
1592 -S "122 bytes read"
1593
1594run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1595 "$P_SRV" \
1596 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1597 request_size=123 force_version=tls1 recsplit=0" \
1598 0 \
1599 -s "Read from client: 123 bytes read" \
1600 -S "Read from client: 1 bytes read" \
1601 -S "122 bytes read"
1602
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001603run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1604 "$P_SRV nbio=2" \
1605 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-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
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001612# Tests for Session Tickets
1613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001614run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001615 "$P_SRV debug_level=3 tickets=1" \
1616 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001617 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001618 -c "client hello, adding session ticket extension" \
1619 -s "found session ticket extension" \
1620 -s "server hello, adding session ticket extension" \
1621 -c "found session_ticket extension" \
1622 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001623 -S "session successfully restored from cache" \
1624 -s "session successfully restored from ticket" \
1625 -s "a session has been resumed" \
1626 -c "a session has been resumed"
1627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001628run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001629 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1630 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001631 0 \
1632 -c "client hello, adding session ticket extension" \
1633 -s "found session ticket extension" \
1634 -s "server hello, adding session ticket extension" \
1635 -c "found session_ticket extension" \
1636 -c "parse new session ticket" \
1637 -S "session successfully restored from cache" \
1638 -s "session successfully restored from ticket" \
1639 -s "a session has been resumed" \
1640 -c "a session has been resumed"
1641
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001642run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001643 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1644 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001645 0 \
1646 -c "client hello, adding session ticket extension" \
1647 -s "found session ticket extension" \
1648 -s "server hello, adding session ticket extension" \
1649 -c "found session_ticket extension" \
1650 -c "parse new session ticket" \
1651 -S "session successfully restored from cache" \
1652 -S "session successfully restored from ticket" \
1653 -S "a session has been resumed" \
1654 -C "a session has been resumed"
1655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001656run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001657 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001658 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001659 0 \
1660 -c "client hello, adding session ticket extension" \
1661 -c "found session_ticket extension" \
1662 -c "parse new session ticket" \
1663 -c "a session has been resumed"
1664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001665run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001666 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001667 "( $O_CLI -sess_out $SESSION; \
1668 $O_CLI -sess_in $SESSION; \
1669 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001670 0 \
1671 -s "found session ticket extension" \
1672 -s "server hello, adding session ticket extension" \
1673 -S "session successfully restored from cache" \
1674 -s "session successfully restored from ticket" \
1675 -s "a session has been resumed"
1676
Hanno Becker1d739932018-08-21 13:55:22 +01001677# Tests for Session Tickets with DTLS
1678
1679run_test "Session resume using tickets, DTLS: basic" \
1680 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001681 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001682 0 \
1683 -c "client hello, adding session ticket extension" \
1684 -s "found session ticket extension" \
1685 -s "server hello, adding session ticket extension" \
1686 -c "found session_ticket extension" \
1687 -c "parse new session ticket" \
1688 -S "session successfully restored from cache" \
1689 -s "session successfully restored from ticket" \
1690 -s "a session has been resumed" \
1691 -c "a session has been resumed"
1692
1693run_test "Session resume using tickets, DTLS: cache disabled" \
1694 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001695 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001696 0 \
1697 -c "client hello, adding session ticket extension" \
1698 -s "found session ticket extension" \
1699 -s "server hello, adding session ticket extension" \
1700 -c "found session_ticket extension" \
1701 -c "parse new session ticket" \
1702 -S "session successfully restored from cache" \
1703 -s "session successfully restored from ticket" \
1704 -s "a session has been resumed" \
1705 -c "a session has been resumed"
1706
1707run_test "Session resume using tickets, DTLS: timeout" \
1708 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001709 "$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 +01001710 0 \
1711 -c "client hello, adding session ticket extension" \
1712 -s "found session ticket extension" \
1713 -s "server hello, adding session ticket extension" \
1714 -c "found session_ticket extension" \
1715 -c "parse new session ticket" \
1716 -S "session successfully restored from cache" \
1717 -S "session successfully restored from ticket" \
1718 -S "a session has been resumed" \
1719 -C "a session has been resumed"
1720
1721run_test "Session resume using tickets, DTLS: openssl server" \
1722 "$O_SRV -dtls1" \
1723 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1724 0 \
1725 -c "client hello, adding session ticket extension" \
1726 -c "found session_ticket extension" \
1727 -c "parse new session ticket" \
1728 -c "a session has been resumed"
1729
1730run_test "Session resume using tickets, DTLS: openssl client" \
1731 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1732 "( $O_CLI -dtls1 -sess_out $SESSION; \
1733 $O_CLI -dtls1 -sess_in $SESSION; \
1734 rm -f $SESSION )" \
1735 0 \
1736 -s "found session ticket extension" \
1737 -s "server hello, adding session ticket extension" \
1738 -S "session successfully restored from cache" \
1739 -s "session successfully restored from ticket" \
1740 -s "a session has been resumed"
1741
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001742# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001744run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001745 "$P_SRV debug_level=3 tickets=0" \
1746 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001747 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001748 -c "client hello, adding session ticket extension" \
1749 -s "found session ticket extension" \
1750 -S "server hello, adding session ticket extension" \
1751 -C "found session_ticket extension" \
1752 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001753 -s "session successfully restored from cache" \
1754 -S "session successfully restored from ticket" \
1755 -s "a session has been resumed" \
1756 -c "a session has been resumed"
1757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001758run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001759 "$P_SRV debug_level=3 tickets=1" \
1760 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001761 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001762 -C "client hello, adding session ticket extension" \
1763 -S "found session ticket extension" \
1764 -S "server hello, adding session ticket extension" \
1765 -C "found session_ticket extension" \
1766 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001767 -s "session successfully restored from cache" \
1768 -S "session successfully restored from ticket" \
1769 -s "a session has been resumed" \
1770 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001773 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1774 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001775 0 \
1776 -S "session successfully restored from cache" \
1777 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001778 -S "a session has been resumed" \
1779 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001781run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001782 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1783 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001784 0 \
1785 -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"
1789
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001790run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001791 "$P_SRV debug_level=3 tickets=0" \
1792 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001793 0 \
1794 -s "session successfully restored from cache" \
1795 -S "session successfully restored from ticket" \
1796 -s "a session has been resumed" \
1797 -c "a session has been resumed"
1798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001799run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001800 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1801 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
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é-Gonnard8e03c712014-08-30 21:42:40 +02001808run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001809 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1810 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +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: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001818 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001819 "( $O_CLI -sess_out $SESSION; \
1820 $O_CLI -sess_in $SESSION; \
1821 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001822 0 \
1823 -s "found session ticket extension" \
1824 -S "server hello, adding session ticket extension" \
1825 -s "session successfully restored from cache" \
1826 -S "session successfully restored from ticket" \
1827 -s "a session has been resumed"
1828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001829run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001830 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001831 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001832 0 \
1833 -C "found session_ticket extension" \
1834 -C "parse new session ticket" \
1835 -c "a session has been resumed"
1836
Hanno Becker1d739932018-08-21 13:55:22 +01001837# Tests for Session Resume based on session-ID and cache, DTLS
1838
1839run_test "Session resume using cache, DTLS: tickets enabled on client" \
1840 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001841 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001842 0 \
1843 -c "client hello, adding session ticket extension" \
1844 -s "found session ticket extension" \
1845 -S "server hello, adding session ticket extension" \
1846 -C "found session_ticket extension" \
1847 -C "parse new session ticket" \
1848 -s "session successfully restored from cache" \
1849 -S "session successfully restored from ticket" \
1850 -s "a session has been resumed" \
1851 -c "a session has been resumed"
1852
1853run_test "Session resume using cache, DTLS: tickets enabled on server" \
1854 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001855 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001856 0 \
1857 -C "client hello, adding session ticket extension" \
1858 -S "found session ticket extension" \
1859 -S "server hello, adding session ticket extension" \
1860 -C "found session_ticket extension" \
1861 -C "parse new session ticket" \
1862 -s "session successfully restored from cache" \
1863 -S "session successfully restored from ticket" \
1864 -s "a session has been resumed" \
1865 -c "a session has been resumed"
1866
1867run_test "Session resume using cache, DTLS: cache_max=0" \
1868 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001869 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001870 0 \
1871 -S "session successfully restored from cache" \
1872 -S "session successfully restored from ticket" \
1873 -S "a session has been resumed" \
1874 -C "a session has been resumed"
1875
1876run_test "Session resume using cache, DTLS: cache_max=1" \
1877 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001878 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001879 0 \
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: timeout > delay" \
1886 "$P_SRV dtls=1 debug_level=3 tickets=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 reco_delay=0" \
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: timeout < delay" \
1895 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=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 reco_delay=2" \
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: no timeout" \
1904 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=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=2" \
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: openssl client" \
1913 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1914 "( $O_CLI -dtls1 -sess_out $SESSION; \
1915 $O_CLI -dtls1 -sess_in $SESSION; \
1916 rm -f $SESSION )" \
1917 0 \
1918 -s "found session ticket extension" \
1919 -S "server hello, adding session ticket extension" \
1920 -s "session successfully restored from cache" \
1921 -S "session successfully restored from ticket" \
1922 -s "a session has been resumed"
1923
1924run_test "Session resume using cache, DTLS: openssl server" \
1925 "$O_SRV -dtls1" \
1926 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1927 0 \
1928 -C "found session_ticket extension" \
1929 -C "parse new session ticket" \
1930 -c "a session has been resumed"
1931
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001932# Tests for Max Fragment Length extension
1933
Angus Grattonc4dd0732018-04-11 16:28:39 +10001934if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001935 printf '%s defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n' "${CONFIG_H}"
Hanno Becker6428f8d2017-09-22 16:58:50 +01001936 exit 1
1937fi
1938
Angus Grattonc4dd0732018-04-11 16:28:39 +10001939if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02001940 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10001941fi
1942
Hanno Becker4aed27e2017-09-18 15:00:34 +01001943requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001944run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001945 "$P_SRV debug_level=3" \
1946 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001947 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001948 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1949 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001950 -C "client hello, adding max_fragment_length extension" \
1951 -S "found max fragment length extension" \
1952 -S "server hello, max_fragment_length extension" \
1953 -C "found max_fragment_length extension"
1954
Hanno Becker4aed27e2017-09-18 15:00:34 +01001955requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001956run_test "Max fragment length: enabled, default, larger message" \
1957 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001958 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001959 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001960 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1961 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001962 -C "client hello, adding max_fragment_length extension" \
1963 -S "found max fragment length extension" \
1964 -S "server hello, max_fragment_length extension" \
1965 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001966 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1967 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001968 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001969
1970requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1971run_test "Max fragment length, DTLS: enabled, default, larger message" \
1972 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001973 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001974 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001975 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1976 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001977 -C "client hello, adding max_fragment_length extension" \
1978 -S "found max fragment length extension" \
1979 -S "server hello, max_fragment_length extension" \
1980 -C "found max_fragment_length extension" \
1981 -c "fragment larger than.*maximum "
1982
Angus Grattonc4dd0732018-04-11 16:28:39 +10001983# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1984# (session fragment length will be 16384 regardless of mbedtls
1985# content length configuration.)
1986
Hanno Beckerc5266962017-09-18 15:01:50 +01001987requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1988run_test "Max fragment length: disabled, larger message" \
1989 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001990 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001991 0 \
1992 -C "Maximum fragment length is 16384" \
1993 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001994 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1995 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001996 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001997
1998requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1999run_test "Max fragment length DTLS: disabled, larger message" \
2000 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002001 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002002 1 \
2003 -C "Maximum fragment length is 16384" \
2004 -S "Maximum fragment length is 16384" \
2005 -c "fragment larger than.*maximum "
2006
2007requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002008run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002009 "$P_SRV debug_level=3" \
2010 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002011 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002012 -c "Maximum fragment length is 4096" \
2013 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002014 -c "client hello, adding max_fragment_length extension" \
2015 -s "found max fragment length extension" \
2016 -s "server hello, max_fragment_length extension" \
2017 -c "found max_fragment_length extension"
2018
Hanno Becker4aed27e2017-09-18 15:00:34 +01002019requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002020run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002021 "$P_SRV debug_level=3 max_frag_len=4096" \
2022 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002023 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002024 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002025 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002026 -C "client hello, adding max_fragment_length extension" \
2027 -S "found max fragment length extension" \
2028 -S "server hello, max_fragment_length extension" \
2029 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002030
Hanno Becker4aed27e2017-09-18 15:00:34 +01002031requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002032requires_gnutls
2033run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002034 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002035 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002036 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002037 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002038 -c "client hello, adding max_fragment_length extension" \
2039 -c "found max_fragment_length extension"
2040
Hanno Becker4aed27e2017-09-18 15:00:34 +01002041requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002042run_test "Max fragment length: client, message just fits" \
2043 "$P_SRV debug_level=3" \
2044 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2045 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002046 -c "Maximum fragment length is 2048" \
2047 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002048 -c "client hello, adding max_fragment_length extension" \
2049 -s "found max fragment length extension" \
2050 -s "server hello, max_fragment_length extension" \
2051 -c "found max_fragment_length extension" \
2052 -c "2048 bytes written in 1 fragments" \
2053 -s "2048 bytes read"
2054
Hanno Becker4aed27e2017-09-18 15:00:34 +01002055requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002056run_test "Max fragment length: client, larger message" \
2057 "$P_SRV debug_level=3" \
2058 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2059 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002060 -c "Maximum fragment length is 2048" \
2061 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002062 -c "client hello, adding max_fragment_length extension" \
2063 -s "found max fragment length extension" \
2064 -s "server hello, max_fragment_length extension" \
2065 -c "found max_fragment_length extension" \
2066 -c "2345 bytes written in 2 fragments" \
2067 -s "2048 bytes read" \
2068 -s "297 bytes read"
2069
Hanno Becker4aed27e2017-09-18 15:00:34 +01002070requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002071run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002072 "$P_SRV debug_level=3 dtls=1" \
2073 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2074 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002075 -c "Maximum fragment length is 2048" \
2076 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002077 -c "client hello, adding max_fragment_length extension" \
2078 -s "found max fragment length extension" \
2079 -s "server hello, max_fragment_length extension" \
2080 -c "found max_fragment_length extension" \
2081 -c "fragment larger than.*maximum"
2082
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002083# Tests for renegotiation
2084
Hanno Becker6a243642017-10-12 15:18:45 +01002085# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002086run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002087 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002088 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002089 0 \
2090 -C "client hello, adding renegotiation extension" \
2091 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2092 -S "found renegotiation extension" \
2093 -s "server hello, secure renegotiation extension" \
2094 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002095 -C "=> renegotiate" \
2096 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002097 -S "write hello request"
2098
Hanno Becker6a243642017-10-12 15:18:45 +01002099requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002100run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002101 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002102 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002103 0 \
2104 -c "client hello, adding renegotiation extension" \
2105 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2106 -s "found renegotiation extension" \
2107 -s "server hello, secure renegotiation extension" \
2108 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002109 -c "=> renegotiate" \
2110 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002111 -S "write hello request"
2112
Hanno Becker6a243642017-10-12 15:18:45 +01002113requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002114run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002115 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002116 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002117 0 \
2118 -c "client hello, adding renegotiation extension" \
2119 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2120 -s "found renegotiation extension" \
2121 -s "server hello, secure renegotiation extension" \
2122 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002123 -c "=> renegotiate" \
2124 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002125 -s "write hello request"
2126
Janos Follathb0f148c2017-10-05 12:29:42 +01002127# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2128# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2129# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002130requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002131run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2132 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2133 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2134 0 \
2135 -c "client hello, adding renegotiation extension" \
2136 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2137 -s "found renegotiation extension" \
2138 -s "server hello, secure renegotiation extension" \
2139 -c "found renegotiation extension" \
2140 -c "=> renegotiate" \
2141 -s "=> renegotiate" \
2142 -S "write hello request" \
2143 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2144
2145# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2146# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2147# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002148requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002149run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2150 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2151 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2152 0 \
2153 -c "client hello, adding renegotiation extension" \
2154 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2155 -s "found renegotiation extension" \
2156 -s "server hello, secure renegotiation extension" \
2157 -c "found renegotiation extension" \
2158 -c "=> renegotiate" \
2159 -s "=> renegotiate" \
2160 -s "write hello request" \
2161 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2162
Hanno Becker6a243642017-10-12 15:18:45 +01002163requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002164run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002165 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002166 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002167 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" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002173 -c "=> renegotiate" \
2174 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002175 -s "write hello request"
2176
Hanno Becker6a243642017-10-12 15:18:45 +01002177requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002178run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002179 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002180 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002181 1 \
2182 -c "client hello, adding renegotiation extension" \
2183 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2184 -S "found renegotiation extension" \
2185 -s "server hello, secure renegotiation extension" \
2186 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002187 -c "=> renegotiate" \
2188 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002189 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002190 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002191 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002192
Hanno Becker6a243642017-10-12 15:18:45 +01002193requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002194run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002195 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002196 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002197 0 \
2198 -C "client hello, adding renegotiation extension" \
2199 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2200 -S "found renegotiation extension" \
2201 -s "server hello, secure renegotiation extension" \
2202 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002203 -C "=> renegotiate" \
2204 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002205 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002206 -S "SSL - An unexpected message was received from our peer" \
2207 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002208
Hanno Becker6a243642017-10-12 15:18:45 +01002209requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002210run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002211 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002212 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002213 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002214 0 \
2215 -C "client hello, adding renegotiation extension" \
2216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2217 -S "found renegotiation extension" \
2218 -s "server hello, secure renegotiation extension" \
2219 -c "found renegotiation extension" \
2220 -C "=> renegotiate" \
2221 -S "=> renegotiate" \
2222 -s "write hello request" \
2223 -S "SSL - An unexpected message was received from our peer" \
2224 -S "failed"
2225
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002226# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002227requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002228run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002229 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002230 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002231 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002232 0 \
2233 -C "client hello, adding renegotiation extension" \
2234 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2235 -S "found renegotiation extension" \
2236 -s "server hello, secure renegotiation extension" \
2237 -c "found renegotiation extension" \
2238 -C "=> renegotiate" \
2239 -S "=> renegotiate" \
2240 -s "write hello request" \
2241 -S "SSL - An unexpected message was received from our peer" \
2242 -S "failed"
2243
Hanno Becker6a243642017-10-12 15:18:45 +01002244requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002245run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002246 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002247 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002248 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002249 0 \
2250 -C "client hello, adding renegotiation extension" \
2251 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2252 -S "found renegotiation extension" \
2253 -s "server hello, secure renegotiation extension" \
2254 -c "found renegotiation extension" \
2255 -C "=> renegotiate" \
2256 -S "=> renegotiate" \
2257 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002258 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002259
Hanno Becker6a243642017-10-12 15:18:45 +01002260requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002261run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002262 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002263 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002264 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002265 0 \
2266 -c "client hello, adding renegotiation extension" \
2267 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2268 -s "found renegotiation extension" \
2269 -s "server hello, secure renegotiation extension" \
2270 -c "found renegotiation extension" \
2271 -c "=> renegotiate" \
2272 -s "=> renegotiate" \
2273 -s "write hello request" \
2274 -S "SSL - An unexpected message was received from our peer" \
2275 -S "failed"
2276
Hanno Becker6a243642017-10-12 15:18:45 +01002277requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002278run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002279 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002280 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2281 0 \
2282 -C "client hello, adding renegotiation extension" \
2283 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2284 -S "found renegotiation extension" \
2285 -s "server hello, secure renegotiation extension" \
2286 -c "found renegotiation extension" \
2287 -S "record counter limit reached: renegotiate" \
2288 -C "=> renegotiate" \
2289 -S "=> renegotiate" \
2290 -S "write hello request" \
2291 -S "SSL - An unexpected message was received from our peer" \
2292 -S "failed"
2293
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002294# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002295requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002296run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002297 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002298 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002299 0 \
2300 -c "client hello, adding renegotiation extension" \
2301 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2302 -s "found renegotiation extension" \
2303 -s "server hello, secure renegotiation extension" \
2304 -c "found renegotiation extension" \
2305 -s "record counter limit reached: renegotiate" \
2306 -c "=> renegotiate" \
2307 -s "=> renegotiate" \
2308 -s "write hello request" \
2309 -S "SSL - An unexpected message was received from our peer" \
2310 -S "failed"
2311
Hanno Becker6a243642017-10-12 15:18:45 +01002312requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002313run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002314 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002315 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002316 0 \
2317 -c "client hello, adding renegotiation extension" \
2318 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2319 -s "found renegotiation extension" \
2320 -s "server hello, secure renegotiation extension" \
2321 -c "found renegotiation extension" \
2322 -s "record counter limit reached: renegotiate" \
2323 -c "=> renegotiate" \
2324 -s "=> renegotiate" \
2325 -s "write hello request" \
2326 -S "SSL - An unexpected message was received from our peer" \
2327 -S "failed"
2328
Hanno Becker6a243642017-10-12 15:18:45 +01002329requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002330run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002331 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002332 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2333 0 \
2334 -C "client hello, adding renegotiation extension" \
2335 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2336 -S "found renegotiation extension" \
2337 -s "server hello, secure renegotiation extension" \
2338 -c "found renegotiation extension" \
2339 -S "record counter limit reached: renegotiate" \
2340 -C "=> renegotiate" \
2341 -S "=> renegotiate" \
2342 -S "write hello request" \
2343 -S "SSL - An unexpected message was received from our peer" \
2344 -S "failed"
2345
Hanno Becker6a243642017-10-12 15:18:45 +01002346requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002347run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002348 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002349 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002350 0 \
2351 -c "client hello, adding renegotiation extension" \
2352 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2353 -s "found renegotiation extension" \
2354 -s "server hello, secure renegotiation extension" \
2355 -c "found renegotiation extension" \
2356 -c "=> renegotiate" \
2357 -s "=> renegotiate" \
2358 -S "write hello request"
2359
Hanno Becker6a243642017-10-12 15:18:45 +01002360requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002361run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002362 "$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 +02002363 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002364 0 \
2365 -c "client hello, adding renegotiation extension" \
2366 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2367 -s "found renegotiation extension" \
2368 -s "server hello, secure renegotiation extension" \
2369 -c "found renegotiation extension" \
2370 -c "=> renegotiate" \
2371 -s "=> renegotiate" \
2372 -s "write hello request"
2373
Hanno Becker6a243642017-10-12 15:18:45 +01002374requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002375run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002376 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002377 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002378 0 \
2379 -c "client hello, adding renegotiation extension" \
2380 -c "found renegotiation extension" \
2381 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002382 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002383 -C "error" \
2384 -c "HTTP/1.0 200 [Oo][Kk]"
2385
Paul Bakker539d9722015-02-08 16:18:35 +01002386requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002387requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002388run_test "Renegotiation: gnutls server strict, client-initiated" \
2389 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002390 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002391 0 \
2392 -c "client hello, adding renegotiation extension" \
2393 -c "found renegotiation extension" \
2394 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002395 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002396 -C "error" \
2397 -c "HTTP/1.0 200 [Oo][Kk]"
2398
Paul Bakker539d9722015-02-08 16:18:35 +01002399requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002400requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002401run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2402 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2403 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2404 1 \
2405 -c "client hello, adding renegotiation extension" \
2406 -C "found renegotiation extension" \
2407 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002408 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002409 -c "error" \
2410 -C "HTTP/1.0 200 [Oo][Kk]"
2411
Paul Bakker539d9722015-02-08 16:18:35 +01002412requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002413requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002414run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2415 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2416 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2417 allow_legacy=0" \
2418 1 \
2419 -c "client hello, adding renegotiation extension" \
2420 -C "found renegotiation extension" \
2421 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002422 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002423 -c "error" \
2424 -C "HTTP/1.0 200 [Oo][Kk]"
2425
Paul Bakker539d9722015-02-08 16:18:35 +01002426requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002428run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2429 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2430 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2431 allow_legacy=1" \
2432 0 \
2433 -c "client hello, adding renegotiation extension" \
2434 -C "found renegotiation extension" \
2435 -c "=> renegotiate" \
2436 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002437 -C "error" \
2438 -c "HTTP/1.0 200 [Oo][Kk]"
2439
Hanno Becker6a243642017-10-12 15:18:45 +01002440requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002441run_test "Renegotiation: DTLS, client-initiated" \
2442 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2443 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2444 0 \
2445 -c "client hello, adding renegotiation extension" \
2446 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2447 -s "found renegotiation extension" \
2448 -s "server hello, secure renegotiation extension" \
2449 -c "found renegotiation extension" \
2450 -c "=> renegotiate" \
2451 -s "=> renegotiate" \
2452 -S "write hello request"
2453
Hanno Becker6a243642017-10-12 15:18:45 +01002454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002455run_test "Renegotiation: DTLS, server-initiated" \
2456 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002457 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2458 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002459 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
Andres AG692ad842017-01-19 16:30:57 +00002470run_test "Renegotiation: DTLS, renego_period overflow" \
2471 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2472 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2473 0 \
2474 -c "client hello, adding renegotiation extension" \
2475 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2476 -s "found renegotiation extension" \
2477 -s "server hello, secure renegotiation extension" \
2478 -s "record counter limit reached: renegotiate" \
2479 -c "=> renegotiate" \
2480 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002481 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002482
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002483requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002484requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002485run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2486 "$G_SRV -u --mtu 4096" \
2487 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2488 0 \
2489 -c "client hello, adding renegotiation extension" \
2490 -c "found renegotiation extension" \
2491 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002492 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002493 -C "error" \
2494 -s "Extra-header:"
2495
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002496# Test for the "secure renegotation" extension only (no actual renegotiation)
2497
Paul Bakker539d9722015-02-08 16:18:35 +01002498requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002499run_test "Renego ext: gnutls server strict, client default" \
2500 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2501 "$P_CLI debug_level=3" \
2502 0 \
2503 -c "found renegotiation extension" \
2504 -C "error" \
2505 -c "HTTP/1.0 200 [Oo][Kk]"
2506
Paul Bakker539d9722015-02-08 16:18:35 +01002507requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002508run_test "Renego ext: gnutls server unsafe, client default" \
2509 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2510 "$P_CLI debug_level=3" \
2511 0 \
2512 -C "found renegotiation extension" \
2513 -C "error" \
2514 -c "HTTP/1.0 200 [Oo][Kk]"
2515
Paul Bakker539d9722015-02-08 16:18:35 +01002516requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002517run_test "Renego ext: gnutls server unsafe, client break legacy" \
2518 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2519 "$P_CLI debug_level=3 allow_legacy=-1" \
2520 1 \
2521 -C "found renegotiation extension" \
2522 -c "error" \
2523 -C "HTTP/1.0 200 [Oo][Kk]"
2524
Paul Bakker539d9722015-02-08 16:18:35 +01002525requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002526run_test "Renego ext: gnutls client strict, server default" \
2527 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002528 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002529 0 \
2530 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2531 -s "server hello, secure renegotiation extension"
2532
Paul Bakker539d9722015-02-08 16:18:35 +01002533requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002534run_test "Renego ext: gnutls client unsafe, server default" \
2535 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002536 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002537 0 \
2538 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2539 -S "server hello, secure renegotiation extension"
2540
Paul Bakker539d9722015-02-08 16:18:35 +01002541requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002542run_test "Renego ext: gnutls client unsafe, server break legacy" \
2543 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002544 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002545 1 \
2546 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2547 -S "server hello, secure renegotiation extension"
2548
Janos Follath0b242342016-02-17 10:11:21 +00002549# Tests for silently dropping trailing extra bytes in .der certificates
2550
2551requires_gnutls
2552run_test "DER format: no trailing bytes" \
2553 "$P_SRV crt_file=data_files/server5-der0.crt \
2554 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002555 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002556 0 \
2557 -c "Handshake was completed" \
2558
2559requires_gnutls
2560run_test "DER format: with a trailing zero byte" \
2561 "$P_SRV crt_file=data_files/server5-der1a.crt \
2562 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002563 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002564 0 \
2565 -c "Handshake was completed" \
2566
2567requires_gnutls
2568run_test "DER format: with a trailing random byte" \
2569 "$P_SRV crt_file=data_files/server5-der1b.crt \
2570 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002571 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002572 0 \
2573 -c "Handshake was completed" \
2574
2575requires_gnutls
2576run_test "DER format: with 2 trailing random bytes" \
2577 "$P_SRV crt_file=data_files/server5-der2.crt \
2578 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002579 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002580 0 \
2581 -c "Handshake was completed" \
2582
2583requires_gnutls
2584run_test "DER format: with 4 trailing random bytes" \
2585 "$P_SRV crt_file=data_files/server5-der4.crt \
2586 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002587 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002588 0 \
2589 -c "Handshake was completed" \
2590
2591requires_gnutls
2592run_test "DER format: with 8 trailing random bytes" \
2593 "$P_SRV crt_file=data_files/server5-der8.crt \
2594 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002595 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002596 0 \
2597 -c "Handshake was completed" \
2598
2599requires_gnutls
2600run_test "DER format: with 9 trailing random bytes" \
2601 "$P_SRV crt_file=data_files/server5-der9.crt \
2602 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002603 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002604 0 \
2605 -c "Handshake was completed" \
2606
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002607# Tests for auth_mode
2608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002609run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002610 "$P_SRV crt_file=data_files/server5-badsign.crt \
2611 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002612 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002613 1 \
2614 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002615 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002616 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002617 -c "X509 - Certificate verification failed"
2618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002619run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002620 "$P_SRV crt_file=data_files/server5-badsign.crt \
2621 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002622 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002623 0 \
2624 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002625 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002626 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002627 -C "X509 - Certificate verification failed"
2628
Hanno Beckere6706e62017-05-15 16:05:15 +01002629run_test "Authentication: server goodcert, client optional, no trusted CA" \
2630 "$P_SRV" \
2631 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2632 0 \
2633 -c "x509_verify_cert() returned" \
2634 -c "! The certificate is not correctly signed by the trusted CA" \
2635 -c "! Certificate verification flags"\
2636 -C "! mbedtls_ssl_handshake returned" \
2637 -C "X509 - Certificate verification failed" \
2638 -C "SSL - No CA Chain is set, but required to operate"
2639
2640run_test "Authentication: server goodcert, client required, no trusted CA" \
2641 "$P_SRV" \
2642 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2643 1 \
2644 -c "x509_verify_cert() returned" \
2645 -c "! The certificate is not correctly signed by the trusted CA" \
2646 -c "! Certificate verification flags"\
2647 -c "! mbedtls_ssl_handshake returned" \
2648 -c "SSL - No CA Chain is set, but required to operate"
2649
2650# The purpose of the next two tests is to test the client's behaviour when receiving a server
2651# certificate with an unsupported elliptic curve. This should usually not happen because
2652# the client informs the server about the supported curves - it does, though, in the
2653# corner case of a static ECDH suite, because the server doesn't check the curve on that
2654# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2655# different means to have the server ignoring the client's supported curve list.
2656
2657requires_config_enabled MBEDTLS_ECP_C
2658run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2659 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2660 crt_file=data_files/server5.ku-ka.crt" \
2661 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2662 1 \
2663 -c "bad certificate (EC key curve)"\
2664 -c "! Certificate verification flags"\
2665 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2666
2667requires_config_enabled MBEDTLS_ECP_C
2668run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2669 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2670 crt_file=data_files/server5.ku-ka.crt" \
2671 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2672 1 \
2673 -c "bad certificate (EC key curve)"\
2674 -c "! Certificate verification flags"\
2675 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002677run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002678 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002679 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002680 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002681 0 \
2682 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002683 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002684 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002685 -C "X509 - Certificate verification failed"
2686
Simon Butcher99000142016-10-13 17:21:01 +01002687run_test "Authentication: client SHA256, server required" \
2688 "$P_SRV auth_mode=required" \
2689 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2690 key_file=data_files/server6.key \
2691 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2692 0 \
2693 -c "Supported Signature Algorithm found: 4," \
2694 -c "Supported Signature Algorithm found: 5,"
2695
2696run_test "Authentication: client SHA384, server required" \
2697 "$P_SRV auth_mode=required" \
2698 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2699 key_file=data_files/server6.key \
2700 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2701 0 \
2702 -c "Supported Signature Algorithm found: 4," \
2703 -c "Supported Signature Algorithm found: 5,"
2704
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002705requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2706run_test "Authentication: client has no cert, server required (SSLv3)" \
2707 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2708 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2709 key_file=data_files/server5.key" \
2710 1 \
2711 -S "skip write certificate request" \
2712 -C "skip parse certificate request" \
2713 -c "got a certificate request" \
2714 -c "got no certificate to send" \
2715 -S "x509_verify_cert() returned" \
2716 -s "client has no certificate" \
2717 -s "! mbedtls_ssl_handshake returned" \
2718 -c "! mbedtls_ssl_handshake returned" \
2719 -s "No client certification received from the client, but required by the authentication mode"
2720
2721run_test "Authentication: client has no cert, server required (TLS)" \
2722 "$P_SRV debug_level=3 auth_mode=required" \
2723 "$P_CLI debug_level=3 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 "= write certificate$" \
2730 -C "skip write certificate$" \
2731 -S "x509_verify_cert() returned" \
2732 -s "client has no certificate" \
2733 -s "! mbedtls_ssl_handshake returned" \
2734 -c "! mbedtls_ssl_handshake returned" \
2735 -s "No client certification received from the client, but required by the authentication mode"
2736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002737run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002738 "$P_SRV debug_level=3 auth_mode=required" \
2739 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002740 key_file=data_files/server5.key" \
2741 1 \
2742 -S "skip write certificate request" \
2743 -C "skip parse certificate request" \
2744 -c "got a certificate request" \
2745 -C "skip write certificate" \
2746 -C "skip write certificate verify" \
2747 -S "skip parse certificate verify" \
2748 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002749 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002750 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002751 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002752 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002753 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002754# We don't check that the client receives the alert because it might
2755# detect that its write end of the connection is closed and abort
2756# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002757
Janos Follath89baba22017-04-10 14:34:35 +01002758run_test "Authentication: client cert not trusted, server required" \
2759 "$P_SRV debug_level=3 auth_mode=required" \
2760 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2761 key_file=data_files/server5.key" \
2762 1 \
2763 -S "skip write certificate request" \
2764 -C "skip parse certificate request" \
2765 -c "got a certificate request" \
2766 -C "skip write certificate" \
2767 -C "skip write certificate verify" \
2768 -S "skip parse certificate verify" \
2769 -s "x509_verify_cert() returned" \
2770 -s "! The certificate is not correctly signed by the trusted CA" \
2771 -s "! mbedtls_ssl_handshake returned" \
2772 -c "! mbedtls_ssl_handshake returned" \
2773 -s "X509 - Certificate verification failed"
2774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002775run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002776 "$P_SRV debug_level=3 auth_mode=optional" \
2777 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002778 key_file=data_files/server5.key" \
2779 0 \
2780 -S "skip write certificate request" \
2781 -C "skip parse certificate request" \
2782 -c "got a certificate request" \
2783 -C "skip write certificate" \
2784 -C "skip write certificate verify" \
2785 -S "skip parse certificate verify" \
2786 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002787 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002788 -S "! mbedtls_ssl_handshake returned" \
2789 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002790 -S "X509 - Certificate verification failed"
2791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002792run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002793 "$P_SRV debug_level=3 auth_mode=none" \
2794 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002795 key_file=data_files/server5.key" \
2796 0 \
2797 -s "skip write certificate request" \
2798 -C "skip parse certificate request" \
2799 -c "got no certificate request" \
2800 -c "skip write certificate" \
2801 -c "skip write certificate verify" \
2802 -s "skip parse certificate verify" \
2803 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002804 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002805 -S "! mbedtls_ssl_handshake returned" \
2806 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002807 -S "X509 - Certificate verification failed"
2808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002809run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002810 "$P_SRV debug_level=3 auth_mode=optional" \
2811 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002812 0 \
2813 -S "skip write certificate request" \
2814 -C "skip parse certificate request" \
2815 -c "got a certificate request" \
2816 -C "skip write certificate$" \
2817 -C "got no certificate to send" \
2818 -S "SSLv3 client has no certificate" \
2819 -c "skip write certificate verify" \
2820 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002821 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002822 -S "! mbedtls_ssl_handshake returned" \
2823 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002824 -S "X509 - Certificate verification failed"
2825
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002826run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002827 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002828 "$O_CLI" \
2829 0 \
2830 -S "skip write certificate request" \
2831 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002832 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002833 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002834 -S "X509 - Certificate verification failed"
2835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002836run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002837 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002838 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002839 0 \
2840 -C "skip parse certificate request" \
2841 -c "got a certificate request" \
2842 -C "skip write certificate$" \
2843 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002844 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002845
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002846run_test "Authentication: client no cert, openssl server required" \
2847 "$O_SRV -Verify 10" \
2848 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2849 1 \
2850 -C "skip parse certificate request" \
2851 -c "got a certificate request" \
2852 -C "skip write certificate$" \
2853 -c "skip write certificate verify" \
2854 -c "! mbedtls_ssl_handshake returned"
2855
Janos Follathe2681a42016-03-07 15:57:05 +00002856requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002857run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002858 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002859 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002860 0 \
2861 -S "skip write certificate request" \
2862 -C "skip parse certificate request" \
2863 -c "got a certificate request" \
2864 -C "skip write certificate$" \
2865 -c "skip write certificate verify" \
2866 -c "got no certificate to send" \
2867 -s "SSLv3 client has no certificate" \
2868 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002869 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002870 -S "! mbedtls_ssl_handshake returned" \
2871 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002872 -S "X509 - Certificate verification failed"
2873
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002874# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2875# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002876
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002877MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002878MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002879
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002880if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002881 cat <<EOF
2882${CONFIG_H} contains a value for the configuration of
2883MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
2884test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01002885
Gilles Peskineffdcadf2020-08-26 20:05:11 +02002886The tests assume this value and if it changes, the tests in this
2887script should also be adjusted.
2888EOF
Simon Butcher06b78632017-07-28 01:00:17 +01002889 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002890fi
2891
Angus Grattonc4dd0732018-04-11 16:28:39 +10002892requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002893run_test "Authentication: server max_int chain, client default" \
2894 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2895 key_file=data_files/dir-maxpath/09.key" \
2896 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2897 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002898 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002899
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+1 chain, client default" \
2902 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2903 key_file=data_files/dir-maxpath/10.key" \
2904 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2905 1 \
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
Angus Grattonc4dd0732018-04-11 16:28:39 +10002908requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002909run_test "Authentication: server max_int+1 chain, client optional" \
2910 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2911 key_file=data_files/dir-maxpath/10.key" \
2912 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2913 auth_mode=optional" \
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
Angus Grattonc4dd0732018-04-11 16:28:39 +10002917requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002918run_test "Authentication: server max_int+1 chain, client none" \
2919 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2920 key_file=data_files/dir-maxpath/10.key" \
2921 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2922 auth_mode=none" \
2923 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002924 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002925
Angus Grattonc4dd0732018-04-11 16:28:39 +10002926requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002927run_test "Authentication: client max_int+1 chain, server default" \
2928 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2929 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2930 key_file=data_files/dir-maxpath/10.key" \
2931 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002932 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002933
Angus Grattonc4dd0732018-04-11 16:28:39 +10002934requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002935run_test "Authentication: client max_int+1 chain, server optional" \
2936 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2937 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2938 key_file=data_files/dir-maxpath/10.key" \
2939 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002940 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002941
Angus Grattonc4dd0732018-04-11 16:28:39 +10002942requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002943run_test "Authentication: client max_int+1 chain, server required" \
2944 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2945 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2946 key_file=data_files/dir-maxpath/10.key" \
2947 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002948 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002949
Angus Grattonc4dd0732018-04-11 16:28:39 +10002950requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002951run_test "Authentication: client max_int chain, server required" \
2952 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2953 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2954 key_file=data_files/dir-maxpath/09.key" \
2955 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002956 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002957
Janos Follath89baba22017-04-10 14:34:35 +01002958# Tests for CA list in CertificateRequest messages
2959
2960run_test "Authentication: send CA list in CertificateRequest (default)" \
2961 "$P_SRV debug_level=3 auth_mode=required" \
2962 "$P_CLI crt_file=data_files/server6.crt \
2963 key_file=data_files/server6.key" \
2964 0 \
2965 -s "requested DN"
2966
2967run_test "Authentication: do not send CA list in CertificateRequest" \
2968 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2969 "$P_CLI crt_file=data_files/server6.crt \
2970 key_file=data_files/server6.key" \
2971 0 \
2972 -S "requested DN"
2973
2974run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2975 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2976 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2977 key_file=data_files/server5.key" \
2978 1 \
2979 -S "requested DN" \
2980 -s "x509_verify_cert() returned" \
2981 -s "! The certificate is not correctly signed by the trusted CA" \
2982 -s "! mbedtls_ssl_handshake returned" \
2983 -c "! mbedtls_ssl_handshake returned" \
2984 -s "X509 - Certificate verification failed"
2985
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002986# Tests for certificate selection based on SHA verson
2987
2988run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2989 "$P_SRV crt_file=data_files/server5.crt \
2990 key_file=data_files/server5.key \
2991 crt_file2=data_files/server5-sha1.crt \
2992 key_file2=data_files/server5.key" \
2993 "$P_CLI force_version=tls1_2" \
2994 0 \
2995 -c "signed using.*ECDSA with SHA256" \
2996 -C "signed using.*ECDSA with SHA1"
2997
2998run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2999 "$P_SRV crt_file=data_files/server5.crt \
3000 key_file=data_files/server5.key \
3001 crt_file2=data_files/server5-sha1.crt \
3002 key_file2=data_files/server5.key" \
3003 "$P_CLI force_version=tls1_1" \
3004 0 \
3005 -C "signed using.*ECDSA with SHA256" \
3006 -c "signed using.*ECDSA with SHA1"
3007
3008run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3009 "$P_SRV crt_file=data_files/server5.crt \
3010 key_file=data_files/server5.key \
3011 crt_file2=data_files/server5-sha1.crt \
3012 key_file2=data_files/server5.key" \
3013 "$P_CLI force_version=tls1" \
3014 0 \
3015 -C "signed using.*ECDSA with SHA256" \
3016 -c "signed using.*ECDSA with SHA1"
3017
3018run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3019 "$P_SRV crt_file=data_files/server5.crt \
3020 key_file=data_files/server5.key \
3021 crt_file2=data_files/server6.crt \
3022 key_file2=data_files/server6.key" \
3023 "$P_CLI force_version=tls1_1" \
3024 0 \
3025 -c "serial number.*09" \
3026 -c "signed using.*ECDSA with SHA256" \
3027 -C "signed using.*ECDSA with SHA1"
3028
3029run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3030 "$P_SRV crt_file=data_files/server6.crt \
3031 key_file=data_files/server6.key \
3032 crt_file2=data_files/server5.crt \
3033 key_file2=data_files/server5.key" \
3034 "$P_CLI force_version=tls1_1" \
3035 0 \
3036 -c "serial number.*0A" \
3037 -c "signed using.*ECDSA with SHA256" \
3038 -C "signed using.*ECDSA with SHA1"
3039
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003040# tests for SNI
3041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003042run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003043 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003044 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003045 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003046 0 \
3047 -S "parse ServerName extension" \
3048 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3049 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003050
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003051run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003052 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003053 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003054 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 +02003055 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003056 0 \
3057 -s "parse ServerName extension" \
3058 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3059 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003061run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003062 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003063 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003064 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 +02003065 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003066 0 \
3067 -s "parse ServerName extension" \
3068 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3069 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003071run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003072 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003073 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003074 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 +02003075 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003076 1 \
3077 -s "parse ServerName extension" \
3078 -s "ssl_sni_wrapper() returned" \
3079 -s "mbedtls_ssl_handshake returned" \
3080 -c "mbedtls_ssl_handshake returned" \
3081 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003082
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003083run_test "SNI: client auth no override: optional" \
3084 "$P_SRV debug_level=3 auth_mode=optional \
3085 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3086 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3087 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003088 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003089 -S "skip write certificate request" \
3090 -C "skip parse certificate request" \
3091 -c "got a certificate request" \
3092 -C "skip write certificate" \
3093 -C "skip write certificate verify" \
3094 -S "skip parse certificate verify"
3095
3096run_test "SNI: client auth override: none -> optional" \
3097 "$P_SRV debug_level=3 auth_mode=none \
3098 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3099 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3100 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003101 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003102 -S "skip write certificate request" \
3103 -C "skip parse certificate request" \
3104 -c "got a certificate request" \
3105 -C "skip write certificate" \
3106 -C "skip write certificate verify" \
3107 -S "skip parse certificate verify"
3108
3109run_test "SNI: client auth override: optional -> none" \
3110 "$P_SRV debug_level=3 auth_mode=optional \
3111 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3112 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3113 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003114 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003115 -s "skip write certificate request" \
3116 -C "skip parse certificate request" \
3117 -c "got no certificate request" \
3118 -c "skip write certificate" \
3119 -c "skip write certificate verify" \
3120 -s "skip parse certificate verify"
3121
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003122run_test "SNI: CA no override" \
3123 "$P_SRV debug_level=3 auth_mode=optional \
3124 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3125 ca_file=data_files/test-ca.crt \
3126 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3127 "$P_CLI debug_level=3 server_name=localhost \
3128 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3129 1 \
3130 -S "skip write certificate request" \
3131 -C "skip parse certificate request" \
3132 -c "got a certificate request" \
3133 -C "skip write certificate" \
3134 -C "skip write certificate verify" \
3135 -S "skip parse certificate verify" \
3136 -s "x509_verify_cert() returned" \
3137 -s "! The certificate is not correctly signed by the trusted CA" \
3138 -S "The certificate has been revoked (is on a CRL)"
3139
3140run_test "SNI: CA override" \
3141 "$P_SRV debug_level=3 auth_mode=optional \
3142 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3143 ca_file=data_files/test-ca.crt \
3144 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3145 "$P_CLI debug_level=3 server_name=localhost \
3146 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3147 0 \
3148 -S "skip write certificate request" \
3149 -C "skip parse certificate request" \
3150 -c "got a certificate request" \
3151 -C "skip write certificate" \
3152 -C "skip write certificate verify" \
3153 -S "skip parse certificate verify" \
3154 -S "x509_verify_cert() returned" \
3155 -S "! The certificate is not correctly signed by the trusted CA" \
3156 -S "The certificate has been revoked (is on a CRL)"
3157
3158run_test "SNI: CA override with CRL" \
3159 "$P_SRV debug_level=3 auth_mode=optional \
3160 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3161 ca_file=data_files/test-ca.crt \
3162 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3163 "$P_CLI debug_level=3 server_name=localhost \
3164 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3165 1 \
3166 -S "skip write certificate request" \
3167 -C "skip parse certificate request" \
3168 -c "got a certificate request" \
3169 -C "skip write certificate" \
3170 -C "skip write certificate verify" \
3171 -S "skip parse certificate verify" \
3172 -s "x509_verify_cert() returned" \
3173 -S "! The certificate is not correctly signed by the trusted CA" \
3174 -s "The certificate has been revoked (is on a CRL)"
3175
Andres AG1a834452016-12-07 10:01:30 +00003176# Tests for SNI and DTLS
3177
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003178run_test "SNI: DTLS, no SNI callback" \
3179 "$P_SRV debug_level=3 dtls=1 \
3180 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3181 "$P_CLI server_name=localhost dtls=1" \
3182 0 \
3183 -S "parse ServerName extension" \
3184 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3185 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3186
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003187run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003188 "$P_SRV debug_level=3 dtls=1 \
3189 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3190 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3191 "$P_CLI server_name=localhost dtls=1" \
3192 0 \
3193 -s "parse ServerName extension" \
3194 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3195 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3196
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003197run_test "SNI: DTLS, matching cert 2" \
3198 "$P_SRV debug_level=3 dtls=1 \
3199 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3200 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3201 "$P_CLI server_name=polarssl.example dtls=1" \
3202 0 \
3203 -s "parse ServerName extension" \
3204 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3205 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3206
3207run_test "SNI: DTLS, no matching cert" \
3208 "$P_SRV debug_level=3 dtls=1 \
3209 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3210 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3211 "$P_CLI server_name=nonesuch.example dtls=1" \
3212 1 \
3213 -s "parse ServerName extension" \
3214 -s "ssl_sni_wrapper() returned" \
3215 -s "mbedtls_ssl_handshake returned" \
3216 -c "mbedtls_ssl_handshake returned" \
3217 -c "SSL - A fatal alert message was received from our peer"
3218
3219run_test "SNI: DTLS, client auth no override: optional" \
3220 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3221 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3222 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3223 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3224 0 \
3225 -S "skip write certificate request" \
3226 -C "skip parse certificate request" \
3227 -c "got a certificate request" \
3228 -C "skip write certificate" \
3229 -C "skip write certificate verify" \
3230 -S "skip parse certificate verify"
3231
3232run_test "SNI: DTLS, client auth override: none -> optional" \
3233 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3234 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3235 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3236 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3237 0 \
3238 -S "skip write certificate request" \
3239 -C "skip parse certificate request" \
3240 -c "got a certificate request" \
3241 -C "skip write certificate" \
3242 -C "skip write certificate verify" \
3243 -S "skip parse certificate verify"
3244
3245run_test "SNI: DTLS, client auth override: optional -> none" \
3246 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3247 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3248 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3249 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3250 0 \
3251 -s "skip write certificate request" \
3252 -C "skip parse certificate request" \
3253 -c "got no certificate request" \
3254 -c "skip write certificate" \
3255 -c "skip write certificate verify" \
3256 -s "skip parse certificate verify"
3257
3258run_test "SNI: DTLS, CA no override" \
3259 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3260 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3261 ca_file=data_files/test-ca.crt \
3262 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3263 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3264 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3265 1 \
3266 -S "skip write certificate request" \
3267 -C "skip parse certificate request" \
3268 -c "got a certificate request" \
3269 -C "skip write certificate" \
3270 -C "skip write certificate verify" \
3271 -S "skip parse certificate verify" \
3272 -s "x509_verify_cert() returned" \
3273 -s "! The certificate is not correctly signed by the trusted CA" \
3274 -S "The certificate has been revoked (is on a CRL)"
3275
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003276run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003277 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3278 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3279 ca_file=data_files/test-ca.crt \
3280 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3281 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3282 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3283 0 \
3284 -S "skip write certificate request" \
3285 -C "skip parse certificate request" \
3286 -c "got a certificate request" \
3287 -C "skip write certificate" \
3288 -C "skip write certificate verify" \
3289 -S "skip parse certificate verify" \
3290 -S "x509_verify_cert() returned" \
3291 -S "! The certificate is not correctly signed by the trusted CA" \
3292 -S "The certificate has been revoked (is on a CRL)"
3293
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003294run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003295 "$P_SRV debug_level=3 auth_mode=optional \
3296 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3297 ca_file=data_files/test-ca.crt \
3298 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3299 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3300 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3301 1 \
3302 -S "skip write certificate request" \
3303 -C "skip parse certificate request" \
3304 -c "got a certificate request" \
3305 -C "skip write certificate" \
3306 -C "skip write certificate verify" \
3307 -S "skip parse certificate verify" \
3308 -s "x509_verify_cert() returned" \
3309 -S "! The certificate is not correctly signed by the trusted CA" \
3310 -s "The certificate has been revoked (is on a CRL)"
3311
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003312# Tests for non-blocking I/O: exercise a variety of handshake flows
3313
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003314run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003315 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3316 "$P_CLI nbio=2 tickets=0" \
3317 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003318 -S "mbedtls_ssl_handshake returned" \
3319 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003320 -c "Read from server: .* bytes read"
3321
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003322run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003323 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3324 "$P_CLI nbio=2 tickets=0" \
3325 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003326 -S "mbedtls_ssl_handshake returned" \
3327 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003328 -c "Read from server: .* bytes read"
3329
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003330run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003331 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3332 "$P_CLI nbio=2 tickets=1" \
3333 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003334 -S "mbedtls_ssl_handshake returned" \
3335 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003336 -c "Read from server: .* bytes read"
3337
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003338run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003339 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3340 "$P_CLI nbio=2 tickets=1" \
3341 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003342 -S "mbedtls_ssl_handshake returned" \
3343 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003344 -c "Read from server: .* bytes read"
3345
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003346run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003347 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3348 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3349 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003350 -S "mbedtls_ssl_handshake returned" \
3351 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003352 -c "Read from server: .* bytes read"
3353
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003354run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003355 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3356 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3357 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003358 -S "mbedtls_ssl_handshake returned" \
3359 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003360 -c "Read from server: .* bytes read"
3361
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003362run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003363 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3364 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3365 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003366 -S "mbedtls_ssl_handshake returned" \
3367 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003368 -c "Read from server: .* bytes read"
3369
Hanno Becker00076712017-11-15 16:39:08 +00003370# Tests for event-driven I/O: exercise a variety of handshake flows
3371
3372run_test "Event-driven I/O: basic handshake" \
3373 "$P_SRV event=1 tickets=0 auth_mode=none" \
3374 "$P_CLI event=1 tickets=0" \
3375 0 \
3376 -S "mbedtls_ssl_handshake returned" \
3377 -C "mbedtls_ssl_handshake returned" \
3378 -c "Read from server: .* bytes read"
3379
3380run_test "Event-driven I/O: client auth" \
3381 "$P_SRV event=1 tickets=0 auth_mode=required" \
3382 "$P_CLI event=1 tickets=0" \
3383 0 \
3384 -S "mbedtls_ssl_handshake returned" \
3385 -C "mbedtls_ssl_handshake returned" \
3386 -c "Read from server: .* bytes read"
3387
3388run_test "Event-driven I/O: ticket" \
3389 "$P_SRV event=1 tickets=1 auth_mode=none" \
3390 "$P_CLI event=1 tickets=1" \
3391 0 \
3392 -S "mbedtls_ssl_handshake returned" \
3393 -C "mbedtls_ssl_handshake returned" \
3394 -c "Read from server: .* bytes read"
3395
3396run_test "Event-driven I/O: ticket + client auth" \
3397 "$P_SRV event=1 tickets=1 auth_mode=required" \
3398 "$P_CLI event=1 tickets=1" \
3399 0 \
3400 -S "mbedtls_ssl_handshake returned" \
3401 -C "mbedtls_ssl_handshake returned" \
3402 -c "Read from server: .* bytes read"
3403
3404run_test "Event-driven I/O: ticket + client auth + resume" \
3405 "$P_SRV event=1 tickets=1 auth_mode=required" \
3406 "$P_CLI event=1 tickets=1 reconnect=1" \
3407 0 \
3408 -S "mbedtls_ssl_handshake returned" \
3409 -C "mbedtls_ssl_handshake returned" \
3410 -c "Read from server: .* bytes read"
3411
3412run_test "Event-driven I/O: ticket + resume" \
3413 "$P_SRV event=1 tickets=1 auth_mode=none" \
3414 "$P_CLI event=1 tickets=1 reconnect=1" \
3415 0 \
3416 -S "mbedtls_ssl_handshake returned" \
3417 -C "mbedtls_ssl_handshake returned" \
3418 -c "Read from server: .* bytes read"
3419
3420run_test "Event-driven I/O: session-id resume" \
3421 "$P_SRV event=1 tickets=0 auth_mode=none" \
3422 "$P_CLI event=1 tickets=0 reconnect=1" \
3423 0 \
3424 -S "mbedtls_ssl_handshake returned" \
3425 -C "mbedtls_ssl_handshake returned" \
3426 -c "Read from server: .* bytes read"
3427
Hanno Becker6a33f592018-03-13 11:38:46 +00003428run_test "Event-driven I/O, DTLS: basic handshake" \
3429 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3430 "$P_CLI dtls=1 event=1 tickets=0" \
3431 0 \
3432 -c "Read from server: .* bytes read"
3433
3434run_test "Event-driven I/O, DTLS: client auth" \
3435 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3436 "$P_CLI dtls=1 event=1 tickets=0" \
3437 0 \
3438 -c "Read from server: .* bytes read"
3439
3440run_test "Event-driven I/O, DTLS: ticket" \
3441 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3442 "$P_CLI dtls=1 event=1 tickets=1" \
3443 0 \
3444 -c "Read from server: .* bytes read"
3445
3446run_test "Event-driven I/O, DTLS: ticket + client auth" \
3447 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3448 "$P_CLI dtls=1 event=1 tickets=1" \
3449 0 \
3450 -c "Read from server: .* bytes read"
3451
3452run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3453 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003454 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003455 0 \
3456 -c "Read from server: .* bytes read"
3457
3458run_test "Event-driven I/O, DTLS: ticket + resume" \
3459 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003460 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003461 0 \
3462 -c "Read from server: .* bytes read"
3463
3464run_test "Event-driven I/O, DTLS: session-id resume" \
3465 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003466 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003467 0 \
3468 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003469
3470# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3471# During session resumption, the client will send its ApplicationData record
3472# within the same datagram as the Finished messages. In this situation, the
3473# server MUST NOT idle on the underlying transport after handshake completion,
3474# because the ApplicationData request has already been queued internally.
3475run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003476 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003477 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003478 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003479 0 \
3480 -c "Read from server: .* bytes read"
3481
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003482# Tests for version negotiation
3483
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003484run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003485 "$P_SRV" \
3486 "$P_CLI" \
3487 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003488 -S "mbedtls_ssl_handshake returned" \
3489 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003490 -s "Protocol is TLSv1.2" \
3491 -c "Protocol is TLSv1.2"
3492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003493run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003494 "$P_SRV" \
3495 "$P_CLI max_version=tls1_1" \
3496 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003497 -S "mbedtls_ssl_handshake returned" \
3498 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003499 -s "Protocol is TLSv1.1" \
3500 -c "Protocol is TLSv1.1"
3501
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003502run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003503 "$P_SRV max_version=tls1_1" \
3504 "$P_CLI" \
3505 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003506 -S "mbedtls_ssl_handshake returned" \
3507 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003508 -s "Protocol is TLSv1.1" \
3509 -c "Protocol is TLSv1.1"
3510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003511run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003512 "$P_SRV max_version=tls1_1" \
3513 "$P_CLI max_version=tls1_1" \
3514 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003515 -S "mbedtls_ssl_handshake returned" \
3516 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003517 -s "Protocol is TLSv1.1" \
3518 -c "Protocol is TLSv1.1"
3519
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003520run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003521 "$P_SRV min_version=tls1_1" \
3522 "$P_CLI max_version=tls1_1" \
3523 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003524 -S "mbedtls_ssl_handshake returned" \
3525 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003526 -s "Protocol is TLSv1.1" \
3527 -c "Protocol is TLSv1.1"
3528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003529run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003530 "$P_SRV max_version=tls1_1" \
3531 "$P_CLI min_version=tls1_1" \
3532 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003533 -S "mbedtls_ssl_handshake returned" \
3534 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003535 -s "Protocol is TLSv1.1" \
3536 -c "Protocol is TLSv1.1"
3537
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003538run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003539 "$P_SRV max_version=tls1_1" \
3540 "$P_CLI min_version=tls1_2" \
3541 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003542 -s "mbedtls_ssl_handshake returned" \
3543 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003544 -c "SSL - Handshake protocol not within min/max boundaries"
3545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003546run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003547 "$P_SRV min_version=tls1_2" \
3548 "$P_CLI max_version=tls1_1" \
3549 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003550 -s "mbedtls_ssl_handshake returned" \
3551 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003552 -s "SSL - Handshake protocol not within min/max boundaries"
3553
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003554# Tests for ALPN extension
3555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003556run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003557 "$P_SRV debug_level=3" \
3558 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003559 0 \
3560 -C "client hello, adding alpn extension" \
3561 -S "found alpn extension" \
3562 -C "got an alert message, type: \\[2:120]" \
3563 -S "server hello, adding alpn extension" \
3564 -C "found alpn extension " \
3565 -C "Application Layer Protocol is" \
3566 -S "Application Layer Protocol is"
3567
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003568run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003569 "$P_SRV debug_level=3" \
3570 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003571 0 \
3572 -c "client hello, adding alpn extension" \
3573 -s "found alpn extension" \
3574 -C "got an alert message, type: \\[2:120]" \
3575 -S "server hello, adding alpn extension" \
3576 -C "found alpn extension " \
3577 -c "Application Layer Protocol is (none)" \
3578 -S "Application Layer Protocol is"
3579
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003580run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003581 "$P_SRV debug_level=3 alpn=abc,1234" \
3582 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003583 0 \
3584 -C "client hello, adding alpn extension" \
3585 -S "found alpn extension" \
3586 -C "got an alert message, type: \\[2:120]" \
3587 -S "server hello, adding alpn extension" \
3588 -C "found alpn extension " \
3589 -C "Application Layer Protocol is" \
3590 -s "Application Layer Protocol is (none)"
3591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003592run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003593 "$P_SRV debug_level=3 alpn=abc,1234" \
3594 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003595 0 \
3596 -c "client hello, adding alpn extension" \
3597 -s "found alpn extension" \
3598 -C "got an alert message, type: \\[2:120]" \
3599 -s "server hello, adding alpn extension" \
3600 -c "found alpn extension" \
3601 -c "Application Layer Protocol is abc" \
3602 -s "Application Layer Protocol is abc"
3603
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003604run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003605 "$P_SRV debug_level=3 alpn=abc,1234" \
3606 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003607 0 \
3608 -c "client hello, adding alpn extension" \
3609 -s "found alpn extension" \
3610 -C "got an alert message, type: \\[2:120]" \
3611 -s "server hello, adding alpn extension" \
3612 -c "found alpn extension" \
3613 -c "Application Layer Protocol is abc" \
3614 -s "Application Layer Protocol is abc"
3615
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003616run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003617 "$P_SRV debug_level=3 alpn=abc,1234" \
3618 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003619 0 \
3620 -c "client hello, adding alpn extension" \
3621 -s "found alpn extension" \
3622 -C "got an alert message, type: \\[2:120]" \
3623 -s "server hello, adding alpn extension" \
3624 -c "found alpn extension" \
3625 -c "Application Layer Protocol is 1234" \
3626 -s "Application Layer Protocol is 1234"
3627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003628run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003629 "$P_SRV debug_level=3 alpn=abc,123" \
3630 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003631 1 \
3632 -c "client hello, adding alpn extension" \
3633 -s "found alpn extension" \
3634 -c "got an alert message, type: \\[2:120]" \
3635 -S "server hello, adding alpn extension" \
3636 -C "found alpn extension" \
3637 -C "Application Layer Protocol is 1234" \
3638 -S "Application Layer Protocol is 1234"
3639
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003640
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003641# Tests for keyUsage in leaf certificates, part 1:
3642# server-side certificate/suite selection
3643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003644run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003645 "$P_SRV key_file=data_files/server2.key \
3646 crt_file=data_files/server2.ku-ds.crt" \
3647 "$P_CLI" \
3648 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003649 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003650
3651
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003652run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003653 "$P_SRV key_file=data_files/server2.key \
3654 crt_file=data_files/server2.ku-ke.crt" \
3655 "$P_CLI" \
3656 0 \
3657 -c "Ciphersuite is TLS-RSA-WITH-"
3658
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003659run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003660 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003661 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003662 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003663 1 \
3664 -C "Ciphersuite is "
3665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003666run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003667 "$P_SRV key_file=data_files/server5.key \
3668 crt_file=data_files/server5.ku-ds.crt" \
3669 "$P_CLI" \
3670 0 \
3671 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3672
3673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003674run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003675 "$P_SRV key_file=data_files/server5.key \
3676 crt_file=data_files/server5.ku-ka.crt" \
3677 "$P_CLI" \
3678 0 \
3679 -c "Ciphersuite is TLS-ECDH-"
3680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003681run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003682 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003683 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003684 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003685 1 \
3686 -C "Ciphersuite is "
3687
3688# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003689# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003691run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003692 "$O_SRV -key data_files/server2.key \
3693 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003694 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003695 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3696 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003697 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003698 -C "Processing of the Certificate handshake message failed" \
3699 -c "Ciphersuite is TLS-"
3700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003701run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003702 "$O_SRV -key data_files/server2.key \
3703 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003704 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003705 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3706 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003707 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003708 -C "Processing of the Certificate handshake message failed" \
3709 -c "Ciphersuite is TLS-"
3710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003711run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003712 "$O_SRV -key data_files/server2.key \
3713 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003714 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003715 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3716 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003717 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003718 -C "Processing of the Certificate handshake message failed" \
3719 -c "Ciphersuite is TLS-"
3720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003721run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003722 "$O_SRV -key data_files/server2.key \
3723 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003724 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003725 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3726 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003727 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003728 -c "Processing of the Certificate handshake message failed" \
3729 -C "Ciphersuite is TLS-"
3730
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003731run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3732 "$O_SRV -key data_files/server2.key \
3733 -cert data_files/server2.ku-ke.crt" \
3734 "$P_CLI debug_level=1 auth_mode=optional \
3735 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3736 0 \
3737 -c "bad certificate (usage extensions)" \
3738 -C "Processing of the Certificate handshake message failed" \
3739 -c "Ciphersuite is TLS-" \
3740 -c "! Usage does not match the keyUsage extension"
3741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003742run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003743 "$O_SRV -key data_files/server2.key \
3744 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003745 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003746 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3747 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003748 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003749 -C "Processing of the Certificate handshake message failed" \
3750 -c "Ciphersuite is TLS-"
3751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003752run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003753 "$O_SRV -key data_files/server2.key \
3754 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003755 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003756 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3757 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003758 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003759 -c "Processing of the Certificate handshake message failed" \
3760 -C "Ciphersuite is TLS-"
3761
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003762run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3763 "$O_SRV -key data_files/server2.key \
3764 -cert data_files/server2.ku-ds.crt" \
3765 "$P_CLI debug_level=1 auth_mode=optional \
3766 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3767 0 \
3768 -c "bad certificate (usage extensions)" \
3769 -C "Processing of the Certificate handshake message failed" \
3770 -c "Ciphersuite is TLS-" \
3771 -c "! Usage does not match the keyUsage extension"
3772
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003773# Tests for keyUsage in leaf certificates, part 3:
3774# server-side checking of client cert
3775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003776run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003777 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003778 "$O_CLI -key data_files/server2.key \
3779 -cert data_files/server2.ku-ds.crt" \
3780 0 \
3781 -S "bad certificate (usage extensions)" \
3782 -S "Processing of the Certificate handshake message failed"
3783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003784run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003785 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003786 "$O_CLI -key data_files/server2.key \
3787 -cert data_files/server2.ku-ke.crt" \
3788 0 \
3789 -s "bad certificate (usage extensions)" \
3790 -S "Processing of the Certificate handshake message failed"
3791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003792run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003793 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003794 "$O_CLI -key data_files/server2.key \
3795 -cert data_files/server2.ku-ke.crt" \
3796 1 \
3797 -s "bad certificate (usage extensions)" \
3798 -s "Processing of the Certificate handshake message failed"
3799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003800run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003801 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003802 "$O_CLI -key data_files/server5.key \
3803 -cert data_files/server5.ku-ds.crt" \
3804 0 \
3805 -S "bad certificate (usage extensions)" \
3806 -S "Processing of the Certificate handshake message failed"
3807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003808run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003809 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003810 "$O_CLI -key data_files/server5.key \
3811 -cert data_files/server5.ku-ka.crt" \
3812 0 \
3813 -s "bad certificate (usage extensions)" \
3814 -S "Processing of the Certificate handshake message failed"
3815
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003816# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003818run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003819 "$P_SRV key_file=data_files/server5.key \
3820 crt_file=data_files/server5.eku-srv.crt" \
3821 "$P_CLI" \
3822 0
3823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003824run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003825 "$P_SRV key_file=data_files/server5.key \
3826 crt_file=data_files/server5.eku-srv.crt" \
3827 "$P_CLI" \
3828 0
3829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003830run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003831 "$P_SRV key_file=data_files/server5.key \
3832 crt_file=data_files/server5.eku-cs_any.crt" \
3833 "$P_CLI" \
3834 0
3835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003836run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003837 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003838 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003839 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003840 1
3841
3842# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003844run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003845 "$O_SRV -key data_files/server5.key \
3846 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003847 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003848 0 \
3849 -C "bad certificate (usage extensions)" \
3850 -C "Processing of the Certificate handshake message failed" \
3851 -c "Ciphersuite is TLS-"
3852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003853run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003854 "$O_SRV -key data_files/server5.key \
3855 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003856 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003857 0 \
3858 -C "bad certificate (usage extensions)" \
3859 -C "Processing of the Certificate handshake message failed" \
3860 -c "Ciphersuite is TLS-"
3861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003862run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003863 "$O_SRV -key data_files/server5.key \
3864 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003865 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003866 0 \
3867 -C "bad certificate (usage extensions)" \
3868 -C "Processing of the Certificate handshake message failed" \
3869 -c "Ciphersuite is TLS-"
3870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003872 "$O_SRV -key data_files/server5.key \
3873 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003874 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003875 1 \
3876 -c "bad certificate (usage extensions)" \
3877 -c "Processing of the Certificate handshake message failed" \
3878 -C "Ciphersuite is TLS-"
3879
3880# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003882run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003883 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003884 "$O_CLI -key data_files/server5.key \
3885 -cert data_files/server5.eku-cli.crt" \
3886 0 \
3887 -S "bad certificate (usage extensions)" \
3888 -S "Processing of the Certificate handshake message failed"
3889
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003890run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003891 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003892 "$O_CLI -key data_files/server5.key \
3893 -cert data_files/server5.eku-srv_cli.crt" \
3894 0 \
3895 -S "bad certificate (usage extensions)" \
3896 -S "Processing of the Certificate handshake message failed"
3897
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003898run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003899 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003900 "$O_CLI -key data_files/server5.key \
3901 -cert data_files/server5.eku-cs_any.crt" \
3902 0 \
3903 -S "bad certificate (usage extensions)" \
3904 -S "Processing of the Certificate handshake message failed"
3905
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003906run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003907 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003908 "$O_CLI -key data_files/server5.key \
3909 -cert data_files/server5.eku-cs.crt" \
3910 0 \
3911 -s "bad certificate (usage extensions)" \
3912 -S "Processing of the Certificate handshake message failed"
3913
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003914run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003915 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003916 "$O_CLI -key data_files/server5.key \
3917 -cert data_files/server5.eku-cs.crt" \
3918 1 \
3919 -s "bad certificate (usage extensions)" \
3920 -s "Processing of the Certificate handshake message failed"
3921
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003922# Tests for DHM parameters loading
3923
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003924run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003925 "$P_SRV" \
3926 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3927 debug_level=3" \
3928 0 \
3929 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003930 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003932run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003933 "$P_SRV dhm_file=data_files/dhparams.pem" \
3934 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3935 debug_level=3" \
3936 0 \
3937 -c "value of 'DHM: P ' (1024 bits)" \
3938 -c "value of 'DHM: G ' (2 bits)"
3939
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003940# Tests for DHM client-side size checking
3941
3942run_test "DHM size: server default, client default, OK" \
3943 "$P_SRV" \
3944 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3945 debug_level=1" \
3946 0 \
3947 -C "DHM prime too short:"
3948
3949run_test "DHM size: server default, client 2048, OK" \
3950 "$P_SRV" \
3951 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3952 debug_level=1 dhmlen=2048" \
3953 0 \
3954 -C "DHM prime too short:"
3955
3956run_test "DHM size: server 1024, client default, OK" \
3957 "$P_SRV dhm_file=data_files/dhparams.pem" \
3958 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3959 debug_level=1" \
3960 0 \
3961 -C "DHM prime too short:"
3962
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003963run_test "DHM size: server 999, client 999, OK" \
3964 "$P_SRV dhm_file=data_files/dh.999.pem" \
3965 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3966 debug_level=1 dhmlen=999" \
3967 0 \
3968 -C "DHM prime too short:"
3969
3970run_test "DHM size: server 1000, client 1000, OK" \
3971 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3972 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3973 debug_level=1 dhmlen=1000" \
3974 0 \
3975 -C "DHM prime too short:"
3976
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003977run_test "DHM size: server 1000, client default, rejected" \
3978 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3979 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3980 debug_level=1" \
3981 1 \
3982 -c "DHM prime too short:"
3983
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01003984run_test "DHM size: server 1000, client 1001, rejected" \
3985 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3986 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3987 debug_level=1 dhmlen=1001" \
3988 1 \
3989 -c "DHM prime too short:"
3990
3991run_test "DHM size: server 999, client 1000, rejected" \
3992 "$P_SRV dhm_file=data_files/dh.999.pem" \
3993 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3994 debug_level=1 dhmlen=1000" \
3995 1 \
3996 -c "DHM prime too short:"
3997
3998run_test "DHM size: server 998, client 999, rejected" \
3999 "$P_SRV dhm_file=data_files/dh.998.pem" \
4000 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4001 debug_level=1 dhmlen=999" \
4002 1 \
4003 -c "DHM prime too short:"
4004
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004005run_test "DHM size: server default, client 2049, rejected" \
4006 "$P_SRV" \
4007 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4008 debug_level=1 dhmlen=2049" \
4009 1 \
4010 -c "DHM prime too short:"
4011
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004012# Tests for PSK callback
4013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004014run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004015 "$P_SRV psk=abc123 psk_identity=foo" \
4016 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4017 psk_identity=foo psk=abc123" \
4018 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004019 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004020 -S "SSL - Unknown identity received" \
4021 -S "SSL - Verification of the message MAC failed"
4022
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004023run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004024 "$P_SRV" \
4025 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4026 psk_identity=foo psk=abc123" \
4027 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004028 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004029 -S "SSL - Unknown identity received" \
4030 -S "SSL - Verification of the message MAC failed"
4031
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004032run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004033 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4034 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4035 psk_identity=foo psk=abc123" \
4036 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004037 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004038 -s "SSL - Unknown identity received" \
4039 -S "SSL - Verification of the message MAC failed"
4040
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004041run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004042 "$P_SRV psk_list=abc,dead,def,beef" \
4043 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4044 psk_identity=abc psk=dead" \
4045 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004046 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004047 -S "SSL - Unknown identity received" \
4048 -S "SSL - Verification of the message MAC failed"
4049
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004050run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004051 "$P_SRV psk_list=abc,dead,def,beef" \
4052 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4053 psk_identity=def psk=beef" \
4054 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004055 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004056 -S "SSL - Unknown identity received" \
4057 -S "SSL - Verification of the message MAC failed"
4058
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004059run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004060 "$P_SRV psk_list=abc,dead,def,beef" \
4061 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4062 psk_identity=ghi psk=beef" \
4063 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004064 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004065 -s "SSL - Unknown identity received" \
4066 -S "SSL - Verification of the message MAC failed"
4067
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004068run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004069 "$P_SRV psk_list=abc,dead,def,beef" \
4070 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4071 psk_identity=abc psk=beef" \
4072 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004073 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004074 -S "SSL - Unknown identity received" \
4075 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004076
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004077# Tests for EC J-PAKE
4078
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004079requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004080run_test "ECJPAKE: client not configured" \
4081 "$P_SRV debug_level=3" \
4082 "$P_CLI debug_level=3" \
4083 0 \
4084 -C "add ciphersuite: c0ff" \
4085 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004086 -S "found ecjpake kkpp extension" \
4087 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004088 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004089 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004090 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004091 -S "None of the common ciphersuites is usable"
4092
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004093requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004094run_test "ECJPAKE: server not configured" \
4095 "$P_SRV debug_level=3" \
4096 "$P_CLI debug_level=3 ecjpake_pw=bla \
4097 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4098 1 \
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é-Gonnardbf57be62015-09-16 15:04:01 +02004109run_test "ECJPAKE: working, TLS" \
4110 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4111 "$P_CLI debug_level=3 ecjpake_pw=bla \
4112 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004113 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004114 -c "add ciphersuite: c0ff" \
4115 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004116 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004117 -s "found ecjpake kkpp extension" \
4118 -S "skip ecjpake kkpp extension" \
4119 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004120 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004121 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004122 -S "None of the common ciphersuites is usable" \
4123 -S "SSL - Verification of the message MAC failed"
4124
Janos Follath74537a62016-09-02 13:45:28 +01004125server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004126requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004127run_test "ECJPAKE: password mismatch, TLS" \
4128 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4129 "$P_CLI debug_level=3 ecjpake_pw=bad \
4130 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4131 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004132 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004133 -s "SSL - Verification of the message MAC failed"
4134
Dave Rodgmancee9e922021-06-29 19:05:34 +01004135requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004136run_test "ECJPAKE: working, DTLS" \
4137 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4138 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4139 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4140 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004141 -c "re-using cached ecjpake parameters" \
4142 -S "SSL - Verification of the message MAC failed"
4143
Dave Rodgmancee9e922021-06-29 19:05:34 +01004144requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004145run_test "ECJPAKE: working, DTLS, no cookie" \
4146 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4147 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4148 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4149 0 \
4150 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004151 -S "SSL - Verification of the message MAC failed"
4152
Janos Follath74537a62016-09-02 13:45:28 +01004153server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004154requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004155run_test "ECJPAKE: password mismatch, DTLS" \
4156 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4157 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4158 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4159 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004160 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004161 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004162
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004163# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004164requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004165run_test "ECJPAKE: working, DTLS, nolog" \
4166 "$P_SRV dtls=1 ecjpake_pw=bla" \
4167 "$P_CLI dtls=1 ecjpake_pw=bla \
4168 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4169 0
4170
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004171# Tests for ciphersuites per version
4172
Janos Follathe2681a42016-03-07 15:57:05 +00004173requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004174requires_config_enabled MBEDTLS_CAMELLIA_C
4175requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004176run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004177 "$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 +02004178 "$P_CLI force_version=ssl3" \
4179 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004180 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004181
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004182requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4183requires_config_enabled MBEDTLS_CAMELLIA_C
4184requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004185run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004186 "$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 +01004187 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004188 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004189 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004190
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004191requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4192requires_config_enabled MBEDTLS_CAMELLIA_C
4193requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004194run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004195 "$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 +02004196 "$P_CLI force_version=tls1_1" \
4197 0 \
4198 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4199
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004200requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4201requires_config_enabled MBEDTLS_CAMELLIA_C
4202requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004203run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004204 "$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 +02004205 "$P_CLI force_version=tls1_2" \
4206 0 \
4207 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4208
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004209# Test for ClientHello without extensions
4210
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004211requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004212run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004213 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004214 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004215 0 \
4216 -s "dumping 'client hello extensions' (0 bytes)"
4217
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004218# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004219
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004220run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004221 "$P_SRV" \
4222 "$P_CLI request_size=100" \
4223 0 \
4224 -s "Read from client: 100 bytes read$"
4225
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004226run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004227 "$P_SRV" \
4228 "$P_CLI request_size=500" \
4229 0 \
4230 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004231
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004232# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004233
Janos Follathe2681a42016-03-07 15:57:05 +00004234requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004235run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004236 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004237 "$P_CLI request_size=1 force_version=ssl3 \
4238 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4239 0 \
4240 -s "Read from client: 1 bytes read"
4241
Janos Follathe2681a42016-03-07 15:57:05 +00004242requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004243run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004244 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004245 "$P_CLI request_size=1 force_version=ssl3 \
4246 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4247 0 \
4248 -s "Read from client: 1 bytes read"
4249
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004250run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004251 "$P_SRV" \
4252 "$P_CLI request_size=1 force_version=tls1 \
4253 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4254 0 \
4255 -s "Read from client: 1 bytes read"
4256
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004257run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004258 "$P_SRV" \
4259 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4260 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4261 0 \
4262 -s "Read from client: 1 bytes read"
4263
Hanno Becker32c55012017-11-10 08:42:54 +00004264requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004265run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004266 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004267 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004268 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004269 0 \
4270 -s "Read from client: 1 bytes read"
4271
Hanno Becker32c55012017-11-10 08:42:54 +00004272requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004273run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004274 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004275 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004277 0 \
4278 -s "Read from client: 1 bytes read"
4279
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004280run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004281 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004282 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004283 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4284 0 \
4285 -s "Read from client: 1 bytes read"
4286
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004287run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004288 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4289 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004290 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004291 0 \
4292 -s "Read from client: 1 bytes read"
4293
4294requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004295run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004296 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004297 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004298 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004299 0 \
4300 -s "Read from client: 1 bytes read"
4301
Hanno Becker8501f982017-11-10 08:59:04 +00004302requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004303run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004304 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4305 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4306 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004307 0 \
4308 -s "Read from client: 1 bytes read"
4309
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004310run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004311 "$P_SRV" \
4312 "$P_CLI request_size=1 force_version=tls1_1 \
4313 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4314 0 \
4315 -s "Read from client: 1 bytes read"
4316
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004317run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004318 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004319 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004320 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004321 0 \
4322 -s "Read from client: 1 bytes read"
4323
4324requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004325run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004326 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004327 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004328 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004329 0 \
4330 -s "Read from client: 1 bytes read"
4331
4332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004333run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004334 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004335 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004336 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004337 0 \
4338 -s "Read from client: 1 bytes read"
4339
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004340run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004341 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004342 "$P_CLI request_size=1 force_version=tls1_1 \
4343 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4344 0 \
4345 -s "Read from client: 1 bytes read"
4346
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004347run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004348 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004349 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004350 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004351 0 \
4352 -s "Read from client: 1 bytes read"
4353
Hanno Becker8501f982017-11-10 08:59:04 +00004354requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004355run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004356 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004357 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004359 0 \
4360 -s "Read from client: 1 bytes read"
4361
Hanno Becker32c55012017-11-10 08:42:54 +00004362requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004363run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004364 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004365 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004366 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004367 0 \
4368 -s "Read from client: 1 bytes read"
4369
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004370run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004371 "$P_SRV" \
4372 "$P_CLI request_size=1 force_version=tls1_2 \
4373 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4374 0 \
4375 -s "Read from client: 1 bytes read"
4376
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004377run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004378 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004379 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004380 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004381 0 \
4382 -s "Read from client: 1 bytes read"
4383
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004384run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004385 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004386 "$P_CLI request_size=1 force_version=tls1_2 \
4387 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004388 0 \
4389 -s "Read from client: 1 bytes read"
4390
Hanno Becker32c55012017-11-10 08:42:54 +00004391requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004392run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004393 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004394 "$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 trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004396 0 \
4397 -s "Read from client: 1 bytes read"
4398
Hanno Becker8501f982017-11-10 08:59:04 +00004399requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004400run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004401 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004402 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004404 0 \
4405 -s "Read from client: 1 bytes read"
4406
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004407run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004408 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004409 "$P_CLI request_size=1 force_version=tls1_2 \
4410 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4411 0 \
4412 -s "Read from client: 1 bytes read"
4413
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004414run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004415 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004416 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004417 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004418 0 \
4419 -s "Read from client: 1 bytes read"
4420
Hanno Becker32c55012017-11-10 08:42:54 +00004421requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004422run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004423 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004424 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004426 0 \
4427 -s "Read from client: 1 bytes read"
4428
Hanno Becker8501f982017-11-10 08:59:04 +00004429requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004430run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004431 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004432 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004433 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004434 0 \
4435 -s "Read from client: 1 bytes read"
4436
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004437run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004438 "$P_SRV" \
4439 "$P_CLI request_size=1 force_version=tls1_2 \
4440 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4441 0 \
4442 -s "Read from client: 1 bytes read"
4443
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004444run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004445 "$P_SRV" \
4446 "$P_CLI request_size=1 force_version=tls1_2 \
4447 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4448 0 \
4449 -s "Read from client: 1 bytes read"
4450
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004451# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004452
4453requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004454run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004455 "$P_SRV dtls=1 force_version=dtls1" \
4456 "$P_CLI dtls=1 request_size=1 \
4457 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4458 0 \
4459 -s "Read from client: 1 bytes read"
4460
4461requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004462run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004463 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4464 "$P_CLI dtls=1 request_size=1 \
4465 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4466 0 \
4467 -s "Read from client: 1 bytes read"
4468
4469requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004471run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004472 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4473 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004474 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4475 0 \
4476 -s "Read from client: 1 bytes read"
4477
4478requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4479requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004480run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004481 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004482 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004483 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004484 0 \
4485 -s "Read from client: 1 bytes read"
4486
4487requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004488run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004489 "$P_SRV dtls=1 force_version=dtls1_2" \
4490 "$P_CLI dtls=1 request_size=1 \
4491 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4492 0 \
4493 -s "Read from client: 1 bytes read"
4494
4495requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004496run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004497 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004498 "$P_CLI dtls=1 request_size=1 \
4499 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4500 0 \
4501 -s "Read from client: 1 bytes read"
4502
4503requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4504requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004505run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004506 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004507 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004508 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004509 0 \
4510 -s "Read from client: 1 bytes read"
4511
4512requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4513requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004514run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004515 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004516 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004517 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004518 0 \
4519 -s "Read from client: 1 bytes read"
4520
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004521# Tests for small server packets
4522
4523requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4524run_test "Small server packet SSLv3 BlockCipher" \
4525 "$P_SRV response_size=1 min_version=ssl3" \
4526 "$P_CLI force_version=ssl3 \
4527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4528 0 \
4529 -c "Read from server: 1 bytes read"
4530
4531requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4532run_test "Small server packet SSLv3 StreamCipher" \
4533 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4534 "$P_CLI force_version=ssl3 \
4535 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4536 0 \
4537 -c "Read from server: 1 bytes read"
4538
4539run_test "Small server packet TLS 1.0 BlockCipher" \
4540 "$P_SRV response_size=1" \
4541 "$P_CLI force_version=tls1 \
4542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4543 0 \
4544 -c "Read from server: 1 bytes read"
4545
4546run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4547 "$P_SRV response_size=1" \
4548 "$P_CLI force_version=tls1 etm=0 \
4549 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4550 0 \
4551 -c "Read from server: 1 bytes read"
4552
4553requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4554run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4555 "$P_SRV response_size=1 trunc_hmac=1" \
4556 "$P_CLI force_version=tls1 \
4557 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4558 0 \
4559 -c "Read from server: 1 bytes read"
4560
4561requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4562run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4563 "$P_SRV response_size=1 trunc_hmac=1" \
4564 "$P_CLI force_version=tls1 \
4565 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4566 0 \
4567 -c "Read from server: 1 bytes read"
4568
4569run_test "Small server packet TLS 1.0 StreamCipher" \
4570 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4571 "$P_CLI force_version=tls1 \
4572 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4573 0 \
4574 -c "Read from server: 1 bytes read"
4575
4576run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4577 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4578 "$P_CLI force_version=tls1 \
4579 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4580 0 \
4581 -c "Read from server: 1 bytes read"
4582
4583requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4584run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4585 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4586 "$P_CLI force_version=tls1 \
4587 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4588 0 \
4589 -c "Read from server: 1 bytes read"
4590
4591requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4592run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4593 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4594 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4595 trunc_hmac=1 etm=0" \
4596 0 \
4597 -c "Read from server: 1 bytes read"
4598
4599run_test "Small server packet TLS 1.1 BlockCipher" \
4600 "$P_SRV response_size=1" \
4601 "$P_CLI force_version=tls1_1 \
4602 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4603 0 \
4604 -c "Read from server: 1 bytes read"
4605
4606run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4607 "$P_SRV response_size=1" \
4608 "$P_CLI force_version=tls1_1 \
4609 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4610 0 \
4611 -c "Read from server: 1 bytes read"
4612
4613requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4614run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4615 "$P_SRV response_size=1 trunc_hmac=1" \
4616 "$P_CLI force_version=tls1_1 \
4617 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4618 0 \
4619 -c "Read from server: 1 bytes read"
4620
4621requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4622run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4623 "$P_SRV response_size=1 trunc_hmac=1" \
4624 "$P_CLI force_version=tls1_1 \
4625 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4626 0 \
4627 -c "Read from server: 1 bytes read"
4628
4629run_test "Small server packet TLS 1.1 StreamCipher" \
4630 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4631 "$P_CLI force_version=tls1_1 \
4632 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4633 0 \
4634 -c "Read from server: 1 bytes read"
4635
4636run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4637 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4638 "$P_CLI force_version=tls1_1 \
4639 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4640 0 \
4641 -c "Read from server: 1 bytes read"
4642
4643requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4644run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4645 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4646 "$P_CLI force_version=tls1_1 \
4647 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4648 0 \
4649 -c "Read from server: 1 bytes read"
4650
4651requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4652run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4653 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4654 "$P_CLI force_version=tls1_1 \
4655 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4656 0 \
4657 -c "Read from server: 1 bytes read"
4658
4659run_test "Small server packet TLS 1.2 BlockCipher" \
4660 "$P_SRV response_size=1" \
4661 "$P_CLI force_version=tls1_2 \
4662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4663 0 \
4664 -c "Read from server: 1 bytes read"
4665
4666run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4667 "$P_SRV response_size=1" \
4668 "$P_CLI force_version=tls1_2 \
4669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4670 0 \
4671 -c "Read from server: 1 bytes read"
4672
4673run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4674 "$P_SRV response_size=1" \
4675 "$P_CLI force_version=tls1_2 \
4676 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4677 0 \
4678 -c "Read from server: 1 bytes read"
4679
4680requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4681run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4682 "$P_SRV response_size=1 trunc_hmac=1" \
4683 "$P_CLI force_version=tls1_2 \
4684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4685 0 \
4686 -c "Read from server: 1 bytes read"
4687
4688requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4689run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4690 "$P_SRV response_size=1 trunc_hmac=1" \
4691 "$P_CLI force_version=tls1_2 \
4692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4693 0 \
4694 -c "Read from server: 1 bytes read"
4695
4696run_test "Small server packet TLS 1.2 StreamCipher" \
4697 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4698 "$P_CLI force_version=tls1_2 \
4699 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4700 0 \
4701 -c "Read from server: 1 bytes read"
4702
4703run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4704 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4705 "$P_CLI force_version=tls1_2 \
4706 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4707 0 \
4708 -c "Read from server: 1 bytes read"
4709
4710requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4711run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4712 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4713 "$P_CLI force_version=tls1_2 \
4714 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4715 0 \
4716 -c "Read from server: 1 bytes read"
4717
4718requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4719run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4720 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4721 "$P_CLI force_version=tls1_2 \
4722 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4723 0 \
4724 -c "Read from server: 1 bytes read"
4725
4726run_test "Small server packet TLS 1.2 AEAD" \
4727 "$P_SRV response_size=1" \
4728 "$P_CLI force_version=tls1_2 \
4729 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4730 0 \
4731 -c "Read from server: 1 bytes read"
4732
4733run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4734 "$P_SRV response_size=1" \
4735 "$P_CLI force_version=tls1_2 \
4736 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4737 0 \
4738 -c "Read from server: 1 bytes read"
4739
4740# Tests for small server packets in DTLS
4741
4742requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4743run_test "Small server packet DTLS 1.0" \
4744 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4745 "$P_CLI dtls=1 \
4746 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4747 0 \
4748 -c "Read from server: 1 bytes read"
4749
4750requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4751run_test "Small server packet DTLS 1.0, without EtM" \
4752 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4753 "$P_CLI dtls=1 \
4754 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4755 0 \
4756 -c "Read from server: 1 bytes read"
4757
4758requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4759requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4760run_test "Small server packet DTLS 1.0, truncated hmac" \
4761 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4762 "$P_CLI dtls=1 trunc_hmac=1 \
4763 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4764 0 \
4765 -c "Read from server: 1 bytes read"
4766
4767requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4768requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4769run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4770 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4771 "$P_CLI dtls=1 \
4772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4773 0 \
4774 -c "Read from server: 1 bytes read"
4775
4776requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4777run_test "Small server packet DTLS 1.2" \
4778 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4779 "$P_CLI dtls=1 \
4780 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4781 0 \
4782 -c "Read from server: 1 bytes read"
4783
4784requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4785run_test "Small server packet DTLS 1.2, without EtM" \
4786 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4787 "$P_CLI dtls=1 \
4788 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4789 0 \
4790 -c "Read from server: 1 bytes read"
4791
4792requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4793requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4794run_test "Small server packet DTLS 1.2, truncated hmac" \
4795 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4796 "$P_CLI dtls=1 \
4797 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4798 0 \
4799 -c "Read from server: 1 bytes read"
4800
4801requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4802requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4803run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4804 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4805 "$P_CLI dtls=1 \
4806 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4807 0 \
4808 -c "Read from server: 1 bytes read"
4809
Janos Follath00efff72016-05-06 13:48:23 +01004810# A test for extensions in SSLv3
4811
4812requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4813run_test "SSLv3 with extensions, server side" \
4814 "$P_SRV min_version=ssl3 debug_level=3" \
4815 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4816 0 \
4817 -S "dumping 'client hello extensions'" \
4818 -S "server hello, total extension length:"
4819
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004820# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004821
Angus Grattonc4dd0732018-04-11 16:28:39 +10004822# How many fragments do we expect to write $1 bytes?
4823fragments_for_write() {
4824 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4825}
4826
Janos Follathe2681a42016-03-07 15:57:05 +00004827requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004828run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004829 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004830 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004831 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4832 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004833 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4834 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004835
Janos Follathe2681a42016-03-07 15:57:05 +00004836requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004837run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004838 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004839 "$P_CLI request_size=16384 force_version=ssl3 \
4840 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4841 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004842 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4843 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004844
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004845run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004846 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004847 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004848 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4849 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004850 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4851 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004852
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004853run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004854 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004855 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4857 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004858 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004859
Hanno Becker32c55012017-11-10 08:42:54 +00004860requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004861run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004862 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004863 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004864 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004865 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004866 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4867 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004868
Hanno Becker32c55012017-11-10 08:42:54 +00004869requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004870run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004871 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004872 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004873 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004874 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004875 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004876
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004877run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004878 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004879 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004880 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4881 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004882 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004883
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004884run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004885 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4886 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004888 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004889 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004890
4891requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004892run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004893 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004894 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004895 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004896 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004897 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004898
Hanno Becker278fc7a2017-11-10 09:16:28 +00004899requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004900run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004901 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004902 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004903 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004904 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004905 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4906 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004907
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004908run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004909 "$P_SRV" \
4910 "$P_CLI request_size=16384 force_version=tls1_1 \
4911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4912 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004913 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4914 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004915
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004916run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004917 "$P_SRV" \
4918 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4919 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004920 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004921 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004922
Hanno Becker32c55012017-11-10 08:42:54 +00004923requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004924run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004925 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004926 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004928 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004929 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004930
Hanno Becker32c55012017-11-10 08:42:54 +00004931requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004932run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004933 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004934 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004935 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004936 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004937 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004938
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004939run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004940 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4941 "$P_CLI request_size=16384 force_version=tls1_1 \
4942 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4943 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004944 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4945 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004946
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004947run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004948 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004949 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004950 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004951 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004952 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4953 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004954
Hanno Becker278fc7a2017-11-10 09:16:28 +00004955requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004956run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004957 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004958 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004959 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004960 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004961 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004962
Hanno Becker278fc7a2017-11-10 09:16:28 +00004963requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004964run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004965 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004966 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004967 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004968 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004969 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4970 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004971
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004972run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004973 "$P_SRV" \
4974 "$P_CLI request_size=16384 force_version=tls1_2 \
4975 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4976 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004977 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4978 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004979
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004980run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004981 "$P_SRV" \
4982 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4983 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4984 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004985 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004986
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004987run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004988 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004989 "$P_CLI request_size=16384 force_version=tls1_2 \
4990 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004991 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
Hanno Becker32c55012017-11-10 08:42:54 +00004995requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004996run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004997 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004998 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004999 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005000 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005001 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005002
Hanno Becker278fc7a2017-11-10 09:16:28 +00005003requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005004run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005005 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005006 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005007 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005008 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005009 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5010 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005011
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005012run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005013 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005014 "$P_CLI request_size=16384 force_version=tls1_2 \
5015 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5016 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005017 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5018 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005019
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005020run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005021 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005022 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005023 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5024 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005025 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005026
Hanno Becker32c55012017-11-10 08:42:54 +00005027requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005028run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005029 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005030 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005031 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005032 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005033 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005034
Hanno Becker278fc7a2017-11-10 09:16:28 +00005035requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005036run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005037 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005038 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005039 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005040 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005041 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5042 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005043
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005044run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005045 "$P_SRV" \
5046 "$P_CLI request_size=16384 force_version=tls1_2 \
5047 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5048 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005049 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5050 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005051
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005052run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005053 "$P_SRV" \
5054 "$P_CLI request_size=16384 force_version=tls1_2 \
5055 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5056 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005057 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5058 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005059
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005060# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005061requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5062run_test "Large server packet SSLv3 StreamCipher" \
5063 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5064 "$P_CLI force_version=ssl3 \
5065 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5066 0 \
5067 -c "Read from server: 16384 bytes read"
5068
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005069# Checking next 4 tests logs for 1n-1 split against BEAST too
5070requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5071run_test "Large server packet SSLv3 BlockCipher" \
5072 "$P_SRV response_size=16384 min_version=ssl3" \
5073 "$P_CLI force_version=ssl3 recsplit=0 \
5074 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5075 0 \
5076 -c "Read from server: 1 bytes read"\
5077 -c "16383 bytes read"\
5078 -C "Read from server: 16384 bytes read"
5079
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005080run_test "Large server packet TLS 1.0 BlockCipher" \
5081 "$P_SRV response_size=16384" \
5082 "$P_CLI force_version=tls1 recsplit=0 \
5083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5084 0 \
5085 -c "Read from server: 1 bytes read"\
5086 -c "16383 bytes read"\
5087 -C "Read from server: 16384 bytes read"
5088
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005089run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5090 "$P_SRV response_size=16384" \
5091 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5092 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5093 0 \
5094 -c "Read from server: 1 bytes read"\
5095 -c "16383 bytes read"\
5096 -C "Read from server: 16384 bytes read"
5097
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005098requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5099run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5100 "$P_SRV response_size=16384" \
5101 "$P_CLI force_version=tls1 recsplit=0 \
5102 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5103 trunc_hmac=1" \
5104 0 \
5105 -c "Read from server: 1 bytes read"\
5106 -c "16383 bytes read"\
5107 -C "Read from server: 16384 bytes read"
5108
5109requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5110run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5111 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5112 "$P_CLI force_version=tls1 \
5113 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5114 trunc_hmac=1" \
5115 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005116 -s "16384 bytes written in 1 fragments" \
5117 -c "Read from server: 16384 bytes read"
5118
5119run_test "Large server packet TLS 1.0 StreamCipher" \
5120 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5121 "$P_CLI force_version=tls1 \
5122 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5123 0 \
5124 -s "16384 bytes written in 1 fragments" \
5125 -c "Read from server: 16384 bytes read"
5126
5127run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5128 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5129 "$P_CLI force_version=tls1 \
5130 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5131 0 \
5132 -s "16384 bytes written in 1 fragments" \
5133 -c "Read from server: 16384 bytes read"
5134
5135requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5136run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5137 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5138 "$P_CLI force_version=tls1 \
5139 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5140 0 \
5141 -s "16384 bytes written in 1 fragments" \
5142 -c "Read from server: 16384 bytes read"
5143
5144requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5145run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5146 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5147 "$P_CLI force_version=tls1 \
5148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5149 0 \
5150 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005151 -c "Read from server: 16384 bytes read"
5152
5153run_test "Large server packet TLS 1.1 BlockCipher" \
5154 "$P_SRV response_size=16384" \
5155 "$P_CLI force_version=tls1_1 \
5156 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5157 0 \
5158 -c "Read from server: 16384 bytes read"
5159
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005160run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5161 "$P_SRV response_size=16384" \
5162 "$P_CLI force_version=tls1_1 etm=0 \
5163 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005164 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005165 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005166 -c "Read from server: 16384 bytes read"
5167
5168requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5169run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5170 "$P_SRV response_size=16384" \
5171 "$P_CLI force_version=tls1_1 \
5172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5173 trunc_hmac=1" \
5174 0 \
5175 -c "Read from server: 16384 bytes read"
5176
5177requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005178run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5179 "$P_SRV response_size=16384 trunc_hmac=1" \
5180 "$P_CLI force_version=tls1_1 \
5181 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5182 0 \
5183 -s "16384 bytes written in 1 fragments" \
5184 -c "Read from server: 16384 bytes read"
5185
5186run_test "Large server packet TLS 1.1 StreamCipher" \
5187 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5188 "$P_CLI force_version=tls1_1 \
5189 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5190 0 \
5191 -c "Read from server: 16384 bytes read"
5192
5193run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5194 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5195 "$P_CLI force_version=tls1_1 \
5196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5197 0 \
5198 -s "16384 bytes written in 1 fragments" \
5199 -c "Read from server: 16384 bytes read"
5200
5201requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005202run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5203 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5204 "$P_CLI force_version=tls1_1 \
5205 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5206 trunc_hmac=1" \
5207 0 \
5208 -c "Read from server: 16384 bytes read"
5209
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005210run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5211 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5212 "$P_CLI force_version=tls1_1 \
5213 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5214 0 \
5215 -s "16384 bytes written in 1 fragments" \
5216 -c "Read from server: 16384 bytes read"
5217
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005218run_test "Large server packet TLS 1.2 BlockCipher" \
5219 "$P_SRV response_size=16384" \
5220 "$P_CLI force_version=tls1_2 \
5221 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
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.2 BlockCipher, without EtM" \
5226 "$P_SRV response_size=16384" \
5227 "$P_CLI force_version=tls1_2 etm=0 \
5228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
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 larger MAC" \
5234 "$P_SRV response_size=16384" \
5235 "$P_CLI force_version=tls1_2 \
5236 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5237 0 \
5238 -c "Read from server: 16384 bytes read"
5239
5240requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5241run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5242 "$P_SRV response_size=16384" \
5243 "$P_CLI force_version=tls1_2 \
5244 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5245 trunc_hmac=1" \
5246 0 \
5247 -c "Read from server: 16384 bytes read"
5248
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005249run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5250 "$P_SRV response_size=16384 trunc_hmac=1" \
5251 "$P_CLI force_version=tls1_2 \
5252 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5253 0 \
5254 -s "16384 bytes written in 1 fragments" \
5255 -c "Read from server: 16384 bytes read"
5256
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005257run_test "Large server packet TLS 1.2 StreamCipher" \
5258 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5259 "$P_CLI force_version=tls1_2 \
5260 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5261 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005262 -s "16384 bytes written in 1 fragments" \
5263 -c "Read from server: 16384 bytes read"
5264
5265run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5266 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5267 "$P_CLI force_version=tls1_2 \
5268 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5269 0 \
5270 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005271 -c "Read from server: 16384 bytes read"
5272
5273requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5274run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5275 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5276 "$P_CLI force_version=tls1_2 \
5277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5278 trunc_hmac=1" \
5279 0 \
5280 -c "Read from server: 16384 bytes read"
5281
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005282requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5283run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5284 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5285 "$P_CLI force_version=tls1_2 \
5286 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5287 0 \
5288 -s "16384 bytes written in 1 fragments" \
5289 -c "Read from server: 16384 bytes read"
5290
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005291run_test "Large server packet TLS 1.2 AEAD" \
5292 "$P_SRV response_size=16384" \
5293 "$P_CLI force_version=tls1_2 \
5294 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5295 0 \
5296 -c "Read from server: 16384 bytes read"
5297
5298run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5299 "$P_SRV response_size=16384" \
5300 "$P_CLI force_version=tls1_2 \
5301 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5302 0 \
5303 -c "Read from server: 16384 bytes read"
5304
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005305# Tests for restartable ECC
5306
5307requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5308run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005309 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005310 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005311 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005312 debug_level=1" \
5313 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005314 -C "x509_verify_cert.*4b00" \
5315 -C "mbedtls_pk_verify.*4b00" \
5316 -C "mbedtls_ecdh_make_public.*4b00" \
5317 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005318
5319requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5320run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005321 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005322 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005323 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005324 debug_level=1 ec_max_ops=0" \
5325 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005326 -C "x509_verify_cert.*4b00" \
5327 -C "mbedtls_pk_verify.*4b00" \
5328 -C "mbedtls_ecdh_make_public.*4b00" \
5329 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005330
5331requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5332run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005333 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005334 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005335 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005336 debug_level=1 ec_max_ops=65535" \
5337 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005338 -C "x509_verify_cert.*4b00" \
5339 -C "mbedtls_pk_verify.*4b00" \
5340 -C "mbedtls_ecdh_make_public.*4b00" \
5341 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005342
5343requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5344run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005345 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005346 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005347 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005348 debug_level=1 ec_max_ops=1000" \
5349 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005350 -c "x509_verify_cert.*4b00" \
5351 -c "mbedtls_pk_verify.*4b00" \
5352 -c "mbedtls_ecdh_make_public.*4b00" \
5353 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005354
5355requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005356run_test "EC restart: TLS, max_ops=1000, badsign" \
5357 "$P_SRV auth_mode=required \
5358 crt_file=data_files/server5-badsign.crt \
5359 key_file=data_files/server5.key" \
5360 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5361 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5362 debug_level=1 ec_max_ops=1000" \
5363 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005364 -c "x509_verify_cert.*4b00" \
5365 -C "mbedtls_pk_verify.*4b00" \
5366 -C "mbedtls_ecdh_make_public.*4b00" \
5367 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005368 -c "! The certificate is not correctly signed by the trusted CA" \
5369 -c "! mbedtls_ssl_handshake returned" \
5370 -c "X509 - Certificate verification failed"
5371
5372requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5373run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5374 "$P_SRV auth_mode=required \
5375 crt_file=data_files/server5-badsign.crt \
5376 key_file=data_files/server5.key" \
5377 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5378 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5379 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5380 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005381 -c "x509_verify_cert.*4b00" \
5382 -c "mbedtls_pk_verify.*4b00" \
5383 -c "mbedtls_ecdh_make_public.*4b00" \
5384 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005385 -c "! The certificate is not correctly signed by the trusted CA" \
5386 -C "! mbedtls_ssl_handshake returned" \
5387 -C "X509 - Certificate verification failed"
5388
5389requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5390run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5391 "$P_SRV auth_mode=required \
5392 crt_file=data_files/server5-badsign.crt \
5393 key_file=data_files/server5.key" \
5394 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5395 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5396 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5397 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005398 -C "x509_verify_cert.*4b00" \
5399 -c "mbedtls_pk_verify.*4b00" \
5400 -c "mbedtls_ecdh_make_public.*4b00" \
5401 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005402 -C "! The certificate is not correctly signed by the trusted CA" \
5403 -C "! mbedtls_ssl_handshake returned" \
5404 -C "X509 - Certificate verification failed"
5405
5406requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005407run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005408 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005409 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005410 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005411 dtls=1 debug_level=1 ec_max_ops=1000" \
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é-Gonnard2350b4e2017-05-16 09:26:48 +02005417
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005418requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5419run_test "EC restart: TLS, max_ops=1000 no client auth" \
5420 "$P_SRV" \
5421 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5422 debug_level=1 ec_max_ops=1000" \
5423 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005424 -c "x509_verify_cert.*4b00" \
5425 -c "mbedtls_pk_verify.*4b00" \
5426 -c "mbedtls_ecdh_make_public.*4b00" \
5427 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005428
5429requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5430run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5431 "$P_SRV psk=abc123" \
5432 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5433 psk=abc123 debug_level=1 ec_max_ops=1000" \
5434 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005435 -C "x509_verify_cert.*4b00" \
5436 -C "mbedtls_pk_verify.*4b00" \
5437 -C "mbedtls_ecdh_make_public.*4b00" \
5438 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005439
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005440# Tests of asynchronous private key support in SSL
5441
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005442requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005443run_test "SSL async private: sign, delay=0" \
5444 "$P_SRV \
5445 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005446 "$P_CLI" \
5447 0 \
5448 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005449 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005450
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005451requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005452run_test "SSL async private: sign, delay=1" \
5453 "$P_SRV \
5454 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005455 "$P_CLI" \
5456 0 \
5457 -s "Async sign callback: using key slot " \
5458 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005459 -s "Async resume (slot [0-9]): sign done, status=0"
5460
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005461requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5462run_test "SSL async private: sign, delay=2" \
5463 "$P_SRV \
5464 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5465 "$P_CLI" \
5466 0 \
5467 -s "Async sign callback: using key slot " \
5468 -U "Async sign callback: using key slot " \
5469 -s "Async resume (slot [0-9]): call 1 more times." \
5470 -s "Async resume (slot [0-9]): call 0 more times." \
5471 -s "Async resume (slot [0-9]): sign done, status=0"
5472
Gilles Peskined3268832018-04-26 06:23:59 +02005473# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5474# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5475requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5476requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5477run_test "SSL async private: sign, RSA, TLS 1.1" \
5478 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5479 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5480 "$P_CLI force_version=tls1_1" \
5481 0 \
5482 -s "Async sign callback: using key slot " \
5483 -s "Async resume (slot [0-9]): sign done, status=0"
5484
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005485requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005486run_test "SSL async private: sign, SNI" \
5487 "$P_SRV debug_level=3 \
5488 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5489 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5490 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5491 "$P_CLI server_name=polarssl.example" \
5492 0 \
5493 -s "Async sign callback: using key slot " \
5494 -s "Async resume (slot [0-9]): sign done, status=0" \
5495 -s "parse ServerName extension" \
5496 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5497 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5498
5499requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005500run_test "SSL async private: decrypt, delay=0" \
5501 "$P_SRV \
5502 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5503 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5504 0 \
5505 -s "Async decrypt callback: using key slot " \
5506 -s "Async resume (slot [0-9]): decrypt done, status=0"
5507
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005508requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005509run_test "SSL async private: decrypt, delay=1" \
5510 "$P_SRV \
5511 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5512 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5513 0 \
5514 -s "Async decrypt callback: using key slot " \
5515 -s "Async resume (slot [0-9]): call 0 more times." \
5516 -s "Async resume (slot [0-9]): decrypt done, status=0"
5517
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005518requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005519run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5520 "$P_SRV psk=abc123 \
5521 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5522 "$P_CLI psk=abc123 \
5523 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5524 0 \
5525 -s "Async decrypt callback: using key slot " \
5526 -s "Async resume (slot [0-9]): decrypt done, status=0"
5527
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005528requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005529run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5530 "$P_SRV psk=abc123 \
5531 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5532 "$P_CLI psk=abc123 \
5533 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5534 0 \
5535 -s "Async decrypt callback: using key slot " \
5536 -s "Async resume (slot [0-9]): call 0 more times." \
5537 -s "Async resume (slot [0-9]): decrypt done, status=0"
5538
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005539requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005540run_test "SSL async private: sign callback not present" \
5541 "$P_SRV \
5542 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5543 "$P_CLI; [ \$? -eq 1 ] &&
5544 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5545 0 \
5546 -S "Async sign callback" \
5547 -s "! mbedtls_ssl_handshake returned" \
5548 -s "The own private key or pre-shared key is not set, but needed" \
5549 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5550 -s "Successful connection"
5551
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005552requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005553run_test "SSL async private: decrypt callback not present" \
5554 "$P_SRV debug_level=1 \
5555 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5556 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5557 [ \$? -eq 1 ] && $P_CLI" \
5558 0 \
5559 -S "Async decrypt callback" \
5560 -s "! mbedtls_ssl_handshake returned" \
5561 -s "got no RSA private key" \
5562 -s "Async resume (slot [0-9]): sign done, status=0" \
5563 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005564
5565# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005566requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005567run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005568 "$P_SRV \
5569 async_operations=s async_private_delay1=1 \
5570 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5571 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005572 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5573 0 \
5574 -s "Async sign callback: using key slot 0," \
5575 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005576 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005577
5578# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005579requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005580run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005581 "$P_SRV \
5582 async_operations=s async_private_delay2=1 \
5583 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5584 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005585 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5586 0 \
5587 -s "Async sign callback: using key slot 0," \
5588 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005589 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005590
5591# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005592requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005593run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005594 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005595 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005596 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5597 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005598 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5599 0 \
5600 -s "Async sign callback: using key slot 1," \
5601 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005602 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005603
5604# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005605requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005606run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005607 "$P_SRV \
5608 async_operations=s async_private_delay1=1 \
5609 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5610 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005611 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5612 0 \
5613 -s "Async sign callback: no key matches this certificate."
5614
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005615requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005616run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005617 "$P_SRV \
5618 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5619 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005620 "$P_CLI" \
5621 1 \
5622 -s "Async sign callback: injected error" \
5623 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005624 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005625 -s "! mbedtls_ssl_handshake returned"
5626
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005627requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005628run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005629 "$P_SRV \
5630 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5631 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005632 "$P_CLI" \
5633 1 \
5634 -s "Async sign callback: using key slot " \
5635 -S "Async resume" \
5636 -s "Async cancel"
5637
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005638requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005639run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005640 "$P_SRV \
5641 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5642 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005643 "$P_CLI" \
5644 1 \
5645 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005646 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005647 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005648 -s "! mbedtls_ssl_handshake returned"
5649
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005650requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005651run_test "SSL async private: decrypt, error in start" \
5652 "$P_SRV \
5653 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5654 async_private_error=1" \
5655 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5656 1 \
5657 -s "Async decrypt callback: injected error" \
5658 -S "Async resume" \
5659 -S "Async cancel" \
5660 -s "! mbedtls_ssl_handshake returned"
5661
5662requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5663run_test "SSL async private: decrypt, cancel after start" \
5664 "$P_SRV \
5665 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5666 async_private_error=2" \
5667 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5668 1 \
5669 -s "Async decrypt callback: using key slot " \
5670 -S "Async resume" \
5671 -s "Async cancel"
5672
5673requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5674run_test "SSL async private: decrypt, error in resume" \
5675 "$P_SRV \
5676 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5677 async_private_error=3" \
5678 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5679 1 \
5680 -s "Async decrypt callback: using key slot " \
5681 -s "Async resume callback: decrypt done but injected error" \
5682 -S "Async cancel" \
5683 -s "! mbedtls_ssl_handshake returned"
5684
5685requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005686run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005687 "$P_SRV \
5688 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5689 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005690 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5691 0 \
5692 -s "Async cancel" \
5693 -s "! mbedtls_ssl_handshake returned" \
5694 -s "Async resume" \
5695 -s "Successful connection"
5696
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005697requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005698run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005699 "$P_SRV \
5700 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5701 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005702 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5703 0 \
5704 -s "! mbedtls_ssl_handshake returned" \
5705 -s "Async resume" \
5706 -s "Successful connection"
5707
5708# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005709requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005710run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005711 "$P_SRV \
5712 async_operations=s async_private_delay1=1 async_private_error=-2 \
5713 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5714 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005715 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5716 [ \$? -eq 1 ] &&
5717 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5718 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005719 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005720 -S "Async resume" \
5721 -s "Async cancel" \
5722 -s "! mbedtls_ssl_handshake returned" \
5723 -s "Async sign callback: no key matches this certificate." \
5724 -s "Successful connection"
5725
5726# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005727requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005728run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005729 "$P_SRV \
5730 async_operations=s async_private_delay1=1 async_private_error=-3 \
5731 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5732 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005733 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5734 [ \$? -eq 1 ] &&
5735 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5736 0 \
5737 -s "Async resume" \
5738 -s "! mbedtls_ssl_handshake returned" \
5739 -s "Async sign callback: no key matches this certificate." \
5740 -s "Successful connection"
5741
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005742requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005743requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005744run_test "SSL async private: renegotiation: client-initiated; sign" \
5745 "$P_SRV \
5746 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005747 exchanges=2 renegotiation=1" \
5748 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5749 0 \
5750 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005751 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005752
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005753requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005754requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005755run_test "SSL async private: renegotiation: server-initiated; sign" \
5756 "$P_SRV \
5757 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005758 exchanges=2 renegotiation=1 renegotiate=1" \
5759 "$P_CLI exchanges=2 renegotiation=1" \
5760 0 \
5761 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005762 -s "Async resume (slot [0-9]): sign done, status=0"
5763
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005764requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005765requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5766run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5767 "$P_SRV \
5768 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5769 exchanges=2 renegotiation=1" \
5770 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5771 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5772 0 \
5773 -s "Async decrypt callback: using key slot " \
5774 -s "Async resume (slot [0-9]): decrypt done, status=0"
5775
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005776requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005777requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5778run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5779 "$P_SRV \
5780 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5781 exchanges=2 renegotiation=1 renegotiate=1" \
5782 "$P_CLI exchanges=2 renegotiation=1 \
5783 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5784 0 \
5785 -s "Async decrypt callback: using key slot " \
5786 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005787
Ron Eldor58093c82018-06-28 13:22:05 +03005788# Tests for ECC extensions (rfc 4492)
5789
Ron Eldor643df7c2018-06-28 16:17:00 +03005790requires_config_enabled MBEDTLS_AES_C
5791requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5792requires_config_enabled MBEDTLS_SHA256_C
5793requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005794run_test "Force a non ECC ciphersuite in the client side" \
5795 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005796 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005797 0 \
5798 -C "client hello, adding supported_elliptic_curves extension" \
5799 -C "client hello, adding supported_point_formats extension" \
5800 -S "found supported elliptic curves extension" \
5801 -S "found supported point formats extension"
5802
Ron Eldor643df7c2018-06-28 16:17:00 +03005803requires_config_enabled MBEDTLS_AES_C
5804requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5805requires_config_enabled MBEDTLS_SHA256_C
5806requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005807run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005808 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005809 "$P_CLI debug_level=3" \
5810 0 \
5811 -C "found supported_point_formats extension" \
5812 -S "server hello, supported_point_formats extension"
5813
Ron Eldor643df7c2018-06-28 16:17:00 +03005814requires_config_enabled MBEDTLS_AES_C
5815requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5816requires_config_enabled MBEDTLS_SHA256_C
5817requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005818run_test "Force an ECC ciphersuite in the client side" \
5819 "$P_SRV debug_level=3" \
5820 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5821 0 \
5822 -c "client hello, adding supported_elliptic_curves extension" \
5823 -c "client hello, adding supported_point_formats extension" \
5824 -s "found supported elliptic curves extension" \
5825 -s "found supported point formats extension"
5826
Ron Eldor643df7c2018-06-28 16:17:00 +03005827requires_config_enabled MBEDTLS_AES_C
5828requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5829requires_config_enabled MBEDTLS_SHA256_C
5830requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005831run_test "Force an ECC ciphersuite in the server side" \
5832 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5833 "$P_CLI debug_level=3" \
5834 0 \
5835 -c "found supported_point_formats extension" \
5836 -s "server hello, supported_point_formats extension"
5837
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005838# Tests for DTLS HelloVerifyRequest
5839
5840run_test "DTLS cookie: enabled" \
5841 "$P_SRV dtls=1 debug_level=2" \
5842 "$P_CLI dtls=1 debug_level=2" \
5843 0 \
5844 -s "cookie verification failed" \
5845 -s "cookie verification passed" \
5846 -S "cookie verification skipped" \
5847 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005848 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005849 -S "SSL - The requested feature is not available"
5850
5851run_test "DTLS cookie: disabled" \
5852 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5853 "$P_CLI dtls=1 debug_level=2" \
5854 0 \
5855 -S "cookie verification failed" \
5856 -S "cookie verification passed" \
5857 -s "cookie verification skipped" \
5858 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005859 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005860 -S "SSL - The requested feature is not available"
5861
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005862run_test "DTLS cookie: default (failing)" \
5863 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5864 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5865 1 \
5866 -s "cookie verification failed" \
5867 -S "cookie verification passed" \
5868 -S "cookie verification skipped" \
5869 -C "received hello verify request" \
5870 -S "hello verification requested" \
5871 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005872
5873requires_ipv6
5874run_test "DTLS cookie: enabled, IPv6" \
5875 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5876 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5877 0 \
5878 -s "cookie verification failed" \
5879 -s "cookie verification passed" \
5880 -S "cookie verification skipped" \
5881 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005882 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005883 -S "SSL - The requested feature is not available"
5884
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005885run_test "DTLS cookie: enabled, nbio" \
5886 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5887 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5888 0 \
5889 -s "cookie verification failed" \
5890 -s "cookie verification passed" \
5891 -S "cookie verification skipped" \
5892 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005893 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005894 -S "SSL - The requested feature is not available"
5895
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005896# Tests for client reconnecting from the same port with DTLS
5897
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005898not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005899run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005900 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5901 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005902 0 \
5903 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005904 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005905 -S "Client initiated reconnection from same port"
5906
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005907not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005908run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005909 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5910 "$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 +02005911 0 \
5912 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005913 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005914 -s "Client initiated reconnection from same port"
5915
Paul Bakker362689d2016-05-13 10:33:25 +01005916not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5917run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005918 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5919 "$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 +02005920 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005921 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005922 -s "Client initiated reconnection from same port"
5923
Paul Bakker362689d2016-05-13 10:33:25 +01005924only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5925run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5926 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5927 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5928 0 \
5929 -S "The operation timed out" \
5930 -s "Client initiated reconnection from same port"
5931
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005932run_test "DTLS client reconnect from same port: no cookies" \
5933 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005934 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5935 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005936 -s "The operation timed out" \
5937 -S "Client initiated reconnection from same port"
5938
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005939run_test "DTLS client reconnect from same port: attacker-injected" \
5940 -p "$P_PXY inject_clihlo=1" \
5941 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5942 "$P_CLI dtls=1 exchanges=2" \
5943 0 \
5944 -s "possible client reconnect from the same port" \
5945 -S "Client initiated reconnection from same port"
5946
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005947# Tests for various cases of client authentication with DTLS
5948# (focused on handshake flows and message parsing)
5949
5950run_test "DTLS client auth: required" \
5951 "$P_SRV dtls=1 auth_mode=required" \
5952 "$P_CLI dtls=1" \
5953 0 \
5954 -s "Verifying peer X.509 certificate... ok"
5955
5956run_test "DTLS client auth: optional, client has no cert" \
5957 "$P_SRV dtls=1 auth_mode=optional" \
5958 "$P_CLI dtls=1 crt_file=none key_file=none" \
5959 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005960 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005961
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005962run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005963 "$P_SRV dtls=1 auth_mode=none" \
5964 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5965 0 \
5966 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005967 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005968
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005969run_test "DTLS wrong PSK: badmac alert" \
5970 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5971 "$P_CLI dtls=1 psk=abc124" \
5972 1 \
5973 -s "SSL - Verification of the message MAC failed" \
5974 -c "SSL - A fatal alert message was received from our peer"
5975
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005976# Tests for receiving fragmented handshake messages with DTLS
5977
5978requires_gnutls
5979run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5980 "$G_SRV -u --mtu 2048 -a" \
5981 "$P_CLI dtls=1 debug_level=2" \
5982 0 \
5983 -C "found fragmented DTLS handshake message" \
5984 -C "error"
5985
5986requires_gnutls
5987run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5988 "$G_SRV -u --mtu 512" \
5989 "$P_CLI dtls=1 debug_level=2" \
5990 0 \
5991 -c "found fragmented DTLS handshake message" \
5992 -C "error"
5993
5994requires_gnutls
5995run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5996 "$G_SRV -u --mtu 128" \
5997 "$P_CLI dtls=1 debug_level=2" \
5998 0 \
5999 -c "found fragmented DTLS handshake message" \
6000 -C "error"
6001
6002requires_gnutls
6003run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6004 "$G_SRV -u --mtu 128" \
6005 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6006 0 \
6007 -c "found fragmented DTLS handshake message" \
6008 -C "error"
6009
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006010requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006011requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006012run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6013 "$G_SRV -u --mtu 256" \
6014 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6015 0 \
6016 -c "found fragmented DTLS handshake message" \
6017 -c "client hello, adding renegotiation extension" \
6018 -c "found renegotiation extension" \
6019 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006020 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006021 -C "error" \
6022 -s "Extra-header:"
6023
6024requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006025requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006026run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6027 "$G_SRV -u --mtu 256" \
6028 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6029 0 \
6030 -c "found fragmented DTLS handshake message" \
6031 -c "client hello, adding renegotiation extension" \
6032 -c "found renegotiation extension" \
6033 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006034 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006035 -C "error" \
6036 -s "Extra-header:"
6037
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006038run_test "DTLS reassembly: no fragmentation (openssl server)" \
6039 "$O_SRV -dtls1 -mtu 2048" \
6040 "$P_CLI dtls=1 debug_level=2" \
6041 0 \
6042 -C "found fragmented DTLS handshake message" \
6043 -C "error"
6044
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006045run_test "DTLS reassembly: some fragmentation (openssl server)" \
6046 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006047 "$P_CLI dtls=1 debug_level=2" \
6048 0 \
6049 -c "found fragmented DTLS handshake message" \
6050 -C "error"
6051
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006052run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006053 "$O_SRV -dtls1 -mtu 256" \
6054 "$P_CLI dtls=1 debug_level=2" \
6055 0 \
6056 -c "found fragmented DTLS handshake message" \
6057 -C "error"
6058
6059run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6060 "$O_SRV -dtls1 -mtu 256" \
6061 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6062 0 \
6063 -c "found fragmented DTLS handshake message" \
6064 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006065
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006066# Tests for sending fragmented handshake messages with DTLS
6067#
6068# Use client auth when we need the client to send large messages,
6069# and use large cert chains on both sides too (the long chains we have all use
6070# both RSA and ECDSA, but ideally we should have long chains with either).
6071# Sizes reached (UDP payload):
6072# - 2037B for server certificate
6073# - 1542B for client certificate
6074# - 1013B for newsessionticket
6075# - all others below 512B
6076# All those tests assume MAX_CONTENT_LEN is at least 2048
6077
6078requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6079requires_config_enabled MBEDTLS_RSA_C
6080requires_config_enabled MBEDTLS_ECDSA_C
6081requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6082run_test "DTLS fragmenting: none (for reference)" \
6083 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6084 crt_file=data_files/server7_int-ca.crt \
6085 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006086 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006087 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006088 "$P_CLI dtls=1 debug_level=2 \
6089 crt_file=data_files/server8_int-ca2.crt \
6090 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006091 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006092 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006093 0 \
6094 -S "found fragmented DTLS handshake message" \
6095 -C "found fragmented DTLS handshake message" \
6096 -C "error"
6097
6098requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6099requires_config_enabled MBEDTLS_RSA_C
6100requires_config_enabled MBEDTLS_ECDSA_C
6101requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006102run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006103 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6104 crt_file=data_files/server7_int-ca.crt \
6105 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006106 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006107 max_frag_len=1024" \
6108 "$P_CLI dtls=1 debug_level=2 \
6109 crt_file=data_files/server8_int-ca2.crt \
6110 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006111 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006112 max_frag_len=2048" \
6113 0 \
6114 -S "found fragmented DTLS handshake message" \
6115 -c "found fragmented DTLS handshake message" \
6116 -C "error"
6117
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006118# With the MFL extension, the server has no way of forcing
6119# the client to not exceed a certain MTU; hence, the following
6120# test can't be replicated with an MTU proxy such as the one
6121# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006122requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6123requires_config_enabled MBEDTLS_RSA_C
6124requires_config_enabled MBEDTLS_ECDSA_C
6125requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006126run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006127 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6128 crt_file=data_files/server7_int-ca.crt \
6129 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006130 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006131 max_frag_len=512" \
6132 "$P_CLI dtls=1 debug_level=2 \
6133 crt_file=data_files/server8_int-ca2.crt \
6134 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006135 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006136 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006137 0 \
6138 -S "found fragmented DTLS handshake message" \
6139 -c "found fragmented DTLS handshake message" \
6140 -C "error"
6141
6142requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6143requires_config_enabled MBEDTLS_RSA_C
6144requires_config_enabled MBEDTLS_ECDSA_C
6145requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006146run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006147 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6148 crt_file=data_files/server7_int-ca.crt \
6149 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006150 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006151 max_frag_len=2048" \
6152 "$P_CLI dtls=1 debug_level=2 \
6153 crt_file=data_files/server8_int-ca2.crt \
6154 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006155 hs_timeout=2500-60000 \
6156 max_frag_len=1024" \
6157 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006158 -S "found fragmented DTLS handshake message" \
6159 -c "found fragmented DTLS handshake message" \
6160 -C "error"
6161
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006162# While not required by the standard defining the MFL extension
6163# (according to which it only applies to records, not to datagrams),
6164# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6165# as otherwise there wouldn't be any means to communicate MTU restrictions
6166# to the peer.
6167# The next test checks that no datagrams significantly larger than the
6168# negotiated MFL are sent.
6169requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6170requires_config_enabled MBEDTLS_RSA_C
6171requires_config_enabled MBEDTLS_ECDSA_C
6172requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6173run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006174 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006175 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6176 crt_file=data_files/server7_int-ca.crt \
6177 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006178 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006179 max_frag_len=2048" \
6180 "$P_CLI dtls=1 debug_level=2 \
6181 crt_file=data_files/server8_int-ca2.crt \
6182 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006183 hs_timeout=2500-60000 \
6184 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006185 0 \
6186 -S "found fragmented DTLS handshake message" \
6187 -c "found fragmented DTLS handshake message" \
6188 -C "error"
6189
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006190requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6191requires_config_enabled MBEDTLS_RSA_C
6192requires_config_enabled MBEDTLS_ECDSA_C
6193requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006194run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006195 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6196 crt_file=data_files/server7_int-ca.crt \
6197 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006198 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006199 max_frag_len=2048" \
6200 "$P_CLI dtls=1 debug_level=2 \
6201 crt_file=data_files/server8_int-ca2.crt \
6202 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006203 hs_timeout=2500-60000 \
6204 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006205 0 \
6206 -s "found fragmented DTLS handshake message" \
6207 -c "found fragmented DTLS handshake message" \
6208 -C "error"
6209
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006210# While not required by the standard defining the MFL extension
6211# (according to which it only applies to records, not to datagrams),
6212# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6213# as otherwise there wouldn't be any means to communicate MTU restrictions
6214# to the peer.
6215# The next test checks that no datagrams significantly larger than the
6216# negotiated MFL are sent.
6217requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6218requires_config_enabled MBEDTLS_RSA_C
6219requires_config_enabled MBEDTLS_ECDSA_C
6220requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6221run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006222 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006223 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6224 crt_file=data_files/server7_int-ca.crt \
6225 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006226 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006227 max_frag_len=2048" \
6228 "$P_CLI dtls=1 debug_level=2 \
6229 crt_file=data_files/server8_int-ca2.crt \
6230 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006231 hs_timeout=2500-60000 \
6232 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006233 0 \
6234 -s "found fragmented DTLS handshake message" \
6235 -c "found fragmented DTLS handshake message" \
6236 -C "error"
6237
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006238requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6239requires_config_enabled MBEDTLS_RSA_C
6240requires_config_enabled MBEDTLS_ECDSA_C
6241run_test "DTLS fragmenting: none (for reference) (MTU)" \
6242 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6243 crt_file=data_files/server7_int-ca.crt \
6244 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006245 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006246 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006247 "$P_CLI dtls=1 debug_level=2 \
6248 crt_file=data_files/server8_int-ca2.crt \
6249 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006250 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006251 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006252 0 \
6253 -S "found fragmented DTLS handshake message" \
6254 -C "found fragmented DTLS handshake message" \
6255 -C "error"
6256
6257requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6258requires_config_enabled MBEDTLS_RSA_C
6259requires_config_enabled MBEDTLS_ECDSA_C
6260run_test "DTLS fragmenting: client (MTU)" \
6261 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6262 crt_file=data_files/server7_int-ca.crt \
6263 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006264 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006265 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006266 "$P_CLI dtls=1 debug_level=2 \
6267 crt_file=data_files/server8_int-ca2.crt \
6268 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006269 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006270 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006271 0 \
6272 -s "found fragmented DTLS handshake message" \
6273 -C "found fragmented DTLS handshake message" \
6274 -C "error"
6275
6276requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6277requires_config_enabled MBEDTLS_RSA_C
6278requires_config_enabled MBEDTLS_ECDSA_C
6279run_test "DTLS fragmenting: server (MTU)" \
6280 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6281 crt_file=data_files/server7_int-ca.crt \
6282 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006283 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006284 mtu=512" \
6285 "$P_CLI dtls=1 debug_level=2 \
6286 crt_file=data_files/server8_int-ca2.crt \
6287 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006288 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006289 mtu=2048" \
6290 0 \
6291 -S "found fragmented DTLS handshake message" \
6292 -c "found fragmented DTLS handshake message" \
6293 -C "error"
6294
6295requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6296requires_config_enabled MBEDTLS_RSA_C
6297requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006298run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006299 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006300 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6301 crt_file=data_files/server7_int-ca.crt \
6302 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006303 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006304 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006305 "$P_CLI dtls=1 debug_level=2 \
6306 crt_file=data_files/server8_int-ca2.crt \
6307 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006308 hs_timeout=2500-60000 \
6309 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006310 0 \
6311 -s "found fragmented DTLS handshake message" \
6312 -c "found fragmented DTLS handshake message" \
6313 -C "error"
6314
Andrzej Kurek77826052018-10-11 07:34:08 -04006315# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006316requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6317requires_config_enabled MBEDTLS_RSA_C
6318requires_config_enabled MBEDTLS_ECDSA_C
6319requires_config_enabled MBEDTLS_SHA256_C
6320requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6321requires_config_enabled MBEDTLS_AES_C
6322requires_config_enabled MBEDTLS_GCM_C
6323run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006324 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006325 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6326 crt_file=data_files/server7_int-ca.crt \
6327 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006328 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006329 mtu=512" \
6330 "$P_CLI dtls=1 debug_level=2 \
6331 crt_file=data_files/server8_int-ca2.crt \
6332 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006333 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6334 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006335 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006336 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006337 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006338 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006339 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006340
Andrzej Kurek7311c782018-10-11 06:49:41 -04006341# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006342# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006343# The ratio of max/min timeout should ideally equal 4 to accept two
6344# retransmissions, but in some cases (like both the server and client using
6345# fragmentation and auto-reduction) an extra retransmission might occur,
6346# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006347not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006348requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6349requires_config_enabled MBEDTLS_RSA_C
6350requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006351requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6352requires_config_enabled MBEDTLS_AES_C
6353requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006354run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6355 -p "$P_PXY mtu=508" \
6356 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6357 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006358 key_file=data_files/server7.key \
6359 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006360 "$P_CLI dtls=1 debug_level=2 \
6361 crt_file=data_files/server8_int-ca2.crt \
6362 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006363 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6364 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006365 0 \
6366 -s "found fragmented DTLS handshake message" \
6367 -c "found fragmented DTLS handshake message" \
6368 -C "error"
6369
Andrzej Kurek77826052018-10-11 07:34:08 -04006370# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006371only_with_valgrind
6372requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6373requires_config_enabled MBEDTLS_RSA_C
6374requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006375requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6376requires_config_enabled MBEDTLS_AES_C
6377requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006378run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6379 -p "$P_PXY mtu=508" \
6380 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6381 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006382 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006383 hs_timeout=250-10000" \
6384 "$P_CLI dtls=1 debug_level=2 \
6385 crt_file=data_files/server8_int-ca2.crt \
6386 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006387 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006388 hs_timeout=250-10000" \
6389 0 \
6390 -s "found fragmented DTLS handshake message" \
6391 -c "found fragmented DTLS handshake message" \
6392 -C "error"
6393
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006394# 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 +02006395# OTOH the client might resend if the server is to slow to reset after sending
6396# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006397not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006398requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6399requires_config_enabled MBEDTLS_RSA_C
6400requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006401run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006402 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006403 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6404 crt_file=data_files/server7_int-ca.crt \
6405 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006406 hs_timeout=10000-60000 \
6407 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006408 "$P_CLI dtls=1 debug_level=2 \
6409 crt_file=data_files/server8_int-ca2.crt \
6410 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006411 hs_timeout=10000-60000 \
6412 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006413 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006414 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006415 -s "found fragmented DTLS handshake message" \
6416 -c "found fragmented DTLS handshake message" \
6417 -C "error"
6418
Andrzej Kurek77826052018-10-11 07:34:08 -04006419# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006420# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6421# OTOH the client might resend if the server is to slow to reset after sending
6422# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006423not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006424requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6425requires_config_enabled MBEDTLS_RSA_C
6426requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006427requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6428requires_config_enabled MBEDTLS_AES_C
6429requires_config_enabled MBEDTLS_GCM_C
6430run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006431 -p "$P_PXY mtu=512" \
6432 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6433 crt_file=data_files/server7_int-ca.crt \
6434 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006435 hs_timeout=10000-60000 \
6436 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006437 "$P_CLI dtls=1 debug_level=2 \
6438 crt_file=data_files/server8_int-ca2.crt \
6439 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006440 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6441 hs_timeout=10000-60000 \
6442 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006443 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006444 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006445 -s "found fragmented DTLS handshake message" \
6446 -c "found fragmented DTLS handshake message" \
6447 -C "error"
6448
Andrzej Kurek7311c782018-10-11 06:49:41 -04006449not_with_valgrind # spurious autoreduction due to timeout
6450requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6451requires_config_enabled MBEDTLS_RSA_C
6452requires_config_enabled MBEDTLS_ECDSA_C
6453run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006454 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006455 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6456 crt_file=data_files/server7_int-ca.crt \
6457 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006458 hs_timeout=10000-60000 \
6459 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006460 "$P_CLI dtls=1 debug_level=2 \
6461 crt_file=data_files/server8_int-ca2.crt \
6462 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006463 hs_timeout=10000-60000 \
6464 mtu=1024 nbio=2" \
6465 0 \
6466 -S "autoreduction" \
6467 -s "found fragmented DTLS handshake message" \
6468 -c "found fragmented DTLS handshake message" \
6469 -C "error"
6470
Andrzej Kurek77826052018-10-11 07:34:08 -04006471# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006472not_with_valgrind # spurious autoreduction due to timeout
6473requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6474requires_config_enabled MBEDTLS_RSA_C
6475requires_config_enabled MBEDTLS_ECDSA_C
6476requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6477requires_config_enabled MBEDTLS_AES_C
6478requires_config_enabled MBEDTLS_GCM_C
6479run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6480 -p "$P_PXY mtu=512" \
6481 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6482 crt_file=data_files/server7_int-ca.crt \
6483 key_file=data_files/server7.key \
6484 hs_timeout=10000-60000 \
6485 mtu=512 nbio=2" \
6486 "$P_CLI dtls=1 debug_level=2 \
6487 crt_file=data_files/server8_int-ca2.crt \
6488 key_file=data_files/server8.key \
6489 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6490 hs_timeout=10000-60000 \
6491 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006492 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006493 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006494 -s "found fragmented DTLS handshake message" \
6495 -c "found fragmented DTLS handshake message" \
6496 -C "error"
6497
Andrzej Kurek77826052018-10-11 07:34:08 -04006498# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006499# This ensures things still work after session_reset().
6500# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006501# Since we don't support reading fragmented ClientHello yet,
6502# up the MTU to 1450 (larger than ClientHello with session ticket,
6503# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006504# An autoreduction on the client-side might happen if the server is
6505# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006506# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006507# resumed listening, which would result in a spurious autoreduction.
6508not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006509requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6510requires_config_enabled MBEDTLS_RSA_C
6511requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006512requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6513requires_config_enabled MBEDTLS_AES_C
6514requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006515run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6516 -p "$P_PXY mtu=1450" \
6517 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6518 crt_file=data_files/server7_int-ca.crt \
6519 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006520 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006521 mtu=1450" \
6522 "$P_CLI dtls=1 debug_level=2 \
6523 crt_file=data_files/server8_int-ca2.crt \
6524 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006525 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006526 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006527 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006528 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006529 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006530 -s "found fragmented DTLS handshake message" \
6531 -c "found fragmented DTLS handshake message" \
6532 -C "error"
6533
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006534# An autoreduction on the client-side might happen if the server is
6535# slow to reset, therefore omitting '-C "autoreduction"' below.
6536not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006537requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6538requires_config_enabled MBEDTLS_RSA_C
6539requires_config_enabled MBEDTLS_ECDSA_C
6540requires_config_enabled MBEDTLS_SHA256_C
6541requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6542requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6543requires_config_enabled MBEDTLS_CHACHAPOLY_C
6544run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6545 -p "$P_PXY mtu=512" \
6546 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6547 crt_file=data_files/server7_int-ca.crt \
6548 key_file=data_files/server7.key \
6549 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006550 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006551 mtu=512" \
6552 "$P_CLI dtls=1 debug_level=2 \
6553 crt_file=data_files/server8_int-ca2.crt \
6554 key_file=data_files/server8.key \
6555 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006556 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006557 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006558 mtu=512" \
6559 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006560 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006561 -s "found fragmented DTLS handshake message" \
6562 -c "found fragmented DTLS handshake message" \
6563 -C "error"
6564
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006565# An autoreduction on the client-side might happen if the server is
6566# slow to reset, therefore omitting '-C "autoreduction"' below.
6567not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006568requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6569requires_config_enabled MBEDTLS_RSA_C
6570requires_config_enabled MBEDTLS_ECDSA_C
6571requires_config_enabled MBEDTLS_SHA256_C
6572requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6573requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6574requires_config_enabled MBEDTLS_AES_C
6575requires_config_enabled MBEDTLS_GCM_C
6576run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6577 -p "$P_PXY mtu=512" \
6578 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6579 crt_file=data_files/server7_int-ca.crt \
6580 key_file=data_files/server7.key \
6581 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006582 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006583 mtu=512" \
6584 "$P_CLI dtls=1 debug_level=2 \
6585 crt_file=data_files/server8_int-ca2.crt \
6586 key_file=data_files/server8.key \
6587 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006588 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006589 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006590 mtu=512" \
6591 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006592 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006593 -s "found fragmented DTLS handshake message" \
6594 -c "found fragmented DTLS handshake message" \
6595 -C "error"
6596
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006597# An autoreduction on the client-side might happen if the server is
6598# slow to reset, therefore omitting '-C "autoreduction"' below.
6599not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006600requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6601requires_config_enabled MBEDTLS_RSA_C
6602requires_config_enabled MBEDTLS_ECDSA_C
6603requires_config_enabled MBEDTLS_SHA256_C
6604requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6605requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6606requires_config_enabled MBEDTLS_AES_C
6607requires_config_enabled MBEDTLS_CCM_C
6608run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006609 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006610 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6611 crt_file=data_files/server7_int-ca.crt \
6612 key_file=data_files/server7.key \
6613 exchanges=2 renegotiation=1 \
6614 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006615 hs_timeout=10000-60000 \
6616 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006617 "$P_CLI dtls=1 debug_level=2 \
6618 crt_file=data_files/server8_int-ca2.crt \
6619 key_file=data_files/server8.key \
6620 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006621 hs_timeout=10000-60000 \
6622 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006623 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006624 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006625 -s "found fragmented DTLS handshake message" \
6626 -c "found fragmented DTLS handshake message" \
6627 -C "error"
6628
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006629# An autoreduction on the client-side might happen if the server is
6630# slow to reset, therefore omitting '-C "autoreduction"' below.
6631not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006632requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6633requires_config_enabled MBEDTLS_RSA_C
6634requires_config_enabled MBEDTLS_ECDSA_C
6635requires_config_enabled MBEDTLS_SHA256_C
6636requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6637requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6638requires_config_enabled MBEDTLS_AES_C
6639requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6640requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6641run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006642 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006643 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6644 crt_file=data_files/server7_int-ca.crt \
6645 key_file=data_files/server7.key \
6646 exchanges=2 renegotiation=1 \
6647 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006648 hs_timeout=10000-60000 \
6649 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006650 "$P_CLI dtls=1 debug_level=2 \
6651 crt_file=data_files/server8_int-ca2.crt \
6652 key_file=data_files/server8.key \
6653 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006654 hs_timeout=10000-60000 \
6655 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006656 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006657 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006658 -s "found fragmented DTLS handshake message" \
6659 -c "found fragmented DTLS handshake message" \
6660 -C "error"
6661
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006662# An autoreduction on the client-side might happen if the server is
6663# slow to reset, therefore omitting '-C "autoreduction"' below.
6664not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006665requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6666requires_config_enabled MBEDTLS_RSA_C
6667requires_config_enabled MBEDTLS_ECDSA_C
6668requires_config_enabled MBEDTLS_SHA256_C
6669requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6670requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6671requires_config_enabled MBEDTLS_AES_C
6672requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6673run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006674 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006675 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6676 crt_file=data_files/server7_int-ca.crt \
6677 key_file=data_files/server7.key \
6678 exchanges=2 renegotiation=1 \
6679 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006680 hs_timeout=10000-60000 \
6681 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006682 "$P_CLI dtls=1 debug_level=2 \
6683 crt_file=data_files/server8_int-ca2.crt \
6684 key_file=data_files/server8.key \
6685 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006686 hs_timeout=10000-60000 \
6687 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006688 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006689 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006690 -s "found fragmented DTLS handshake message" \
6691 -c "found fragmented DTLS handshake message" \
6692 -C "error"
6693
Andrzej Kurek77826052018-10-11 07:34:08 -04006694# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006695requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6696requires_config_enabled MBEDTLS_RSA_C
6697requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006698requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6699requires_config_enabled MBEDTLS_AES_C
6700requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006701client_needs_more_time 2
6702run_test "DTLS fragmenting: proxy MTU + 3d" \
6703 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006704 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006705 crt_file=data_files/server7_int-ca.crt \
6706 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006707 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006708 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006709 crt_file=data_files/server8_int-ca2.crt \
6710 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006711 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006712 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006713 0 \
6714 -s "found fragmented DTLS handshake message" \
6715 -c "found fragmented DTLS handshake message" \
6716 -C "error"
6717
Andrzej Kurek77826052018-10-11 07:34:08 -04006718# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006719requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6720requires_config_enabled MBEDTLS_RSA_C
6721requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006722requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6723requires_config_enabled MBEDTLS_AES_C
6724requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006725client_needs_more_time 2
6726run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6727 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6728 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6729 crt_file=data_files/server7_int-ca.crt \
6730 key_file=data_files/server7.key \
6731 hs_timeout=250-10000 mtu=512 nbio=2" \
6732 "$P_CLI dtls=1 debug_level=2 \
6733 crt_file=data_files/server8_int-ca2.crt \
6734 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006735 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006736 hs_timeout=250-10000 mtu=512 nbio=2" \
6737 0 \
6738 -s "found fragmented DTLS handshake message" \
6739 -c "found fragmented DTLS handshake message" \
6740 -C "error"
6741
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006742# interop tests for DTLS fragmentating with reliable connection
6743#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006744# here and below we just want to test that the we fragment in a way that
6745# pleases other implementations, so we don't need the peer to fragment
6746requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6747requires_config_enabled MBEDTLS_RSA_C
6748requires_config_enabled MBEDTLS_ECDSA_C
6749requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006750requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006751run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6752 "$G_SRV -u" \
6753 "$P_CLI dtls=1 debug_level=2 \
6754 crt_file=data_files/server8_int-ca2.crt \
6755 key_file=data_files/server8.key \
6756 mtu=512 force_version=dtls1_2" \
6757 0 \
6758 -c "fragmenting handshake message" \
6759 -C "error"
6760
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_1
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.0" \
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 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006771 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006772 0 \
6773 -c "fragmenting handshake message" \
6774 -C "error"
6775
Hanno Beckerb9a00862018-08-28 10:20:22 +01006776# We use --insecure for the GnuTLS client because it expects
6777# the hostname / IP it connects to to be the name used in the
6778# certificate obtained from the server. Here, however, it
6779# connects to 127.0.0.1 while our test certificates use 'localhost'
6780# as the server name in the certificate. This will make the
6781# certifiate validation fail, but passing --insecure makes
6782# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006783requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6784requires_config_enabled MBEDTLS_RSA_C
6785requires_config_enabled MBEDTLS_ECDSA_C
6786requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006787requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006788requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006789run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006790 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006791 crt_file=data_files/server7_int-ca.crt \
6792 key_file=data_files/server7.key \
6793 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006794 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006795 0 \
6796 -s "fragmenting handshake message"
6797
Hanno Beckerb9a00862018-08-28 10:20:22 +01006798# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006799requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6800requires_config_enabled MBEDTLS_RSA_C
6801requires_config_enabled MBEDTLS_ECDSA_C
6802requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006803requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006804requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006805run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006806 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006807 crt_file=data_files/server7_int-ca.crt \
6808 key_file=data_files/server7.key \
6809 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006810 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006811 0 \
6812 -s "fragmenting handshake message"
6813
6814requires_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_2
6818run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6819 "$O_SRV -dtls1_2 -verify 10" \
6820 "$P_CLI dtls=1 debug_level=2 \
6821 crt_file=data_files/server8_int-ca2.crt \
6822 key_file=data_files/server8.key \
6823 mtu=512 force_version=dtls1_2" \
6824 0 \
6825 -c "fragmenting handshake message" \
6826 -C "error"
6827
6828requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6829requires_config_enabled MBEDTLS_RSA_C
6830requires_config_enabled MBEDTLS_ECDSA_C
6831requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6832run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6833 "$O_SRV -dtls1 -verify 10" \
6834 "$P_CLI dtls=1 debug_level=2 \
6835 crt_file=data_files/server8_int-ca2.crt \
6836 key_file=data_files/server8.key \
6837 mtu=512 force_version=dtls1" \
6838 0 \
6839 -c "fragmenting handshake message" \
6840 -C "error"
6841
6842requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6843requires_config_enabled MBEDTLS_RSA_C
6844requires_config_enabled MBEDTLS_ECDSA_C
6845requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6846run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6847 "$P_SRV dtls=1 debug_level=2 \
6848 crt_file=data_files/server7_int-ca.crt \
6849 key_file=data_files/server7.key \
6850 mtu=512 force_version=dtls1_2" \
6851 "$O_CLI -dtls1_2" \
6852 0 \
6853 -s "fragmenting handshake message"
6854
6855requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6856requires_config_enabled MBEDTLS_RSA_C
6857requires_config_enabled MBEDTLS_ECDSA_C
6858requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6859run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6860 "$P_SRV dtls=1 debug_level=2 \
6861 crt_file=data_files/server7_int-ca.crt \
6862 key_file=data_files/server7.key \
6863 mtu=512 force_version=dtls1" \
6864 "$O_CLI -dtls1" \
6865 0 \
6866 -s "fragmenting handshake message"
6867
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006868# interop tests for DTLS fragmentating with unreliable connection
6869#
6870# again we just want to test that the we fragment in a way that
6871# pleases other implementations, so we don't need the peer to fragment
6872requires_gnutls_next
6873requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6874requires_config_enabled MBEDTLS_RSA_C
6875requires_config_enabled MBEDTLS_ECDSA_C
6876requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006877client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006878run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6879 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6880 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006881 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006882 crt_file=data_files/server8_int-ca2.crt \
6883 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006884 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006885 0 \
6886 -c "fragmenting handshake message" \
6887 -C "error"
6888
6889requires_gnutls_next
6890requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6891requires_config_enabled MBEDTLS_RSA_C
6892requires_config_enabled MBEDTLS_ECDSA_C
6893requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006894client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006895run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6896 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6897 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006898 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006899 crt_file=data_files/server8_int-ca2.crt \
6900 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006901 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006902 0 \
6903 -c "fragmenting handshake message" \
6904 -C "error"
6905
k-stachowiakabb843e2019-02-18 16:14:03 +01006906requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006907requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6908requires_config_enabled MBEDTLS_RSA_C
6909requires_config_enabled MBEDTLS_ECDSA_C
6910requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6911client_needs_more_time 4
6912run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6913 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6914 "$P_SRV dtls=1 debug_level=2 \
6915 crt_file=data_files/server7_int-ca.crt \
6916 key_file=data_files/server7.key \
6917 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006918 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006919 0 \
6920 -s "fragmenting handshake message"
6921
k-stachowiakabb843e2019-02-18 16:14:03 +01006922requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006923requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6924requires_config_enabled MBEDTLS_RSA_C
6925requires_config_enabled MBEDTLS_ECDSA_C
6926requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6927client_needs_more_time 4
6928run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6929 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6930 "$P_SRV dtls=1 debug_level=2 \
6931 crt_file=data_files/server7_int-ca.crt \
6932 key_file=data_files/server7.key \
6933 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006934 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006935 0 \
6936 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006937
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006938## Interop test with OpenSSL might trigger a bug in recent versions (including
6939## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006940## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006941## They should be re-enabled once a fixed version of OpenSSL is available
6942## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006943skip_next_test
6944requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6945requires_config_enabled MBEDTLS_RSA_C
6946requires_config_enabled MBEDTLS_ECDSA_C
6947requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6948client_needs_more_time 4
6949run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6950 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6951 "$O_SRV -dtls1_2 -verify 10" \
6952 "$P_CLI dtls=1 debug_level=2 \
6953 crt_file=data_files/server8_int-ca2.crt \
6954 key_file=data_files/server8.key \
6955 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6956 0 \
6957 -c "fragmenting handshake message" \
6958 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006959
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006960skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006961requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6962requires_config_enabled MBEDTLS_RSA_C
6963requires_config_enabled MBEDTLS_ECDSA_C
6964requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006965client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006966run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6967 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006968 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006969 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006970 crt_file=data_files/server8_int-ca2.crt \
6971 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006972 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006973 0 \
6974 -c "fragmenting handshake message" \
6975 -C "error"
6976
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006977skip_next_test
6978requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6979requires_config_enabled MBEDTLS_RSA_C
6980requires_config_enabled MBEDTLS_ECDSA_C
6981requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6982client_needs_more_time 4
6983run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6984 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6985 "$P_SRV dtls=1 debug_level=2 \
6986 crt_file=data_files/server7_int-ca.crt \
6987 key_file=data_files/server7.key \
6988 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6989 "$O_CLI -dtls1_2" \
6990 0 \
6991 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006992
6993# -nbio is added to prevent s_client from blocking in case of duplicated
6994# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006995skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006996requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6997requires_config_enabled MBEDTLS_RSA_C
6998requires_config_enabled MBEDTLS_ECDSA_C
6999requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007000client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007001run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7002 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007003 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007004 crt_file=data_files/server7_int-ca.crt \
7005 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007006 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007007 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007008 0 \
7009 -s "fragmenting handshake message"
7010
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007011# Tests for specific things with "unreliable" UDP connection
7012
7013not_with_valgrind # spurious resend due to timeout
7014run_test "DTLS proxy: reference" \
7015 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007016 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7017 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007018 0 \
7019 -C "replayed record" \
7020 -S "replayed record" \
7021 -C "record from another epoch" \
7022 -S "record from another epoch" \
7023 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007024 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007025 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007026 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007027 -c "HTTP/1.0 200 OK"
7028
7029not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007030run_test "DTLS proxy: duplicate every packet" \
7031 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007032 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7033 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007034 0 \
7035 -c "replayed record" \
7036 -s "replayed record" \
7037 -c "record from another epoch" \
7038 -s "record from another epoch" \
7039 -S "resend" \
7040 -s "Extra-header:" \
7041 -c "HTTP/1.0 200 OK"
7042
7043run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7044 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007045 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7046 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007047 0 \
7048 -c "replayed record" \
7049 -S "replayed record" \
7050 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007051 -s "record from another epoch" \
7052 -c "resend" \
7053 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007054 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007055 -c "HTTP/1.0 200 OK"
7056
7057run_test "DTLS proxy: multiple records in same datagram" \
7058 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007059 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7060 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007061 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007062 -c "next record in same datagram" \
7063 -s "next record in same datagram"
7064
7065run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7066 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007067 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7068 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007069 0 \
7070 -c "next record in same datagram" \
7071 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007072
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007073run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7074 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007075 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7076 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007077 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007078 -c "discarding invalid record (mac)" \
7079 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007080 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007081 -c "HTTP/1.0 200 OK" \
7082 -S "too many records with bad MAC" \
7083 -S "Verification of the message MAC failed"
7084
7085run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7086 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007087 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7088 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007089 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007090 -C "discarding invalid record (mac)" \
7091 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007092 -S "Extra-header:" \
7093 -C "HTTP/1.0 200 OK" \
7094 -s "too many records with bad MAC" \
7095 -s "Verification of the message MAC failed"
7096
7097run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7098 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007099 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7100 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007101 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007102 -c "discarding invalid record (mac)" \
7103 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007104 -s "Extra-header:" \
7105 -c "HTTP/1.0 200 OK" \
7106 -S "too many records with bad MAC" \
7107 -S "Verification of the message MAC failed"
7108
7109run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7110 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007111 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7112 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007113 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007114 -c "discarding invalid record (mac)" \
7115 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007116 -s "Extra-header:" \
7117 -c "HTTP/1.0 200 OK" \
7118 -s "too many records with bad MAC" \
7119 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007120
7121run_test "DTLS proxy: delay ChangeCipherSpec" \
7122 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007123 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7124 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007125 0 \
7126 -c "record from another epoch" \
7127 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007128 -s "Extra-header:" \
7129 -c "HTTP/1.0 200 OK"
7130
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007131# Tests for reordering support with DTLS
7132
Hanno Becker56cdfd12018-08-17 13:42:15 +01007133run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7134 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007135 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7136 hs_timeout=2500-60000" \
7137 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7138 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007139 0 \
7140 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007141 -c "Next handshake message has been buffered - load"\
7142 -S "Buffering HS message" \
7143 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007144 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007145 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007146 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007147 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007148
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007149run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7150 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007151 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7152 hs_timeout=2500-60000" \
7153 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7154 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007155 0 \
7156 -c "Buffering HS message" \
7157 -c "found fragmented DTLS handshake message"\
7158 -c "Next handshake message 1 not or only partially bufffered" \
7159 -c "Next handshake message has been buffered - load"\
7160 -S "Buffering HS message" \
7161 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007162 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007163 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007164 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007165 -S "Remember CCS message"
7166
Hanno Beckera1adcca2018-08-24 14:41:07 +01007167# The client buffers the ServerKeyExchange before receiving the fragmented
7168# Certificate message; at the time of writing, together these are aroudn 1200b
7169# in size, so that the bound below ensures that the certificate can be reassembled
7170# while keeping the ServerKeyExchange.
7171requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7172run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007173 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007174 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7175 hs_timeout=2500-60000" \
7176 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7177 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007178 0 \
7179 -c "Buffering HS message" \
7180 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007181 -C "attempt to make space by freeing buffered messages" \
7182 -S "Buffering HS message" \
7183 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007184 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007185 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007186 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007187 -S "Remember CCS message"
7188
7189# The size constraints ensure that the delayed certificate message can't
7190# be reassembled while keeping the ServerKeyExchange message, but it can
7191# when dropping it first.
7192requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7193requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7194run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7195 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007196 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7197 hs_timeout=2500-60000" \
7198 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7199 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007200 0 \
7201 -c "Buffering HS message" \
7202 -c "attempt to make space by freeing buffered future messages" \
7203 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007204 -S "Buffering HS message" \
7205 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007206 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007207 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007208 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007209 -S "Remember CCS message"
7210
Hanno Becker56cdfd12018-08-17 13:42:15 +01007211run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7212 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007213 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7214 hs_timeout=2500-60000" \
7215 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7216 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007217 0 \
7218 -C "Buffering HS message" \
7219 -C "Next handshake message has been buffered - load"\
7220 -s "Buffering HS message" \
7221 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007222 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007223 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007224 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007225 -S "Remember CCS message"
7226
7227run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7228 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007229 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7230 hs_timeout=2500-60000" \
7231 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7232 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007233 0 \
7234 -C "Buffering HS message" \
7235 -C "Next handshake message has been buffered - load"\
7236 -S "Buffering HS message" \
7237 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007238 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007239 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007240 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007241 -S "Remember CCS message"
7242
7243run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7244 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007245 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7246 hs_timeout=2500-60000" \
7247 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7248 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007249 0 \
7250 -C "Buffering HS message" \
7251 -C "Next handshake message has been buffered - load"\
7252 -S "Buffering HS message" \
7253 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007254 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007255 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007256 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007257 -s "Remember CCS message"
7258
Hanno Beckera1adcca2018-08-24 14:41:07 +01007259run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007260 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007261 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7262 hs_timeout=2500-60000" \
7263 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7264 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007265 0 \
7266 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007267 -s "Found buffered record from current epoch - load" \
7268 -c "Buffer record from epoch 1" \
7269 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007270
Hanno Beckera1adcca2018-08-24 14:41:07 +01007271# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7272# from the server are delayed, so that the encrypted Finished message
7273# is received and buffered. When the fragmented NewSessionTicket comes
7274# in afterwards, the encrypted Finished message must be freed in order
7275# to make space for the NewSessionTicket to be reassembled.
7276# This works only in very particular circumstances:
7277# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7278# of the NewSessionTicket, but small enough to also allow buffering of
7279# the encrypted Finished message.
7280# - The MTU setting on the server must be so small that the NewSessionTicket
7281# needs to be fragmented.
7282# - All messages sent by the server must be small enough to be either sent
7283# without fragmentation or be reassembled within the bounds of
7284# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7285# handshake, omitting CRTs.
7286requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7287requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7288run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7289 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7290 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7291 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7292 0 \
7293 -s "Buffer record from epoch 1" \
7294 -s "Found buffered record from current epoch - load" \
7295 -c "Buffer record from epoch 1" \
7296 -C "Found buffered record from current epoch - load" \
7297 -c "Enough space available after freeing future epoch record"
7298
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007299# Tests for "randomly unreliable connection": try a variety of flows and peers
7300
7301client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007302run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7303 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007304 "$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 +02007305 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007306 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007307 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7308 0 \
7309 -s "Extra-header:" \
7310 -c "HTTP/1.0 200 OK"
7311
Janos Follath74537a62016-09-02 13:45:28 +01007312client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007313run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7314 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007315 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7316 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007317 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7318 0 \
7319 -s "Extra-header:" \
7320 -c "HTTP/1.0 200 OK"
7321
Janos Follath74537a62016-09-02 13:45:28 +01007322client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007323run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7324 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007325 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7326 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007327 0 \
7328 -s "Extra-header:" \
7329 -c "HTTP/1.0 200 OK"
7330
Janos Follath74537a62016-09-02 13:45:28 +01007331client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007332run_test "DTLS proxy: 3d, FS, client auth" \
7333 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007334 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7335 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007336 0 \
7337 -s "Extra-header:" \
7338 -c "HTTP/1.0 200 OK"
7339
Janos Follath74537a62016-09-02 13:45:28 +01007340client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007341run_test "DTLS proxy: 3d, FS, ticket" \
7342 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007343 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7344 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007345 0 \
7346 -s "Extra-header:" \
7347 -c "HTTP/1.0 200 OK"
7348
Janos Follath74537a62016-09-02 13:45:28 +01007349client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007350run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7351 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007352 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7353 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007354 0 \
7355 -s "Extra-header:" \
7356 -c "HTTP/1.0 200 OK"
7357
Janos Follath74537a62016-09-02 13:45:28 +01007358client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007359run_test "DTLS proxy: 3d, max handshake, nbio" \
7360 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007361 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007362 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007363 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007364 0 \
7365 -s "Extra-header:" \
7366 -c "HTTP/1.0 200 OK"
7367
Janos Follath74537a62016-09-02 13:45:28 +01007368client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007369run_test "DTLS proxy: 3d, min handshake, resumption" \
7370 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007371 "$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 +02007372 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007373 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007374 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007375 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7376 0 \
7377 -s "a session has been resumed" \
7378 -c "a session has been resumed" \
7379 -s "Extra-header:" \
7380 -c "HTTP/1.0 200 OK"
7381
Janos Follath74537a62016-09-02 13:45:28 +01007382client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007383run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7384 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007385 "$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 +02007386 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007387 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007388 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007389 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7390 0 \
7391 -s "a session has been resumed" \
7392 -c "a session has been resumed" \
7393 -s "Extra-header:" \
7394 -c "HTTP/1.0 200 OK"
7395
Janos Follath74537a62016-09-02 13:45:28 +01007396client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007397requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007398run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007399 -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é-Gonnard37a4de22014-10-01 16:38:03 +02007401 psk=abc123 renegotiation=1 debug_level=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é-Gonnard37a4de22014-10-01 16:38:03 +02007403 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007404 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7405 0 \
7406 -c "=> renegotiate" \
7407 -s "=> renegotiate" \
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, nbio" \
7414 -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é-Gonnard6093d812014-09-29 17:52:57 +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é-Gonnardba958b82014-10-09 16:13:44 +02007428run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007429 -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é-Gonnarda6ace042014-10-15 12:44:41 +02007431 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007432 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007433 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007434 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007435 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7436 0 \
7437 -c "=> renegotiate" \
7438 -s "=> renegotiate" \
7439 -s "Extra-header:" \
7440 -c "HTTP/1.0 200 OK"
7441
Janos Follath74537a62016-09-02 13:45:28 +01007442client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007443requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007444run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007445 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007446 "$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 +02007447 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007448 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007449 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007450 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007451 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7452 0 \
7453 -c "=> renegotiate" \
7454 -s "=> renegotiate" \
7455 -s "Extra-header:" \
7456 -c "HTTP/1.0 200 OK"
7457
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007458## Interop tests with OpenSSL might trigger a bug in recent versions (including
7459## all versions installed on the CI machines), reported here:
7460## Bug report: https://github.com/openssl/openssl/issues/6902
7461## They should be re-enabled once a fixed version of OpenSSL is available
7462## (this should happen in some 1.1.1_ release according to the ticket).
7463skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007464client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007465not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007466run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007467 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7468 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007469 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007470 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007471 -c "HTTP/1.0 200 OK"
7472
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007473skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007474client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007475not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007476run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7477 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7478 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007479 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007480 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007481 -c "HTTP/1.0 200 OK"
7482
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007483skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007484client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007485not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007486run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7487 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7488 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007489 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007490 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007491 -c "HTTP/1.0 200 OK"
7492
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007493requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007494client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007495not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007496run_test "DTLS proxy: 3d, gnutls server" \
7497 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7498 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007499 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007500 0 \
7501 -s "Extra-header:" \
7502 -c "Extra-header:"
7503
k-stachowiakabb843e2019-02-18 16:14:03 +01007504requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007505client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007506not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007507run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7508 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007509 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007510 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007511 0 \
7512 -s "Extra-header:" \
7513 -c "Extra-header:"
7514
k-stachowiakabb843e2019-02-18 16:14:03 +01007515requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007516client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007517not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007518run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7519 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007520 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007521 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007522 0 \
7523 -s "Extra-header:" \
7524 -c "Extra-header:"
7525
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007526# Final report
7527
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007528echo "------------------------------------------------------------------------"
7529
7530if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007531 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007532else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007533 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007534fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007535PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007536echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007537
7538exit $FAILS