blob: dac9942d83fcdffd854ff4fd0a1e1cfcfaa92c70 [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
Paul Elliott19f1f782021-10-13 18:31:07 +010096if [ -n "${OPENSSL_NEXT:-}" ]; then
97 O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key"
98 O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client"
99else
100 O_NEXT_SRV=false
101 O_NEXT_CLI=false
102fi
103
Hanno Becker58e9dc32018-08-17 15:53:21 +0100104if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200105 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
106else
107 G_NEXT_SRV=false
108fi
109
Hanno Becker58e9dc32018-08-17 15:53:21 +0100110if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200111 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
112else
113 G_NEXT_CLI=false
114fi
115
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100116TESTS=0
117FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200118SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100119
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000120CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200121
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100122MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100123FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200124EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100125
Paul Bakkere20310a2016-05-10 11:18:17 +0100126SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100127RUN_TEST_NUMBER=''
128
Paul Bakkeracaac852016-05-10 11:47:13 +0100129PRESERVE_LOGS=0
130
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200131# Pick a "unique" server port in the range 10000-19999, and a proxy
132# port which is this plus 10000. Each port number may be independently
133# overridden by a command line option.
134SRV_PORT=$(($$ % 10000 + 10000))
135PXY_PORT=$((SRV_PORT + 10000))
136
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100137print_usage() {
138 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100139 printf " -h|--help\tPrint this help.\n"
140 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200141 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
142 printf " -e|--exclude\tMatching tests are excluded (substring or BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100143 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100144 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100145 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200146 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
147 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100148 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100149}
150
151get_options() {
152 while [ $# -gt 0 ]; do
153 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100154 -f|--filter)
155 shift; FILTER=$1
156 ;;
157 -e|--exclude)
158 shift; EXCLUDE=$1
159 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100160 -m|--memcheck)
161 MEMCHECK=1
162 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100163 -n|--number)
164 shift; RUN_TEST_NUMBER=$1
165 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100166 -s|--show-numbers)
167 SHOW_TEST_NUMBER=1
168 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100169 -p|--preserve-logs)
170 PRESERVE_LOGS=1
171 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200172 --port)
173 shift; SRV_PORT=$1
174 ;;
175 --proxy-port)
176 shift; PXY_PORT=$1
177 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100178 --seed)
179 shift; SEED="$1"
180 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100181 -h|--help)
182 print_usage
183 exit 0
184 ;;
185 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200186 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100187 print_usage
188 exit 1
189 ;;
190 esac
191 shift
192 done
193}
194
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200195# Read boolean configuration options from config.h for easy and quick
196# testing. Skip non-boolean options (with something other than spaces
197# and a comment after "#define SYMBOL"). The variable contains a
198# space-separated list of symbols.
199CONFIGS_ENABLED=" $(<"$CONFIG_H" \
200 sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
201 tr '\n' ' ')"
202
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100203# Skip next test; use this macro to skip tests which are legitimate
204# in theory and expected to be re-introduced at some point, but
205# aren't expected to succeed at the moment due to problems outside
206# our control (such as bugs in other TLS implementations).
207skip_next_test() {
208 SKIP_NEXT="YES"
209}
210
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100211# skip next test if the flag is not enabled in config.h
212requires_config_enabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200213 case $CONFIGS_ENABLED in
214 *" $1 "*) :;;
215 *) SKIP_NEXT="YES";;
216 esac
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100217}
218
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200219# skip next test if the flag is enabled in config.h
220requires_config_disabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200221 case $CONFIGS_ENABLED in
222 *" $1 "*) SKIP_NEXT="YES";;
223 esac
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200224}
225
Hanno Becker7c48dd12018-08-28 16:09:22 +0100226get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100227 # This function uses the query_config command line option to query the
228 # required Mbed TLS compile time configuration from the ssl_server2
229 # program. The command will always return a success value if the
230 # configuration is defined and the value will be printed to stdout.
231 #
232 # Note that if the configuration is not defined or is defined to nothing,
233 # the output of this function will be an empty string.
234 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100235}
236
237requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100238 VAL="$( get_config_value_or_default "$1" )"
239 if [ -z "$VAL" ]; then
240 # Should never happen
241 echo "Mbed TLS configuration $1 is not defined"
242 exit 1
243 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100244 SKIP_NEXT="YES"
245 fi
246}
247
248requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100249 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100250 if [ -z "$VAL" ]; then
251 # Should never happen
252 echo "Mbed TLS configuration $1 is not defined"
253 exit 1
254 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100255 SKIP_NEXT="YES"
256 fi
257}
258
Yuto Takanobc632c22021-07-02 13:10:41 +0100259requires_config_value_equals() {
260 VAL=$( get_config_value_or_default "$1" )
261 if [ -z "$VAL" ]; then
262 # Should never happen
263 echo "Mbed TLS configuration $1 is not defined"
264 exit 1
265 elif [ "$VAL" -ne "$2" ]; then
266 SKIP_NEXT="YES"
267 fi
268}
269
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200270# skip next test if OpenSSL doesn't support FALLBACK_SCSV
271requires_openssl_with_fallback_scsv() {
272 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
273 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
274 then
275 OPENSSL_HAS_FBSCSV="YES"
276 else
277 OPENSSL_HAS_FBSCSV="NO"
278 fi
279 fi
280 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
281 SKIP_NEXT="YES"
282 fi
283}
284
Yuto Takano0807e1d2021-07-02 10:10:49 +0100285# skip next test if either IN_CONTENT_LEN or MAX_CONTENT_LEN are below a value
286requires_max_content_len() {
287 requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" $1
288 requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" $1
289}
290
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200291# skip next test if GnuTLS isn't available
292requires_gnutls() {
293 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200294 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200295 GNUTLS_AVAILABLE="YES"
296 else
297 GNUTLS_AVAILABLE="NO"
298 fi
299 fi
300 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
301 SKIP_NEXT="YES"
302 fi
303}
304
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200305# skip next test if GnuTLS-next isn't available
306requires_gnutls_next() {
307 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
308 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
309 GNUTLS_NEXT_AVAILABLE="YES"
310 else
311 GNUTLS_NEXT_AVAILABLE="NO"
312 fi
313 fi
314 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
315 SKIP_NEXT="YES"
316 fi
317}
318
319# skip next test if OpenSSL-legacy isn't available
320requires_openssl_legacy() {
321 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
322 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
323 OPENSSL_LEGACY_AVAILABLE="YES"
324 else
325 OPENSSL_LEGACY_AVAILABLE="NO"
326 fi
327 fi
328 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
329 SKIP_NEXT="YES"
330 fi
331}
332
Paul Elliott19f1f782021-10-13 18:31:07 +0100333requires_openssl_next() {
334 if [ -z "${OPENSSL_NEXT_AVAILABLE:-}" ]; then
335 if which "${OPENSSL_NEXT:-}" >/dev/null 2>&1; then
336 OPENSSL_NEXT_AVAILABLE="YES"
337 else
338 OPENSSL_NEXT_AVAILABLE="NO"
339 fi
340 fi
341 if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then
342 SKIP_NEXT="YES"
343 fi
344}
345
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200346# skip next test if IPv6 isn't available on this host
347requires_ipv6() {
348 if [ -z "${HAS_IPV6:-}" ]; then
349 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
350 SRV_PID=$!
351 sleep 1
352 kill $SRV_PID >/dev/null 2>&1
353 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
354 HAS_IPV6="NO"
355 else
356 HAS_IPV6="YES"
357 fi
358 rm -r $SRV_OUT
359 fi
360
361 if [ "$HAS_IPV6" = "NO" ]; then
362 SKIP_NEXT="YES"
363 fi
364}
365
Andrzej Kurekb4593462018-10-11 08:43:30 -0400366# skip next test if it's i686 or uname is not available
367requires_not_i686() {
368 if [ -z "${IS_I686:-}" ]; then
369 IS_I686="YES"
370 if which "uname" >/dev/null 2>&1; then
371 if [ -z "$(uname -a | grep i686)" ]; then
372 IS_I686="NO"
373 fi
374 fi
375 fi
376 if [ "$IS_I686" = "YES" ]; then
377 SKIP_NEXT="YES"
378 fi
379}
380
Angus Grattonc4dd0732018-04-11 16:28:39 +1000381# Calculate the input & output maximum content lengths set in the config
Yuto Takanobbf657a2021-06-22 07:16:40 +0100382MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_CONTENT_LEN" )
383MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" )
384MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" )
Angus Grattonc4dd0732018-04-11 16:28:39 +1000385
Yuto Takano2e580ce2021-06-21 19:43:33 +0100386# Calculate the maximum content length that fits both
Angus Grattonc4dd0732018-04-11 16:28:39 +1000387if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
388 MAX_CONTENT_LEN="$MAX_IN_LEN"
389fi
390if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
391 MAX_CONTENT_LEN="$MAX_OUT_LEN"
392fi
393
394# skip the next test if the SSL output buffer is less than 16KB
395requires_full_size_output_buffer() {
396 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
397 SKIP_NEXT="YES"
398 fi
399}
400
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200401# skip the next test if valgrind is in use
402not_with_valgrind() {
403 if [ "$MEMCHECK" -gt 0 ]; then
404 SKIP_NEXT="YES"
405 fi
406}
407
Paul Bakker362689d2016-05-13 10:33:25 +0100408# skip the next test if valgrind is NOT in use
409only_with_valgrind() {
410 if [ "$MEMCHECK" -eq 0 ]; then
411 SKIP_NEXT="YES"
412 fi
413}
414
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200415# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100416client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200417 CLI_DELAY_FACTOR=$1
418}
419
Janos Follath74537a62016-09-02 13:45:28 +0100420# wait for the given seconds after the client finished in the next test
421server_needs_more_time() {
422 SRV_DELAY_SECONDS=$1
423}
424
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100425# print_name <name>
426print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100427 TESTS=$(( $TESTS + 1 ))
428 LINE=""
429
430 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
431 LINE="$TESTS "
432 fi
433
434 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200435 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100436 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100437 for i in `seq 1 $LEN`; do printf '.'; done
438 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100439
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100440}
441
442# fail <message>
443fail() {
444 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100445 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100446
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200447 mv $SRV_OUT o-srv-${TESTS}.log
448 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200449 if [ -n "$PXY_CMD" ]; then
450 mv $PXY_OUT o-pxy-${TESTS}.log
451 fi
452 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100453
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200454 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200455 echo " ! server output:"
456 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200458 echo " ! client output:"
459 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200460 if [ -n "$PXY_CMD" ]; then
461 echo " ! ========================================================"
462 echo " ! proxy output:"
463 cat o-pxy-${TESTS}.log
464 fi
465 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200466 fi
467
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200468 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100469}
470
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100471# is_polar <cmd_line>
472is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200473 case "$1" in
474 *ssl_client2*) true;;
475 *ssl_server2*) true;;
476 *) false;;
477 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100478}
479
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200480# openssl s_server doesn't have -www with DTLS
481check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200482 case "$SRV_CMD" in
483 *s_server*-dtls*)
484 NEEDS_INPUT=1
485 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
486 *) NEEDS_INPUT=0;;
487 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200488}
489
490# provide input to commands that need it
491provide_input() {
492 if [ $NEEDS_INPUT -eq 0 ]; then
493 return
494 fi
495
496 while true; do
497 echo "HTTP/1.0 200 OK"
498 sleep 1
499 done
500}
501
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100502# has_mem_err <log_file_name>
503has_mem_err() {
504 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
505 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
506 then
507 return 1 # false: does not have errors
508 else
509 return 0 # true: has errors
510 fi
511}
512
Unknown43dc0d62019-09-02 10:42:57 -0400513# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100514if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400515 wait_app_start() {
Paul Elliott46e57d92021-10-20 15:59:33 +0100516 newline='
517'
Gilles Peskine418b5362017-12-14 18:58:42 +0100518 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200519 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100520 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200521 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100522 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200523 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100524 # Make a tight loop, server normally takes less than 1s to start.
Paul Elliott355a1f42021-10-19 17:56:39 +0100525 while true; do
Paul Elliott46e57d92021-10-20 15:59:33 +0100526 SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p)
527 # When we use a proxy, it will be listening on the same port we
528 # are checking for as well as the server and lsof will list both.
529 # If multiple PIDs are returned, each one will be on a separate
530 # line, each prepended with 'p'.
531 case ${newline}${SERVER_PIDS}${newline} in
532 *${newline}p${2}${newline}*) break;;
533 esac
Gilles Peskine418b5362017-12-14 18:58:42 +0100534 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400535 echo "$3 START TIMEOUT"
536 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100537 break
538 fi
539 # Linux and *BSD support decimal arguments to sleep. On other
540 # OSes this may be a tight loop.
541 sleep 0.1 2>/dev/null || true
542 done
543 }
544else
Unknown43dc0d62019-09-02 10:42:57 -0400545 echo "Warning: lsof not available, wait_app_start = sleep"
546 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200547 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100548 }
549fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200550
Unknown43dc0d62019-09-02 10:42:57 -0400551# Wait for server process $2 to be listening on port $1.
552wait_server_start() {
553 wait_app_start $1 $2 "SERVER" $SRV_OUT
554}
555
556# Wait for proxy process $2 to be listening on port $1.
557wait_proxy_start() {
558 wait_app_start $1 $2 "PROXY" $PXY_OUT
559}
560
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100561# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100562# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100563# acceptable bounds
564check_server_hello_time() {
565 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100566 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100567 # Get the Unix timestamp for now
568 CUR_TIME=$(date +'%s')
569 THRESHOLD_IN_SECS=300
570
571 # Check if the ServerHello time was printed
572 if [ -z "$SERVER_HELLO_TIME" ]; then
573 return 1
574 fi
575
576 # Check the time in ServerHello is within acceptable bounds
577 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
578 # The time in ServerHello is at least 5 minutes before now
579 return 1
580 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100581 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100582 return 1
583 else
584 return 0
585 fi
586}
587
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200588# wait for client to terminate and set CLI_EXIT
589# must be called right after starting the client
590wait_client_done() {
591 CLI_PID=$!
592
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200593 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
594 CLI_DELAY_FACTOR=1
595
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200596 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200597 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200598
599 wait $CLI_PID
600 CLI_EXIT=$?
601
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200602 kill $DOG_PID >/dev/null 2>&1
603 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200604
605 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100606
607 sleep $SRV_DELAY_SECONDS
608 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200609}
610
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200611# check if the given command uses dtls and sets global variable DTLS
612detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200613 case "$1" in
Paul Elliott316a6aa2021-10-12 16:02:55 +0100614 *dtls=1*|*-dtls*|*-u*) DTLS=1;;
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200615 *) DTLS=0;;
616 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200617}
618
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200619# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100620# Options: -s pattern pattern that must be present in server output
621# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100622# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100623# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100624# -S pattern pattern that must be absent in server output
625# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100626# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100627# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100628run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100629 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200630 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100631
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200632 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200633 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100634 return
635 fi
636
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100637 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100638
Paul Bakkerb7584a52016-05-10 10:50:43 +0100639 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200640 if [ -n "$RUN_TEST_NUMBER" ]; then
641 case ",$RUN_TEST_NUMBER," in
642 *",$TESTS,"*) :;;
643 *) SKIP_NEXT="YES";;
644 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100645 fi
646
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200647 # should we skip?
648 if [ "X$SKIP_NEXT" = "XYES" ]; then
649 SKIP_NEXT="NO"
650 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200651 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200652 return
653 fi
654
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200655 # does this test use a proxy?
656 if [ "X$1" = "X-p" ]; then
657 PXY_CMD="$2"
658 shift 2
659 else
660 PXY_CMD=""
661 fi
662
663 # get commands and client output
664 SRV_CMD="$1"
665 CLI_CMD="$2"
666 CLI_EXPECT="$3"
667 shift 3
668
Hanno Becker7a11e722019-05-10 14:38:42 +0100669 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200670 case "$SRV_CMD $CLI_CMD" in
671 *data_files/*)
672 requires_config_enabled MBEDTLS_FS_IO;;
673 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100674
675 # should we skip?
676 if [ "X$SKIP_NEXT" = "XYES" ]; then
677 SKIP_NEXT="NO"
678 echo "SKIP"
679 SKIPS=$(( $SKIPS + 1 ))
680 return
681 fi
682
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200683 # update DTLS variable
684 detect_dtls "$SRV_CMD"
685
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200686 # if the test uses DTLS but no custom proxy, add a simple proxy
687 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200688 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200689 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200690 case " $SRV_CMD " in
691 *' server_addr=::1 '*)
692 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
693 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200694 fi
695
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200696 # fix client port
697 if [ -n "$PXY_CMD" ]; then
698 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
699 else
700 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
701 fi
702
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100703 # prepend valgrind to our commands if active
704 if [ "$MEMCHECK" -gt 0 ]; then
705 if is_polar "$SRV_CMD"; then
706 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
707 fi
708 if is_polar "$CLI_CMD"; then
709 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
710 fi
711 fi
712
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200713 TIMES_LEFT=2
714 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200715 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200716
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200717 # run the commands
718 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200719 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200720 $PXY_CMD >> $PXY_OUT 2>&1 &
721 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400722 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200723 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200724
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200725 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200726 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200727 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
728 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100729 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200730
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200731 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200732 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
733 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100734
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100735 sleep 0.05
736
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200737 # terminate the server (and the proxy)
738 kill $SRV_PID
739 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100740 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100741
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200742 if [ -n "$PXY_CMD" ]; then
743 kill $PXY_PID >/dev/null 2>&1
744 wait $PXY_PID
745 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100746
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200747 # retry only on timeouts
748 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
749 printf "RETRY "
750 else
751 TIMES_LEFT=0
752 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200753 done
754
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100755 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200756 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100757 # expected client exit to incorrectly succeed in case of catastrophic
758 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100759 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200760 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100761 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100762 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100763 return
764 fi
765 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100766 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200767 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100768 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100769 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100770 return
771 fi
772 fi
773
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100774 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
775 # exit with status 0 when interrupted by a signal, and we don't really
776 # care anyway), in case e.g. the server reports a memory leak.
777 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100778 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100779 return
780 fi
781
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100782 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100783 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
784 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100785 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200786 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100787 return
788 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100789
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100790 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200791 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100792 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100793 while [ $# -gt 0 ]
794 do
795 case $1 in
796 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100797 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 +0100798 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100799 return
800 fi
801 ;;
802
803 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100804 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 +0100805 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100806 return
807 fi
808 ;;
809
810 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100811 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 +0100812 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100813 return
814 fi
815 ;;
816
817 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100818 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 +0100819 fail "pattern '$2' MUST NOT be present in the Client output"
820 return
821 fi
822 ;;
823
824 # The filtering in the following two options (-u and -U) do the following
825 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100826 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100827 # - keep one of each non-unique line
828 # - count how many lines remain
829 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
830 # if there were no duplicates.
831 "-U")
832 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
833 fail "lines following pattern '$2' must be unique in Server output"
834 return
835 fi
836 ;;
837
838 "-u")
839 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
840 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100841 return
842 fi
843 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100844 "-F")
845 if ! $2 "$SRV_OUT"; then
846 fail "function call to '$2' failed on Server output"
847 return
848 fi
849 ;;
850 "-f")
851 if ! $2 "$CLI_OUT"; then
852 fail "function call to '$2' failed on Client output"
853 return
854 fi
855 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100856
857 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200858 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100859 exit 1
860 esac
861 shift 2
862 done
863
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100864 # check valgrind's results
865 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200866 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100867 fail "Server has memory errors"
868 return
869 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200870 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100871 fail "Client has memory errors"
872 return
873 fi
874 fi
875
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100876 # if we're here, everything is ok
877 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100878 if [ "$PRESERVE_LOGS" -gt 0 ]; then
879 mv $SRV_OUT o-srv-${TESTS}.log
880 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100881 if [ -n "$PXY_CMD" ]; then
882 mv $PXY_OUT o-pxy-${TESTS}.log
883 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100884 fi
885
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200886 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100887}
888
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100889cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200890 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200891 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
892 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
893 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
894 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100895 exit 1
896}
897
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100898#
899# MAIN
900#
901
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100902get_options "$@"
903
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200904# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
905# patterns rather than regular expressions, use a case statement instead
906# of calling grep. To keep the optimizer simple, it is incomplete and only
907# detects simple cases: plain substring, everything, nothing.
908#
909# As an exception, the character '.' is treated as an ordinary character
910# if it is the only special character in the string. This is because it's
911# rare to need "any one character", but needing a literal '.' is common
912# (e.g. '-f "DTLS 1.2"').
913need_grep=
914case "$FILTER" in
915 '^$') simple_filter=;;
916 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200917 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200918 need_grep=1;;
919 *) # No regexp or shell-pattern special character
920 simple_filter="*$FILTER*";;
921esac
922case "$EXCLUDE" in
923 '^$') simple_exclude=;;
924 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200925 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200926 need_grep=1;;
927 *) # No regexp or shell-pattern special character
928 simple_exclude="*$EXCLUDE*";;
929esac
930if [ -n "$need_grep" ]; then
931 is_excluded () {
932 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
933 }
934else
935 is_excluded () {
936 case "$1" in
937 $simple_exclude) true;;
938 $simple_filter) false;;
939 *) true;;
940 esac
941 }
942fi
943
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100944# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100945P_SRV_BIN="${P_SRV%%[ ]*}"
946P_CLI_BIN="${P_CLI%%[ ]*}"
947P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100948if [ ! -x "$P_SRV_BIN" ]; then
949 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100950 exit 1
951fi
Hanno Becker17c04932017-10-10 14:44:53 +0100952if [ ! -x "$P_CLI_BIN" ]; then
953 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100954 exit 1
955fi
Hanno Becker17c04932017-10-10 14:44:53 +0100956if [ ! -x "$P_PXY_BIN" ]; then
957 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200958 exit 1
959fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100960if [ "$MEMCHECK" -gt 0 ]; then
961 if which valgrind >/dev/null 2>&1; then :; else
962 echo "Memcheck not possible. Valgrind not found"
963 exit 1
964 fi
965fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100966if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
967 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100968 exit 1
969fi
970
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200971# used by watchdog
972MAIN_PID="$$"
973
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100974# We use somewhat arbitrary delays for tests:
975# - how long do we wait for the server to start (when lsof not available)?
976# - how long do we allow for the client to finish?
977# (not to check performance, just to avoid waiting indefinitely)
978# Things are slower with valgrind, so give extra time here.
979#
980# Note: without lsof, there is a trade-off between the running time of this
981# script and the risk of spurious errors because we didn't wait long enough.
982# The watchdog delay on the other hand doesn't affect normal running time of
983# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200984if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100985 START_DELAY=6
986 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200987else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100988 START_DELAY=2
989 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200990fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100991
992# some particular tests need more time:
993# - for the client, we multiply the usual watchdog limit by a factor
994# - for the server, we sleep for a number of seconds after the client exits
995# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200996CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100997SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200998
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200999# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001000# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Paul Elliott0ab79412021-10-12 16:10:37 +01001001# Note: Using 'localhost' rather than 127.0.0.1 here is unwise, as on many
1002# machines that will resolve to ::1, and we don't want ipv6 here.
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001003P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1004P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001005P_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 +02001006O_SRV="$O_SRV -accept $SRV_PORT"
Paul Elliott0ab79412021-10-12 16:10:37 +01001007O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001008G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001009G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001010
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001011if [ -n "${OPENSSL_LEGACY:-}" ]; then
1012 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Paul Elliott0ab79412021-10-12 16:10:37 +01001013 O_LEGACY_CLI="$O_LEGACY_CLI -connect 127.0.0.1:+SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001014fi
1015
Paul Elliott19f1f782021-10-13 18:31:07 +01001016if [ -n "${OPENSSL_NEXT:-}" ]; then
1017 O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT"
Paul Elliott0ab79412021-10-12 16:10:37 +01001018 O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT"
Paul Elliott19f1f782021-10-13 18:31:07 +01001019fi
1020
Hanno Becker58e9dc32018-08-17 15:53:21 +01001021if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001022 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1023fi
1024
Hanno Becker58e9dc32018-08-17 15:53:21 +01001025if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001026 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001027fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001028
Gilles Peskine62469d92017-05-10 10:13:59 +02001029# Allow SHA-1, because many of our test certificates use it
1030P_SRV="$P_SRV allow_sha1=1"
1031P_CLI="$P_CLI allow_sha1=1"
1032
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001033# Also pick a unique name for intermediate files
1034SRV_OUT="srv_out.$$"
1035CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001036PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001037SESSION="session.$$"
1038
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001039SKIP_NEXT="NO"
1040
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001041trap cleanup INT TERM HUP
1042
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001043# Basic test
1044
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001045# Checks that:
1046# - things work with all ciphersuites active (used with config-full in all.sh)
1047# - the expected (highest security) parameters are selected
1048# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001049run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001050 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001051 "$P_CLI" \
1052 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001053 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001054 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001055 -s "client hello v3, signature_algorithm ext: 6" \
1056 -s "ECDHE curve: secp521r1" \
1057 -S "error" \
1058 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001059
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001060run_test "Default, DTLS" \
1061 "$P_SRV dtls=1" \
1062 "$P_CLI dtls=1" \
1063 0 \
1064 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001065 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001066
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001067requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1068run_test "Default (compression enabled)" \
1069 "$P_SRV debug_level=3" \
1070 "$P_CLI debug_level=3" \
1071 0 \
1072 -s "Allocating compression buffer" \
1073 -c "Allocating compression buffer" \
1074 -s "Record expansion is unknown (compression)" \
1075 -c "Record expansion is unknown (compression)" \
1076 -S "error" \
1077 -C "error"
1078
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001079# Test current time in ServerHello
1080requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001081run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001082 "$P_SRV debug_level=3" \
1083 "$P_CLI debug_level=3" \
1084 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001085 -f "check_server_hello_time" \
1086 -F "check_server_hello_time"
1087
Simon Butcher8e004102016-10-14 00:48:33 +01001088# Test for uniqueness of IVs in AEAD ciphersuites
1089run_test "Unique IV in GCM" \
1090 "$P_SRV exchanges=20 debug_level=4" \
1091 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1092 0 \
1093 -u "IV used" \
1094 -U "IV used"
1095
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001096# Tests for rc4 option
1097
Simon Butchera410af52016-05-19 22:12:18 +01001098requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001099run_test "RC4: server disabled, client enabled" \
1100 "$P_SRV" \
1101 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1102 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001103 -s "SSL - The server has no ciphersuites in common"
1104
Simon Butchera410af52016-05-19 22:12:18 +01001105requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001106run_test "RC4: server half, client enabled" \
1107 "$P_SRV arc4=1" \
1108 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1109 1 \
1110 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001111
1112run_test "RC4: server enabled, client disabled" \
1113 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1114 "$P_CLI" \
1115 1 \
1116 -s "SSL - The server has no ciphersuites in common"
1117
1118run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001119 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001120 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1121 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001122 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001123 -S "SSL - The server has no ciphersuites in common"
1124
Hanno Beckerd26bb202018-08-17 09:54:10 +01001125# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1126
1127requires_gnutls
1128requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1129run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1130 "$G_SRV"\
1131 "$P_CLI force_version=tls1_1" \
1132 0
1133
1134requires_gnutls
1135requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1136run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1137 "$G_SRV"\
1138 "$P_CLI force_version=tls1" \
1139 0
1140
Gilles Peskinebc70a182017-05-09 15:59:24 +02001141# Tests for SHA-1 support
1142
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001143requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001144run_test "SHA-1 forbidden by default in server certificate" \
1145 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1146 "$P_CLI debug_level=2 allow_sha1=0" \
1147 1 \
1148 -c "The certificate is signed with an unacceptable hash"
1149
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001150requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1151run_test "SHA-1 forbidden by default in server certificate" \
1152 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1153 "$P_CLI debug_level=2 allow_sha1=0" \
1154 0
1155
Gilles Peskinebc70a182017-05-09 15:59:24 +02001156run_test "SHA-1 explicitly allowed in server certificate" \
1157 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1158 "$P_CLI allow_sha1=1" \
1159 0
1160
1161run_test "SHA-256 allowed by default in server certificate" \
1162 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1163 "$P_CLI allow_sha1=0" \
1164 0
1165
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001166requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001167run_test "SHA-1 forbidden by default in client certificate" \
1168 "$P_SRV auth_mode=required allow_sha1=0" \
1169 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1170 1 \
1171 -s "The certificate is signed with an unacceptable hash"
1172
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001173requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1174run_test "SHA-1 forbidden by default in client certificate" \
1175 "$P_SRV auth_mode=required allow_sha1=0" \
1176 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1177 0
1178
Gilles Peskinebc70a182017-05-09 15:59:24 +02001179run_test "SHA-1 explicitly allowed in client certificate" \
1180 "$P_SRV auth_mode=required allow_sha1=1" \
1181 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1182 0
1183
1184run_test "SHA-256 allowed by default in client certificate" \
1185 "$P_SRV auth_mode=required allow_sha1=0" \
1186 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1187 0
1188
Hanno Becker7ae8a762018-08-14 15:43:35 +01001189# Tests for datagram packing
1190run_test "DTLS: multiple records in same datagram, client and server" \
1191 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1192 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1193 0 \
1194 -c "next record in same datagram" \
1195 -s "next record in same datagram"
1196
1197run_test "DTLS: multiple records in same datagram, client only" \
1198 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1199 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1200 0 \
1201 -s "next record in same datagram" \
1202 -C "next record in same datagram"
1203
1204run_test "DTLS: multiple records in same datagram, server only" \
1205 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1206 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1207 0 \
1208 -S "next record in same datagram" \
1209 -c "next record in same datagram"
1210
1211run_test "DTLS: multiple records in same datagram, neither client nor server" \
1212 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1213 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1214 0 \
1215 -S "next record in same datagram" \
1216 -C "next record in same datagram"
1217
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001218# Tests for Truncated HMAC extension
1219
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001220run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001221 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001222 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001223 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001224 -s "dumping 'expected mac' (20 bytes)" \
1225 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001226
Hanno Becker32c55012017-11-10 08:42:54 +00001227requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001228run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001229 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001230 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001231 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001232 -s "dumping 'expected mac' (20 bytes)" \
1233 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001234
Hanno Becker32c55012017-11-10 08:42:54 +00001235requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001236run_test "Truncated HMAC: client enabled, server default" \
1237 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001238 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001239 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001240 -s "dumping 'expected mac' (20 bytes)" \
1241 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001242
Hanno Becker32c55012017-11-10 08:42:54 +00001243requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001244run_test "Truncated HMAC: client enabled, server disabled" \
1245 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001246 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001247 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001248 -s "dumping 'expected mac' (20 bytes)" \
1249 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001250
Hanno Becker32c55012017-11-10 08:42:54 +00001251requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001252run_test "Truncated HMAC: client disabled, server enabled" \
1253 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001254 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001255 0 \
1256 -s "dumping 'expected mac' (20 bytes)" \
1257 -S "dumping 'expected mac' (10 bytes)"
1258
1259requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001260run_test "Truncated HMAC: client enabled, server enabled" \
1261 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001262 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001263 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001264 -S "dumping 'expected mac' (20 bytes)" \
1265 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001266
Hanno Becker4c4f4102017-11-10 09:16:05 +00001267run_test "Truncated HMAC, DTLS: client default, server default" \
1268 "$P_SRV dtls=1 debug_level=4" \
1269 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1270 0 \
1271 -s "dumping 'expected mac' (20 bytes)" \
1272 -S "dumping 'expected mac' (10 bytes)"
1273
1274requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1275run_test "Truncated HMAC, DTLS: client disabled, server default" \
1276 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001277 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001278 0 \
1279 -s "dumping 'expected mac' (20 bytes)" \
1280 -S "dumping 'expected mac' (10 bytes)"
1281
1282requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1283run_test "Truncated HMAC, DTLS: client enabled, server default" \
1284 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001285 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001286 0 \
1287 -s "dumping 'expected mac' (20 bytes)" \
1288 -S "dumping 'expected mac' (10 bytes)"
1289
1290requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1291run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1292 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001293 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001294 0 \
1295 -s "dumping 'expected mac' (20 bytes)" \
1296 -S "dumping 'expected mac' (10 bytes)"
1297
1298requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1299run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1300 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001301 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001302 0 \
1303 -s "dumping 'expected mac' (20 bytes)" \
1304 -S "dumping 'expected mac' (10 bytes)"
1305
1306requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1307run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1308 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001309 "$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 +01001310 0 \
1311 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001312 -s "dumping 'expected mac' (10 bytes)"
1313
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001314# Tests for Encrypt-then-MAC extension
1315
1316run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001317 "$P_SRV debug_level=3 \
1318 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001319 "$P_CLI debug_level=3" \
1320 0 \
1321 -c "client hello, adding encrypt_then_mac extension" \
1322 -s "found encrypt then mac extension" \
1323 -s "server hello, adding encrypt then mac extension" \
1324 -c "found encrypt_then_mac extension" \
1325 -c "using encrypt then mac" \
1326 -s "using encrypt then mac"
1327
1328run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001329 "$P_SRV debug_level=3 etm=0 \
1330 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001331 "$P_CLI debug_level=3 etm=1" \
1332 0 \
1333 -c "client hello, adding encrypt_then_mac extension" \
1334 -s "found encrypt then mac extension" \
1335 -S "server hello, adding encrypt then mac extension" \
1336 -C "found encrypt_then_mac extension" \
1337 -C "using encrypt then mac" \
1338 -S "using encrypt then mac"
1339
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001340run_test "Encrypt then MAC: client enabled, aead cipher" \
1341 "$P_SRV debug_level=3 etm=1 \
1342 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1343 "$P_CLI debug_level=3 etm=1" \
1344 0 \
1345 -c "client hello, adding encrypt_then_mac extension" \
1346 -s "found encrypt then mac extension" \
1347 -S "server hello, adding encrypt then mac extension" \
1348 -C "found encrypt_then_mac extension" \
1349 -C "using encrypt then mac" \
1350 -S "using encrypt then mac"
1351
1352run_test "Encrypt then MAC: client enabled, stream cipher" \
1353 "$P_SRV debug_level=3 etm=1 \
1354 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001355 "$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 +01001356 0 \
1357 -c "client hello, adding encrypt_then_mac extension" \
1358 -s "found encrypt then mac extension" \
1359 -S "server hello, adding encrypt then mac extension" \
1360 -C "found encrypt_then_mac extension" \
1361 -C "using encrypt then mac" \
1362 -S "using encrypt then mac"
1363
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001364run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001365 "$P_SRV debug_level=3 etm=1 \
1366 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001367 "$P_CLI debug_level=3 etm=0" \
1368 0 \
1369 -C "client hello, adding encrypt_then_mac extension" \
1370 -S "found encrypt then mac extension" \
1371 -S "server hello, adding encrypt then mac extension" \
1372 -C "found encrypt_then_mac extension" \
1373 -C "using encrypt then mac" \
1374 -S "using encrypt then mac"
1375
Janos Follathe2681a42016-03-07 15:57:05 +00001376requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001377run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001378 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001379 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001380 "$P_CLI debug_level=3 force_version=ssl3" \
1381 0 \
1382 -C "client hello, adding encrypt_then_mac extension" \
1383 -S "found encrypt then mac extension" \
1384 -S "server hello, adding encrypt then mac extension" \
1385 -C "found encrypt_then_mac extension" \
1386 -C "using encrypt then mac" \
1387 -S "using encrypt then mac"
1388
Janos Follathe2681a42016-03-07 15:57:05 +00001389requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001390run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001391 "$P_SRV debug_level=3 force_version=ssl3 \
1392 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001393 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001394 0 \
1395 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001396 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001397 -S "server hello, adding encrypt then mac extension" \
1398 -C "found encrypt_then_mac extension" \
1399 -C "using encrypt then mac" \
1400 -S "using encrypt then mac"
1401
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001402# Tests for Extended Master Secret extension
1403
1404run_test "Extended Master Secret: default" \
1405 "$P_SRV debug_level=3" \
1406 "$P_CLI debug_level=3" \
1407 0 \
1408 -c "client hello, adding extended_master_secret extension" \
1409 -s "found extended master secret extension" \
1410 -s "server hello, adding extended master secret extension" \
1411 -c "found extended_master_secret extension" \
1412 -c "using extended master secret" \
1413 -s "using extended master secret"
1414
1415run_test "Extended Master Secret: client enabled, server disabled" \
1416 "$P_SRV debug_level=3 extended_ms=0" \
1417 "$P_CLI debug_level=3 extended_ms=1" \
1418 0 \
1419 -c "client hello, adding extended_master_secret extension" \
1420 -s "found extended master secret extension" \
1421 -S "server hello, adding extended master secret extension" \
1422 -C "found extended_master_secret extension" \
1423 -C "using extended master secret" \
1424 -S "using extended master secret"
1425
1426run_test "Extended Master Secret: client disabled, server enabled" \
1427 "$P_SRV debug_level=3 extended_ms=1" \
1428 "$P_CLI debug_level=3 extended_ms=0" \
1429 0 \
1430 -C "client hello, adding extended_master_secret extension" \
1431 -S "found extended master secret extension" \
1432 -S "server hello, adding extended master secret extension" \
1433 -C "found extended_master_secret extension" \
1434 -C "using extended master secret" \
1435 -S "using extended master secret"
1436
Janos Follathe2681a42016-03-07 15:57:05 +00001437requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001438run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001439 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001440 "$P_CLI debug_level=3 force_version=ssl3" \
1441 0 \
1442 -C "client hello, adding extended_master_secret extension" \
1443 -S "found extended master secret extension" \
1444 -S "server hello, adding extended master secret extension" \
1445 -C "found extended_master_secret extension" \
1446 -C "using extended master secret" \
1447 -S "using extended master secret"
1448
Janos Follathe2681a42016-03-07 15:57:05 +00001449requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001450run_test "Extended Master Secret: client enabled, server SSLv3" \
1451 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001452 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001453 0 \
1454 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001455 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001456 -S "server hello, adding extended master secret extension" \
1457 -C "found extended_master_secret extension" \
1458 -C "using extended master secret" \
1459 -S "using extended master secret"
1460
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001461# Tests for FALLBACK_SCSV
1462
1463run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001464 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001465 "$P_CLI debug_level=3 force_version=tls1_1" \
1466 0 \
1467 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001468 -S "received FALLBACK_SCSV" \
1469 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001470 -C "is a fatal alert message (msg 86)"
1471
1472run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001473 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001474 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1475 0 \
1476 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001477 -S "received FALLBACK_SCSV" \
1478 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001479 -C "is a fatal alert message (msg 86)"
1480
1481run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001482 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001483 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001484 1 \
1485 -c "adding FALLBACK_SCSV" \
1486 -s "received FALLBACK_SCSV" \
1487 -s "inapropriate fallback" \
1488 -c "is a fatal alert message (msg 86)"
1489
1490run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001491 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001492 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001493 0 \
1494 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001495 -s "received FALLBACK_SCSV" \
1496 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001497 -C "is a fatal alert message (msg 86)"
1498
1499requires_openssl_with_fallback_scsv
1500run_test "Fallback SCSV: default, openssl server" \
1501 "$O_SRV" \
1502 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1503 0 \
1504 -C "adding FALLBACK_SCSV" \
1505 -C "is a fatal alert message (msg 86)"
1506
1507requires_openssl_with_fallback_scsv
1508run_test "Fallback SCSV: enabled, openssl server" \
1509 "$O_SRV" \
1510 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1511 1 \
1512 -c "adding FALLBACK_SCSV" \
1513 -c "is a fatal alert message (msg 86)"
1514
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001515requires_openssl_with_fallback_scsv
1516run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001517 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001518 "$O_CLI -tls1_1" \
1519 0 \
1520 -S "received FALLBACK_SCSV" \
1521 -S "inapropriate fallback"
1522
1523requires_openssl_with_fallback_scsv
1524run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001525 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001526 "$O_CLI -tls1_1 -fallback_scsv" \
1527 1 \
1528 -s "received FALLBACK_SCSV" \
1529 -s "inapropriate fallback"
1530
1531requires_openssl_with_fallback_scsv
1532run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001533 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001534 "$O_CLI -fallback_scsv" \
1535 0 \
1536 -s "received FALLBACK_SCSV" \
1537 -S "inapropriate fallback"
1538
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001539# Test sending and receiving empty application data records
1540
1541run_test "Encrypt then MAC: empty application data record" \
1542 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1543 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1544 0 \
1545 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1546 -s "dumping 'input payload after decrypt' (0 bytes)" \
1547 -c "0 bytes written in 1 fragments"
1548
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001549run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001550 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1551 "$P_CLI auth_mode=none etm=0 request_size=0" \
1552 0 \
1553 -s "dumping 'input payload after decrypt' (0 bytes)" \
1554 -c "0 bytes written in 1 fragments"
1555
1556run_test "Encrypt then MAC, DTLS: empty application data record" \
1557 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1558 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1559 0 \
1560 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1561 -s "dumping 'input payload after decrypt' (0 bytes)" \
1562 -c "0 bytes written in 1 fragments"
1563
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001564run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001565 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1566 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1567 0 \
1568 -s "dumping 'input payload after decrypt' (0 bytes)" \
1569 -c "0 bytes written in 1 fragments"
1570
Gilles Peskined50177f2017-05-16 17:53:03 +02001571## ClientHello generated with
1572## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1573## then manually twiddling the ciphersuite list.
1574## The ClientHello content is spelled out below as a hex string as
1575## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1576## The expected response is an inappropriate_fallback alert.
1577requires_openssl_with_fallback_scsv
1578run_test "Fallback SCSV: beginning of list" \
1579 "$P_SRV debug_level=2" \
1580 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1581 0 \
1582 -s "received FALLBACK_SCSV" \
1583 -s "inapropriate fallback"
1584
1585requires_openssl_with_fallback_scsv
1586run_test "Fallback SCSV: end of list" \
1587 "$P_SRV debug_level=2" \
1588 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1589 0 \
1590 -s "received FALLBACK_SCSV" \
1591 -s "inapropriate fallback"
1592
1593## Here the expected response is a valid ServerHello prefix, up to the random.
1594requires_openssl_with_fallback_scsv
1595run_test "Fallback SCSV: not in list" \
1596 "$P_SRV debug_level=2" \
1597 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1598 0 \
1599 -S "received FALLBACK_SCSV" \
1600 -S "inapropriate fallback"
1601
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001602# Tests for CBC 1/n-1 record splitting
1603
1604run_test "CBC Record splitting: TLS 1.2, no splitting" \
1605 "$P_SRV" \
1606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1607 request_size=123 force_version=tls1_2" \
1608 0 \
1609 -s "Read from client: 123 bytes read" \
1610 -S "Read from client: 1 bytes read" \
1611 -S "122 bytes read"
1612
1613run_test "CBC Record splitting: TLS 1.1, no splitting" \
1614 "$P_SRV" \
1615 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1616 request_size=123 force_version=tls1_1" \
1617 0 \
1618 -s "Read from client: 123 bytes read" \
1619 -S "Read from client: 1 bytes read" \
1620 -S "122 bytes read"
1621
1622run_test "CBC Record splitting: TLS 1.0, splitting" \
1623 "$P_SRV" \
1624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1625 request_size=123 force_version=tls1" \
1626 0 \
1627 -S "Read from client: 123 bytes read" \
1628 -s "Read from client: 1 bytes read" \
1629 -s "122 bytes read"
1630
Janos Follathe2681a42016-03-07 15:57:05 +00001631requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001632run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001633 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001634 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1635 request_size=123 force_version=ssl3" \
1636 0 \
1637 -S "Read from client: 123 bytes read" \
1638 -s "Read from client: 1 bytes read" \
1639 -s "122 bytes read"
1640
1641run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001642 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001643 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1644 request_size=123 force_version=tls1" \
1645 0 \
1646 -s "Read from client: 123 bytes read" \
1647 -S "Read from client: 1 bytes read" \
1648 -S "122 bytes read"
1649
1650run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1651 "$P_SRV" \
1652 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1653 request_size=123 force_version=tls1 recsplit=0" \
1654 0 \
1655 -s "Read from client: 123 bytes read" \
1656 -S "Read from client: 1 bytes read" \
1657 -S "122 bytes read"
1658
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001659run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1660 "$P_SRV nbio=2" \
1661 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1662 request_size=123 force_version=tls1" \
1663 0 \
1664 -S "Read from client: 123 bytes read" \
1665 -s "Read from client: 1 bytes read" \
1666 -s "122 bytes read"
1667
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001668# Tests for Session Tickets
1669
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001670run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001671 "$P_SRV debug_level=3 tickets=1" \
1672 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001673 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001674 -c "client hello, adding session ticket extension" \
1675 -s "found session ticket extension" \
1676 -s "server hello, adding session ticket extension" \
1677 -c "found session_ticket extension" \
1678 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001679 -S "session successfully restored from cache" \
1680 -s "session successfully restored from ticket" \
1681 -s "a session has been resumed" \
1682 -c "a session has been resumed"
1683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001684run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001685 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1686 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001687 0 \
1688 -c "client hello, adding session ticket extension" \
1689 -s "found session ticket extension" \
1690 -s "server hello, adding session ticket extension" \
1691 -c "found session_ticket extension" \
1692 -c "parse new session ticket" \
1693 -S "session successfully restored from cache" \
1694 -s "session successfully restored from ticket" \
1695 -s "a session has been resumed" \
1696 -c "a session has been resumed"
1697
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001698run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001699 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1700 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001701 0 \
1702 -c "client hello, adding session ticket extension" \
1703 -s "found session ticket extension" \
1704 -s "server hello, adding session ticket extension" \
1705 -c "found session_ticket extension" \
1706 -c "parse new session ticket" \
1707 -S "session successfully restored from cache" \
1708 -S "session successfully restored from ticket" \
1709 -S "a session has been resumed" \
1710 -C "a session has been resumed"
1711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001712run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001713 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001714 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001715 0 \
1716 -c "client hello, adding session ticket extension" \
1717 -c "found session_ticket extension" \
1718 -c "parse new session ticket" \
1719 -c "a session has been resumed"
1720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001721run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001722 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001723 "( $O_CLI -sess_out $SESSION; \
1724 $O_CLI -sess_in $SESSION; \
1725 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001726 0 \
1727 -s "found session ticket extension" \
1728 -s "server hello, adding session ticket extension" \
1729 -S "session successfully restored from cache" \
1730 -s "session successfully restored from ticket" \
1731 -s "a session has been resumed"
1732
Hanno Becker1d739932018-08-21 13:55:22 +01001733# Tests for Session Tickets with DTLS
1734
1735run_test "Session resume using tickets, DTLS: basic" \
1736 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001737 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001738 0 \
1739 -c "client hello, adding session ticket extension" \
1740 -s "found session ticket extension" \
1741 -s "server hello, adding session ticket extension" \
1742 -c "found session_ticket extension" \
1743 -c "parse new session ticket" \
1744 -S "session successfully restored from cache" \
1745 -s "session successfully restored from ticket" \
1746 -s "a session has been resumed" \
1747 -c "a session has been resumed"
1748
1749run_test "Session resume using tickets, DTLS: cache disabled" \
1750 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001751 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001752 0 \
1753 -c "client hello, adding session ticket extension" \
1754 -s "found session ticket extension" \
1755 -s "server hello, adding session ticket extension" \
1756 -c "found session_ticket extension" \
1757 -c "parse new session ticket" \
1758 -S "session successfully restored from cache" \
1759 -s "session successfully restored from ticket" \
1760 -s "a session has been resumed" \
1761 -c "a session has been resumed"
1762
1763run_test "Session resume using tickets, DTLS: timeout" \
1764 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001765 "$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 +01001766 0 \
1767 -c "client hello, adding session ticket extension" \
1768 -s "found session ticket extension" \
1769 -s "server hello, adding session ticket extension" \
1770 -c "found session_ticket extension" \
1771 -c "parse new session ticket" \
1772 -S "session successfully restored from cache" \
1773 -S "session successfully restored from ticket" \
1774 -S "a session has been resumed" \
1775 -C "a session has been resumed"
1776
1777run_test "Session resume using tickets, DTLS: openssl server" \
1778 "$O_SRV -dtls1" \
1779 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1780 0 \
1781 -c "client hello, adding session ticket extension" \
1782 -c "found session_ticket extension" \
1783 -c "parse new session ticket" \
1784 -c "a session has been resumed"
1785
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001786# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001787# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001788requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001789run_test "Session resume using tickets, DTLS: openssl client" \
1790 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001791 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1792 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001793 rm -f $SESSION )" \
1794 0 \
1795 -s "found session ticket extension" \
1796 -s "server hello, adding session ticket extension" \
1797 -S "session successfully restored from cache" \
1798 -s "session successfully restored from ticket" \
1799 -s "a session has been resumed"
1800
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001801# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001802
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001803run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001804 "$P_SRV debug_level=3 tickets=0" \
1805 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001806 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001807 -c "client hello, adding session ticket extension" \
1808 -s "found session ticket extension" \
1809 -S "server hello, adding session ticket extension" \
1810 -C "found session_ticket extension" \
1811 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001812 -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: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001818 "$P_SRV debug_level=3 tickets=1" \
1819 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001820 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001821 -C "client hello, adding session ticket extension" \
1822 -S "found session ticket extension" \
1823 -S "server hello, adding session ticket extension" \
1824 -C "found session_ticket extension" \
1825 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001826 -s "session successfully restored from cache" \
1827 -S "session successfully restored from ticket" \
1828 -s "a session has been resumed" \
1829 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001831run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001832 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1833 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001834 0 \
1835 -S "session successfully restored from cache" \
1836 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001837 -S "a session has been resumed" \
1838 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001840run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001841 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1842 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001843 0 \
1844 -s "session successfully restored from cache" \
1845 -S "session successfully restored from ticket" \
1846 -s "a session has been resumed" \
1847 -c "a session has been resumed"
1848
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001849run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001850 "$P_SRV debug_level=3 tickets=0" \
1851 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001852 0 \
1853 -s "session successfully restored from cache" \
1854 -S "session successfully restored from ticket" \
1855 -s "a session has been resumed" \
1856 -c "a session has been resumed"
1857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001858run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001859 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1860 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001861 0 \
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001867run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001868 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1869 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001877 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001878 "( $O_CLI -sess_out $SESSION; \
1879 $O_CLI -sess_in $SESSION; \
1880 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001881 0 \
1882 -s "found session ticket extension" \
1883 -S "server hello, adding session ticket extension" \
1884 -s "session successfully restored from cache" \
1885 -S "session successfully restored from ticket" \
1886 -s "a session has been resumed"
1887
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001888run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001889 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001890 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001891 0 \
1892 -C "found session_ticket extension" \
1893 -C "parse new session ticket" \
1894 -c "a session has been resumed"
1895
Hanno Becker1d739932018-08-21 13:55:22 +01001896# Tests for Session Resume based on session-ID and cache, DTLS
1897
1898run_test "Session resume using cache, DTLS: tickets enabled on client" \
1899 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001900 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001901 0 \
1902 -c "client hello, adding session ticket extension" \
1903 -s "found session ticket extension" \
1904 -S "server hello, adding session ticket extension" \
1905 -C "found session_ticket extension" \
1906 -C "parse new session ticket" \
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: tickets enabled on server" \
1913 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001914 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001915 0 \
1916 -C "client hello, adding session ticket extension" \
1917 -S "found session ticket extension" \
1918 -S "server hello, adding session ticket extension" \
1919 -C "found session_ticket extension" \
1920 -C "parse new session ticket" \
1921 -s "session successfully restored from cache" \
1922 -S "session successfully restored from ticket" \
1923 -s "a session has been resumed" \
1924 -c "a session has been resumed"
1925
1926run_test "Session resume using cache, DTLS: cache_max=0" \
1927 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001928 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001929 0 \
1930 -S "session successfully restored from cache" \
1931 -S "session successfully restored from ticket" \
1932 -S "a session has been resumed" \
1933 -C "a session has been resumed"
1934
1935run_test "Session resume using cache, DTLS: cache_max=1" \
1936 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001937 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001938 0 \
1939 -s "session successfully restored from cache" \
1940 -S "session successfully restored from ticket" \
1941 -s "a session has been resumed" \
1942 -c "a session has been resumed"
1943
1944run_test "Session resume using cache, DTLS: timeout > delay" \
1945 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001946 "$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 +01001947 0 \
1948 -s "session successfully restored from cache" \
1949 -S "session successfully restored from ticket" \
1950 -s "a session has been resumed" \
1951 -c "a session has been resumed"
1952
1953run_test "Session resume using cache, DTLS: timeout < delay" \
1954 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001955 "$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 +01001956 0 \
1957 -S "session successfully restored from cache" \
1958 -S "session successfully restored from ticket" \
1959 -S "a session has been resumed" \
1960 -C "a session has been resumed"
1961
1962run_test "Session resume using cache, DTLS: no timeout" \
1963 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001964 "$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 +01001965 0 \
1966 -s "session successfully restored from cache" \
1967 -S "session successfully restored from ticket" \
1968 -s "a session has been resumed" \
1969 -c "a session has been resumed"
1970
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001971# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001972# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001973requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001974run_test "Session resume using cache, DTLS: openssl client" \
1975 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001976 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1977 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001978 rm -f $SESSION )" \
1979 0 \
1980 -s "found session ticket extension" \
1981 -S "server hello, adding session ticket extension" \
1982 -s "session successfully restored from cache" \
1983 -S "session successfully restored from ticket" \
1984 -s "a session has been resumed"
1985
1986run_test "Session resume using cache, DTLS: openssl server" \
1987 "$O_SRV -dtls1" \
1988 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1989 0 \
1990 -C "found session_ticket extension" \
1991 -C "parse new session ticket" \
1992 -c "a session has been resumed"
1993
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001994# Tests for Max Fragment Length extension
1995
Hanno Becker4aed27e2017-09-18 15:00:34 +01001996requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001997run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001998 "$P_SRV debug_level=3" \
1999 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002000 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002001 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2002 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002003 -C "client hello, adding max_fragment_length extension" \
2004 -S "found max fragment length extension" \
2005 -S "server hello, max_fragment_length extension" \
2006 -C "found max_fragment_length extension"
2007
Hanno Becker4aed27e2017-09-18 15:00:34 +01002008requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002009run_test "Max fragment length: enabled, default, larger message" \
2010 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002011 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002012 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002013 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2014 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002015 -C "client hello, adding max_fragment_length extension" \
2016 -S "found max fragment length extension" \
2017 -S "server hello, max_fragment_length extension" \
2018 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002019 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2020 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002021 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002022
2023requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2024run_test "Max fragment length, DTLS: enabled, default, larger message" \
2025 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002026 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002027 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002028 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2029 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002030 -C "client hello, adding max_fragment_length extension" \
2031 -S "found max fragment length extension" \
2032 -S "server hello, max_fragment_length extension" \
2033 -C "found max_fragment_length extension" \
2034 -c "fragment larger than.*maximum "
2035
Angus Grattonc4dd0732018-04-11 16:28:39 +10002036# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2037# (session fragment length will be 16384 regardless of mbedtls
2038# content length configuration.)
2039
Hanno Beckerc5266962017-09-18 15:01:50 +01002040requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2041run_test "Max fragment length: disabled, larger message" \
2042 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002043 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002044 0 \
2045 -C "Maximum fragment length is 16384" \
2046 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002047 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2048 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002049 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002050
2051requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takano2e580ce2021-06-21 19:43:33 +01002052run_test "Max fragment length, DTLS: disabled, larger message" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002053 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002054 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002055 1 \
2056 -C "Maximum fragment length is 16384" \
2057 -S "Maximum fragment length is 16384" \
2058 -c "fragment larger than.*maximum "
2059
Yuto Takano0807e1d2021-07-02 10:10:49 +01002060requires_max_content_len 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01002061requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002062run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002063 "$P_SRV debug_level=3" \
2064 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002065 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002066 -c "Maximum fragment length is 4096" \
2067 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002068 -c "client hello, adding max_fragment_length extension" \
2069 -s "found max fragment length extension" \
2070 -s "server hello, max_fragment_length extension" \
2071 -c "found max_fragment_length extension"
2072
Yuto Takano0807e1d2021-07-02 10:10:49 +01002073requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002074requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002075run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002076 "$P_SRV debug_level=3 max_frag_len=4096" \
2077 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002078 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002079 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002080 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002081 -C "client hello, adding max_fragment_length extension" \
2082 -S "found max fragment length extension" \
2083 -S "server hello, max_fragment_length extension" \
2084 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002085
Yuto Takano0807e1d2021-07-02 10:10:49 +01002086requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002087requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002088requires_gnutls
2089run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002090 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002091 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002092 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002093 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002094 -c "client hello, adding max_fragment_length extension" \
2095 -c "found max_fragment_length extension"
2096
Yuto Takano0807e1d2021-07-02 10:10:49 +01002097requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002098requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002099run_test "Max fragment length: client, message just fits" \
2100 "$P_SRV debug_level=3" \
2101 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2102 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002103 -c "Maximum fragment length is 2048" \
2104 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002105 -c "client hello, adding max_fragment_length extension" \
2106 -s "found max fragment length extension" \
2107 -s "server hello, max_fragment_length extension" \
2108 -c "found max_fragment_length extension" \
2109 -c "2048 bytes written in 1 fragments" \
2110 -s "2048 bytes read"
2111
Yuto Takano0807e1d2021-07-02 10:10:49 +01002112requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002113requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002114run_test "Max fragment length: client, larger message" \
2115 "$P_SRV debug_level=3" \
2116 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2117 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002118 -c "Maximum fragment length is 2048" \
2119 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002120 -c "client hello, adding max_fragment_length extension" \
2121 -s "found max fragment length extension" \
2122 -s "server hello, max_fragment_length extension" \
2123 -c "found max_fragment_length extension" \
2124 -c "2345 bytes written in 2 fragments" \
2125 -s "2048 bytes read" \
2126 -s "297 bytes read"
2127
Yuto Takano0807e1d2021-07-02 10:10:49 +01002128requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002129requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002130run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002131 "$P_SRV debug_level=3 dtls=1" \
2132 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2133 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002134 -c "Maximum fragment length is 2048" \
2135 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002136 -c "client hello, adding max_fragment_length extension" \
2137 -s "found max fragment length extension" \
2138 -s "server hello, max_fragment_length extension" \
2139 -c "found max_fragment_length extension" \
2140 -c "fragment larger than.*maximum"
2141
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002142# Tests for renegotiation
2143
Hanno Becker6a243642017-10-12 15:18:45 +01002144# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002145run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002146 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002147 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002148 0 \
2149 -C "client hello, adding renegotiation extension" \
2150 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2151 -S "found renegotiation extension" \
2152 -s "server hello, secure renegotiation extension" \
2153 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002154 -C "=> renegotiate" \
2155 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002156 -S "write hello request"
2157
Hanno Becker6a243642017-10-12 15:18:45 +01002158requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002159run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002160 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002161 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002162 0 \
2163 -c "client hello, adding renegotiation extension" \
2164 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2165 -s "found renegotiation extension" \
2166 -s "server hello, secure renegotiation extension" \
2167 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002168 -c "=> renegotiate" \
2169 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002170 -S "write hello request"
2171
Hanno Becker6a243642017-10-12 15:18:45 +01002172requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002173run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002174 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002175 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002176 0 \
2177 -c "client hello, adding renegotiation extension" \
2178 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2179 -s "found renegotiation extension" \
2180 -s "server hello, secure renegotiation extension" \
2181 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002182 -c "=> renegotiate" \
2183 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002184 -s "write hello request"
2185
Janos Follathb0f148c2017-10-05 12:29:42 +01002186# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2187# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2188# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002189requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002190run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2191 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2192 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2193 0 \
2194 -c "client hello, adding renegotiation extension" \
2195 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2196 -s "found renegotiation extension" \
2197 -s "server hello, secure renegotiation extension" \
2198 -c "found renegotiation extension" \
2199 -c "=> renegotiate" \
2200 -s "=> renegotiate" \
2201 -S "write hello request" \
2202 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2203
2204# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2205# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2206# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002207requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002208run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2209 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2210 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2211 0 \
2212 -c "client hello, adding renegotiation extension" \
2213 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2214 -s "found renegotiation extension" \
2215 -s "server hello, secure renegotiation extension" \
2216 -c "found renegotiation extension" \
2217 -c "=> renegotiate" \
2218 -s "=> renegotiate" \
2219 -s "write hello request" \
2220 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2221
Hanno Becker6a243642017-10-12 15:18:45 +01002222requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002223run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002224 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002225 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002226 0 \
2227 -c "client hello, adding renegotiation extension" \
2228 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2229 -s "found renegotiation extension" \
2230 -s "server hello, secure renegotiation extension" \
2231 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002232 -c "=> renegotiate" \
2233 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002234 -s "write hello request"
2235
Hanno Becker6a243642017-10-12 15:18:45 +01002236requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002237run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002238 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002239 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002240 1 \
2241 -c "client hello, adding renegotiation extension" \
2242 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2243 -S "found renegotiation extension" \
2244 -s "server hello, secure renegotiation extension" \
2245 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002246 -c "=> renegotiate" \
2247 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002248 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002249 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002250 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002251
Hanno Becker6a243642017-10-12 15:18:45 +01002252requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002253run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002254 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002255 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002256 0 \
2257 -C "client hello, adding renegotiation extension" \
2258 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2259 -S "found renegotiation extension" \
2260 -s "server hello, secure renegotiation extension" \
2261 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002262 -C "=> renegotiate" \
2263 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002264 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002265 -S "SSL - An unexpected message was received from our peer" \
2266 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002267
Hanno Becker6a243642017-10-12 15:18:45 +01002268requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002269run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002270 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002271 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002272 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002273 0 \
2274 -C "client hello, adding renegotiation extension" \
2275 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2276 -S "found renegotiation extension" \
2277 -s "server hello, secure renegotiation extension" \
2278 -c "found renegotiation extension" \
2279 -C "=> renegotiate" \
2280 -S "=> renegotiate" \
2281 -s "write hello request" \
2282 -S "SSL - An unexpected message was received from our peer" \
2283 -S "failed"
2284
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002285# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002286requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002287run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002288 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002289 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002290 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002291 0 \
2292 -C "client hello, adding renegotiation extension" \
2293 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2294 -S "found renegotiation extension" \
2295 -s "server hello, secure renegotiation extension" \
2296 -c "found renegotiation extension" \
2297 -C "=> renegotiate" \
2298 -S "=> renegotiate" \
2299 -s "write hello request" \
2300 -S "SSL - An unexpected message was received from our peer" \
2301 -S "failed"
2302
Hanno Becker6a243642017-10-12 15:18:45 +01002303requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002304run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002305 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002306 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002307 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002308 0 \
2309 -C "client hello, adding renegotiation extension" \
2310 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2311 -S "found renegotiation extension" \
2312 -s "server hello, secure renegotiation extension" \
2313 -c "found renegotiation extension" \
2314 -C "=> renegotiate" \
2315 -S "=> renegotiate" \
2316 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002317 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002318
Hanno Becker6a243642017-10-12 15:18:45 +01002319requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002320run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002321 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002322 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002323 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002324 0 \
2325 -c "client hello, adding renegotiation extension" \
2326 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2327 -s "found renegotiation extension" \
2328 -s "server hello, secure renegotiation extension" \
2329 -c "found renegotiation extension" \
2330 -c "=> renegotiate" \
2331 -s "=> renegotiate" \
2332 -s "write hello request" \
2333 -S "SSL - An unexpected message was received from our peer" \
2334 -S "failed"
2335
Hanno Becker6a243642017-10-12 15:18:45 +01002336requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002337run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002338 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002339 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2340 0 \
2341 -C "client hello, adding renegotiation extension" \
2342 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2343 -S "found renegotiation extension" \
2344 -s "server hello, secure renegotiation extension" \
2345 -c "found renegotiation extension" \
2346 -S "record counter limit reached: renegotiate" \
2347 -C "=> renegotiate" \
2348 -S "=> renegotiate" \
2349 -S "write hello request" \
2350 -S "SSL - An unexpected message was received from our peer" \
2351 -S "failed"
2352
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002353# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002354requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002355run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002356 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002357 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002358 0 \
2359 -c "client hello, adding renegotiation extension" \
2360 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2361 -s "found renegotiation extension" \
2362 -s "server hello, secure renegotiation extension" \
2363 -c "found renegotiation extension" \
2364 -s "record counter limit reached: renegotiate" \
2365 -c "=> renegotiate" \
2366 -s "=> renegotiate" \
2367 -s "write hello request" \
2368 -S "SSL - An unexpected message was received from our peer" \
2369 -S "failed"
2370
Hanno Becker6a243642017-10-12 15:18:45 +01002371requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002372run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002373 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002374 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002375 0 \
2376 -c "client hello, adding renegotiation extension" \
2377 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2378 -s "found renegotiation extension" \
2379 -s "server hello, secure renegotiation extension" \
2380 -c "found renegotiation extension" \
2381 -s "record counter limit reached: renegotiate" \
2382 -c "=> renegotiate" \
2383 -s "=> renegotiate" \
2384 -s "write hello request" \
2385 -S "SSL - An unexpected message was received from our peer" \
2386 -S "failed"
2387
Hanno Becker6a243642017-10-12 15:18:45 +01002388requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002389run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002390 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002391 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2392 0 \
2393 -C "client hello, adding renegotiation extension" \
2394 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2395 -S "found renegotiation extension" \
2396 -s "server hello, secure renegotiation extension" \
2397 -c "found renegotiation extension" \
2398 -S "record counter limit reached: renegotiate" \
2399 -C "=> renegotiate" \
2400 -S "=> renegotiate" \
2401 -S "write hello request" \
2402 -S "SSL - An unexpected message was received from our peer" \
2403 -S "failed"
2404
Hanno Becker6a243642017-10-12 15:18:45 +01002405requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002406run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002407 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002408 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002409 0 \
2410 -c "client hello, adding renegotiation extension" \
2411 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2412 -s "found renegotiation extension" \
2413 -s "server hello, secure renegotiation extension" \
2414 -c "found renegotiation extension" \
2415 -c "=> renegotiate" \
2416 -s "=> renegotiate" \
2417 -S "write hello request"
2418
Hanno Becker6a243642017-10-12 15:18:45 +01002419requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002420run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002421 "$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 +02002422 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002423 0 \
2424 -c "client hello, adding renegotiation extension" \
2425 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2426 -s "found renegotiation extension" \
2427 -s "server hello, secure renegotiation extension" \
2428 -c "found renegotiation extension" \
2429 -c "=> renegotiate" \
2430 -s "=> renegotiate" \
2431 -s "write hello request"
2432
Hanno Becker6a243642017-10-12 15:18:45 +01002433requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002434run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002435 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002436 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002437 0 \
2438 -c "client hello, adding renegotiation extension" \
2439 -c "found renegotiation extension" \
2440 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002441 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002442 -C "error" \
2443 -c "HTTP/1.0 200 [Oo][Kk]"
2444
Paul Bakker539d9722015-02-08 16:18:35 +01002445requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002446requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002447run_test "Renegotiation: gnutls server strict, client-initiated" \
2448 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002449 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002450 0 \
2451 -c "client hello, adding renegotiation extension" \
2452 -c "found renegotiation extension" \
2453 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002454 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002455 -C "error" \
2456 -c "HTTP/1.0 200 [Oo][Kk]"
2457
Paul Bakker539d9722015-02-08 16:18:35 +01002458requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002459requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002460run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2461 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2462 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2463 1 \
2464 -c "client hello, adding renegotiation extension" \
2465 -C "found renegotiation extension" \
2466 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002467 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002468 -c "error" \
2469 -C "HTTP/1.0 200 [Oo][Kk]"
2470
Paul Bakker539d9722015-02-08 16:18:35 +01002471requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002472requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002473run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2474 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2475 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2476 allow_legacy=0" \
2477 1 \
2478 -c "client hello, adding renegotiation extension" \
2479 -C "found renegotiation extension" \
2480 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002481 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002482 -c "error" \
2483 -C "HTTP/1.0 200 [Oo][Kk]"
2484
Paul Bakker539d9722015-02-08 16:18:35 +01002485requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002486requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002487run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2488 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2489 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2490 allow_legacy=1" \
2491 0 \
2492 -c "client hello, adding renegotiation extension" \
2493 -C "found renegotiation extension" \
2494 -c "=> renegotiate" \
2495 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002496 -C "error" \
2497 -c "HTTP/1.0 200 [Oo][Kk]"
2498
Hanno Becker6a243642017-10-12 15:18:45 +01002499requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002500run_test "Renegotiation: DTLS, client-initiated" \
2501 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2502 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2503 0 \
2504 -c "client hello, adding renegotiation extension" \
2505 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2506 -s "found renegotiation extension" \
2507 -s "server hello, secure renegotiation extension" \
2508 -c "found renegotiation extension" \
2509 -c "=> renegotiate" \
2510 -s "=> renegotiate" \
2511 -S "write hello request"
2512
Hanno Becker6a243642017-10-12 15:18:45 +01002513requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002514run_test "Renegotiation: DTLS, server-initiated" \
2515 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002516 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2517 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002518 0 \
2519 -c "client hello, adding renegotiation extension" \
2520 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2521 -s "found renegotiation extension" \
2522 -s "server hello, secure renegotiation extension" \
2523 -c "found renegotiation extension" \
2524 -c "=> renegotiate" \
2525 -s "=> renegotiate" \
2526 -s "write hello request"
2527
Hanno Becker6a243642017-10-12 15:18:45 +01002528requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002529run_test "Renegotiation: DTLS, renego_period overflow" \
2530 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2531 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2532 0 \
2533 -c "client hello, adding renegotiation extension" \
2534 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2535 -s "found renegotiation extension" \
2536 -s "server hello, secure renegotiation extension" \
2537 -s "record counter limit reached: renegotiate" \
2538 -c "=> renegotiate" \
2539 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002540 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002541
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002542requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002543requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002544run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2545 "$G_SRV -u --mtu 4096" \
2546 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2547 0 \
2548 -c "client hello, adding renegotiation extension" \
2549 -c "found renegotiation extension" \
2550 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002551 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002552 -C "error" \
2553 -s "Extra-header:"
2554
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002555# Test for the "secure renegotation" extension only (no actual renegotiation)
2556
Paul Bakker539d9722015-02-08 16:18:35 +01002557requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002558run_test "Renego ext: gnutls server strict, client default" \
2559 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2560 "$P_CLI debug_level=3" \
2561 0 \
2562 -c "found renegotiation extension" \
2563 -C "error" \
2564 -c "HTTP/1.0 200 [Oo][Kk]"
2565
Paul Bakker539d9722015-02-08 16:18:35 +01002566requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002567run_test "Renego ext: gnutls server unsafe, client default" \
2568 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2569 "$P_CLI debug_level=3" \
2570 0 \
2571 -C "found renegotiation extension" \
2572 -C "error" \
2573 -c "HTTP/1.0 200 [Oo][Kk]"
2574
Paul Bakker539d9722015-02-08 16:18:35 +01002575requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002576run_test "Renego ext: gnutls server unsafe, client break legacy" \
2577 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2578 "$P_CLI debug_level=3 allow_legacy=-1" \
2579 1 \
2580 -C "found renegotiation extension" \
2581 -c "error" \
2582 -C "HTTP/1.0 200 [Oo][Kk]"
2583
Paul Bakker539d9722015-02-08 16:18:35 +01002584requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002585run_test "Renego ext: gnutls client strict, server default" \
2586 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002587 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002588 0 \
2589 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2590 -s "server hello, secure renegotiation extension"
2591
Paul Bakker539d9722015-02-08 16:18:35 +01002592requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002593run_test "Renego ext: gnutls client unsafe, server default" \
2594 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002595 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002596 0 \
2597 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2598 -S "server hello, secure renegotiation extension"
2599
Paul Bakker539d9722015-02-08 16:18:35 +01002600requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002601run_test "Renego ext: gnutls client unsafe, server break legacy" \
2602 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002603 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002604 1 \
2605 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2606 -S "server hello, secure renegotiation extension"
2607
Janos Follath0b242342016-02-17 10:11:21 +00002608# Tests for silently dropping trailing extra bytes in .der certificates
2609
2610requires_gnutls
2611run_test "DER format: no trailing bytes" \
2612 "$P_SRV crt_file=data_files/server5-der0.crt \
2613 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002614 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002615 0 \
2616 -c "Handshake was completed" \
2617
2618requires_gnutls
2619run_test "DER format: with a trailing zero byte" \
2620 "$P_SRV crt_file=data_files/server5-der1a.crt \
2621 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002622 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002623 0 \
2624 -c "Handshake was completed" \
2625
2626requires_gnutls
2627run_test "DER format: with a trailing random byte" \
2628 "$P_SRV crt_file=data_files/server5-der1b.crt \
2629 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002630 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002631 0 \
2632 -c "Handshake was completed" \
2633
2634requires_gnutls
2635run_test "DER format: with 2 trailing random bytes" \
2636 "$P_SRV crt_file=data_files/server5-der2.crt \
2637 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002638 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002639 0 \
2640 -c "Handshake was completed" \
2641
2642requires_gnutls
2643run_test "DER format: with 4 trailing random bytes" \
2644 "$P_SRV crt_file=data_files/server5-der4.crt \
2645 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002646 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002647 0 \
2648 -c "Handshake was completed" \
2649
2650requires_gnutls
2651run_test "DER format: with 8 trailing random bytes" \
2652 "$P_SRV crt_file=data_files/server5-der8.crt \
2653 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002654 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002655 0 \
2656 -c "Handshake was completed" \
2657
2658requires_gnutls
2659run_test "DER format: with 9 trailing random bytes" \
2660 "$P_SRV crt_file=data_files/server5-der9.crt \
2661 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002662 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002663 0 \
2664 -c "Handshake was completed" \
2665
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002666# Tests for auth_mode
2667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002668run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002669 "$P_SRV crt_file=data_files/server5-badsign.crt \
2670 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002671 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002672 1 \
2673 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002674 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002675 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002676 -c "X509 - Certificate verification failed"
2677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002678run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002679 "$P_SRV crt_file=data_files/server5-badsign.crt \
2680 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002681 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002682 0 \
2683 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002684 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002685 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002686 -C "X509 - Certificate verification failed"
2687
Hanno Beckere6706e62017-05-15 16:05:15 +01002688run_test "Authentication: server goodcert, client optional, no trusted CA" \
2689 "$P_SRV" \
2690 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2691 0 \
2692 -c "x509_verify_cert() returned" \
2693 -c "! The certificate is not correctly signed by the trusted CA" \
2694 -c "! Certificate verification flags"\
2695 -C "! mbedtls_ssl_handshake returned" \
2696 -C "X509 - Certificate verification failed" \
2697 -C "SSL - No CA Chain is set, but required to operate"
2698
2699run_test "Authentication: server goodcert, client required, no trusted CA" \
2700 "$P_SRV" \
2701 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2702 1 \
2703 -c "x509_verify_cert() returned" \
2704 -c "! The certificate is not correctly signed by the trusted CA" \
2705 -c "! Certificate verification flags"\
2706 -c "! mbedtls_ssl_handshake returned" \
2707 -c "SSL - No CA Chain is set, but required to operate"
2708
2709# The purpose of the next two tests is to test the client's behaviour when receiving a server
2710# certificate with an unsupported elliptic curve. This should usually not happen because
2711# the client informs the server about the supported curves - it does, though, in the
2712# corner case of a static ECDH suite, because the server doesn't check the curve on that
2713# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2714# different means to have the server ignoring the client's supported curve list.
2715
2716requires_config_enabled MBEDTLS_ECP_C
2717run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2718 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2719 crt_file=data_files/server5.ku-ka.crt" \
2720 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2721 1 \
2722 -c "bad certificate (EC key curve)"\
2723 -c "! Certificate verification flags"\
2724 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2725
2726requires_config_enabled MBEDTLS_ECP_C
2727run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2728 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2729 crt_file=data_files/server5.ku-ka.crt" \
2730 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2731 1 \
2732 -c "bad certificate (EC key curve)"\
2733 -c "! Certificate verification flags"\
2734 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002736run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002737 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002738 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002739 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002740 0 \
2741 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002742 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002743 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002744 -C "X509 - Certificate verification failed"
2745
Simon Butcher99000142016-10-13 17:21:01 +01002746run_test "Authentication: client SHA256, server required" \
2747 "$P_SRV auth_mode=required" \
2748 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2749 key_file=data_files/server6.key \
2750 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2751 0 \
2752 -c "Supported Signature Algorithm found: 4," \
2753 -c "Supported Signature Algorithm found: 5,"
2754
2755run_test "Authentication: client SHA384, server required" \
2756 "$P_SRV auth_mode=required" \
2757 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2758 key_file=data_files/server6.key \
2759 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2760 0 \
2761 -c "Supported Signature Algorithm found: 4," \
2762 -c "Supported Signature Algorithm found: 5,"
2763
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002764requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2765run_test "Authentication: client has no cert, server required (SSLv3)" \
2766 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2767 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2768 key_file=data_files/server5.key" \
2769 1 \
2770 -S "skip write certificate request" \
2771 -C "skip parse certificate request" \
2772 -c "got a certificate request" \
2773 -c "got no certificate to send" \
2774 -S "x509_verify_cert() returned" \
2775 -s "client has no certificate" \
2776 -s "! mbedtls_ssl_handshake returned" \
2777 -c "! mbedtls_ssl_handshake returned" \
2778 -s "No client certification received from the client, but required by the authentication mode"
2779
2780run_test "Authentication: client has no cert, server required (TLS)" \
2781 "$P_SRV debug_level=3 auth_mode=required" \
2782 "$P_CLI debug_level=3 crt_file=none \
2783 key_file=data_files/server5.key" \
2784 1 \
2785 -S "skip write certificate request" \
2786 -C "skip parse certificate request" \
2787 -c "got a certificate request" \
2788 -c "= write certificate$" \
2789 -C "skip write certificate$" \
2790 -S "x509_verify_cert() returned" \
2791 -s "client has no certificate" \
2792 -s "! mbedtls_ssl_handshake returned" \
2793 -c "! mbedtls_ssl_handshake returned" \
2794 -s "No client certification received from the client, but required by the authentication mode"
2795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002796run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002797 "$P_SRV debug_level=3 auth_mode=required" \
2798 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002799 key_file=data_files/server5.key" \
2800 1 \
2801 -S "skip write certificate request" \
2802 -C "skip parse certificate request" \
2803 -c "got a certificate request" \
2804 -C "skip write certificate" \
2805 -C "skip write certificate verify" \
2806 -S "skip parse certificate verify" \
2807 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002808 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002809 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002810 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002811 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002812 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002813# We don't check that the client receives the alert because it might
2814# detect that its write end of the connection is closed and abort
2815# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002816
Janos Follath89baba22017-04-10 14:34:35 +01002817run_test "Authentication: client cert not trusted, server required" \
2818 "$P_SRV debug_level=3 auth_mode=required" \
2819 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2820 key_file=data_files/server5.key" \
2821 1 \
2822 -S "skip write certificate request" \
2823 -C "skip parse certificate request" \
2824 -c "got a certificate request" \
2825 -C "skip write certificate" \
2826 -C "skip write certificate verify" \
2827 -S "skip parse certificate verify" \
2828 -s "x509_verify_cert() returned" \
2829 -s "! The certificate is not correctly signed by the trusted CA" \
2830 -s "! mbedtls_ssl_handshake returned" \
2831 -c "! mbedtls_ssl_handshake returned" \
2832 -s "X509 - Certificate verification failed"
2833
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002834run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002835 "$P_SRV debug_level=3 auth_mode=optional" \
2836 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002837 key_file=data_files/server5.key" \
2838 0 \
2839 -S "skip write certificate request" \
2840 -C "skip parse certificate request" \
2841 -c "got a certificate request" \
2842 -C "skip write certificate" \
2843 -C "skip write certificate verify" \
2844 -S "skip parse certificate verify" \
2845 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002846 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002847 -S "! mbedtls_ssl_handshake returned" \
2848 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002849 -S "X509 - Certificate verification failed"
2850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002851run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002852 "$P_SRV debug_level=3 auth_mode=none" \
2853 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002854 key_file=data_files/server5.key" \
2855 0 \
2856 -s "skip write certificate request" \
2857 -C "skip parse certificate request" \
2858 -c "got no certificate request" \
2859 -c "skip write certificate" \
2860 -c "skip write certificate verify" \
2861 -s "skip parse certificate verify" \
2862 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002863 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002864 -S "! mbedtls_ssl_handshake returned" \
2865 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002866 -S "X509 - Certificate verification failed"
2867
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002868run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002869 "$P_SRV debug_level=3 auth_mode=optional" \
2870 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002871 0 \
2872 -S "skip write certificate request" \
2873 -C "skip parse certificate request" \
2874 -c "got a certificate request" \
2875 -C "skip write certificate$" \
2876 -C "got no certificate to send" \
2877 -S "SSLv3 client has no certificate" \
2878 -c "skip write certificate verify" \
2879 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002880 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002881 -S "! mbedtls_ssl_handshake returned" \
2882 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002883 -S "X509 - Certificate verification failed"
2884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002885run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002886 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002887 "$O_CLI" \
2888 0 \
2889 -S "skip write certificate request" \
2890 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002891 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002892 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002893 -S "X509 - Certificate verification failed"
2894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002895run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002896 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002897 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002898 0 \
2899 -C "skip parse certificate request" \
2900 -c "got a certificate request" \
2901 -C "skip write certificate$" \
2902 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002903 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002904
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002905run_test "Authentication: client no cert, openssl server required" \
2906 "$O_SRV -Verify 10" \
2907 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2908 1 \
2909 -C "skip parse certificate request" \
2910 -c "got a certificate request" \
2911 -C "skip write certificate$" \
2912 -c "skip write certificate verify" \
2913 -c "! mbedtls_ssl_handshake returned"
2914
Janos Follathe2681a42016-03-07 15:57:05 +00002915requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002916run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002917 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002918 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002919 0 \
2920 -S "skip write certificate request" \
2921 -C "skip parse certificate request" \
2922 -c "got a certificate request" \
2923 -C "skip write certificate$" \
2924 -c "skip write certificate verify" \
2925 -c "got no certificate to send" \
2926 -s "SSLv3 client has no certificate" \
2927 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002928 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002929 -S "! mbedtls_ssl_handshake returned" \
2930 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002931 -S "X509 - Certificate verification failed"
2932
Yuto Takano8df2d252021-07-02 13:05:15 +01002933# This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default
2934# value, defined here as MAX_IM_CA. Some test cases will be skipped if the
2935# library is configured with a different value.
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002936
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002937MAX_IM_CA='8'
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002938
Yuto Takano8df2d252021-07-02 13:05:15 +01002939# The tests for the max_int tests can pass with any number higher than MAX_IM_CA
2940# because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1
2941# tests can pass with any number less than MAX_IM_CA. However, stricter preconditions
2942# are in place so that the semantics are consistent with the test description.
Yuto Takanobc632c22021-07-02 13:10:41 +01002943requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002944requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002945run_test "Authentication: server max_int chain, client default" \
2946 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2947 key_file=data_files/dir-maxpath/09.key" \
2948 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2949 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002950 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002951
Yuto Takanobc632c22021-07-02 13:10:41 +01002952requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002953requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002954run_test "Authentication: server max_int+1 chain, client default" \
2955 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2956 key_file=data_files/dir-maxpath/10.key" \
2957 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2958 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002959 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002960
Yuto Takanobc632c22021-07-02 13:10:41 +01002961requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002962requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002963run_test "Authentication: server max_int+1 chain, client optional" \
2964 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2965 key_file=data_files/dir-maxpath/10.key" \
2966 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2967 auth_mode=optional" \
2968 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002969 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002970
Yuto Takanobc632c22021-07-02 13:10:41 +01002971requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002972requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002973run_test "Authentication: server max_int+1 chain, client none" \
2974 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2975 key_file=data_files/dir-maxpath/10.key" \
2976 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2977 auth_mode=none" \
2978 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002979 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002980
Yuto Takanobc632c22021-07-02 13:10:41 +01002981requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002982requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002983run_test "Authentication: client max_int+1 chain, server default" \
2984 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2985 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2986 key_file=data_files/dir-maxpath/10.key" \
2987 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002988 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002989
Yuto Takanobc632c22021-07-02 13:10:41 +01002990requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002991requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002992run_test "Authentication: client max_int+1 chain, server optional" \
2993 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2994 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2995 key_file=data_files/dir-maxpath/10.key" \
2996 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002997 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002998
Yuto Takanobc632c22021-07-02 13:10:41 +01002999requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10003000requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003001run_test "Authentication: client max_int+1 chain, server required" \
3002 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3003 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3004 key_file=data_files/dir-maxpath/10.key" \
3005 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003006 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003007
Yuto Takanobc632c22021-07-02 13:10:41 +01003008requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10003009requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003010run_test "Authentication: client max_int chain, server required" \
3011 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3012 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
3013 key_file=data_files/dir-maxpath/09.key" \
3014 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003015 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003016
Janos Follath89baba22017-04-10 14:34:35 +01003017# Tests for CA list in CertificateRequest messages
3018
3019run_test "Authentication: send CA list in CertificateRequest (default)" \
3020 "$P_SRV debug_level=3 auth_mode=required" \
3021 "$P_CLI crt_file=data_files/server6.crt \
3022 key_file=data_files/server6.key" \
3023 0 \
3024 -s "requested DN"
3025
3026run_test "Authentication: do not send CA list in CertificateRequest" \
3027 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3028 "$P_CLI crt_file=data_files/server6.crt \
3029 key_file=data_files/server6.key" \
3030 0 \
3031 -S "requested DN"
3032
3033run_test "Authentication: send CA list in CertificateRequest, client self signed" \
3034 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3035 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3036 key_file=data_files/server5.key" \
3037 1 \
3038 -S "requested DN" \
3039 -s "x509_verify_cert() returned" \
3040 -s "! The certificate is not correctly signed by the trusted CA" \
3041 -s "! mbedtls_ssl_handshake returned" \
3042 -c "! mbedtls_ssl_handshake returned" \
3043 -s "X509 - Certificate verification failed"
3044
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01003045# Tests for certificate selection based on SHA verson
3046
3047run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3048 "$P_SRV crt_file=data_files/server5.crt \
3049 key_file=data_files/server5.key \
3050 crt_file2=data_files/server5-sha1.crt \
3051 key_file2=data_files/server5.key" \
3052 "$P_CLI force_version=tls1_2" \
3053 0 \
3054 -c "signed using.*ECDSA with SHA256" \
3055 -C "signed using.*ECDSA with SHA1"
3056
3057run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3058 "$P_SRV crt_file=data_files/server5.crt \
3059 key_file=data_files/server5.key \
3060 crt_file2=data_files/server5-sha1.crt \
3061 key_file2=data_files/server5.key" \
3062 "$P_CLI force_version=tls1_1" \
3063 0 \
3064 -C "signed using.*ECDSA with SHA256" \
3065 -c "signed using.*ECDSA with SHA1"
3066
3067run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3068 "$P_SRV crt_file=data_files/server5.crt \
3069 key_file=data_files/server5.key \
3070 crt_file2=data_files/server5-sha1.crt \
3071 key_file2=data_files/server5.key" \
3072 "$P_CLI force_version=tls1" \
3073 0 \
3074 -C "signed using.*ECDSA with SHA256" \
3075 -c "signed using.*ECDSA with SHA1"
3076
3077run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3078 "$P_SRV crt_file=data_files/server5.crt \
3079 key_file=data_files/server5.key \
3080 crt_file2=data_files/server6.crt \
3081 key_file2=data_files/server6.key" \
3082 "$P_CLI force_version=tls1_1" \
3083 0 \
3084 -c "serial number.*09" \
3085 -c "signed using.*ECDSA with SHA256" \
3086 -C "signed using.*ECDSA with SHA1"
3087
3088run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3089 "$P_SRV crt_file=data_files/server6.crt \
3090 key_file=data_files/server6.key \
3091 crt_file2=data_files/server5.crt \
3092 key_file2=data_files/server5.key" \
3093 "$P_CLI force_version=tls1_1" \
3094 0 \
3095 -c "serial number.*0A" \
3096 -c "signed using.*ECDSA with SHA256" \
3097 -C "signed using.*ECDSA with SHA1"
3098
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003099# tests for SNI
3100
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003101run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003102 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003103 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003104 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003105 0 \
3106 -S "parse ServerName extension" \
3107 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3108 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003110run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003111 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003112 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003113 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 +02003114 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003115 0 \
3116 -s "parse ServerName extension" \
3117 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3118 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003120run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003121 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003122 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003123 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 +02003124 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003125 0 \
3126 -s "parse ServerName extension" \
3127 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3128 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003129
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003130run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003131 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003132 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003133 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 +02003134 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003135 1 \
3136 -s "parse ServerName extension" \
3137 -s "ssl_sni_wrapper() returned" \
3138 -s "mbedtls_ssl_handshake returned" \
3139 -c "mbedtls_ssl_handshake returned" \
3140 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003141
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003142run_test "SNI: client auth no override: optional" \
3143 "$P_SRV debug_level=3 auth_mode=optional \
3144 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3145 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3146 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003147 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003148 -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
3155run_test "SNI: client auth override: none -> optional" \
3156 "$P_SRV debug_level=3 auth_mode=none \
3157 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3158 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3159 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003160 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003161 -S "skip write certificate request" \
3162 -C "skip parse certificate request" \
3163 -c "got a certificate request" \
3164 -C "skip write certificate" \
3165 -C "skip write certificate verify" \
3166 -S "skip parse certificate verify"
3167
3168run_test "SNI: client auth override: optional -> none" \
3169 "$P_SRV debug_level=3 auth_mode=optional \
3170 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3171 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3172 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003173 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003174 -s "skip write certificate request" \
3175 -C "skip parse certificate request" \
3176 -c "got no certificate request" \
3177 -c "skip write certificate" \
3178 -c "skip write certificate verify" \
3179 -s "skip parse certificate verify"
3180
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003181run_test "SNI: CA no override" \
3182 "$P_SRV debug_level=3 auth_mode=optional \
3183 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3184 ca_file=data_files/test-ca.crt \
3185 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3186 "$P_CLI debug_level=3 server_name=localhost \
3187 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3188 1 \
3189 -S "skip write certificate request" \
3190 -C "skip parse certificate request" \
3191 -c "got a certificate request" \
3192 -C "skip write certificate" \
3193 -C "skip write certificate verify" \
3194 -S "skip parse certificate verify" \
3195 -s "x509_verify_cert() returned" \
3196 -s "! The certificate is not correctly signed by the trusted CA" \
3197 -S "The certificate has been revoked (is on a CRL)"
3198
3199run_test "SNI: CA override" \
3200 "$P_SRV debug_level=3 auth_mode=optional \
3201 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3202 ca_file=data_files/test-ca.crt \
3203 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3204 "$P_CLI debug_level=3 server_name=localhost \
3205 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3206 0 \
3207 -S "skip write certificate request" \
3208 -C "skip parse certificate request" \
3209 -c "got a certificate request" \
3210 -C "skip write certificate" \
3211 -C "skip write certificate verify" \
3212 -S "skip parse certificate verify" \
3213 -S "x509_verify_cert() returned" \
3214 -S "! The certificate is not correctly signed by the trusted CA" \
3215 -S "The certificate has been revoked (is on a CRL)"
3216
3217run_test "SNI: CA override with CRL" \
3218 "$P_SRV debug_level=3 auth_mode=optional \
3219 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3220 ca_file=data_files/test-ca.crt \
3221 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3222 "$P_CLI debug_level=3 server_name=localhost \
3223 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3224 1 \
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 -s "x509_verify_cert() returned" \
3232 -S "! The certificate is not correctly signed by the trusted CA" \
3233 -s "The certificate has been revoked (is on a CRL)"
3234
Andres AG1a834452016-12-07 10:01:30 +00003235# Tests for SNI and DTLS
3236
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003237run_test "SNI: DTLS, no SNI callback" \
3238 "$P_SRV debug_level=3 dtls=1 \
3239 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3240 "$P_CLI server_name=localhost dtls=1" \
3241 0 \
3242 -S "parse ServerName extension" \
3243 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3244 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3245
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003246run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003247 "$P_SRV debug_level=3 dtls=1 \
3248 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3249 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3250 "$P_CLI server_name=localhost dtls=1" \
3251 0 \
3252 -s "parse ServerName extension" \
3253 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3254 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3255
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003256run_test "SNI: DTLS, matching cert 2" \
3257 "$P_SRV debug_level=3 dtls=1 \
3258 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3259 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3260 "$P_CLI server_name=polarssl.example dtls=1" \
3261 0 \
3262 -s "parse ServerName extension" \
3263 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3264 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3265
3266run_test "SNI: DTLS, no matching cert" \
3267 "$P_SRV debug_level=3 dtls=1 \
3268 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3269 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3270 "$P_CLI server_name=nonesuch.example dtls=1" \
3271 1 \
3272 -s "parse ServerName extension" \
3273 -s "ssl_sni_wrapper() returned" \
3274 -s "mbedtls_ssl_handshake returned" \
3275 -c "mbedtls_ssl_handshake returned" \
3276 -c "SSL - A fatal alert message was received from our peer"
3277
3278run_test "SNI: DTLS, client auth no override: optional" \
3279 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3280 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3281 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3282 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
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
3291run_test "SNI: DTLS, client auth override: none -> optional" \
3292 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3293 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3294 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3295 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3296 0 \
3297 -S "skip write certificate request" \
3298 -C "skip parse certificate request" \
3299 -c "got a certificate request" \
3300 -C "skip write certificate" \
3301 -C "skip write certificate verify" \
3302 -S "skip parse certificate verify"
3303
3304run_test "SNI: DTLS, client auth override: optional -> none" \
3305 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3306 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3307 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3308 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3309 0 \
3310 -s "skip write certificate request" \
3311 -C "skip parse certificate request" \
3312 -c "got no certificate request" \
3313 -c "skip write certificate" \
3314 -c "skip write certificate verify" \
3315 -s "skip parse certificate verify"
3316
3317run_test "SNI: DTLS, CA no override" \
3318 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3319 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3320 ca_file=data_files/test-ca.crt \
3321 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3322 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3323 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3324 1 \
3325 -S "skip write certificate request" \
3326 -C "skip parse certificate request" \
3327 -c "got a certificate request" \
3328 -C "skip write certificate" \
3329 -C "skip write certificate verify" \
3330 -S "skip parse certificate verify" \
3331 -s "x509_verify_cert() returned" \
3332 -s "! The certificate is not correctly signed by the trusted CA" \
3333 -S "The certificate has been revoked (is on a CRL)"
3334
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003335run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003336 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3337 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3338 ca_file=data_files/test-ca.crt \
3339 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3340 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3341 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3342 0 \
3343 -S "skip write certificate request" \
3344 -C "skip parse certificate request" \
3345 -c "got a certificate request" \
3346 -C "skip write certificate" \
3347 -C "skip write certificate verify" \
3348 -S "skip parse certificate verify" \
3349 -S "x509_verify_cert() returned" \
3350 -S "! The certificate is not correctly signed by the trusted CA" \
3351 -S "The certificate has been revoked (is on a CRL)"
3352
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003353run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003354 "$P_SRV debug_level=3 auth_mode=optional \
3355 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3356 ca_file=data_files/test-ca.crt \
3357 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3358 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3359 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3360 1 \
3361 -S "skip write certificate request" \
3362 -C "skip parse certificate request" \
3363 -c "got a certificate request" \
3364 -C "skip write certificate" \
3365 -C "skip write certificate verify" \
3366 -S "skip parse certificate verify" \
3367 -s "x509_verify_cert() returned" \
3368 -S "! The certificate is not correctly signed by the trusted CA" \
3369 -s "The certificate has been revoked (is on a CRL)"
3370
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003371# Tests for non-blocking I/O: exercise a variety of handshake flows
3372
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003373run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003374 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3375 "$P_CLI nbio=2 tickets=0" \
3376 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003377 -S "mbedtls_ssl_handshake returned" \
3378 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003379 -c "Read from server: .* bytes read"
3380
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003381run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003382 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3383 "$P_CLI nbio=2 tickets=0" \
3384 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003385 -S "mbedtls_ssl_handshake returned" \
3386 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003387 -c "Read from server: .* bytes read"
3388
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003389run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003390 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3391 "$P_CLI nbio=2 tickets=1" \
3392 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003393 -S "mbedtls_ssl_handshake returned" \
3394 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003395 -c "Read from server: .* bytes read"
3396
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003397run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003398 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3399 "$P_CLI nbio=2 tickets=1" \
3400 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003401 -S "mbedtls_ssl_handshake returned" \
3402 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003403 -c "Read from server: .* bytes read"
3404
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003405run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003406 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3407 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3408 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003409 -S "mbedtls_ssl_handshake returned" \
3410 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003411 -c "Read from server: .* bytes read"
3412
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003413run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003414 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3415 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3416 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003417 -S "mbedtls_ssl_handshake returned" \
3418 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003419 -c "Read from server: .* bytes read"
3420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003421run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003422 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3423 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3424 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003425 -S "mbedtls_ssl_handshake returned" \
3426 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003427 -c "Read from server: .* bytes read"
3428
Hanno Becker00076712017-11-15 16:39:08 +00003429# Tests for event-driven I/O: exercise a variety of handshake flows
3430
3431run_test "Event-driven I/O: basic handshake" \
3432 "$P_SRV event=1 tickets=0 auth_mode=none" \
3433 "$P_CLI event=1 tickets=0" \
3434 0 \
3435 -S "mbedtls_ssl_handshake returned" \
3436 -C "mbedtls_ssl_handshake returned" \
3437 -c "Read from server: .* bytes read"
3438
3439run_test "Event-driven I/O: client auth" \
3440 "$P_SRV event=1 tickets=0 auth_mode=required" \
3441 "$P_CLI event=1 tickets=0" \
3442 0 \
3443 -S "mbedtls_ssl_handshake returned" \
3444 -C "mbedtls_ssl_handshake returned" \
3445 -c "Read from server: .* bytes read"
3446
3447run_test "Event-driven I/O: ticket" \
3448 "$P_SRV event=1 tickets=1 auth_mode=none" \
3449 "$P_CLI event=1 tickets=1" \
3450 0 \
3451 -S "mbedtls_ssl_handshake returned" \
3452 -C "mbedtls_ssl_handshake returned" \
3453 -c "Read from server: .* bytes read"
3454
3455run_test "Event-driven I/O: ticket + client auth" \
3456 "$P_SRV event=1 tickets=1 auth_mode=required" \
3457 "$P_CLI event=1 tickets=1" \
3458 0 \
3459 -S "mbedtls_ssl_handshake returned" \
3460 -C "mbedtls_ssl_handshake returned" \
3461 -c "Read from server: .* bytes read"
3462
3463run_test "Event-driven I/O: ticket + client auth + resume" \
3464 "$P_SRV event=1 tickets=1 auth_mode=required" \
3465 "$P_CLI event=1 tickets=1 reconnect=1" \
3466 0 \
3467 -S "mbedtls_ssl_handshake returned" \
3468 -C "mbedtls_ssl_handshake returned" \
3469 -c "Read from server: .* bytes read"
3470
3471run_test "Event-driven I/O: ticket + resume" \
3472 "$P_SRV event=1 tickets=1 auth_mode=none" \
3473 "$P_CLI event=1 tickets=1 reconnect=1" \
3474 0 \
3475 -S "mbedtls_ssl_handshake returned" \
3476 -C "mbedtls_ssl_handshake returned" \
3477 -c "Read from server: .* bytes read"
3478
3479run_test "Event-driven I/O: session-id resume" \
3480 "$P_SRV event=1 tickets=0 auth_mode=none" \
3481 "$P_CLI event=1 tickets=0 reconnect=1" \
3482 0 \
3483 -S "mbedtls_ssl_handshake returned" \
3484 -C "mbedtls_ssl_handshake returned" \
3485 -c "Read from server: .* bytes read"
3486
Hanno Becker6a33f592018-03-13 11:38:46 +00003487run_test "Event-driven I/O, DTLS: basic handshake" \
3488 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3489 "$P_CLI dtls=1 event=1 tickets=0" \
3490 0 \
3491 -c "Read from server: .* bytes read"
3492
3493run_test "Event-driven I/O, DTLS: client auth" \
3494 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3495 "$P_CLI dtls=1 event=1 tickets=0" \
3496 0 \
3497 -c "Read from server: .* bytes read"
3498
3499run_test "Event-driven I/O, DTLS: ticket" \
3500 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3501 "$P_CLI dtls=1 event=1 tickets=1" \
3502 0 \
3503 -c "Read from server: .* bytes read"
3504
3505run_test "Event-driven I/O, DTLS: ticket + client auth" \
3506 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3507 "$P_CLI dtls=1 event=1 tickets=1" \
3508 0 \
3509 -c "Read from server: .* bytes read"
3510
3511run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3512 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003513 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003514 0 \
3515 -c "Read from server: .* bytes read"
3516
3517run_test "Event-driven I/O, DTLS: ticket + resume" \
3518 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003519 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003520 0 \
3521 -c "Read from server: .* bytes read"
3522
3523run_test "Event-driven I/O, DTLS: session-id resume" \
3524 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003525 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003526 0 \
3527 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003528
3529# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3530# During session resumption, the client will send its ApplicationData record
3531# within the same datagram as the Finished messages. In this situation, the
3532# server MUST NOT idle on the underlying transport after handshake completion,
3533# because the ApplicationData request has already been queued internally.
3534run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003535 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003536 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003537 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003538 0 \
3539 -c "Read from server: .* bytes read"
3540
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003541# Tests for version negotiation
3542
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003543run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003544 "$P_SRV" \
3545 "$P_CLI" \
3546 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003547 -S "mbedtls_ssl_handshake returned" \
3548 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003549 -s "Protocol is TLSv1.2" \
3550 -c "Protocol is TLSv1.2"
3551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003552run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003553 "$P_SRV" \
3554 "$P_CLI max_version=tls1_1" \
3555 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003556 -S "mbedtls_ssl_handshake returned" \
3557 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003558 -s "Protocol is TLSv1.1" \
3559 -c "Protocol is TLSv1.1"
3560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003561run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003562 "$P_SRV max_version=tls1_1" \
3563 "$P_CLI" \
3564 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003565 -S "mbedtls_ssl_handshake returned" \
3566 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003567 -s "Protocol is TLSv1.1" \
3568 -c "Protocol is TLSv1.1"
3569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003570run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003571 "$P_SRV max_version=tls1_1" \
3572 "$P_CLI max_version=tls1_1" \
3573 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003574 -S "mbedtls_ssl_handshake returned" \
3575 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003576 -s "Protocol is TLSv1.1" \
3577 -c "Protocol is TLSv1.1"
3578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003579run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003580 "$P_SRV min_version=tls1_1" \
3581 "$P_CLI max_version=tls1_1" \
3582 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003583 -S "mbedtls_ssl_handshake returned" \
3584 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003585 -s "Protocol is TLSv1.1" \
3586 -c "Protocol is TLSv1.1"
3587
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003588run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003589 "$P_SRV max_version=tls1_1" \
3590 "$P_CLI min_version=tls1_1" \
3591 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003592 -S "mbedtls_ssl_handshake returned" \
3593 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003594 -s "Protocol is TLSv1.1" \
3595 -c "Protocol is TLSv1.1"
3596
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003597run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003598 "$P_SRV max_version=tls1_1" \
3599 "$P_CLI min_version=tls1_2" \
3600 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003601 -s "mbedtls_ssl_handshake returned" \
3602 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003603 -c "SSL - Handshake protocol not within min/max boundaries"
3604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003605run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003606 "$P_SRV min_version=tls1_2" \
3607 "$P_CLI max_version=tls1_1" \
3608 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003609 -s "mbedtls_ssl_handshake returned" \
3610 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003611 -s "SSL - Handshake protocol not within min/max boundaries"
3612
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003613# Tests for ALPN extension
3614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003615run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003616 "$P_SRV debug_level=3" \
3617 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003618 0 \
3619 -C "client hello, adding alpn extension" \
3620 -S "found alpn extension" \
3621 -C "got an alert message, type: \\[2:120]" \
3622 -S "server hello, adding alpn extension" \
3623 -C "found alpn extension " \
3624 -C "Application Layer Protocol is" \
3625 -S "Application Layer Protocol is"
3626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003627run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003628 "$P_SRV debug_level=3" \
3629 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003630 0 \
3631 -c "client hello, adding alpn extension" \
3632 -s "found alpn extension" \
3633 -C "got an alert message, type: \\[2:120]" \
3634 -S "server hello, adding alpn extension" \
3635 -C "found alpn extension " \
3636 -c "Application Layer Protocol is (none)" \
3637 -S "Application Layer Protocol is"
3638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003639run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003640 "$P_SRV debug_level=3 alpn=abc,1234" \
3641 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003642 0 \
3643 -C "client hello, adding alpn extension" \
3644 -S "found alpn extension" \
3645 -C "got an alert message, type: \\[2:120]" \
3646 -S "server hello, adding alpn extension" \
3647 -C "found alpn extension " \
3648 -C "Application Layer Protocol is" \
3649 -s "Application Layer Protocol is (none)"
3650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003651run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003652 "$P_SRV debug_level=3 alpn=abc,1234" \
3653 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003654 0 \
3655 -c "client hello, adding alpn extension" \
3656 -s "found alpn extension" \
3657 -C "got an alert message, type: \\[2:120]" \
3658 -s "server hello, adding alpn extension" \
3659 -c "found alpn extension" \
3660 -c "Application Layer Protocol is abc" \
3661 -s "Application Layer Protocol is abc"
3662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003663run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003664 "$P_SRV debug_level=3 alpn=abc,1234" \
3665 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003666 0 \
3667 -c "client hello, adding alpn extension" \
3668 -s "found alpn extension" \
3669 -C "got an alert message, type: \\[2:120]" \
3670 -s "server hello, adding alpn extension" \
3671 -c "found alpn extension" \
3672 -c "Application Layer Protocol is abc" \
3673 -s "Application Layer Protocol is abc"
3674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003675run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003676 "$P_SRV debug_level=3 alpn=abc,1234" \
3677 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003678 0 \
3679 -c "client hello, adding alpn extension" \
3680 -s "found alpn extension" \
3681 -C "got an alert message, type: \\[2:120]" \
3682 -s "server hello, adding alpn extension" \
3683 -c "found alpn extension" \
3684 -c "Application Layer Protocol is 1234" \
3685 -s "Application Layer Protocol is 1234"
3686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003687run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003688 "$P_SRV debug_level=3 alpn=abc,123" \
3689 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003690 1 \
3691 -c "client hello, adding alpn extension" \
3692 -s "found alpn extension" \
3693 -c "got an alert message, type: \\[2:120]" \
3694 -S "server hello, adding alpn extension" \
3695 -C "found alpn extension" \
3696 -C "Application Layer Protocol is 1234" \
3697 -S "Application Layer Protocol is 1234"
3698
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003699
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003700# Tests for keyUsage in leaf certificates, part 1:
3701# server-side certificate/suite selection
3702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003703run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003704 "$P_SRV key_file=data_files/server2.key \
3705 crt_file=data_files/server2.ku-ds.crt" \
3706 "$P_CLI" \
3707 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003708 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003709
3710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003711run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003712 "$P_SRV key_file=data_files/server2.key \
3713 crt_file=data_files/server2.ku-ke.crt" \
3714 "$P_CLI" \
3715 0 \
3716 -c "Ciphersuite is TLS-RSA-WITH-"
3717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003718run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003719 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003720 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003721 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003722 1 \
3723 -C "Ciphersuite is "
3724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003725run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003726 "$P_SRV key_file=data_files/server5.key \
3727 crt_file=data_files/server5.ku-ds.crt" \
3728 "$P_CLI" \
3729 0 \
3730 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3731
3732
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003733run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003734 "$P_SRV key_file=data_files/server5.key \
3735 crt_file=data_files/server5.ku-ka.crt" \
3736 "$P_CLI" \
3737 0 \
3738 -c "Ciphersuite is TLS-ECDH-"
3739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003740run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003741 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003742 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003743 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003744 1 \
3745 -C "Ciphersuite is "
3746
3747# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003748# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003750run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003751 "$O_SRV -key data_files/server2.key \
3752 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003753 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003754 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3755 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003756 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003757 -C "Processing of the Certificate handshake message failed" \
3758 -c "Ciphersuite is TLS-"
3759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003760run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003761 "$O_SRV -key data_files/server2.key \
3762 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003763 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003764 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3765 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003766 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003767 -C "Processing of the Certificate handshake message failed" \
3768 -c "Ciphersuite is TLS-"
3769
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003770run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003771 "$O_SRV -key data_files/server2.key \
3772 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003773 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003774 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3775 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003776 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003777 -C "Processing of the Certificate handshake message failed" \
3778 -c "Ciphersuite is TLS-"
3779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003780run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003781 "$O_SRV -key data_files/server2.key \
3782 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003783 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003784 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3785 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003786 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003787 -c "Processing of the Certificate handshake message failed" \
3788 -C "Ciphersuite is TLS-"
3789
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003790run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3791 "$O_SRV -key data_files/server2.key \
3792 -cert data_files/server2.ku-ke.crt" \
3793 "$P_CLI debug_level=1 auth_mode=optional \
3794 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3795 0 \
3796 -c "bad certificate (usage extensions)" \
3797 -C "Processing of the Certificate handshake message failed" \
3798 -c "Ciphersuite is TLS-" \
3799 -c "! Usage does not match the keyUsage extension"
3800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003801run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003802 "$O_SRV -key data_files/server2.key \
3803 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003804 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003805 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3806 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003807 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003808 -C "Processing of the Certificate handshake message failed" \
3809 -c "Ciphersuite is TLS-"
3810
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003811run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003812 "$O_SRV -key data_files/server2.key \
3813 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003814 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003815 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3816 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003817 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003818 -c "Processing of the Certificate handshake message failed" \
3819 -C "Ciphersuite is TLS-"
3820
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003821run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3822 "$O_SRV -key data_files/server2.key \
3823 -cert data_files/server2.ku-ds.crt" \
3824 "$P_CLI debug_level=1 auth_mode=optional \
3825 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3826 0 \
3827 -c "bad certificate (usage extensions)" \
3828 -C "Processing of the Certificate handshake message failed" \
3829 -c "Ciphersuite is TLS-" \
3830 -c "! Usage does not match the keyUsage extension"
3831
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003832# Tests for keyUsage in leaf certificates, part 3:
3833# server-side checking of client cert
3834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003835run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003836 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003837 "$O_CLI -key data_files/server2.key \
3838 -cert data_files/server2.ku-ds.crt" \
3839 0 \
3840 -S "bad certificate (usage extensions)" \
3841 -S "Processing of the Certificate handshake message failed"
3842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003843run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003844 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003845 "$O_CLI -key data_files/server2.key \
3846 -cert data_files/server2.ku-ke.crt" \
3847 0 \
3848 -s "bad certificate (usage extensions)" \
3849 -S "Processing of the Certificate handshake message failed"
3850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003851run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003852 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003853 "$O_CLI -key data_files/server2.key \
3854 -cert data_files/server2.ku-ke.crt" \
3855 1 \
3856 -s "bad certificate (usage extensions)" \
3857 -s "Processing of the Certificate handshake message failed"
3858
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003859run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003860 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003861 "$O_CLI -key data_files/server5.key \
3862 -cert data_files/server5.ku-ds.crt" \
3863 0 \
3864 -S "bad certificate (usage extensions)" \
3865 -S "Processing of the Certificate handshake message failed"
3866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003867run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003868 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003869 "$O_CLI -key data_files/server5.key \
3870 -cert data_files/server5.ku-ka.crt" \
3871 0 \
3872 -s "bad certificate (usage extensions)" \
3873 -S "Processing of the Certificate handshake message failed"
3874
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003875# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003877run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003878 "$P_SRV key_file=data_files/server5.key \
3879 crt_file=data_files/server5.eku-srv.crt" \
3880 "$P_CLI" \
3881 0
3882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003883run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003884 "$P_SRV key_file=data_files/server5.key \
3885 crt_file=data_files/server5.eku-srv.crt" \
3886 "$P_CLI" \
3887 0
3888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003889run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003890 "$P_SRV key_file=data_files/server5.key \
3891 crt_file=data_files/server5.eku-cs_any.crt" \
3892 "$P_CLI" \
3893 0
3894
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003895run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003896 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003897 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003898 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003899 1
3900
3901# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003903run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003904 "$O_SRV -key data_files/server5.key \
3905 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003906 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003907 0 \
3908 -C "bad certificate (usage extensions)" \
3909 -C "Processing of the Certificate handshake message failed" \
3910 -c "Ciphersuite is TLS-"
3911
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003912run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003913 "$O_SRV -key data_files/server5.key \
3914 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003915 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003916 0 \
3917 -C "bad certificate (usage extensions)" \
3918 -C "Processing of the Certificate handshake message failed" \
3919 -c "Ciphersuite is TLS-"
3920
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003921run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003922 "$O_SRV -key data_files/server5.key \
3923 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003924 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003925 0 \
3926 -C "bad certificate (usage extensions)" \
3927 -C "Processing of the Certificate handshake message failed" \
3928 -c "Ciphersuite is TLS-"
3929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003930run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003931 "$O_SRV -key data_files/server5.key \
3932 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003933 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003934 1 \
3935 -c "bad certificate (usage extensions)" \
3936 -c "Processing of the Certificate handshake message failed" \
3937 -C "Ciphersuite is TLS-"
3938
3939# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3940
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003941run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003942 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003943 "$O_CLI -key data_files/server5.key \
3944 -cert data_files/server5.eku-cli.crt" \
3945 0 \
3946 -S "bad certificate (usage extensions)" \
3947 -S "Processing of the Certificate handshake message failed"
3948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003949run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003950 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003951 "$O_CLI -key data_files/server5.key \
3952 -cert data_files/server5.eku-srv_cli.crt" \
3953 0 \
3954 -S "bad certificate (usage extensions)" \
3955 -S "Processing of the Certificate handshake message failed"
3956
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003957run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003958 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003959 "$O_CLI -key data_files/server5.key \
3960 -cert data_files/server5.eku-cs_any.crt" \
3961 0 \
3962 -S "bad certificate (usage extensions)" \
3963 -S "Processing of the Certificate handshake message failed"
3964
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003965run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003966 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003967 "$O_CLI -key data_files/server5.key \
3968 -cert data_files/server5.eku-cs.crt" \
3969 0 \
3970 -s "bad certificate (usage extensions)" \
3971 -S "Processing of the Certificate handshake message failed"
3972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003973run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003974 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003975 "$O_CLI -key data_files/server5.key \
3976 -cert data_files/server5.eku-cs.crt" \
3977 1 \
3978 -s "bad certificate (usage extensions)" \
3979 -s "Processing of the Certificate handshake message failed"
3980
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003981# Tests for DHM parameters loading
3982
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003983run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003984 "$P_SRV" \
3985 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3986 debug_level=3" \
3987 0 \
3988 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003989 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003990
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003991run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003992 "$P_SRV dhm_file=data_files/dhparams.pem" \
3993 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3994 debug_level=3" \
3995 0 \
3996 -c "value of 'DHM: P ' (1024 bits)" \
3997 -c "value of 'DHM: G ' (2 bits)"
3998
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003999# Tests for DHM client-side size checking
4000
4001run_test "DHM size: server default, client default, OK" \
4002 "$P_SRV" \
4003 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4004 debug_level=1" \
4005 0 \
4006 -C "DHM prime too short:"
4007
4008run_test "DHM size: server default, client 2048, OK" \
4009 "$P_SRV" \
4010 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4011 debug_level=1 dhmlen=2048" \
4012 0 \
4013 -C "DHM prime too short:"
4014
4015run_test "DHM size: server 1024, client default, OK" \
4016 "$P_SRV dhm_file=data_files/dhparams.pem" \
4017 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4018 debug_level=1" \
4019 0 \
4020 -C "DHM prime too short:"
4021
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004022run_test "DHM size: server 999, client 999, OK" \
4023 "$P_SRV dhm_file=data_files/dh.999.pem" \
4024 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4025 debug_level=1 dhmlen=999" \
4026 0 \
4027 -C "DHM prime too short:"
4028
4029run_test "DHM size: server 1000, client 1000, OK" \
4030 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4031 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4032 debug_level=1 dhmlen=1000" \
4033 0 \
4034 -C "DHM prime too short:"
4035
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004036run_test "DHM size: server 1000, client default, rejected" \
4037 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4038 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4039 debug_level=1" \
4040 1 \
4041 -c "DHM prime too short:"
4042
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004043run_test "DHM size: server 1000, client 1001, rejected" \
4044 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4045 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4046 debug_level=1 dhmlen=1001" \
4047 1 \
4048 -c "DHM prime too short:"
4049
4050run_test "DHM size: server 999, client 1000, rejected" \
4051 "$P_SRV dhm_file=data_files/dh.999.pem" \
4052 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4053 debug_level=1 dhmlen=1000" \
4054 1 \
4055 -c "DHM prime too short:"
4056
4057run_test "DHM size: server 998, client 999, rejected" \
4058 "$P_SRV dhm_file=data_files/dh.998.pem" \
4059 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4060 debug_level=1 dhmlen=999" \
4061 1 \
4062 -c "DHM prime too short:"
4063
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004064run_test "DHM size: server default, client 2049, rejected" \
4065 "$P_SRV" \
4066 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4067 debug_level=1 dhmlen=2049" \
4068 1 \
4069 -c "DHM prime too short:"
4070
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004071# Tests for PSK callback
4072
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004073run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004074 "$P_SRV psk=abc123 psk_identity=foo" \
4075 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4076 psk_identity=foo psk=abc123" \
4077 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004078 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004079 -S "SSL - Unknown identity received" \
4080 -S "SSL - Verification of the message MAC failed"
4081
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004082run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004083 "$P_SRV" \
4084 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4085 psk_identity=foo psk=abc123" \
4086 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004087 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004088 -S "SSL - Unknown identity received" \
4089 -S "SSL - Verification of the message MAC failed"
4090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004091run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004092 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4093 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4094 psk_identity=foo psk=abc123" \
4095 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004096 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004097 -s "SSL - Unknown identity received" \
4098 -S "SSL - Verification of the message MAC failed"
4099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004100run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004101 "$P_SRV psk_list=abc,dead,def,beef" \
4102 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4103 psk_identity=abc psk=dead" \
4104 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004105 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004106 -S "SSL - Unknown identity received" \
4107 -S "SSL - Verification of the message MAC failed"
4108
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004109run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004110 "$P_SRV psk_list=abc,dead,def,beef" \
4111 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4112 psk_identity=def psk=beef" \
4113 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004114 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004115 -S "SSL - Unknown identity received" \
4116 -S "SSL - Verification of the message MAC failed"
4117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004118run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004119 "$P_SRV psk_list=abc,dead,def,beef" \
4120 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4121 psk_identity=ghi psk=beef" \
4122 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004123 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004124 -s "SSL - Unknown identity received" \
4125 -S "SSL - Verification of the message MAC failed"
4126
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004127run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004128 "$P_SRV psk_list=abc,dead,def,beef" \
4129 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4130 psk_identity=abc psk=beef" \
4131 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004132 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004133 -S "SSL - Unknown identity received" \
4134 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004135
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004136# Tests for EC J-PAKE
4137
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004138requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004139run_test "ECJPAKE: client not configured" \
4140 "$P_SRV debug_level=3" \
4141 "$P_CLI debug_level=3" \
4142 0 \
4143 -C "add ciphersuite: c0ff" \
4144 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004145 -S "found ecjpake kkpp extension" \
4146 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004147 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004148 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004149 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004150 -S "None of the common ciphersuites is usable"
4151
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004152requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004153run_test "ECJPAKE: server not configured" \
4154 "$P_SRV debug_level=3" \
4155 "$P_CLI debug_level=3 ecjpake_pw=bla \
4156 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4157 1 \
4158 -c "add ciphersuite: c0ff" \
4159 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004160 -s "found ecjpake kkpp extension" \
4161 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004162 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004163 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004164 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004165 -s "None of the common ciphersuites is usable"
4166
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004167requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004168run_test "ECJPAKE: working, TLS" \
4169 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4170 "$P_CLI debug_level=3 ecjpake_pw=bla \
4171 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004172 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004173 -c "add ciphersuite: c0ff" \
4174 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004175 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004176 -s "found ecjpake kkpp extension" \
4177 -S "skip ecjpake kkpp extension" \
4178 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004179 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004180 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004181 -S "None of the common ciphersuites is usable" \
4182 -S "SSL - Verification of the message MAC failed"
4183
Janos Follath74537a62016-09-02 13:45:28 +01004184server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004185requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004186run_test "ECJPAKE: password mismatch, TLS" \
4187 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4188 "$P_CLI debug_level=3 ecjpake_pw=bad \
4189 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4190 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004191 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004192 -s "SSL - Verification of the message MAC failed"
4193
Dave Rodgmancee9e922021-06-29 19:05:34 +01004194requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004195run_test "ECJPAKE: working, DTLS" \
4196 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4197 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4198 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4199 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004200 -c "re-using cached ecjpake parameters" \
4201 -S "SSL - Verification of the message MAC failed"
4202
Dave Rodgmancee9e922021-06-29 19:05:34 +01004203requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004204run_test "ECJPAKE: working, DTLS, no cookie" \
4205 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4206 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4207 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4208 0 \
4209 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004210 -S "SSL - Verification of the message MAC failed"
4211
Janos Follath74537a62016-09-02 13:45:28 +01004212server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004213requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004214run_test "ECJPAKE: password mismatch, DTLS" \
4215 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4216 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4217 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4218 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004219 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004220 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004221
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004222# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004223requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004224run_test "ECJPAKE: working, DTLS, nolog" \
4225 "$P_SRV dtls=1 ecjpake_pw=bla" \
4226 "$P_CLI dtls=1 ecjpake_pw=bla \
4227 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4228 0
4229
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004230# Tests for ciphersuites per version
4231
Janos Follathe2681a42016-03-07 15:57:05 +00004232requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004233requires_config_enabled MBEDTLS_CAMELLIA_C
4234requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004235run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004236 "$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 +02004237 "$P_CLI force_version=ssl3" \
4238 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004239 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004240
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004241requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4242requires_config_enabled MBEDTLS_CAMELLIA_C
4243requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004244run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004245 "$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 +01004246 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004247 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004248 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004249
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004250requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4251requires_config_enabled MBEDTLS_CAMELLIA_C
4252requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004253run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004254 "$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 +02004255 "$P_CLI force_version=tls1_1" \
4256 0 \
4257 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4258
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004259requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4260requires_config_enabled MBEDTLS_CAMELLIA_C
4261requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004262run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004263 "$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 +02004264 "$P_CLI force_version=tls1_2" \
4265 0 \
4266 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4267
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004268# Test for ClientHello without extensions
4269
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004270requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004271run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004272 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004273 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004274 0 \
4275 -s "dumping 'client hello extensions' (0 bytes)"
4276
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004277# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004278
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004279run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004280 "$P_SRV" \
4281 "$P_CLI request_size=100" \
4282 0 \
4283 -s "Read from client: 100 bytes read$"
4284
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004285run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004286 "$P_SRV" \
4287 "$P_CLI request_size=500" \
4288 0 \
4289 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004290
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004291# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004292
Janos Follathe2681a42016-03-07 15:57:05 +00004293requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004294run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004295 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004296 "$P_CLI request_size=1 force_version=ssl3 \
4297 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4298 0 \
4299 -s "Read from client: 1 bytes read"
4300
Janos Follathe2681a42016-03-07 15:57:05 +00004301requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004302run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004303 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004304 "$P_CLI request_size=1 force_version=ssl3 \
4305 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4306 0 \
4307 -s "Read from client: 1 bytes read"
4308
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004309run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004310 "$P_SRV" \
4311 "$P_CLI request_size=1 force_version=tls1 \
4312 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4313 0 \
4314 -s "Read from client: 1 bytes read"
4315
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004316run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004317 "$P_SRV" \
4318 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4319 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4320 0 \
4321 -s "Read from client: 1 bytes read"
4322
Hanno Becker32c55012017-11-10 08:42:54 +00004323requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004324run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004325 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004326 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004327 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004328 0 \
4329 -s "Read from client: 1 bytes read"
4330
Hanno Becker32c55012017-11-10 08:42:54 +00004331requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004332run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004333 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004334 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004335 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004336 0 \
4337 -s "Read from client: 1 bytes read"
4338
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004339run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004340 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004341 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004342 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4343 0 \
4344 -s "Read from client: 1 bytes read"
4345
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004346run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004347 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4348 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004349 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004350 0 \
4351 -s "Read from client: 1 bytes read"
4352
4353requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004354run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004355 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004356 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004357 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004358 0 \
4359 -s "Read from client: 1 bytes read"
4360
Hanno Becker8501f982017-11-10 08:59:04 +00004361requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004362run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004363 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4364 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4365 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004366 0 \
4367 -s "Read from client: 1 bytes read"
4368
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004369run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004370 "$P_SRV" \
4371 "$P_CLI request_size=1 force_version=tls1_1 \
4372 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4373 0 \
4374 -s "Read from client: 1 bytes read"
4375
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004376run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004377 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004378 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004379 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004380 0 \
4381 -s "Read from client: 1 bytes read"
4382
4383requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004384run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004385 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004386 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004387 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004388 0 \
4389 -s "Read from client: 1 bytes read"
4390
4391requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004392run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004393 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004394 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004396 0 \
4397 -s "Read from client: 1 bytes read"
4398
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004399run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004400 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004401 "$P_CLI request_size=1 force_version=tls1_1 \
4402 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4403 0 \
4404 -s "Read from client: 1 bytes read"
4405
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004406run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004407 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004408 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004409 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004410 0 \
4411 -s "Read from client: 1 bytes read"
4412
Hanno Becker8501f982017-11-10 08:59:04 +00004413requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004414run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004415 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004416 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004417 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004418 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.1 StreamCipher, without EtM, 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_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004425 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004426 0 \
4427 -s "Read from client: 1 bytes read"
4428
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004429run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004430 "$P_SRV" \
4431 "$P_CLI request_size=1 force_version=tls1_2 \
4432 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4433 0 \
4434 -s "Read from client: 1 bytes read"
4435
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004436run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004437 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004438 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004440 0 \
4441 -s "Read from client: 1 bytes read"
4442
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004443run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004444 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004445 "$P_CLI request_size=1 force_version=tls1_2 \
4446 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004447 0 \
4448 -s "Read from client: 1 bytes read"
4449
Hanno Becker32c55012017-11-10 08:42:54 +00004450requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004451run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004452 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004453 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004454 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004455 0 \
4456 -s "Read from client: 1 bytes read"
4457
Hanno Becker8501f982017-11-10 08:59:04 +00004458requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004459run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004460 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004461 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004462 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004463 0 \
4464 -s "Read from client: 1 bytes read"
4465
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004466run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004467 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004468 "$P_CLI request_size=1 force_version=tls1_2 \
4469 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4470 0 \
4471 -s "Read from client: 1 bytes read"
4472
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004473run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004474 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004475 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004476 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004477 0 \
4478 -s "Read from client: 1 bytes read"
4479
Hanno Becker32c55012017-11-10 08:42:54 +00004480requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004481run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004482 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004483 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004485 0 \
4486 -s "Read from client: 1 bytes read"
4487
Hanno Becker8501f982017-11-10 08:59:04 +00004488requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004489run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004490 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004491 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004492 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004493 0 \
4494 -s "Read from client: 1 bytes read"
4495
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004496run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004497 "$P_SRV" \
4498 "$P_CLI request_size=1 force_version=tls1_2 \
4499 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4500 0 \
4501 -s "Read from client: 1 bytes read"
4502
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004503run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004504 "$P_SRV" \
4505 "$P_CLI request_size=1 force_version=tls1_2 \
4506 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4507 0 \
4508 -s "Read from client: 1 bytes read"
4509
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004510# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004511
4512requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004513run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004514 "$P_SRV dtls=1 force_version=dtls1" \
4515 "$P_CLI dtls=1 request_size=1 \
4516 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4517 0 \
4518 -s "Read from client: 1 bytes read"
4519
4520requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004521run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004522 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4523 "$P_CLI dtls=1 request_size=1 \
4524 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4525 0 \
4526 -s "Read from client: 1 bytes read"
4527
4528requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4529requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004530run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004531 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4532 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004533 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4534 0 \
4535 -s "Read from client: 1 bytes read"
4536
4537requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4538requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004539run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004540 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004541 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004542 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004543 0 \
4544 -s "Read from client: 1 bytes read"
4545
4546requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004547run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004548 "$P_SRV dtls=1 force_version=dtls1_2" \
4549 "$P_CLI dtls=1 request_size=1 \
4550 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4551 0 \
4552 -s "Read from client: 1 bytes read"
4553
4554requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004555run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004556 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004557 "$P_CLI dtls=1 request_size=1 \
4558 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4559 0 \
4560 -s "Read from client: 1 bytes read"
4561
4562requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4563requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004564run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004565 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004566 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004567 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004568 0 \
4569 -s "Read from client: 1 bytes read"
4570
4571requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4572requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004573run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004574 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004575 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004576 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004577 0 \
4578 -s "Read from client: 1 bytes read"
4579
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004580# Tests for small server packets
4581
4582requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4583run_test "Small server packet SSLv3 BlockCipher" \
4584 "$P_SRV response_size=1 min_version=ssl3" \
4585 "$P_CLI force_version=ssl3 \
4586 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4587 0 \
4588 -c "Read from server: 1 bytes read"
4589
4590requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4591run_test "Small server packet SSLv3 StreamCipher" \
4592 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4593 "$P_CLI force_version=ssl3 \
4594 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4595 0 \
4596 -c "Read from server: 1 bytes read"
4597
4598run_test "Small server packet TLS 1.0 BlockCipher" \
4599 "$P_SRV response_size=1" \
4600 "$P_CLI force_version=tls1 \
4601 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4602 0 \
4603 -c "Read from server: 1 bytes read"
4604
4605run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4606 "$P_SRV response_size=1" \
4607 "$P_CLI force_version=tls1 etm=0 \
4608 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4609 0 \
4610 -c "Read from server: 1 bytes read"
4611
4612requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4613run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4614 "$P_SRV response_size=1 trunc_hmac=1" \
4615 "$P_CLI force_version=tls1 \
4616 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4617 0 \
4618 -c "Read from server: 1 bytes read"
4619
4620requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4621run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4622 "$P_SRV response_size=1 trunc_hmac=1" \
4623 "$P_CLI force_version=tls1 \
4624 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4625 0 \
4626 -c "Read from server: 1 bytes read"
4627
4628run_test "Small server packet TLS 1.0 StreamCipher" \
4629 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4630 "$P_CLI force_version=tls1 \
4631 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4632 0 \
4633 -c "Read from server: 1 bytes read"
4634
4635run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4636 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4637 "$P_CLI force_version=tls1 \
4638 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4639 0 \
4640 -c "Read from server: 1 bytes read"
4641
4642requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4643run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4644 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4645 "$P_CLI force_version=tls1 \
4646 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4647 0 \
4648 -c "Read from server: 1 bytes read"
4649
4650requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4651run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4652 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4653 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4654 trunc_hmac=1 etm=0" \
4655 0 \
4656 -c "Read from server: 1 bytes read"
4657
4658run_test "Small server packet TLS 1.1 BlockCipher" \
4659 "$P_SRV response_size=1" \
4660 "$P_CLI force_version=tls1_1 \
4661 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4662 0 \
4663 -c "Read from server: 1 bytes read"
4664
4665run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4666 "$P_SRV response_size=1" \
4667 "$P_CLI force_version=tls1_1 \
4668 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4669 0 \
4670 -c "Read from server: 1 bytes read"
4671
4672requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4673run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4674 "$P_SRV response_size=1 trunc_hmac=1" \
4675 "$P_CLI force_version=tls1_1 \
4676 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
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.1 BlockCipher, without EtM, truncated MAC" \
4682 "$P_SRV response_size=1 trunc_hmac=1" \
4683 "$P_CLI force_version=tls1_1 \
4684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4685 0 \
4686 -c "Read from server: 1 bytes read"
4687
4688run_test "Small server packet TLS 1.1 StreamCipher" \
4689 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4690 "$P_CLI force_version=tls1_1 \
4691 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4692 0 \
4693 -c "Read from server: 1 bytes read"
4694
4695run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4696 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4697 "$P_CLI force_version=tls1_1 \
4698 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4699 0 \
4700 -c "Read from server: 1 bytes read"
4701
4702requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4703run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4704 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4705 "$P_CLI force_version=tls1_1 \
4706 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
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.1 StreamCipher, without EtM, 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_1 \
4714 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4715 0 \
4716 -c "Read from server: 1 bytes read"
4717
4718run_test "Small server packet TLS 1.2 BlockCipher" \
4719 "$P_SRV response_size=1" \
4720 "$P_CLI force_version=tls1_2 \
4721 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4722 0 \
4723 -c "Read from server: 1 bytes read"
4724
4725run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4726 "$P_SRV response_size=1" \
4727 "$P_CLI force_version=tls1_2 \
4728 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4729 0 \
4730 -c "Read from server: 1 bytes read"
4731
4732run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4733 "$P_SRV response_size=1" \
4734 "$P_CLI force_version=tls1_2 \
4735 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4736 0 \
4737 -c "Read from server: 1 bytes read"
4738
4739requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4740run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4741 "$P_SRV response_size=1 trunc_hmac=1" \
4742 "$P_CLI force_version=tls1_2 \
4743 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4744 0 \
4745 -c "Read from server: 1 bytes read"
4746
4747requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4748run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4749 "$P_SRV response_size=1 trunc_hmac=1" \
4750 "$P_CLI force_version=tls1_2 \
4751 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4752 0 \
4753 -c "Read from server: 1 bytes read"
4754
4755run_test "Small server packet TLS 1.2 StreamCipher" \
4756 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4757 "$P_CLI force_version=tls1_2 \
4758 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4759 0 \
4760 -c "Read from server: 1 bytes read"
4761
4762run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4763 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4764 "$P_CLI force_version=tls1_2 \
4765 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4766 0 \
4767 -c "Read from server: 1 bytes read"
4768
4769requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4770run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4771 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4772 "$P_CLI force_version=tls1_2 \
4773 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4774 0 \
4775 -c "Read from server: 1 bytes read"
4776
4777requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4778run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4779 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4780 "$P_CLI force_version=tls1_2 \
4781 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4782 0 \
4783 -c "Read from server: 1 bytes read"
4784
4785run_test "Small server packet TLS 1.2 AEAD" \
4786 "$P_SRV response_size=1" \
4787 "$P_CLI force_version=tls1_2 \
4788 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4789 0 \
4790 -c "Read from server: 1 bytes read"
4791
4792run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4793 "$P_SRV response_size=1" \
4794 "$P_CLI force_version=tls1_2 \
4795 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4796 0 \
4797 -c "Read from server: 1 bytes read"
4798
4799# Tests for small server packets in DTLS
4800
4801requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4802run_test "Small server packet DTLS 1.0" \
4803 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4804 "$P_CLI dtls=1 \
4805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4806 0 \
4807 -c "Read from server: 1 bytes read"
4808
4809requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4810run_test "Small server packet DTLS 1.0, without EtM" \
4811 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4812 "$P_CLI dtls=1 \
4813 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4814 0 \
4815 -c "Read from server: 1 bytes read"
4816
4817requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4818requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4819run_test "Small server packet DTLS 1.0, truncated hmac" \
4820 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4821 "$P_CLI dtls=1 trunc_hmac=1 \
4822 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4823 0 \
4824 -c "Read from server: 1 bytes read"
4825
4826requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4827requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4828run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4829 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4830 "$P_CLI dtls=1 \
4831 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4832 0 \
4833 -c "Read from server: 1 bytes read"
4834
4835requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4836run_test "Small server packet DTLS 1.2" \
4837 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4838 "$P_CLI dtls=1 \
4839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4840 0 \
4841 -c "Read from server: 1 bytes read"
4842
4843requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4844run_test "Small server packet DTLS 1.2, without EtM" \
4845 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4846 "$P_CLI dtls=1 \
4847 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4848 0 \
4849 -c "Read from server: 1 bytes read"
4850
4851requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4852requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4853run_test "Small server packet DTLS 1.2, truncated hmac" \
4854 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4855 "$P_CLI dtls=1 \
4856 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4857 0 \
4858 -c "Read from server: 1 bytes read"
4859
4860requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4861requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4862run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4863 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4864 "$P_CLI dtls=1 \
4865 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4866 0 \
4867 -c "Read from server: 1 bytes read"
4868
Janos Follath00efff72016-05-06 13:48:23 +01004869# A test for extensions in SSLv3
Yuto Takanoc75df632021-07-08 15:56:33 +01004870requires_max_content_len 4096
Janos Follath00efff72016-05-06 13:48:23 +01004871requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4872run_test "SSLv3 with extensions, server side" \
4873 "$P_SRV min_version=ssl3 debug_level=3" \
4874 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4875 0 \
4876 -S "dumping 'client hello extensions'" \
4877 -S "server hello, total extension length:"
4878
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004879# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004880
Angus Grattonc4dd0732018-04-11 16:28:39 +10004881# How many fragments do we expect to write $1 bytes?
4882fragments_for_write() {
4883 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4884}
4885
Janos Follathe2681a42016-03-07 15:57:05 +00004886requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004887run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004888 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004889 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004890 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4891 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004892 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4893 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004894
Janos Follathe2681a42016-03-07 15:57:05 +00004895requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004896run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004897 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004898 "$P_CLI request_size=16384 force_version=ssl3 \
4899 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4900 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004901 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4902 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004903
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004904run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004905 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004906 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4908 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004909 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4910 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004912run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004913 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004914 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4916 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004917 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004918
Hanno Becker32c55012017-11-10 08:42:54 +00004919requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004920run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004921 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004922 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004923 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004924 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004925 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4926 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004927
Hanno Becker32c55012017-11-10 08:42:54 +00004928requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004929run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004930 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004931 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004932 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004933 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004934 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004935
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004936run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004937 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004938 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004939 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4940 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004941 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004942
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004943run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004944 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4945 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004946 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004947 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004948 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004949
4950requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004951run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004952 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004954 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004955 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004956 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004957
Hanno Becker278fc7a2017-11-10 09:16:28 +00004958requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004959run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004960 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004961 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004962 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004963 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004964 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4965 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004966
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004967run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004968 "$P_SRV" \
4969 "$P_CLI request_size=16384 force_version=tls1_1 \
4970 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4971 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004972 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4973 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004974
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004975run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004976 "$P_SRV" \
4977 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4978 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004979 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004980 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004981
Hanno Becker32c55012017-11-10 08:42:54 +00004982requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004983run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004984 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004985 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004986 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004987 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004988 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004989
Hanno Becker32c55012017-11-10 08:42:54 +00004990requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004991run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004992 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004993 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004994 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004995 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004996 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004997
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004998run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004999 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5000 "$P_CLI request_size=16384 force_version=tls1_1 \
5001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5002 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005003 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5004 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005005
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005006run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005007 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005008 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005009 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005010 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005011 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5012 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005013
Hanno Becker278fc7a2017-11-10 09:16:28 +00005014requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005015run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005016 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005017 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005018 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005019 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005020 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005021
Hanno Becker278fc7a2017-11-10 09:16:28 +00005022requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005023run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005024 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005025 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005026 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005027 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005028 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5029 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005030
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005031run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005032 "$P_SRV" \
5033 "$P_CLI request_size=16384 force_version=tls1_2 \
5034 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5035 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005036 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5037 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005038
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005039run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005040 "$P_SRV" \
5041 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
5042 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5043 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005044 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005045
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005046run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005047 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005048 "$P_CLI request_size=16384 force_version=tls1_2 \
5049 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005050 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005051 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5052 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005053
Hanno Becker32c55012017-11-10 08:42:54 +00005054requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005055run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005056 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005057 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005058 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005059 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005060 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005061
Hanno Becker278fc7a2017-11-10 09:16:28 +00005062requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005063run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005064 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005065 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005066 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005067 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005068 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5069 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005070
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005071run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005072 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005073 "$P_CLI request_size=16384 force_version=tls1_2 \
5074 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5075 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005076 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5077 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005078
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005079run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005080 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005081 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005082 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5083 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005084 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005085
Hanno Becker32c55012017-11-10 08:42:54 +00005086requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005087run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005088 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005089 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005090 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005091 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005092 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005093
Hanno Becker278fc7a2017-11-10 09:16:28 +00005094requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005095run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005096 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005097 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005099 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005100 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5101 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005102
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005103run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005104 "$P_SRV" \
5105 "$P_CLI request_size=16384 force_version=tls1_2 \
5106 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5107 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005108 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5109 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005110
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005111run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005112 "$P_SRV" \
5113 "$P_CLI request_size=16384 force_version=tls1_2 \
5114 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5115 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005116 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5117 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005118
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005119# Test for large server packets
Yuto Takanoc75df632021-07-08 15:56:33 +01005120# The tests below fail when the server's OUT_CONTENT_LEN is less than 16384.
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005121requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5122run_test "Large server packet SSLv3 StreamCipher" \
5123 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5124 "$P_CLI force_version=ssl3 \
5125 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5126 0 \
5127 -c "Read from server: 16384 bytes read"
5128
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005129# Checking next 4 tests logs for 1n-1 split against BEAST too
5130requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5131run_test "Large server packet SSLv3 BlockCipher" \
5132 "$P_SRV response_size=16384 min_version=ssl3" \
5133 "$P_CLI force_version=ssl3 recsplit=0 \
5134 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5135 0 \
5136 -c "Read from server: 1 bytes read"\
5137 -c "16383 bytes read"\
5138 -C "Read from server: 16384 bytes read"
5139
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005140run_test "Large server packet TLS 1.0 BlockCipher" \
5141 "$P_SRV response_size=16384" \
5142 "$P_CLI force_version=tls1 recsplit=0 \
5143 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5144 0 \
5145 -c "Read from server: 1 bytes read"\
5146 -c "16383 bytes read"\
5147 -C "Read from server: 16384 bytes read"
5148
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005149run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5150 "$P_SRV response_size=16384" \
5151 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5152 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5153 0 \
5154 -c "Read from server: 1 bytes read"\
5155 -c "16383 bytes read"\
5156 -C "Read from server: 16384 bytes read"
5157
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005158requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5159run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5160 "$P_SRV response_size=16384" \
5161 "$P_CLI force_version=tls1 recsplit=0 \
5162 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5163 trunc_hmac=1" \
5164 0 \
5165 -c "Read from server: 1 bytes read"\
5166 -c "16383 bytes read"\
5167 -C "Read from server: 16384 bytes read"
5168
5169requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5170run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5171 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5172 "$P_CLI force_version=tls1 \
5173 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5174 trunc_hmac=1" \
5175 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005176 -s "16384 bytes written in 1 fragments" \
5177 -c "Read from server: 16384 bytes read"
5178
5179run_test "Large server packet TLS 1.0 StreamCipher" \
5180 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5181 "$P_CLI force_version=tls1 \
5182 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5183 0 \
5184 -s "16384 bytes written in 1 fragments" \
5185 -c "Read from server: 16384 bytes read"
5186
5187run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5188 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5189 "$P_CLI force_version=tls1 \
5190 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5191 0 \
5192 -s "16384 bytes written in 1 fragments" \
5193 -c "Read from server: 16384 bytes read"
5194
5195requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5196run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5197 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5198 "$P_CLI force_version=tls1 \
5199 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5200 0 \
5201 -s "16384 bytes written in 1 fragments" \
5202 -c "Read from server: 16384 bytes read"
5203
5204requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5205run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5206 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5207 "$P_CLI force_version=tls1 \
5208 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5209 0 \
5210 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005211 -c "Read from server: 16384 bytes read"
5212
5213run_test "Large server packet TLS 1.1 BlockCipher" \
5214 "$P_SRV response_size=16384" \
5215 "$P_CLI force_version=tls1_1 \
5216 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5217 0 \
5218 -c "Read from server: 16384 bytes read"
5219
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005220run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5221 "$P_SRV response_size=16384" \
5222 "$P_CLI force_version=tls1_1 etm=0 \
5223 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005224 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005225 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005226 -c "Read from server: 16384 bytes read"
5227
5228requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5229run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5230 "$P_SRV response_size=16384" \
5231 "$P_CLI force_version=tls1_1 \
5232 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5233 trunc_hmac=1" \
5234 0 \
5235 -c "Read from server: 16384 bytes read"
5236
5237requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005238run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5239 "$P_SRV response_size=16384 trunc_hmac=1" \
5240 "$P_CLI force_version=tls1_1 \
5241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5242 0 \
5243 -s "16384 bytes written in 1 fragments" \
5244 -c "Read from server: 16384 bytes read"
5245
5246run_test "Large server packet TLS 1.1 StreamCipher" \
5247 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5248 "$P_CLI force_version=tls1_1 \
5249 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5250 0 \
5251 -c "Read from server: 16384 bytes read"
5252
5253run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5254 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5255 "$P_CLI force_version=tls1_1 \
5256 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5257 0 \
5258 -s "16384 bytes written in 1 fragments" \
5259 -c "Read from server: 16384 bytes read"
5260
5261requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005262run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5263 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5264 "$P_CLI force_version=tls1_1 \
5265 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5266 trunc_hmac=1" \
5267 0 \
5268 -c "Read from server: 16384 bytes read"
5269
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005270run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5271 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5272 "$P_CLI force_version=tls1_1 \
5273 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5274 0 \
5275 -s "16384 bytes written in 1 fragments" \
5276 -c "Read from server: 16384 bytes read"
5277
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005278run_test "Large server packet TLS 1.2 BlockCipher" \
5279 "$P_SRV response_size=16384" \
5280 "$P_CLI force_version=tls1_2 \
5281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5282 0 \
5283 -c "Read from server: 16384 bytes read"
5284
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005285run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5286 "$P_SRV response_size=16384" \
5287 "$P_CLI force_version=tls1_2 etm=0 \
5288 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5289 0 \
5290 -s "16384 bytes written in 1 fragments" \
5291 -c "Read from server: 16384 bytes read"
5292
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005293run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5294 "$P_SRV response_size=16384" \
5295 "$P_CLI force_version=tls1_2 \
5296 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5297 0 \
5298 -c "Read from server: 16384 bytes read"
5299
5300requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5301run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5302 "$P_SRV response_size=16384" \
5303 "$P_CLI force_version=tls1_2 \
5304 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5305 trunc_hmac=1" \
5306 0 \
5307 -c "Read from server: 16384 bytes read"
5308
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005309run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5310 "$P_SRV response_size=16384 trunc_hmac=1" \
5311 "$P_CLI force_version=tls1_2 \
5312 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5313 0 \
5314 -s "16384 bytes written in 1 fragments" \
5315 -c "Read from server: 16384 bytes read"
5316
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005317run_test "Large server packet TLS 1.2 StreamCipher" \
5318 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5319 "$P_CLI force_version=tls1_2 \
5320 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5321 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005322 -s "16384 bytes written in 1 fragments" \
5323 -c "Read from server: 16384 bytes read"
5324
5325run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5326 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5327 "$P_CLI force_version=tls1_2 \
5328 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5329 0 \
5330 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005331 -c "Read from server: 16384 bytes read"
5332
5333requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5334run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5335 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5336 "$P_CLI force_version=tls1_2 \
5337 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5338 trunc_hmac=1" \
5339 0 \
5340 -c "Read from server: 16384 bytes read"
5341
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005342requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5343run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5344 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5345 "$P_CLI force_version=tls1_2 \
5346 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5347 0 \
5348 -s "16384 bytes written in 1 fragments" \
5349 -c "Read from server: 16384 bytes read"
5350
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005351run_test "Large server packet TLS 1.2 AEAD" \
5352 "$P_SRV response_size=16384" \
5353 "$P_CLI force_version=tls1_2 \
5354 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5355 0 \
5356 -c "Read from server: 16384 bytes read"
5357
5358run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5359 "$P_SRV response_size=16384" \
5360 "$P_CLI force_version=tls1_2 \
5361 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5362 0 \
5363 -c "Read from server: 16384 bytes read"
5364
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005365# Tests for restartable ECC
5366
5367requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5368run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005369 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005370 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005371 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005372 debug_level=1" \
5373 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005374 -C "x509_verify_cert.*4b00" \
5375 -C "mbedtls_pk_verify.*4b00" \
5376 -C "mbedtls_ecdh_make_public.*4b00" \
5377 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005378
5379requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5380run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005381 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005382 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005383 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005384 debug_level=1 ec_max_ops=0" \
5385 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005386 -C "x509_verify_cert.*4b00" \
5387 -C "mbedtls_pk_verify.*4b00" \
5388 -C "mbedtls_ecdh_make_public.*4b00" \
5389 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005390
5391requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5392run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005393 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005394 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005395 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005396 debug_level=1 ec_max_ops=65535" \
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é-Gonnard2350b4e2017-05-16 09:26:48 +02005402
5403requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5404run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005405 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005406 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005407 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005408 debug_level=1 ec_max_ops=1000" \
5409 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005410 -c "x509_verify_cert.*4b00" \
5411 -c "mbedtls_pk_verify.*4b00" \
5412 -c "mbedtls_ecdh_make_public.*4b00" \
5413 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005414
5415requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005416run_test "EC restart: TLS, max_ops=1000, badsign" \
5417 "$P_SRV auth_mode=required \
5418 crt_file=data_files/server5-badsign.crt \
5419 key_file=data_files/server5.key" \
5420 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5421 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5422 debug_level=1 ec_max_ops=1000" \
5423 1 \
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é-Gonnard3bf49c42017-08-15 13:47:06 +02005428 -c "! The certificate is not correctly signed by the trusted CA" \
5429 -c "! mbedtls_ssl_handshake returned" \
5430 -c "X509 - Certificate verification failed"
5431
5432requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5433run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5434 "$P_SRV auth_mode=required \
5435 crt_file=data_files/server5-badsign.crt \
5436 key_file=data_files/server5.key" \
5437 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5438 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5439 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5440 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005441 -c "x509_verify_cert.*4b00" \
5442 -c "mbedtls_pk_verify.*4b00" \
5443 -c "mbedtls_ecdh_make_public.*4b00" \
5444 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005445 -c "! The certificate is not correctly signed by the trusted CA" \
5446 -C "! mbedtls_ssl_handshake returned" \
5447 -C "X509 - Certificate verification failed"
5448
5449requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5450run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5451 "$P_SRV auth_mode=required \
5452 crt_file=data_files/server5-badsign.crt \
5453 key_file=data_files/server5.key" \
5454 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5455 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5456 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5457 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005458 -C "x509_verify_cert.*4b00" \
5459 -c "mbedtls_pk_verify.*4b00" \
5460 -c "mbedtls_ecdh_make_public.*4b00" \
5461 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005462 -C "! The certificate is not correctly signed by the trusted CA" \
5463 -C "! mbedtls_ssl_handshake returned" \
5464 -C "X509 - Certificate verification failed"
5465
5466requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005467run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005468 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005469 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005470 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005471 dtls=1 debug_level=1 ec_max_ops=1000" \
5472 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005473 -c "x509_verify_cert.*4b00" \
5474 -c "mbedtls_pk_verify.*4b00" \
5475 -c "mbedtls_ecdh_make_public.*4b00" \
5476 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005477
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005478requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5479run_test "EC restart: TLS, max_ops=1000 no client auth" \
5480 "$P_SRV" \
5481 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5482 debug_level=1 ec_max_ops=1000" \
5483 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005484 -c "x509_verify_cert.*4b00" \
5485 -c "mbedtls_pk_verify.*4b00" \
5486 -c "mbedtls_ecdh_make_public.*4b00" \
5487 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005488
5489requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5490run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5491 "$P_SRV psk=abc123" \
5492 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5493 psk=abc123 debug_level=1 ec_max_ops=1000" \
5494 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005495 -C "x509_verify_cert.*4b00" \
5496 -C "mbedtls_pk_verify.*4b00" \
5497 -C "mbedtls_ecdh_make_public.*4b00" \
5498 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005499
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005500# Tests of asynchronous private key support in SSL
5501
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005502requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005503run_test "SSL async private: sign, delay=0" \
5504 "$P_SRV \
5505 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005506 "$P_CLI" \
5507 0 \
5508 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005509 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005510
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005511requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005512run_test "SSL async private: sign, delay=1" \
5513 "$P_SRV \
5514 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005515 "$P_CLI" \
5516 0 \
5517 -s "Async sign callback: using key slot " \
5518 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005519 -s "Async resume (slot [0-9]): sign done, status=0"
5520
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005521requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5522run_test "SSL async private: sign, delay=2" \
5523 "$P_SRV \
5524 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5525 "$P_CLI" \
5526 0 \
5527 -s "Async sign callback: using key slot " \
5528 -U "Async sign callback: using key slot " \
5529 -s "Async resume (slot [0-9]): call 1 more times." \
5530 -s "Async resume (slot [0-9]): call 0 more times." \
5531 -s "Async resume (slot [0-9]): sign done, status=0"
5532
Gilles Peskined3268832018-04-26 06:23:59 +02005533# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5534# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5535requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5536requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5537run_test "SSL async private: sign, RSA, TLS 1.1" \
5538 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5539 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5540 "$P_CLI force_version=tls1_1" \
5541 0 \
5542 -s "Async sign callback: using key slot " \
5543 -s "Async resume (slot [0-9]): sign done, status=0"
5544
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005545requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005546run_test "SSL async private: sign, SNI" \
5547 "$P_SRV debug_level=3 \
5548 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5549 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5550 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5551 "$P_CLI server_name=polarssl.example" \
5552 0 \
5553 -s "Async sign callback: using key slot " \
5554 -s "Async resume (slot [0-9]): sign done, status=0" \
5555 -s "parse ServerName extension" \
5556 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5557 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5558
5559requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005560run_test "SSL async private: decrypt, delay=0" \
5561 "$P_SRV \
5562 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5563 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5564 0 \
5565 -s "Async decrypt callback: using key slot " \
5566 -s "Async resume (slot [0-9]): decrypt done, status=0"
5567
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005568requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005569run_test "SSL async private: decrypt, delay=1" \
5570 "$P_SRV \
5571 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5572 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5573 0 \
5574 -s "Async decrypt callback: using key slot " \
5575 -s "Async resume (slot [0-9]): call 0 more times." \
5576 -s "Async resume (slot [0-9]): decrypt done, status=0"
5577
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005578requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005579run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5580 "$P_SRV psk=abc123 \
5581 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5582 "$P_CLI psk=abc123 \
5583 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5584 0 \
5585 -s "Async decrypt callback: using key slot " \
5586 -s "Async resume (slot [0-9]): decrypt done, status=0"
5587
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005588requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005589run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5590 "$P_SRV psk=abc123 \
5591 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5592 "$P_CLI psk=abc123 \
5593 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5594 0 \
5595 -s "Async decrypt callback: using key slot " \
5596 -s "Async resume (slot [0-9]): call 0 more times." \
5597 -s "Async resume (slot [0-9]): decrypt done, status=0"
5598
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005599requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005600run_test "SSL async private: sign callback not present" \
5601 "$P_SRV \
5602 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5603 "$P_CLI; [ \$? -eq 1 ] &&
5604 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5605 0 \
5606 -S "Async sign callback" \
5607 -s "! mbedtls_ssl_handshake returned" \
5608 -s "The own private key or pre-shared key is not set, but needed" \
5609 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5610 -s "Successful connection"
5611
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005612requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005613run_test "SSL async private: decrypt callback not present" \
5614 "$P_SRV debug_level=1 \
5615 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5616 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5617 [ \$? -eq 1 ] && $P_CLI" \
5618 0 \
5619 -S "Async decrypt callback" \
5620 -s "! mbedtls_ssl_handshake returned" \
5621 -s "got no RSA private key" \
5622 -s "Async resume (slot [0-9]): sign done, status=0" \
5623 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005624
5625# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005626requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005627run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005628 "$P_SRV \
5629 async_operations=s async_private_delay1=1 \
5630 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5631 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005632 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5633 0 \
5634 -s "Async sign callback: using key slot 0," \
5635 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005636 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005637
5638# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005639requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005640run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005641 "$P_SRV \
5642 async_operations=s async_private_delay2=1 \
5643 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5644 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005645 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5646 0 \
5647 -s "Async sign callback: using key slot 0," \
5648 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005649 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005650
5651# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005652requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005653run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005654 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005655 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005656 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5657 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005658 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5659 0 \
5660 -s "Async sign callback: using key slot 1," \
5661 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005662 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005663
5664# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005665requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005666run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005667 "$P_SRV \
5668 async_operations=s async_private_delay1=1 \
5669 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5670 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005671 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5672 0 \
5673 -s "Async sign callback: no key matches this certificate."
5674
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005675requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005676run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005677 "$P_SRV \
5678 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5679 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005680 "$P_CLI" \
5681 1 \
5682 -s "Async sign callback: injected error" \
5683 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005684 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005685 -s "! mbedtls_ssl_handshake returned"
5686
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005687requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005688run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005689 "$P_SRV \
5690 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5691 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005692 "$P_CLI" \
5693 1 \
5694 -s "Async sign callback: using key slot " \
5695 -S "Async resume" \
5696 -s "Async cancel"
5697
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005698requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005699run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005700 "$P_SRV \
5701 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5702 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005703 "$P_CLI" \
5704 1 \
5705 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005706 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005707 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005708 -s "! mbedtls_ssl_handshake returned"
5709
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005710requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005711run_test "SSL async private: decrypt, error in start" \
5712 "$P_SRV \
5713 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5714 async_private_error=1" \
5715 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5716 1 \
5717 -s "Async decrypt callback: injected error" \
5718 -S "Async resume" \
5719 -S "Async cancel" \
5720 -s "! mbedtls_ssl_handshake returned"
5721
5722requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5723run_test "SSL async private: decrypt, cancel after start" \
5724 "$P_SRV \
5725 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5726 async_private_error=2" \
5727 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5728 1 \
5729 -s "Async decrypt callback: using key slot " \
5730 -S "Async resume" \
5731 -s "Async cancel"
5732
5733requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5734run_test "SSL async private: decrypt, error in resume" \
5735 "$P_SRV \
5736 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5737 async_private_error=3" \
5738 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5739 1 \
5740 -s "Async decrypt callback: using key slot " \
5741 -s "Async resume callback: decrypt done but injected error" \
5742 -S "Async cancel" \
5743 -s "! mbedtls_ssl_handshake returned"
5744
5745requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005746run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005747 "$P_SRV \
5748 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5749 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005750 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5751 0 \
5752 -s "Async cancel" \
5753 -s "! mbedtls_ssl_handshake returned" \
5754 -s "Async resume" \
5755 -s "Successful connection"
5756
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005757requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005758run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005759 "$P_SRV \
5760 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5761 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005762 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5763 0 \
5764 -s "! mbedtls_ssl_handshake returned" \
5765 -s "Async resume" \
5766 -s "Successful connection"
5767
5768# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005769requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005770run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005771 "$P_SRV \
5772 async_operations=s async_private_delay1=1 async_private_error=-2 \
5773 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5774 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005775 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5776 [ \$? -eq 1 ] &&
5777 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5778 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005779 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005780 -S "Async resume" \
5781 -s "Async cancel" \
5782 -s "! mbedtls_ssl_handshake returned" \
5783 -s "Async sign callback: no key matches this certificate." \
5784 -s "Successful connection"
5785
5786# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005787requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005788run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005789 "$P_SRV \
5790 async_operations=s async_private_delay1=1 async_private_error=-3 \
5791 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5792 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005793 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5794 [ \$? -eq 1 ] &&
5795 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5796 0 \
5797 -s "Async resume" \
5798 -s "! mbedtls_ssl_handshake returned" \
5799 -s "Async sign callback: no key matches this certificate." \
5800 -s "Successful connection"
5801
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005802requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005803requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005804run_test "SSL async private: renegotiation: client-initiated; sign" \
5805 "$P_SRV \
5806 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005807 exchanges=2 renegotiation=1" \
5808 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5809 0 \
5810 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005811 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005812
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005813requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005814requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005815run_test "SSL async private: renegotiation: server-initiated; sign" \
5816 "$P_SRV \
5817 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005818 exchanges=2 renegotiation=1 renegotiate=1" \
5819 "$P_CLI exchanges=2 renegotiation=1" \
5820 0 \
5821 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005822 -s "Async resume (slot [0-9]): sign done, status=0"
5823
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005824requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005825requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5826run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5827 "$P_SRV \
5828 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5829 exchanges=2 renegotiation=1" \
5830 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5831 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5832 0 \
5833 -s "Async decrypt callback: using key slot " \
5834 -s "Async resume (slot [0-9]): decrypt done, status=0"
5835
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005836requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005837requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5838run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5839 "$P_SRV \
5840 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5841 exchanges=2 renegotiation=1 renegotiate=1" \
5842 "$P_CLI exchanges=2 renegotiation=1 \
5843 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5844 0 \
5845 -s "Async decrypt callback: using key slot " \
5846 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005847
Ron Eldor58093c82018-06-28 13:22:05 +03005848# Tests for ECC extensions (rfc 4492)
5849
Ron Eldor643df7c2018-06-28 16:17:00 +03005850requires_config_enabled MBEDTLS_AES_C
5851requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5852requires_config_enabled MBEDTLS_SHA256_C
5853requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005854run_test "Force a non ECC ciphersuite in the client side" \
5855 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005856 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005857 0 \
5858 -C "client hello, adding supported_elliptic_curves extension" \
5859 -C "client hello, adding supported_point_formats extension" \
5860 -S "found supported elliptic curves extension" \
5861 -S "found supported point formats extension"
5862
Ron Eldor643df7c2018-06-28 16:17:00 +03005863requires_config_enabled MBEDTLS_AES_C
5864requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5865requires_config_enabled MBEDTLS_SHA256_C
5866requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005867run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005868 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005869 "$P_CLI debug_level=3" \
5870 0 \
5871 -C "found supported_point_formats extension" \
5872 -S "server hello, supported_point_formats extension"
5873
Ron Eldor643df7c2018-06-28 16:17:00 +03005874requires_config_enabled MBEDTLS_AES_C
5875requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5876requires_config_enabled MBEDTLS_SHA256_C
5877requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005878run_test "Force an ECC ciphersuite in the client side" \
5879 "$P_SRV debug_level=3" \
5880 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5881 0 \
5882 -c "client hello, adding supported_elliptic_curves extension" \
5883 -c "client hello, adding supported_point_formats extension" \
5884 -s "found supported elliptic curves extension" \
5885 -s "found supported point formats extension"
5886
Ron Eldor643df7c2018-06-28 16:17:00 +03005887requires_config_enabled MBEDTLS_AES_C
5888requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5889requires_config_enabled MBEDTLS_SHA256_C
5890requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005891run_test "Force an ECC ciphersuite in the server side" \
5892 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5893 "$P_CLI debug_level=3" \
5894 0 \
5895 -c "found supported_point_formats extension" \
5896 -s "server hello, supported_point_formats extension"
5897
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005898# Tests for DTLS HelloVerifyRequest
5899
5900run_test "DTLS cookie: enabled" \
5901 "$P_SRV dtls=1 debug_level=2" \
5902 "$P_CLI dtls=1 debug_level=2" \
5903 0 \
5904 -s "cookie verification failed" \
5905 -s "cookie verification passed" \
5906 -S "cookie verification skipped" \
5907 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005908 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005909 -S "SSL - The requested feature is not available"
5910
5911run_test "DTLS cookie: disabled" \
5912 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5913 "$P_CLI dtls=1 debug_level=2" \
5914 0 \
5915 -S "cookie verification failed" \
5916 -S "cookie verification passed" \
5917 -s "cookie verification skipped" \
5918 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005919 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005920 -S "SSL - The requested feature is not available"
5921
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005922run_test "DTLS cookie: default (failing)" \
5923 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5924 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5925 1 \
5926 -s "cookie verification failed" \
5927 -S "cookie verification passed" \
5928 -S "cookie verification skipped" \
5929 -C "received hello verify request" \
5930 -S "hello verification requested" \
5931 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005932
5933requires_ipv6
5934run_test "DTLS cookie: enabled, IPv6" \
5935 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5936 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5937 0 \
5938 -s "cookie verification failed" \
5939 -s "cookie verification passed" \
5940 -S "cookie verification skipped" \
5941 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005942 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005943 -S "SSL - The requested feature is not available"
5944
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005945run_test "DTLS cookie: enabled, nbio" \
5946 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5947 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5948 0 \
5949 -s "cookie verification failed" \
5950 -s "cookie verification passed" \
5951 -S "cookie verification skipped" \
5952 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005953 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005954 -S "SSL - The requested feature is not available"
5955
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005956# Tests for client reconnecting from the same port with DTLS
5957
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005958not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005959run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005960 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5961 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005962 0 \
5963 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005964 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005965 -S "Client initiated reconnection from same port"
5966
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005967not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005968run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005969 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5970 "$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 +02005971 0 \
5972 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005973 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005974 -s "Client initiated reconnection from same port"
5975
Paul Bakker362689d2016-05-13 10:33:25 +01005976not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5977run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005978 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5979 "$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 +02005980 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005981 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005982 -s "Client initiated reconnection from same port"
5983
Paul Bakker362689d2016-05-13 10:33:25 +01005984only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5985run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5986 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5987 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5988 0 \
5989 -S "The operation timed out" \
5990 -s "Client initiated reconnection from same port"
5991
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005992run_test "DTLS client reconnect from same port: no cookies" \
5993 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005994 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5995 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005996 -s "The operation timed out" \
5997 -S "Client initiated reconnection from same port"
5998
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005999run_test "DTLS client reconnect from same port: attacker-injected" \
6000 -p "$P_PXY inject_clihlo=1" \
6001 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
6002 "$P_CLI dtls=1 exchanges=2" \
6003 0 \
6004 -s "possible client reconnect from the same port" \
6005 -S "Client initiated reconnection from same port"
6006
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006007# Tests for various cases of client authentication with DTLS
6008# (focused on handshake flows and message parsing)
6009
6010run_test "DTLS client auth: required" \
6011 "$P_SRV dtls=1 auth_mode=required" \
6012 "$P_CLI dtls=1" \
6013 0 \
6014 -s "Verifying peer X.509 certificate... ok"
6015
6016run_test "DTLS client auth: optional, client has no cert" \
6017 "$P_SRV dtls=1 auth_mode=optional" \
6018 "$P_CLI dtls=1 crt_file=none key_file=none" \
6019 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006020 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006021
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006022run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006023 "$P_SRV dtls=1 auth_mode=none" \
6024 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
6025 0 \
6026 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006027 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006028
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02006029run_test "DTLS wrong PSK: badmac alert" \
6030 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
6031 "$P_CLI dtls=1 psk=abc124" \
6032 1 \
6033 -s "SSL - Verification of the message MAC failed" \
6034 -c "SSL - A fatal alert message was received from our peer"
6035
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02006036# Tests for receiving fragmented handshake messages with DTLS
6037
6038requires_gnutls
6039run_test "DTLS reassembly: no fragmentation (gnutls server)" \
6040 "$G_SRV -u --mtu 2048 -a" \
6041 "$P_CLI dtls=1 debug_level=2" \
6042 0 \
6043 -C "found fragmented DTLS handshake message" \
6044 -C "error"
6045
6046requires_gnutls
6047run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6048 "$G_SRV -u --mtu 512" \
6049 "$P_CLI dtls=1 debug_level=2" \
6050 0 \
6051 -c "found fragmented DTLS handshake message" \
6052 -C "error"
6053
6054requires_gnutls
6055run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6056 "$G_SRV -u --mtu 128" \
6057 "$P_CLI dtls=1 debug_level=2" \
6058 0 \
6059 -c "found fragmented DTLS handshake message" \
6060 -C "error"
6061
6062requires_gnutls
6063run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6064 "$G_SRV -u --mtu 128" \
6065 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6066 0 \
6067 -c "found fragmented DTLS handshake message" \
6068 -C "error"
6069
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006070requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006071requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006072run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6073 "$G_SRV -u --mtu 256" \
6074 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6075 0 \
6076 -c "found fragmented DTLS handshake message" \
6077 -c "client hello, adding renegotiation extension" \
6078 -c "found renegotiation extension" \
6079 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006080 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006081 -C "error" \
6082 -s "Extra-header:"
6083
6084requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006085requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006086run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6087 "$G_SRV -u --mtu 256" \
6088 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6089 0 \
6090 -c "found fragmented DTLS handshake message" \
6091 -c "client hello, adding renegotiation extension" \
6092 -c "found renegotiation extension" \
6093 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006094 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006095 -C "error" \
6096 -s "Extra-header:"
6097
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006098run_test "DTLS reassembly: no fragmentation (openssl server)" \
6099 "$O_SRV -dtls1 -mtu 2048" \
6100 "$P_CLI dtls=1 debug_level=2" \
6101 0 \
6102 -C "found fragmented DTLS handshake message" \
6103 -C "error"
6104
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006105run_test "DTLS reassembly: some fragmentation (openssl server)" \
6106 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006107 "$P_CLI dtls=1 debug_level=2" \
6108 0 \
6109 -c "found fragmented DTLS handshake message" \
6110 -C "error"
6111
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006112run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006113 "$O_SRV -dtls1 -mtu 256" \
6114 "$P_CLI dtls=1 debug_level=2" \
6115 0 \
6116 -c "found fragmented DTLS handshake message" \
6117 -C "error"
6118
6119run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6120 "$O_SRV -dtls1 -mtu 256" \
6121 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6122 0 \
6123 -c "found fragmented DTLS handshake message" \
6124 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006125
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006126# Tests for sending fragmented handshake messages with DTLS
6127#
6128# Use client auth when we need the client to send large messages,
6129# and use large cert chains on both sides too (the long chains we have all use
6130# both RSA and ECDSA, but ideally we should have long chains with either).
6131# Sizes reached (UDP payload):
6132# - 2037B for server certificate
6133# - 1542B for client certificate
6134# - 1013B for newsessionticket
6135# - all others below 512B
6136# All those tests assume MAX_CONTENT_LEN is at least 2048
6137
6138requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6139requires_config_enabled MBEDTLS_RSA_C
6140requires_config_enabled MBEDTLS_ECDSA_C
6141requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006142requires_max_content_len 4096
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006143run_test "DTLS fragmenting: none (for reference)" \
6144 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6145 crt_file=data_files/server7_int-ca.crt \
6146 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006147 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006148 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006149 "$P_CLI dtls=1 debug_level=2 \
6150 crt_file=data_files/server8_int-ca2.crt \
6151 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006152 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006153 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006154 0 \
6155 -S "found fragmented DTLS handshake message" \
6156 -C "found fragmented DTLS handshake message" \
6157 -C "error"
6158
6159requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6160requires_config_enabled MBEDTLS_RSA_C
6161requires_config_enabled MBEDTLS_ECDSA_C
6162requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006163requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006164run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006165 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6166 crt_file=data_files/server7_int-ca.crt \
6167 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006168 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006169 max_frag_len=1024" \
6170 "$P_CLI dtls=1 debug_level=2 \
6171 crt_file=data_files/server8_int-ca2.crt \
6172 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006173 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006174 max_frag_len=2048" \
6175 0 \
6176 -S "found fragmented DTLS handshake message" \
6177 -c "found fragmented DTLS handshake message" \
6178 -C "error"
6179
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006180# With the MFL extension, the server has no way of forcing
6181# the client to not exceed a certain MTU; hence, the following
6182# test can't be replicated with an MTU proxy such as the one
6183# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006184requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6185requires_config_enabled MBEDTLS_RSA_C
6186requires_config_enabled MBEDTLS_ECDSA_C
6187requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006188requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006189run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006190 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6191 crt_file=data_files/server7_int-ca.crt \
6192 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006193 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006194 max_frag_len=512" \
6195 "$P_CLI dtls=1 debug_level=2 \
6196 crt_file=data_files/server8_int-ca2.crt \
6197 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006198 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006199 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006200 0 \
6201 -S "found fragmented DTLS handshake message" \
6202 -c "found fragmented DTLS handshake message" \
6203 -C "error"
6204
6205requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6206requires_config_enabled MBEDTLS_RSA_C
6207requires_config_enabled MBEDTLS_ECDSA_C
6208requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006209requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006210run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006211 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6212 crt_file=data_files/server7_int-ca.crt \
6213 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006214 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006215 max_frag_len=2048" \
6216 "$P_CLI dtls=1 debug_level=2 \
6217 crt_file=data_files/server8_int-ca2.crt \
6218 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006219 hs_timeout=2500-60000 \
6220 max_frag_len=1024" \
6221 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006222 -S "found fragmented DTLS handshake message" \
6223 -c "found fragmented DTLS handshake message" \
6224 -C "error"
6225
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006226# While not required by the standard defining the MFL extension
6227# (according to which it only applies to records, not to datagrams),
6228# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6229# as otherwise there wouldn't be any means to communicate MTU restrictions
6230# to the peer.
6231# The next test checks that no datagrams significantly larger than the
6232# negotiated MFL are sent.
6233requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6234requires_config_enabled MBEDTLS_RSA_C
6235requires_config_enabled MBEDTLS_ECDSA_C
6236requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006237requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006238run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006239 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006240 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6241 crt_file=data_files/server7_int-ca.crt \
6242 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006243 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006244 max_frag_len=2048" \
6245 "$P_CLI dtls=1 debug_level=2 \
6246 crt_file=data_files/server8_int-ca2.crt \
6247 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006248 hs_timeout=2500-60000 \
6249 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006250 0 \
6251 -S "found fragmented DTLS handshake message" \
6252 -c "found fragmented DTLS handshake message" \
6253 -C "error"
6254
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006255requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6256requires_config_enabled MBEDTLS_RSA_C
6257requires_config_enabled MBEDTLS_ECDSA_C
6258requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006259requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006260run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006261 "$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 Kurek52f84912018-10-05 07:53:40 -04006264 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006265 max_frag_len=2048" \
6266 "$P_CLI dtls=1 debug_level=2 \
6267 crt_file=data_files/server8_int-ca2.crt \
6268 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006269 hs_timeout=2500-60000 \
6270 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006271 0 \
6272 -s "found fragmented DTLS handshake message" \
6273 -c "found fragmented DTLS handshake message" \
6274 -C "error"
6275
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006276# While not required by the standard defining the MFL extension
6277# (according to which it only applies to records, not to datagrams),
6278# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6279# as otherwise there wouldn't be any means to communicate MTU restrictions
6280# to the peer.
6281# The next test checks that no datagrams significantly larger than the
6282# negotiated MFL are sent.
6283requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6284requires_config_enabled MBEDTLS_RSA_C
6285requires_config_enabled MBEDTLS_ECDSA_C
6286requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006287requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006288run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006289 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006290 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6291 crt_file=data_files/server7_int-ca.crt \
6292 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006293 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006294 max_frag_len=2048" \
6295 "$P_CLI dtls=1 debug_level=2 \
6296 crt_file=data_files/server8_int-ca2.crt \
6297 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006298 hs_timeout=2500-60000 \
6299 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006300 0 \
6301 -s "found fragmented DTLS handshake message" \
6302 -c "found fragmented DTLS handshake message" \
6303 -C "error"
6304
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006305requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6306requires_config_enabled MBEDTLS_RSA_C
6307requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006308requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006309run_test "DTLS fragmenting: none (for reference) (MTU)" \
6310 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6311 crt_file=data_files/server7_int-ca.crt \
6312 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006313 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006314 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006315 "$P_CLI dtls=1 debug_level=2 \
6316 crt_file=data_files/server8_int-ca2.crt \
6317 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006318 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006319 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006320 0 \
6321 -S "found fragmented DTLS handshake message" \
6322 -C "found fragmented DTLS handshake message" \
6323 -C "error"
6324
6325requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6326requires_config_enabled MBEDTLS_RSA_C
6327requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006328requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006329run_test "DTLS fragmenting: client (MTU)" \
6330 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6331 crt_file=data_files/server7_int-ca.crt \
6332 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006333 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006334 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006335 "$P_CLI dtls=1 debug_level=2 \
6336 crt_file=data_files/server8_int-ca2.crt \
6337 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006338 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006339 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006340 0 \
6341 -s "found fragmented DTLS handshake message" \
6342 -C "found fragmented DTLS handshake message" \
6343 -C "error"
6344
6345requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6346requires_config_enabled MBEDTLS_RSA_C
6347requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006348requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006349run_test "DTLS fragmenting: server (MTU)" \
6350 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6351 crt_file=data_files/server7_int-ca.crt \
6352 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006353 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006354 mtu=512" \
6355 "$P_CLI dtls=1 debug_level=2 \
6356 crt_file=data_files/server8_int-ca2.crt \
6357 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006358 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006359 mtu=2048" \
6360 0 \
6361 -S "found fragmented DTLS handshake message" \
6362 -c "found fragmented DTLS handshake message" \
6363 -C "error"
6364
6365requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6366requires_config_enabled MBEDTLS_RSA_C
6367requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006368requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006369run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006370 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006371 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6372 crt_file=data_files/server7_int-ca.crt \
6373 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006374 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006375 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006376 "$P_CLI dtls=1 debug_level=2 \
6377 crt_file=data_files/server8_int-ca2.crt \
6378 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006379 hs_timeout=2500-60000 \
6380 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006381 0 \
6382 -s "found fragmented DTLS handshake message" \
6383 -c "found fragmented DTLS handshake message" \
6384 -C "error"
6385
Andrzej Kurek77826052018-10-11 07:34:08 -04006386# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006387requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6388requires_config_enabled MBEDTLS_RSA_C
6389requires_config_enabled MBEDTLS_ECDSA_C
6390requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006391requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006392requires_config_enabled MBEDTLS_AES_C
6393requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006394requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006395run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006396 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006397 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6398 crt_file=data_files/server7_int-ca.crt \
6399 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006400 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006401 mtu=512" \
6402 "$P_CLI dtls=1 debug_level=2 \
6403 crt_file=data_files/server8_int-ca2.crt \
6404 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006405 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6406 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006407 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006408 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006409 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006410 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006411 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006412
Andrzej Kurek7311c782018-10-11 06:49:41 -04006413# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006414# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006415# The ratio of max/min timeout should ideally equal 4 to accept two
6416# retransmissions, but in some cases (like both the server and client using
6417# fragmentation and auto-reduction) an extra retransmission might occur,
6418# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006419not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006420requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6421requires_config_enabled MBEDTLS_RSA_C
6422requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006423requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006424requires_config_enabled MBEDTLS_AES_C
6425requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006426requires_max_content_len 2048
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006427run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6428 -p "$P_PXY mtu=508" \
6429 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6430 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006431 key_file=data_files/server7.key \
6432 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006433 "$P_CLI dtls=1 debug_level=2 \
6434 crt_file=data_files/server8_int-ca2.crt \
6435 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006436 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6437 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006438 0 \
6439 -s "found fragmented DTLS handshake message" \
6440 -c "found fragmented DTLS handshake message" \
6441 -C "error"
6442
Andrzej Kurek77826052018-10-11 07:34:08 -04006443# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006444only_with_valgrind
6445requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6446requires_config_enabled MBEDTLS_RSA_C
6447requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006448requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006449requires_config_enabled MBEDTLS_AES_C
6450requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006451requires_max_content_len 2048
Hanno Becker108992e2018-08-29 17:04:18 +01006452run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6453 -p "$P_PXY mtu=508" \
6454 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6455 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006456 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006457 hs_timeout=250-10000" \
6458 "$P_CLI dtls=1 debug_level=2 \
6459 crt_file=data_files/server8_int-ca2.crt \
6460 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006461 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006462 hs_timeout=250-10000" \
6463 0 \
6464 -s "found fragmented DTLS handshake message" \
6465 -c "found fragmented DTLS handshake message" \
6466 -C "error"
6467
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006468# 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 +02006469# OTOH the client might resend if the server is to slow to reset after sending
6470# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006471not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006472requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6473requires_config_enabled MBEDTLS_RSA_C
6474requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006475requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006476run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006477 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006478 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6479 crt_file=data_files/server7_int-ca.crt \
6480 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006481 hs_timeout=10000-60000 \
6482 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006483 "$P_CLI dtls=1 debug_level=2 \
6484 crt_file=data_files/server8_int-ca2.crt \
6485 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006486 hs_timeout=10000-60000 \
6487 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006488 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006489 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006490 -s "found fragmented DTLS handshake message" \
6491 -c "found fragmented DTLS handshake message" \
6492 -C "error"
6493
Andrzej Kurek77826052018-10-11 07:34:08 -04006494# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006495# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6496# OTOH the client might resend if the server is to slow to reset after sending
6497# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006498not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006499requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6500requires_config_enabled MBEDTLS_RSA_C
6501requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006502requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006503requires_config_enabled MBEDTLS_AES_C
6504requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006505requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006506run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006507 -p "$P_PXY mtu=512" \
6508 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6509 crt_file=data_files/server7_int-ca.crt \
6510 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006511 hs_timeout=10000-60000 \
6512 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006513 "$P_CLI dtls=1 debug_level=2 \
6514 crt_file=data_files/server8_int-ca2.crt \
6515 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006516 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6517 hs_timeout=10000-60000 \
6518 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006519 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006520 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006521 -s "found fragmented DTLS handshake message" \
6522 -c "found fragmented DTLS handshake message" \
6523 -C "error"
6524
Andrzej Kurek7311c782018-10-11 06:49:41 -04006525not_with_valgrind # spurious autoreduction due to timeout
6526requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6527requires_config_enabled MBEDTLS_RSA_C
6528requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006529requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006530run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006531 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006532 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6533 crt_file=data_files/server7_int-ca.crt \
6534 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006535 hs_timeout=10000-60000 \
6536 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006537 "$P_CLI dtls=1 debug_level=2 \
6538 crt_file=data_files/server8_int-ca2.crt \
6539 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006540 hs_timeout=10000-60000 \
6541 mtu=1024 nbio=2" \
6542 0 \
6543 -S "autoreduction" \
6544 -s "found fragmented DTLS handshake message" \
6545 -c "found fragmented DTLS handshake message" \
6546 -C "error"
6547
Andrzej Kurek77826052018-10-11 07:34:08 -04006548# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006549not_with_valgrind # spurious autoreduction due to timeout
6550requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6551requires_config_enabled MBEDTLS_RSA_C
6552requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006553requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006554requires_config_enabled MBEDTLS_AES_C
6555requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006556requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006557run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6558 -p "$P_PXY mtu=512" \
6559 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6560 crt_file=data_files/server7_int-ca.crt \
6561 key_file=data_files/server7.key \
6562 hs_timeout=10000-60000 \
6563 mtu=512 nbio=2" \
6564 "$P_CLI dtls=1 debug_level=2 \
6565 crt_file=data_files/server8_int-ca2.crt \
6566 key_file=data_files/server8.key \
6567 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6568 hs_timeout=10000-60000 \
6569 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006570 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006571 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006572 -s "found fragmented DTLS handshake message" \
6573 -c "found fragmented DTLS handshake message" \
6574 -C "error"
6575
Andrzej Kurek77826052018-10-11 07:34:08 -04006576# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006577# This ensures things still work after session_reset().
6578# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006579# Since we don't support reading fragmented ClientHello yet,
6580# up the MTU to 1450 (larger than ClientHello with session ticket,
6581# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006582# An autoreduction on the client-side might happen if the server is
6583# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006584# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006585# resumed listening, which would result in a spurious autoreduction.
6586not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006587requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6588requires_config_enabled MBEDTLS_RSA_C
6589requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006590requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006591requires_config_enabled MBEDTLS_AES_C
6592requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006593requires_max_content_len 2048
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006594run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6595 -p "$P_PXY mtu=1450" \
6596 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6597 crt_file=data_files/server7_int-ca.crt \
6598 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006599 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006600 mtu=1450" \
6601 "$P_CLI dtls=1 debug_level=2 \
6602 crt_file=data_files/server8_int-ca2.crt \
6603 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006604 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006605 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006606 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006607 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006608 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006609 -s "found fragmented DTLS handshake message" \
6610 -c "found fragmented DTLS handshake message" \
6611 -C "error"
6612
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006613# An autoreduction on the client-side might happen if the server is
6614# slow to reset, therefore omitting '-C "autoreduction"' below.
6615not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006616requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6617requires_config_enabled MBEDTLS_RSA_C
6618requires_config_enabled MBEDTLS_ECDSA_C
6619requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006620requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006621requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6622requires_config_enabled MBEDTLS_CHACHAPOLY_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006623requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006624run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6625 -p "$P_PXY mtu=512" \
6626 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6627 crt_file=data_files/server7_int-ca.crt \
6628 key_file=data_files/server7.key \
6629 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006630 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006631 mtu=512" \
6632 "$P_CLI dtls=1 debug_level=2 \
6633 crt_file=data_files/server8_int-ca2.crt \
6634 key_file=data_files/server8.key \
6635 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006636 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006637 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006638 mtu=512" \
6639 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006640 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006641 -s "found fragmented DTLS handshake message" \
6642 -c "found fragmented DTLS handshake message" \
6643 -C "error"
6644
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006645# An autoreduction on the client-side might happen if the server is
6646# slow to reset, therefore omitting '-C "autoreduction"' below.
6647not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006648requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6649requires_config_enabled MBEDTLS_RSA_C
6650requires_config_enabled MBEDTLS_ECDSA_C
6651requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006652requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006653requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6654requires_config_enabled MBEDTLS_AES_C
6655requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006656requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006657run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6658 -p "$P_PXY mtu=512" \
6659 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6660 crt_file=data_files/server7_int-ca.crt \
6661 key_file=data_files/server7.key \
6662 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006663 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006664 mtu=512" \
6665 "$P_CLI dtls=1 debug_level=2 \
6666 crt_file=data_files/server8_int-ca2.crt \
6667 key_file=data_files/server8.key \
6668 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006669 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006670 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006671 mtu=512" \
6672 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006673 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006674 -s "found fragmented DTLS handshake message" \
6675 -c "found fragmented DTLS handshake message" \
6676 -C "error"
6677
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006678# An autoreduction on the client-side might happen if the server is
6679# slow to reset, therefore omitting '-C "autoreduction"' below.
6680not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006681requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6682requires_config_enabled MBEDTLS_RSA_C
6683requires_config_enabled MBEDTLS_ECDSA_C
6684requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006685requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006686requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6687requires_config_enabled MBEDTLS_AES_C
6688requires_config_enabled MBEDTLS_CCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006689requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006690run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006691 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006692 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6693 crt_file=data_files/server7_int-ca.crt \
6694 key_file=data_files/server7.key \
6695 exchanges=2 renegotiation=1 \
6696 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006697 hs_timeout=10000-60000 \
6698 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006699 "$P_CLI dtls=1 debug_level=2 \
6700 crt_file=data_files/server8_int-ca2.crt \
6701 key_file=data_files/server8.key \
6702 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006703 hs_timeout=10000-60000 \
6704 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006705 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006706 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006707 -s "found fragmented DTLS handshake message" \
6708 -c "found fragmented DTLS handshake message" \
6709 -C "error"
6710
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006711# An autoreduction on the client-side might happen if the server is
6712# slow to reset, therefore omitting '-C "autoreduction"' below.
6713not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006714requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6715requires_config_enabled MBEDTLS_RSA_C
6716requires_config_enabled MBEDTLS_ECDSA_C
6717requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006718requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006719requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6720requires_config_enabled MBEDTLS_AES_C
6721requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6722requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
Yuto Takanoc75df632021-07-08 15:56:33 +01006723requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006724run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006725 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006726 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6727 crt_file=data_files/server7_int-ca.crt \
6728 key_file=data_files/server7.key \
6729 exchanges=2 renegotiation=1 \
6730 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006731 hs_timeout=10000-60000 \
6732 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006733 "$P_CLI dtls=1 debug_level=2 \
6734 crt_file=data_files/server8_int-ca2.crt \
6735 key_file=data_files/server8.key \
6736 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006737 hs_timeout=10000-60000 \
6738 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006739 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006740 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006741 -s "found fragmented DTLS handshake message" \
6742 -c "found fragmented DTLS handshake message" \
6743 -C "error"
6744
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006745# An autoreduction on the client-side might happen if the server is
6746# slow to reset, therefore omitting '-C "autoreduction"' below.
6747not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006748requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6749requires_config_enabled MBEDTLS_RSA_C
6750requires_config_enabled MBEDTLS_ECDSA_C
6751requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006752requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006753requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6754requires_config_enabled MBEDTLS_AES_C
6755requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
Yuto Takanoc75df632021-07-08 15:56:33 +01006756requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006757run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006758 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006759 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6760 crt_file=data_files/server7_int-ca.crt \
6761 key_file=data_files/server7.key \
6762 exchanges=2 renegotiation=1 \
6763 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006764 hs_timeout=10000-60000 \
6765 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006766 "$P_CLI dtls=1 debug_level=2 \
6767 crt_file=data_files/server8_int-ca2.crt \
6768 key_file=data_files/server8.key \
6769 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006770 hs_timeout=10000-60000 \
6771 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006772 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006773 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006774 -s "found fragmented DTLS handshake message" \
6775 -c "found fragmented DTLS handshake message" \
6776 -C "error"
6777
Andrzej Kurek77826052018-10-11 07:34:08 -04006778# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006779requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6780requires_config_enabled MBEDTLS_RSA_C
6781requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006782requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006783requires_config_enabled MBEDTLS_AES_C
6784requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006785client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006786requires_max_content_len 2048
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006787run_test "DTLS fragmenting: proxy MTU + 3d" \
6788 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006789 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006790 crt_file=data_files/server7_int-ca.crt \
6791 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006792 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006793 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006794 crt_file=data_files/server8_int-ca2.crt \
6795 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006796 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006797 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006798 0 \
6799 -s "found fragmented DTLS handshake message" \
6800 -c "found fragmented DTLS handshake message" \
6801 -C "error"
6802
Andrzej Kurek77826052018-10-11 07:34:08 -04006803# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006804requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6805requires_config_enabled MBEDTLS_RSA_C
6806requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006807requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006808requires_config_enabled MBEDTLS_AES_C
6809requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006810client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006811requires_max_content_len 2048
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006812run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6813 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6814 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6815 crt_file=data_files/server7_int-ca.crt \
6816 key_file=data_files/server7.key \
6817 hs_timeout=250-10000 mtu=512 nbio=2" \
6818 "$P_CLI dtls=1 debug_level=2 \
6819 crt_file=data_files/server8_int-ca2.crt \
6820 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006821 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006822 hs_timeout=250-10000 mtu=512 nbio=2" \
6823 0 \
6824 -s "found fragmented DTLS handshake message" \
6825 -c "found fragmented DTLS handshake message" \
6826 -C "error"
6827
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006828# interop tests for DTLS fragmentating with reliable connection
6829#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006830# here and below we just want to test that the we fragment in a way that
6831# pleases other implementations, so we don't need the peer to fragment
6832requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6833requires_config_enabled MBEDTLS_RSA_C
6834requires_config_enabled MBEDTLS_ECDSA_C
6835requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006836requires_gnutls
Yuto Takanoc75df632021-07-08 15:56:33 +01006837requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006838run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6839 "$G_SRV -u" \
6840 "$P_CLI dtls=1 debug_level=2 \
6841 crt_file=data_files/server8_int-ca2.crt \
6842 key_file=data_files/server8.key \
6843 mtu=512 force_version=dtls1_2" \
6844 0 \
6845 -c "fragmenting handshake message" \
6846 -C "error"
6847
6848requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6849requires_config_enabled MBEDTLS_RSA_C
6850requires_config_enabled MBEDTLS_ECDSA_C
6851requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006852requires_gnutls
Yuto Takanoc75df632021-07-08 15:56:33 +01006853requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006854run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6855 "$G_SRV -u" \
6856 "$P_CLI dtls=1 debug_level=2 \
6857 crt_file=data_files/server8_int-ca2.crt \
6858 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006859 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006860 0 \
6861 -c "fragmenting handshake message" \
6862 -C "error"
6863
Hanno Beckerb9a00862018-08-28 10:20:22 +01006864# We use --insecure for the GnuTLS client because it expects
6865# the hostname / IP it connects to to be the name used in the
6866# certificate obtained from the server. Here, however, it
6867# connects to 127.0.0.1 while our test certificates use 'localhost'
6868# as the server name in the certificate. This will make the
6869# certifiate validation fail, but passing --insecure makes
6870# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006871requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6872requires_config_enabled MBEDTLS_RSA_C
6873requires_config_enabled MBEDTLS_ECDSA_C
6874requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006875requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006876requires_not_i686
Yuto Takanoc75df632021-07-08 15:56:33 +01006877requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006878run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006879 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006880 crt_file=data_files/server7_int-ca.crt \
6881 key_file=data_files/server7.key \
6882 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006883 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006884 0 \
6885 -s "fragmenting handshake message"
6886
Hanno Beckerb9a00862018-08-28 10:20:22 +01006887# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006888requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6889requires_config_enabled MBEDTLS_RSA_C
6890requires_config_enabled MBEDTLS_ECDSA_C
6891requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006892requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006893requires_not_i686
Yuto Takanoc75df632021-07-08 15:56:33 +01006894requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006895run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006896 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006897 crt_file=data_files/server7_int-ca.crt \
6898 key_file=data_files/server7.key \
6899 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006900 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006901 0 \
6902 -s "fragmenting handshake message"
6903
6904requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6905requires_config_enabled MBEDTLS_RSA_C
6906requires_config_enabled MBEDTLS_ECDSA_C
6907requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Yuto Takanoc75df632021-07-08 15:56:33 +01006908requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006909run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6910 "$O_SRV -dtls1_2 -verify 10" \
6911 "$P_CLI dtls=1 debug_level=2 \
6912 crt_file=data_files/server8_int-ca2.crt \
6913 key_file=data_files/server8.key \
6914 mtu=512 force_version=dtls1_2" \
6915 0 \
6916 -c "fragmenting handshake message" \
6917 -C "error"
6918
6919requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6920requires_config_enabled MBEDTLS_RSA_C
6921requires_config_enabled MBEDTLS_ECDSA_C
6922requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006923requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006924run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6925 "$O_SRV -dtls1 -verify 10" \
6926 "$P_CLI dtls=1 debug_level=2 \
6927 crt_file=data_files/server8_int-ca2.crt \
6928 key_file=data_files/server8.key \
6929 mtu=512 force_version=dtls1" \
6930 0 \
6931 -c "fragmenting handshake message" \
6932 -C "error"
6933
6934requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6935requires_config_enabled MBEDTLS_RSA_C
6936requires_config_enabled MBEDTLS_ECDSA_C
6937requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Yuto Takanoc75df632021-07-08 15:56:33 +01006938requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006939run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6940 "$P_SRV dtls=1 debug_level=2 \
6941 crt_file=data_files/server7_int-ca.crt \
6942 key_file=data_files/server7.key \
6943 mtu=512 force_version=dtls1_2" \
6944 "$O_CLI -dtls1_2" \
6945 0 \
6946 -s "fragmenting handshake message"
6947
6948requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6949requires_config_enabled MBEDTLS_RSA_C
6950requires_config_enabled MBEDTLS_ECDSA_C
6951requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006952requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006953run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6954 "$P_SRV dtls=1 debug_level=2 \
6955 crt_file=data_files/server7_int-ca.crt \
6956 key_file=data_files/server7.key \
6957 mtu=512 force_version=dtls1" \
6958 "$O_CLI -dtls1" \
6959 0 \
6960 -s "fragmenting handshake message"
6961
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006962# interop tests for DTLS fragmentating with unreliable connection
6963#
6964# again we just want to test that the we fragment in a way that
6965# pleases other implementations, so we don't need the peer to fragment
6966requires_gnutls_next
6967requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6968requires_config_enabled MBEDTLS_RSA_C
6969requires_config_enabled MBEDTLS_ECDSA_C
6970requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006971client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006972requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006973run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6974 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6975 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006976 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006977 crt_file=data_files/server8_int-ca2.crt \
6978 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006979 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006980 0 \
6981 -c "fragmenting handshake message" \
6982 -C "error"
6983
6984requires_gnutls_next
6985requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6986requires_config_enabled MBEDTLS_RSA_C
6987requires_config_enabled MBEDTLS_ECDSA_C
6988requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006989client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006990requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006991run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6992 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6993 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006994 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006995 crt_file=data_files/server8_int-ca2.crt \
6996 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006997 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006998 0 \
6999 -c "fragmenting handshake message" \
7000 -C "error"
7001
k-stachowiakabb843e2019-02-18 16:14:03 +01007002requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007003requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7004requires_config_enabled MBEDTLS_RSA_C
7005requires_config_enabled MBEDTLS_ECDSA_C
7006requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7007client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007008requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007009run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
7010 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7011 "$P_SRV dtls=1 debug_level=2 \
7012 crt_file=data_files/server7_int-ca.crt \
7013 key_file=data_files/server7.key \
7014 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007015 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007016 0 \
7017 -s "fragmenting handshake message"
7018
k-stachowiakabb843e2019-02-18 16:14:03 +01007019requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007020requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7021requires_config_enabled MBEDTLS_RSA_C
7022requires_config_enabled MBEDTLS_ECDSA_C
7023requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7024client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007025requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007026run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
7027 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7028 "$P_SRV dtls=1 debug_level=2 \
7029 crt_file=data_files/server7_int-ca.crt \
7030 key_file=data_files/server7.key \
7031 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007032 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007033 0 \
7034 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007035
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007036## Interop test with OpenSSL might trigger a bug in recent versions (including
7037## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007038## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007039## They should be re-enabled once a fixed version of OpenSSL is available
7040## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007041skip_next_test
7042requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7043requires_config_enabled MBEDTLS_RSA_C
7044requires_config_enabled MBEDTLS_ECDSA_C
7045requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7046client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007047requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007048run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
7049 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7050 "$O_SRV -dtls1_2 -verify 10" \
7051 "$P_CLI dtls=1 debug_level=2 \
7052 crt_file=data_files/server8_int-ca2.crt \
7053 key_file=data_files/server8.key \
7054 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7055 0 \
7056 -c "fragmenting handshake message" \
7057 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007058
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007059skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007060requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7061requires_config_enabled MBEDTLS_RSA_C
7062requires_config_enabled MBEDTLS_ECDSA_C
7063requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007064client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007065requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007066run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
7067 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007068 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007069 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007070 crt_file=data_files/server8_int-ca2.crt \
7071 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007072 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007073 0 \
7074 -c "fragmenting handshake message" \
7075 -C "error"
7076
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007077skip_next_test
7078requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7079requires_config_enabled MBEDTLS_RSA_C
7080requires_config_enabled MBEDTLS_ECDSA_C
7081requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7082client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007083requires_max_content_len 2048
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007084run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
7085 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7086 "$P_SRV dtls=1 debug_level=2 \
7087 crt_file=data_files/server7_int-ca.crt \
7088 key_file=data_files/server7.key \
7089 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7090 "$O_CLI -dtls1_2" \
7091 0 \
7092 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007093
7094# -nbio is added to prevent s_client from blocking in case of duplicated
7095# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007096skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007097requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7098requires_config_enabled MBEDTLS_RSA_C
7099requires_config_enabled MBEDTLS_ECDSA_C
7100requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007101client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007102requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007103run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7104 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007105 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007106 crt_file=data_files/server7_int-ca.crt \
7107 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007108 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007109 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007110 0 \
7111 -s "fragmenting handshake message"
7112
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007113# Tests for specific things with "unreliable" UDP connection
7114
7115not_with_valgrind # spurious resend due to timeout
7116run_test "DTLS proxy: reference" \
7117 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007118 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7119 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007120 0 \
7121 -C "replayed record" \
7122 -S "replayed record" \
7123 -C "record from another epoch" \
7124 -S "record from another epoch" \
7125 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007126 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007127 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007128 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007129 -c "HTTP/1.0 200 OK"
7130
7131not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007132run_test "DTLS proxy: duplicate every packet" \
7133 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007134 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7135 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007136 0 \
7137 -c "replayed record" \
7138 -s "replayed record" \
7139 -c "record from another epoch" \
7140 -s "record from another epoch" \
7141 -S "resend" \
7142 -s "Extra-header:" \
7143 -c "HTTP/1.0 200 OK"
7144
7145run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7146 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007147 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7148 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007149 0 \
7150 -c "replayed record" \
7151 -S "replayed record" \
7152 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007153 -s "record from another epoch" \
7154 -c "resend" \
7155 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007156 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007157 -c "HTTP/1.0 200 OK"
7158
7159run_test "DTLS proxy: multiple records in same datagram" \
7160 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007161 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7162 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007163 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007164 -c "next record in same datagram" \
7165 -s "next record in same datagram"
7166
7167run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7168 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007169 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7170 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007171 0 \
7172 -c "next record in same datagram" \
7173 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007174
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007175run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7176 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007177 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7178 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007179 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007180 -c "discarding invalid record (mac)" \
7181 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007182 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007183 -c "HTTP/1.0 200 OK" \
7184 -S "too many records with bad MAC" \
7185 -S "Verification of the message MAC failed"
7186
7187run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7188 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007189 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7190 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007191 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007192 -C "discarding invalid record (mac)" \
7193 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007194 -S "Extra-header:" \
7195 -C "HTTP/1.0 200 OK" \
7196 -s "too many records with bad MAC" \
7197 -s "Verification of the message MAC failed"
7198
7199run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7200 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007201 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7202 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007203 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007204 -c "discarding invalid record (mac)" \
7205 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007206 -s "Extra-header:" \
7207 -c "HTTP/1.0 200 OK" \
7208 -S "too many records with bad MAC" \
7209 -S "Verification of the message MAC failed"
7210
7211run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7212 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007213 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7214 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007215 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007216 -c "discarding invalid record (mac)" \
7217 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007218 -s "Extra-header:" \
7219 -c "HTTP/1.0 200 OK" \
7220 -s "too many records with bad MAC" \
7221 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007222
7223run_test "DTLS proxy: delay ChangeCipherSpec" \
7224 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007225 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7226 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007227 0 \
7228 -c "record from another epoch" \
7229 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007230 -s "Extra-header:" \
7231 -c "HTTP/1.0 200 OK"
7232
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007233# Tests for reordering support with DTLS
7234
Hanno Becker56cdfd12018-08-17 13:42:15 +01007235run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7236 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007237 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7238 hs_timeout=2500-60000" \
7239 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7240 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007241 0 \
7242 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007243 -c "Next handshake message has been buffered - load"\
7244 -S "Buffering HS message" \
7245 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007246 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007247 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007248 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007249 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007250
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007251run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7252 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007253 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7254 hs_timeout=2500-60000" \
7255 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7256 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007257 0 \
7258 -c "Buffering HS message" \
7259 -c "found fragmented DTLS handshake message"\
7260 -c "Next handshake message 1 not or only partially bufffered" \
7261 -c "Next handshake message has been buffered - load"\
7262 -S "Buffering HS message" \
7263 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007264 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007265 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007266 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007267 -S "Remember CCS message"
7268
Hanno Beckera1adcca2018-08-24 14:41:07 +01007269# The client buffers the ServerKeyExchange before receiving the fragmented
7270# Certificate message; at the time of writing, together these are aroudn 1200b
7271# in size, so that the bound below ensures that the certificate can be reassembled
7272# while keeping the ServerKeyExchange.
7273requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7274run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007275 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007276 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7277 hs_timeout=2500-60000" \
7278 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7279 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007280 0 \
7281 -c "Buffering HS message" \
7282 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007283 -C "attempt to make space by freeing buffered messages" \
7284 -S "Buffering HS message" \
7285 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007286 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007287 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007288 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007289 -S "Remember CCS message"
7290
7291# The size constraints ensure that the delayed certificate message can't
7292# be reassembled while keeping the ServerKeyExchange message, but it can
7293# when dropping it first.
7294requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7295requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7296run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7297 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007298 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7299 hs_timeout=2500-60000" \
7300 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7301 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007302 0 \
7303 -c "Buffering HS message" \
7304 -c "attempt to make space by freeing buffered future messages" \
7305 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007306 -S "Buffering HS message" \
7307 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007308 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007309 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007310 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007311 -S "Remember CCS message"
7312
Hanno Becker56cdfd12018-08-17 13:42:15 +01007313run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7314 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007315 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7316 hs_timeout=2500-60000" \
7317 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7318 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007319 0 \
7320 -C "Buffering HS message" \
7321 -C "Next handshake message has been buffered - load"\
7322 -s "Buffering HS message" \
7323 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007324 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007325 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007326 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007327 -S "Remember CCS message"
7328
7329run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7330 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007331 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7332 hs_timeout=2500-60000" \
7333 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7334 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007335 0 \
7336 -C "Buffering HS message" \
7337 -C "Next handshake message has been buffered - load"\
7338 -S "Buffering HS message" \
7339 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007340 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007341 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007342 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007343 -S "Remember CCS message"
7344
7345run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7346 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007347 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7348 hs_timeout=2500-60000" \
7349 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7350 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007351 0 \
7352 -C "Buffering HS message" \
7353 -C "Next handshake message has been buffered - load"\
7354 -S "Buffering HS message" \
7355 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007356 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007357 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007358 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007359 -s "Remember CCS message"
7360
Hanno Beckera1adcca2018-08-24 14:41:07 +01007361run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007362 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007363 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7364 hs_timeout=2500-60000" \
7365 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7366 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007367 0 \
7368 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007369 -s "Found buffered record from current epoch - load" \
7370 -c "Buffer record from epoch 1" \
7371 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007372
Hanno Beckera1adcca2018-08-24 14:41:07 +01007373# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7374# from the server are delayed, so that the encrypted Finished message
7375# is received and buffered. When the fragmented NewSessionTicket comes
7376# in afterwards, the encrypted Finished message must be freed in order
7377# to make space for the NewSessionTicket to be reassembled.
7378# This works only in very particular circumstances:
7379# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7380# of the NewSessionTicket, but small enough to also allow buffering of
7381# the encrypted Finished message.
7382# - The MTU setting on the server must be so small that the NewSessionTicket
7383# needs to be fragmented.
7384# - All messages sent by the server must be small enough to be either sent
7385# without fragmentation or be reassembled within the bounds of
7386# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7387# handshake, omitting CRTs.
7388requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7389requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7390run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7391 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7392 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7393 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7394 0 \
7395 -s "Buffer record from epoch 1" \
7396 -s "Found buffered record from current epoch - load" \
7397 -c "Buffer record from epoch 1" \
7398 -C "Found buffered record from current epoch - load" \
7399 -c "Enough space available after freeing future epoch record"
7400
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007401# Tests for "randomly unreliable connection": try a variety of flows and peers
7402
7403client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007404run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7405 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007406 "$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 +02007407 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007408 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007409 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7410 0 \
7411 -s "Extra-header:" \
7412 -c "HTTP/1.0 200 OK"
7413
Janos Follath74537a62016-09-02 13:45:28 +01007414client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007415run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7416 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007417 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7418 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007419 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7420 0 \
7421 -s "Extra-header:" \
7422 -c "HTTP/1.0 200 OK"
7423
Janos Follath74537a62016-09-02 13:45:28 +01007424client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007425run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7426 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007427 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7428 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007429 0 \
7430 -s "Extra-header:" \
7431 -c "HTTP/1.0 200 OK"
7432
Janos Follath74537a62016-09-02 13:45:28 +01007433client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007434run_test "DTLS proxy: 3d, FS, client auth" \
7435 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007436 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7437 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007438 0 \
7439 -s "Extra-header:" \
7440 -c "HTTP/1.0 200 OK"
7441
Janos Follath74537a62016-09-02 13:45:28 +01007442client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007443run_test "DTLS proxy: 3d, FS, ticket" \
7444 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007445 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7446 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007447 0 \
7448 -s "Extra-header:" \
7449 -c "HTTP/1.0 200 OK"
7450
Janos Follath74537a62016-09-02 13:45:28 +01007451client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007452run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7453 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007454 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7455 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007456 0 \
7457 -s "Extra-header:" \
7458 -c "HTTP/1.0 200 OK"
7459
Janos Follath74537a62016-09-02 13:45:28 +01007460client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007461run_test "DTLS proxy: 3d, max handshake, nbio" \
7462 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007463 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007464 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007465 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007466 0 \
7467 -s "Extra-header:" \
7468 -c "HTTP/1.0 200 OK"
7469
Janos Follath74537a62016-09-02 13:45:28 +01007470client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007471run_test "DTLS proxy: 3d, min handshake, resumption" \
7472 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007473 "$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 +02007474 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007475 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007476 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007477 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7478 0 \
7479 -s "a session has been resumed" \
7480 -c "a session has been resumed" \
7481 -s "Extra-header:" \
7482 -c "HTTP/1.0 200 OK"
7483
Janos Follath74537a62016-09-02 13:45:28 +01007484client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007485run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7486 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007487 "$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 +02007488 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007489 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007490 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007491 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7492 0 \
7493 -s "a session has been resumed" \
7494 -c "a session has been resumed" \
7495 -s "Extra-header:" \
7496 -c "HTTP/1.0 200 OK"
7497
Janos Follath74537a62016-09-02 13:45:28 +01007498client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007499requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007500run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007501 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007502 "$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 +02007503 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007504 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007505 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007506 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7507 0 \
7508 -c "=> renegotiate" \
7509 -s "=> renegotiate" \
7510 -s "Extra-header:" \
7511 -c "HTTP/1.0 200 OK"
7512
Janos Follath74537a62016-09-02 13:45:28 +01007513client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007514requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007515run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7516 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007517 "$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 +02007518 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007519 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007520 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007521 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7522 0 \
7523 -c "=> renegotiate" \
7524 -s "=> renegotiate" \
7525 -s "Extra-header:" \
7526 -c "HTTP/1.0 200 OK"
7527
Janos Follath74537a62016-09-02 13:45:28 +01007528client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007529requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007530run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007531 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007532 "$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 +02007533 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007534 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007535 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007536 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007537 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7538 0 \
7539 -c "=> renegotiate" \
7540 -s "=> renegotiate" \
7541 -s "Extra-header:" \
7542 -c "HTTP/1.0 200 OK"
7543
Janos Follath74537a62016-09-02 13:45:28 +01007544client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007545requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007546run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007547 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007548 "$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 +02007549 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007550 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007551 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007552 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007553 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7554 0 \
7555 -c "=> renegotiate" \
7556 -s "=> renegotiate" \
7557 -s "Extra-header:" \
7558 -c "HTTP/1.0 200 OK"
7559
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007560## Interop tests with OpenSSL might trigger a bug in recent versions (including
7561## all versions installed on the CI machines), reported here:
7562## Bug report: https://github.com/openssl/openssl/issues/6902
7563## They should be re-enabled once a fixed version of OpenSSL is available
7564## (this should happen in some 1.1.1_ release according to the ticket).
7565skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007566client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007567not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007568run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007569 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7570 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007571 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007572 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007573 -c "HTTP/1.0 200 OK"
7574
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007575skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007576client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007577not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007578run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7579 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7580 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007581 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007582 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007583 -c "HTTP/1.0 200 OK"
7584
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007585skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007586client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007587not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007588run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7589 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7590 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007591 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007592 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007593 -c "HTTP/1.0 200 OK"
7594
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007595requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007596client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007597not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007598run_test "DTLS proxy: 3d, gnutls server" \
7599 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7600 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007601 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007602 0 \
7603 -s "Extra-header:" \
7604 -c "Extra-header:"
7605
k-stachowiakabb843e2019-02-18 16:14:03 +01007606requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007607client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007608not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007609run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7610 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007611 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007612 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007613 0 \
7614 -s "Extra-header:" \
7615 -c "Extra-header:"
7616
k-stachowiakabb843e2019-02-18 16:14:03 +01007617requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007618client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007619not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007620run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7621 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007622 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007623 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007624 0 \
7625 -s "Extra-header:" \
7626 -c "Extra-header:"
7627
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007628# Final report
7629
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007630echo "------------------------------------------------------------------------"
7631
7632if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007633 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007634else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007635 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007636fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007637PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007638echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007639
7640exit $FAILS