blob: f3e0f05c191c6b4412d2aaa0727777223c77b42f [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() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100516 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200517 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100518 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200519 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100520 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200521 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100522 # Make a tight loop, server normally takes less than 1s to start.
523 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
524 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400525 echo "$3 START TIMEOUT"
526 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100527 break
528 fi
529 # Linux and *BSD support decimal arguments to sleep. On other
530 # OSes this may be a tight loop.
531 sleep 0.1 2>/dev/null || true
532 done
533 }
534else
Unknown43dc0d62019-09-02 10:42:57 -0400535 echo "Warning: lsof not available, wait_app_start = sleep"
536 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200537 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100538 }
539fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200540
Unknown43dc0d62019-09-02 10:42:57 -0400541# Wait for server process $2 to be listening on port $1.
542wait_server_start() {
543 wait_app_start $1 $2 "SERVER" $SRV_OUT
544}
545
546# Wait for proxy process $2 to be listening on port $1.
547wait_proxy_start() {
548 wait_app_start $1 $2 "PROXY" $PXY_OUT
549}
550
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100551# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100552# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100553# acceptable bounds
554check_server_hello_time() {
555 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100556 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100557 # Get the Unix timestamp for now
558 CUR_TIME=$(date +'%s')
559 THRESHOLD_IN_SECS=300
560
561 # Check if the ServerHello time was printed
562 if [ -z "$SERVER_HELLO_TIME" ]; then
563 return 1
564 fi
565
566 # Check the time in ServerHello is within acceptable bounds
567 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
568 # The time in ServerHello is at least 5 minutes before now
569 return 1
570 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100571 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100572 return 1
573 else
574 return 0
575 fi
576}
577
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200578# wait for client to terminate and set CLI_EXIT
579# must be called right after starting the client
580wait_client_done() {
581 CLI_PID=$!
582
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200583 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
584 CLI_DELAY_FACTOR=1
585
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200586 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200587 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200588
589 wait $CLI_PID
590 CLI_EXIT=$?
591
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200592 kill $DOG_PID >/dev/null 2>&1
593 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200594
595 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100596
597 sleep $SRV_DELAY_SECONDS
598 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200599}
600
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200601# check if the given command uses dtls and sets global variable DTLS
602detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200603 case "$1" in
Paul Elliott316a6aa2021-10-12 16:02:55 +0100604 *dtls=1*|*-dtls*|*-u*) DTLS=1;;
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200605 *) DTLS=0;;
606 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200607}
608
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200609# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610# Options: -s pattern pattern that must be present in server output
611# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100612# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100613# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614# -S pattern pattern that must be absent in server output
615# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100616# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100617# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100619 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200620 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100621
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200622 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200623 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100624 return
625 fi
626
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100627 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100628
Paul Bakkerb7584a52016-05-10 10:50:43 +0100629 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200630 if [ -n "$RUN_TEST_NUMBER" ]; then
631 case ",$RUN_TEST_NUMBER," in
632 *",$TESTS,"*) :;;
633 *) SKIP_NEXT="YES";;
634 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100635 fi
636
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200637 # should we skip?
638 if [ "X$SKIP_NEXT" = "XYES" ]; then
639 SKIP_NEXT="NO"
640 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200641 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200642 return
643 fi
644
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200645 # does this test use a proxy?
646 if [ "X$1" = "X-p" ]; then
647 PXY_CMD="$2"
648 shift 2
649 else
650 PXY_CMD=""
651 fi
652
653 # get commands and client output
654 SRV_CMD="$1"
655 CLI_CMD="$2"
656 CLI_EXPECT="$3"
657 shift 3
658
Hanno Becker7a11e722019-05-10 14:38:42 +0100659 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200660 case "$SRV_CMD $CLI_CMD" in
661 *data_files/*)
662 requires_config_enabled MBEDTLS_FS_IO;;
663 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100664
665 # should we skip?
666 if [ "X$SKIP_NEXT" = "XYES" ]; then
667 SKIP_NEXT="NO"
668 echo "SKIP"
669 SKIPS=$(( $SKIPS + 1 ))
670 return
671 fi
672
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200673 # update DTLS variable
674 detect_dtls "$SRV_CMD"
675
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200676 # if the test uses DTLS but no custom proxy, add a simple proxy
677 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200678 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200679 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200680 case " $SRV_CMD " in
681 *' server_addr=::1 '*)
682 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
683 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200684 fi
685
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200686 # fix client port
687 if [ -n "$PXY_CMD" ]; then
688 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
689 else
690 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
691 fi
692
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100693 # prepend valgrind to our commands if active
694 if [ "$MEMCHECK" -gt 0 ]; then
695 if is_polar "$SRV_CMD"; then
696 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
697 fi
698 if is_polar "$CLI_CMD"; then
699 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
700 fi
701 fi
702
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200703 TIMES_LEFT=2
704 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200705 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200706
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200707 # run the commands
708 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200709 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200710 $PXY_CMD >> $PXY_OUT 2>&1 &
711 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400712 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200713 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200714
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200715 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200716 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200717 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
718 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100719 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200720
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200721 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200722 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
723 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100724
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100725 sleep 0.05
726
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200727 # terminate the server (and the proxy)
728 kill $SRV_PID
729 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100730 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100731
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200732 if [ -n "$PXY_CMD" ]; then
733 kill $PXY_PID >/dev/null 2>&1
734 wait $PXY_PID
735 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100736
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200737 # retry only on timeouts
738 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
739 printf "RETRY "
740 else
741 TIMES_LEFT=0
742 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200743 done
744
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100745 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200746 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100747 # expected client exit to incorrectly succeed in case of catastrophic
748 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100749 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200750 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100751 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100752 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100753 return
754 fi
755 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100756 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200757 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100758 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100759 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100760 return
761 fi
762 fi
763
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100764 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
765 # exit with status 0 when interrupted by a signal, and we don't really
766 # care anyway), in case e.g. the server reports a memory leak.
767 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100768 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100769 return
770 fi
771
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100772 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100773 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
774 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100775 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200776 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100777 return
778 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100779
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100780 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200781 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100782 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100783 while [ $# -gt 0 ]
784 do
785 case $1 in
786 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100787 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 +0100788 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100789 return
790 fi
791 ;;
792
793 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100794 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 +0100795 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100796 return
797 fi
798 ;;
799
800 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100801 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 +0100802 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100803 return
804 fi
805 ;;
806
807 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100808 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 +0100809 fail "pattern '$2' MUST NOT be present in the Client output"
810 return
811 fi
812 ;;
813
814 # The filtering in the following two options (-u and -U) do the following
815 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100816 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100817 # - keep one of each non-unique line
818 # - count how many lines remain
819 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
820 # if there were no duplicates.
821 "-U")
822 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
823 fail "lines following pattern '$2' must be unique in Server output"
824 return
825 fi
826 ;;
827
828 "-u")
829 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
830 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100831 return
832 fi
833 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100834 "-F")
835 if ! $2 "$SRV_OUT"; then
836 fail "function call to '$2' failed on Server output"
837 return
838 fi
839 ;;
840 "-f")
841 if ! $2 "$CLI_OUT"; then
842 fail "function call to '$2' failed on Client output"
843 return
844 fi
845 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100846
847 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200848 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100849 exit 1
850 esac
851 shift 2
852 done
853
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100854 # check valgrind's results
855 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200856 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100857 fail "Server has memory errors"
858 return
859 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200860 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100861 fail "Client has memory errors"
862 return
863 fi
864 fi
865
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100866 # if we're here, everything is ok
867 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100868 if [ "$PRESERVE_LOGS" -gt 0 ]; then
869 mv $SRV_OUT o-srv-${TESTS}.log
870 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100871 if [ -n "$PXY_CMD" ]; then
872 mv $PXY_OUT o-pxy-${TESTS}.log
873 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100874 fi
875
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200876 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100877}
878
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100879cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200880 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200881 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
882 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
883 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
884 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100885 exit 1
886}
887
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100888#
889# MAIN
890#
891
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100892get_options "$@"
893
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200894# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
895# patterns rather than regular expressions, use a case statement instead
896# of calling grep. To keep the optimizer simple, it is incomplete and only
897# detects simple cases: plain substring, everything, nothing.
898#
899# As an exception, the character '.' is treated as an ordinary character
900# if it is the only special character in the string. This is because it's
901# rare to need "any one character", but needing a literal '.' is common
902# (e.g. '-f "DTLS 1.2"').
903need_grep=
904case "$FILTER" in
905 '^$') simple_filter=;;
906 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200907 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200908 need_grep=1;;
909 *) # No regexp or shell-pattern special character
910 simple_filter="*$FILTER*";;
911esac
912case "$EXCLUDE" in
913 '^$') simple_exclude=;;
914 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200915 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200916 need_grep=1;;
917 *) # No regexp or shell-pattern special character
918 simple_exclude="*$EXCLUDE*";;
919esac
920if [ -n "$need_grep" ]; then
921 is_excluded () {
922 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
923 }
924else
925 is_excluded () {
926 case "$1" in
927 $simple_exclude) true;;
928 $simple_filter) false;;
929 *) true;;
930 esac
931 }
932fi
933
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100934# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100935P_SRV_BIN="${P_SRV%%[ ]*}"
936P_CLI_BIN="${P_CLI%%[ ]*}"
937P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100938if [ ! -x "$P_SRV_BIN" ]; then
939 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100940 exit 1
941fi
Hanno Becker17c04932017-10-10 14:44:53 +0100942if [ ! -x "$P_CLI_BIN" ]; then
943 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100944 exit 1
945fi
Hanno Becker17c04932017-10-10 14:44:53 +0100946if [ ! -x "$P_PXY_BIN" ]; then
947 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200948 exit 1
949fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100950if [ "$MEMCHECK" -gt 0 ]; then
951 if which valgrind >/dev/null 2>&1; then :; else
952 echo "Memcheck not possible. Valgrind not found"
953 exit 1
954 fi
955fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100956if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
957 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100958 exit 1
959fi
960
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200961# used by watchdog
962MAIN_PID="$$"
963
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100964# We use somewhat arbitrary delays for tests:
965# - how long do we wait for the server to start (when lsof not available)?
966# - how long do we allow for the client to finish?
967# (not to check performance, just to avoid waiting indefinitely)
968# Things are slower with valgrind, so give extra time here.
969#
970# Note: without lsof, there is a trade-off between the running time of this
971# script and the risk of spurious errors because we didn't wait long enough.
972# The watchdog delay on the other hand doesn't affect normal running time of
973# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200974if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100975 START_DELAY=6
976 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200977else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100978 START_DELAY=2
979 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200980fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100981
982# some particular tests need more time:
983# - for the client, we multiply the usual watchdog limit by a factor
984# - for the server, we sleep for a number of seconds after the client exits
985# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200986CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100987SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200988
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200989# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000990# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Paul Elliott0ab79412021-10-12 16:10:37 +0100991# Note: Using 'localhost' rather than 127.0.0.1 here is unwise, as on many
992# machines that will resolve to ::1, and we don't want ipv6 here.
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200993P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
994P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100995P_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 +0200996O_SRV="$O_SRV -accept $SRV_PORT"
Paul Elliott0ab79412021-10-12 16:10:37 +0100997O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200998G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200999G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001000
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001001if [ -n "${OPENSSL_LEGACY:-}" ]; then
1002 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Paul Elliott0ab79412021-10-12 16:10:37 +01001003 O_LEGACY_CLI="$O_LEGACY_CLI -connect 127.0.0.1:+SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001004fi
1005
Paul Elliott19f1f782021-10-13 18:31:07 +01001006if [ -n "${OPENSSL_NEXT:-}" ]; then
1007 O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT"
Paul Elliott0ab79412021-10-12 16:10:37 +01001008 O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT"
Paul Elliott19f1f782021-10-13 18:31:07 +01001009fi
1010
Hanno Becker58e9dc32018-08-17 15:53:21 +01001011if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001012 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1013fi
1014
Hanno Becker58e9dc32018-08-17 15:53:21 +01001015if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001016 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001017fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001018
Gilles Peskine62469d92017-05-10 10:13:59 +02001019# Allow SHA-1, because many of our test certificates use it
1020P_SRV="$P_SRV allow_sha1=1"
1021P_CLI="$P_CLI allow_sha1=1"
1022
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001023# Also pick a unique name for intermediate files
1024SRV_OUT="srv_out.$$"
1025CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001026PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001027SESSION="session.$$"
1028
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001029SKIP_NEXT="NO"
1030
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001031trap cleanup INT TERM HUP
1032
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001033# Basic test
1034
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001035# Checks that:
1036# - things work with all ciphersuites active (used with config-full in all.sh)
1037# - the expected (highest security) parameters are selected
1038# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001039run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001040 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001041 "$P_CLI" \
1042 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001043 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001044 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001045 -s "client hello v3, signature_algorithm ext: 6" \
1046 -s "ECDHE curve: secp521r1" \
1047 -S "error" \
1048 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001049
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001050run_test "Default, DTLS" \
1051 "$P_SRV dtls=1" \
1052 "$P_CLI dtls=1" \
1053 0 \
1054 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001055 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001056
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001057requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1058run_test "Default (compression enabled)" \
1059 "$P_SRV debug_level=3" \
1060 "$P_CLI debug_level=3" \
1061 0 \
1062 -s "Allocating compression buffer" \
1063 -c "Allocating compression buffer" \
1064 -s "Record expansion is unknown (compression)" \
1065 -c "Record expansion is unknown (compression)" \
1066 -S "error" \
1067 -C "error"
1068
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001069# Test current time in ServerHello
1070requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001071run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001072 "$P_SRV debug_level=3" \
1073 "$P_CLI debug_level=3" \
1074 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001075 -f "check_server_hello_time" \
1076 -F "check_server_hello_time"
1077
Simon Butcher8e004102016-10-14 00:48:33 +01001078# Test for uniqueness of IVs in AEAD ciphersuites
1079run_test "Unique IV in GCM" \
1080 "$P_SRV exchanges=20 debug_level=4" \
1081 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1082 0 \
1083 -u "IV used" \
1084 -U "IV used"
1085
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001086# Tests for rc4 option
1087
Simon Butchera410af52016-05-19 22:12:18 +01001088requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001089run_test "RC4: server disabled, client enabled" \
1090 "$P_SRV" \
1091 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1092 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001093 -s "SSL - The server has no ciphersuites in common"
1094
Simon Butchera410af52016-05-19 22:12:18 +01001095requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001096run_test "RC4: server half, client enabled" \
1097 "$P_SRV arc4=1" \
1098 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1099 1 \
1100 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001101
1102run_test "RC4: server enabled, client disabled" \
1103 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1104 "$P_CLI" \
1105 1 \
1106 -s "SSL - The server has no ciphersuites in common"
1107
1108run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001109 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001110 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1111 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001112 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001113 -S "SSL - The server has no ciphersuites in common"
1114
Hanno Beckerd26bb202018-08-17 09:54:10 +01001115# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1116
1117requires_gnutls
1118requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1119run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1120 "$G_SRV"\
1121 "$P_CLI force_version=tls1_1" \
1122 0
1123
1124requires_gnutls
1125requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1126run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1127 "$G_SRV"\
1128 "$P_CLI force_version=tls1" \
1129 0
1130
Gilles Peskinebc70a182017-05-09 15:59:24 +02001131# Tests for SHA-1 support
1132
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001133requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001134run_test "SHA-1 forbidden by default in server certificate" \
1135 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1136 "$P_CLI debug_level=2 allow_sha1=0" \
1137 1 \
1138 -c "The certificate is signed with an unacceptable hash"
1139
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001140requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1141run_test "SHA-1 forbidden by default in server certificate" \
1142 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1143 "$P_CLI debug_level=2 allow_sha1=0" \
1144 0
1145
Gilles Peskinebc70a182017-05-09 15:59:24 +02001146run_test "SHA-1 explicitly allowed in server certificate" \
1147 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1148 "$P_CLI allow_sha1=1" \
1149 0
1150
1151run_test "SHA-256 allowed by default in server certificate" \
1152 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1153 "$P_CLI allow_sha1=0" \
1154 0
1155
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001156requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001157run_test "SHA-1 forbidden by default in client certificate" \
1158 "$P_SRV auth_mode=required allow_sha1=0" \
1159 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1160 1 \
1161 -s "The certificate is signed with an unacceptable hash"
1162
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001163requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1164run_test "SHA-1 forbidden by default in client certificate" \
1165 "$P_SRV auth_mode=required allow_sha1=0" \
1166 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1167 0
1168
Gilles Peskinebc70a182017-05-09 15:59:24 +02001169run_test "SHA-1 explicitly allowed in client certificate" \
1170 "$P_SRV auth_mode=required allow_sha1=1" \
1171 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1172 0
1173
1174run_test "SHA-256 allowed 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-sha256.crt" \
1177 0
1178
Hanno Becker7ae8a762018-08-14 15:43:35 +01001179# Tests for datagram packing
1180run_test "DTLS: multiple records in same datagram, client and server" \
1181 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1182 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1183 0 \
1184 -c "next record in same datagram" \
1185 -s "next record in same datagram"
1186
1187run_test "DTLS: multiple records in same datagram, client only" \
1188 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1189 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1190 0 \
1191 -s "next record in same datagram" \
1192 -C "next record in same datagram"
1193
1194run_test "DTLS: multiple records in same datagram, server only" \
1195 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1196 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1197 0 \
1198 -S "next record in same datagram" \
1199 -c "next record in same datagram"
1200
1201run_test "DTLS: multiple records in same datagram, neither client nor server" \
1202 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1203 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1204 0 \
1205 -S "next record in same datagram" \
1206 -C "next record in same datagram"
1207
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001208# Tests for Truncated HMAC extension
1209
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001210run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001211 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001212 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001213 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001214 -s "dumping 'expected mac' (20 bytes)" \
1215 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001216
Hanno Becker32c55012017-11-10 08:42:54 +00001217requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001218run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001219 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001220 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001221 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001222 -s "dumping 'expected mac' (20 bytes)" \
1223 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001224
Hanno Becker32c55012017-11-10 08:42:54 +00001225requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001226run_test "Truncated HMAC: client enabled, server default" \
1227 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001228 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001229 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001230 -s "dumping 'expected mac' (20 bytes)" \
1231 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001232
Hanno Becker32c55012017-11-10 08:42:54 +00001233requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001234run_test "Truncated HMAC: client enabled, server disabled" \
1235 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001236 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001237 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001238 -s "dumping 'expected mac' (20 bytes)" \
1239 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001240
Hanno Becker32c55012017-11-10 08:42:54 +00001241requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001242run_test "Truncated HMAC: client disabled, server enabled" \
1243 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001244 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001245 0 \
1246 -s "dumping 'expected mac' (20 bytes)" \
1247 -S "dumping 'expected mac' (10 bytes)"
1248
1249requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001250run_test "Truncated HMAC: client enabled, server enabled" \
1251 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001252 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001253 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001254 -S "dumping 'expected mac' (20 bytes)" \
1255 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001256
Hanno Becker4c4f4102017-11-10 09:16:05 +00001257run_test "Truncated HMAC, DTLS: client default, server default" \
1258 "$P_SRV dtls=1 debug_level=4" \
1259 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1260 0 \
1261 -s "dumping 'expected mac' (20 bytes)" \
1262 -S "dumping 'expected mac' (10 bytes)"
1263
1264requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1265run_test "Truncated HMAC, DTLS: client disabled, server default" \
1266 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001267 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001268 0 \
1269 -s "dumping 'expected mac' (20 bytes)" \
1270 -S "dumping 'expected mac' (10 bytes)"
1271
1272requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1273run_test "Truncated HMAC, DTLS: client enabled, server default" \
1274 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001275 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001276 0 \
1277 -s "dumping 'expected mac' (20 bytes)" \
1278 -S "dumping 'expected mac' (10 bytes)"
1279
1280requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1281run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1282 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001283 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001284 0 \
1285 -s "dumping 'expected mac' (20 bytes)" \
1286 -S "dumping 'expected mac' (10 bytes)"
1287
1288requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1289run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1290 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001291 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001292 0 \
1293 -s "dumping 'expected mac' (20 bytes)" \
1294 -S "dumping 'expected mac' (10 bytes)"
1295
1296requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1297run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1298 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001299 "$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 +01001300 0 \
1301 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001302 -s "dumping 'expected mac' (10 bytes)"
1303
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001304# Tests for Encrypt-then-MAC extension
1305
1306run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001307 "$P_SRV debug_level=3 \
1308 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001309 "$P_CLI debug_level=3" \
1310 0 \
1311 -c "client hello, adding encrypt_then_mac extension" \
1312 -s "found encrypt then mac extension" \
1313 -s "server hello, adding encrypt then mac extension" \
1314 -c "found encrypt_then_mac extension" \
1315 -c "using encrypt then mac" \
1316 -s "using encrypt then mac"
1317
1318run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001319 "$P_SRV debug_level=3 etm=0 \
1320 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001321 "$P_CLI debug_level=3 etm=1" \
1322 0 \
1323 -c "client hello, adding encrypt_then_mac extension" \
1324 -s "found encrypt then mac extension" \
1325 -S "server hello, adding encrypt then mac extension" \
1326 -C "found encrypt_then_mac extension" \
1327 -C "using encrypt then mac" \
1328 -S "using encrypt then mac"
1329
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001330run_test "Encrypt then MAC: client enabled, aead cipher" \
1331 "$P_SRV debug_level=3 etm=1 \
1332 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1333 "$P_CLI debug_level=3 etm=1" \
1334 0 \
1335 -c "client hello, adding encrypt_then_mac extension" \
1336 -s "found encrypt then mac extension" \
1337 -S "server hello, adding encrypt then mac extension" \
1338 -C "found encrypt_then_mac extension" \
1339 -C "using encrypt then mac" \
1340 -S "using encrypt then mac"
1341
1342run_test "Encrypt then MAC: client enabled, stream cipher" \
1343 "$P_SRV debug_level=3 etm=1 \
1344 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001345 "$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 +01001346 0 \
1347 -c "client hello, adding encrypt_then_mac extension" \
1348 -s "found encrypt then mac extension" \
1349 -S "server hello, adding encrypt then mac extension" \
1350 -C "found encrypt_then_mac extension" \
1351 -C "using encrypt then mac" \
1352 -S "using encrypt then mac"
1353
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001354run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001355 "$P_SRV debug_level=3 etm=1 \
1356 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001357 "$P_CLI debug_level=3 etm=0" \
1358 0 \
1359 -C "client hello, adding encrypt_then_mac extension" \
1360 -S "found encrypt then mac extension" \
1361 -S "server hello, adding encrypt then mac extension" \
1362 -C "found encrypt_then_mac extension" \
1363 -C "using encrypt then mac" \
1364 -S "using encrypt then mac"
1365
Janos Follathe2681a42016-03-07 15:57:05 +00001366requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001367run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001368 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001369 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001370 "$P_CLI debug_level=3 force_version=ssl3" \
1371 0 \
1372 -C "client hello, adding encrypt_then_mac extension" \
1373 -S "found encrypt then mac extension" \
1374 -S "server hello, adding encrypt then mac extension" \
1375 -C "found encrypt_then_mac extension" \
1376 -C "using encrypt then mac" \
1377 -S "using encrypt then mac"
1378
Janos Follathe2681a42016-03-07 15:57:05 +00001379requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001380run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001381 "$P_SRV debug_level=3 force_version=ssl3 \
1382 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001383 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001384 0 \
1385 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001386 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001387 -S "server hello, adding encrypt then mac extension" \
1388 -C "found encrypt_then_mac extension" \
1389 -C "using encrypt then mac" \
1390 -S "using encrypt then mac"
1391
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001392# Tests for Extended Master Secret extension
1393
1394run_test "Extended Master Secret: default" \
1395 "$P_SRV debug_level=3" \
1396 "$P_CLI debug_level=3" \
1397 0 \
1398 -c "client hello, adding extended_master_secret extension" \
1399 -s "found extended master secret extension" \
1400 -s "server hello, adding extended master secret extension" \
1401 -c "found extended_master_secret extension" \
1402 -c "using extended master secret" \
1403 -s "using extended master secret"
1404
1405run_test "Extended Master Secret: client enabled, server disabled" \
1406 "$P_SRV debug_level=3 extended_ms=0" \
1407 "$P_CLI debug_level=3 extended_ms=1" \
1408 0 \
1409 -c "client hello, adding extended_master_secret extension" \
1410 -s "found extended master secret extension" \
1411 -S "server hello, adding extended master secret extension" \
1412 -C "found extended_master_secret extension" \
1413 -C "using extended master secret" \
1414 -S "using extended master secret"
1415
1416run_test "Extended Master Secret: client disabled, server enabled" \
1417 "$P_SRV debug_level=3 extended_ms=1" \
1418 "$P_CLI debug_level=3 extended_ms=0" \
1419 0 \
1420 -C "client hello, adding extended_master_secret extension" \
1421 -S "found extended master secret extension" \
1422 -S "server hello, adding extended master secret extension" \
1423 -C "found extended_master_secret extension" \
1424 -C "using extended master secret" \
1425 -S "using extended master secret"
1426
Janos Follathe2681a42016-03-07 15:57:05 +00001427requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001428run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001429 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001430 "$P_CLI debug_level=3 force_version=ssl3" \
1431 0 \
1432 -C "client hello, adding extended_master_secret extension" \
1433 -S "found extended master secret extension" \
1434 -S "server hello, adding extended master secret extension" \
1435 -C "found extended_master_secret extension" \
1436 -C "using extended master secret" \
1437 -S "using extended master secret"
1438
Janos Follathe2681a42016-03-07 15:57:05 +00001439requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001440run_test "Extended Master Secret: client enabled, server SSLv3" \
1441 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001442 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001443 0 \
1444 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001445 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001446 -S "server hello, adding extended master secret extension" \
1447 -C "found extended_master_secret extension" \
1448 -C "using extended master secret" \
1449 -S "using extended master secret"
1450
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001451# Tests for FALLBACK_SCSV
1452
1453run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001454 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001455 "$P_CLI debug_level=3 force_version=tls1_1" \
1456 0 \
1457 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001458 -S "received FALLBACK_SCSV" \
1459 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001460 -C "is a fatal alert message (msg 86)"
1461
1462run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001463 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001464 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1465 0 \
1466 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001467 -S "received FALLBACK_SCSV" \
1468 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001469 -C "is a fatal alert message (msg 86)"
1470
1471run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001472 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001473 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001474 1 \
1475 -c "adding FALLBACK_SCSV" \
1476 -s "received FALLBACK_SCSV" \
1477 -s "inapropriate fallback" \
1478 -c "is a fatal alert message (msg 86)"
1479
1480run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001481 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001482 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001483 0 \
1484 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001485 -s "received FALLBACK_SCSV" \
1486 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001487 -C "is a fatal alert message (msg 86)"
1488
1489requires_openssl_with_fallback_scsv
1490run_test "Fallback SCSV: default, openssl server" \
1491 "$O_SRV" \
1492 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1493 0 \
1494 -C "adding FALLBACK_SCSV" \
1495 -C "is a fatal alert message (msg 86)"
1496
1497requires_openssl_with_fallback_scsv
1498run_test "Fallback SCSV: enabled, openssl server" \
1499 "$O_SRV" \
1500 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1501 1 \
1502 -c "adding FALLBACK_SCSV" \
1503 -c "is a fatal alert message (msg 86)"
1504
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001505requires_openssl_with_fallback_scsv
1506run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001507 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001508 "$O_CLI -tls1_1" \
1509 0 \
1510 -S "received FALLBACK_SCSV" \
1511 -S "inapropriate fallback"
1512
1513requires_openssl_with_fallback_scsv
1514run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001515 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001516 "$O_CLI -tls1_1 -fallback_scsv" \
1517 1 \
1518 -s "received FALLBACK_SCSV" \
1519 -s "inapropriate fallback"
1520
1521requires_openssl_with_fallback_scsv
1522run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001523 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001524 "$O_CLI -fallback_scsv" \
1525 0 \
1526 -s "received FALLBACK_SCSV" \
1527 -S "inapropriate fallback"
1528
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001529# Test sending and receiving empty application data records
1530
1531run_test "Encrypt then MAC: empty application data record" \
1532 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1533 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1534 0 \
1535 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1536 -s "dumping 'input payload after decrypt' (0 bytes)" \
1537 -c "0 bytes written in 1 fragments"
1538
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001539run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001540 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1541 "$P_CLI auth_mode=none etm=0 request_size=0" \
1542 0 \
1543 -s "dumping 'input payload after decrypt' (0 bytes)" \
1544 -c "0 bytes written in 1 fragments"
1545
1546run_test "Encrypt then MAC, DTLS: empty application data record" \
1547 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1548 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1549 0 \
1550 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1551 -s "dumping 'input payload after decrypt' (0 bytes)" \
1552 -c "0 bytes written in 1 fragments"
1553
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001554run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001555 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1556 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1557 0 \
1558 -s "dumping 'input payload after decrypt' (0 bytes)" \
1559 -c "0 bytes written in 1 fragments"
1560
Gilles Peskined50177f2017-05-16 17:53:03 +02001561## ClientHello generated with
1562## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1563## then manually twiddling the ciphersuite list.
1564## The ClientHello content is spelled out below as a hex string as
1565## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1566## The expected response is an inappropriate_fallback alert.
1567requires_openssl_with_fallback_scsv
1568run_test "Fallback SCSV: beginning of list" \
1569 "$P_SRV debug_level=2" \
1570 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1571 0 \
1572 -s "received FALLBACK_SCSV" \
1573 -s "inapropriate fallback"
1574
1575requires_openssl_with_fallback_scsv
1576run_test "Fallback SCSV: end of list" \
1577 "$P_SRV debug_level=2" \
1578 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1579 0 \
1580 -s "received FALLBACK_SCSV" \
1581 -s "inapropriate fallback"
1582
1583## Here the expected response is a valid ServerHello prefix, up to the random.
1584requires_openssl_with_fallback_scsv
1585run_test "Fallback SCSV: not in list" \
1586 "$P_SRV debug_level=2" \
1587 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1588 0 \
1589 -S "received FALLBACK_SCSV" \
1590 -S "inapropriate fallback"
1591
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001592# Tests for CBC 1/n-1 record splitting
1593
1594run_test "CBC Record splitting: TLS 1.2, no splitting" \
1595 "$P_SRV" \
1596 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1597 request_size=123 force_version=tls1_2" \
1598 0 \
1599 -s "Read from client: 123 bytes read" \
1600 -S "Read from client: 1 bytes read" \
1601 -S "122 bytes read"
1602
1603run_test "CBC Record splitting: TLS 1.1, no splitting" \
1604 "$P_SRV" \
1605 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1606 request_size=123 force_version=tls1_1" \
1607 0 \
1608 -s "Read from client: 123 bytes read" \
1609 -S "Read from client: 1 bytes read" \
1610 -S "122 bytes read"
1611
1612run_test "CBC Record splitting: TLS 1.0, splitting" \
1613 "$P_SRV" \
1614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1615 request_size=123 force_version=tls1" \
1616 0 \
1617 -S "Read from client: 123 bytes read" \
1618 -s "Read from client: 1 bytes read" \
1619 -s "122 bytes read"
1620
Janos Follathe2681a42016-03-07 15:57:05 +00001621requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001622run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001623 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001624 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1625 request_size=123 force_version=ssl3" \
1626 0 \
1627 -S "Read from client: 123 bytes read" \
1628 -s "Read from client: 1 bytes read" \
1629 -s "122 bytes read"
1630
1631run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001632 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001633 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1634 request_size=123 force_version=tls1" \
1635 0 \
1636 -s "Read from client: 123 bytes read" \
1637 -S "Read from client: 1 bytes read" \
1638 -S "122 bytes read"
1639
1640run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1641 "$P_SRV" \
1642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1643 request_size=123 force_version=tls1 recsplit=0" \
1644 0 \
1645 -s "Read from client: 123 bytes read" \
1646 -S "Read from client: 1 bytes read" \
1647 -S "122 bytes read"
1648
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001649run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1650 "$P_SRV nbio=2" \
1651 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1652 request_size=123 force_version=tls1" \
1653 0 \
1654 -S "Read from client: 123 bytes read" \
1655 -s "Read from client: 1 bytes read" \
1656 -s "122 bytes read"
1657
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001658# Tests for Session Tickets
1659
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001660run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001661 "$P_SRV debug_level=3 tickets=1" \
1662 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001663 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001664 -c "client hello, adding session ticket extension" \
1665 -s "found session ticket extension" \
1666 -s "server hello, adding session ticket extension" \
1667 -c "found session_ticket extension" \
1668 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001669 -S "session successfully restored from cache" \
1670 -s "session successfully restored from ticket" \
1671 -s "a session has been resumed" \
1672 -c "a session has been resumed"
1673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001674run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001675 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1676 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001677 0 \
1678 -c "client hello, adding session ticket extension" \
1679 -s "found session ticket extension" \
1680 -s "server hello, adding session ticket extension" \
1681 -c "found session_ticket extension" \
1682 -c "parse new session ticket" \
1683 -S "session successfully restored from cache" \
1684 -s "session successfully restored from ticket" \
1685 -s "a session has been resumed" \
1686 -c "a session has been resumed"
1687
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001688run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001689 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1690 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001691 0 \
1692 -c "client hello, adding session ticket extension" \
1693 -s "found session ticket extension" \
1694 -s "server hello, adding session ticket extension" \
1695 -c "found session_ticket extension" \
1696 -c "parse new session ticket" \
1697 -S "session successfully restored from cache" \
1698 -S "session successfully restored from ticket" \
1699 -S "a session has been resumed" \
1700 -C "a session has been resumed"
1701
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001702run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001703 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001704 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001705 0 \
1706 -c "client hello, adding session ticket extension" \
1707 -c "found session_ticket extension" \
1708 -c "parse new session ticket" \
1709 -c "a session has been resumed"
1710
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001711run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001712 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001713 "( $O_CLI -sess_out $SESSION; \
1714 $O_CLI -sess_in $SESSION; \
1715 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001716 0 \
1717 -s "found session ticket extension" \
1718 -s "server hello, adding session ticket extension" \
1719 -S "session successfully restored from cache" \
1720 -s "session successfully restored from ticket" \
1721 -s "a session has been resumed"
1722
Hanno Becker1d739932018-08-21 13:55:22 +01001723# Tests for Session Tickets with DTLS
1724
1725run_test "Session resume using tickets, DTLS: basic" \
1726 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001727 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001728 0 \
1729 -c "client hello, adding session ticket extension" \
1730 -s "found session ticket extension" \
1731 -s "server hello, adding session ticket extension" \
1732 -c "found session_ticket extension" \
1733 -c "parse new session ticket" \
1734 -S "session successfully restored from cache" \
1735 -s "session successfully restored from ticket" \
1736 -s "a session has been resumed" \
1737 -c "a session has been resumed"
1738
1739run_test "Session resume using tickets, DTLS: cache disabled" \
1740 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001741 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001742 0 \
1743 -c "client hello, adding session ticket extension" \
1744 -s "found session ticket extension" \
1745 -s "server hello, adding session ticket extension" \
1746 -c "found session_ticket extension" \
1747 -c "parse new session ticket" \
1748 -S "session successfully restored from cache" \
1749 -s "session successfully restored from ticket" \
1750 -s "a session has been resumed" \
1751 -c "a session has been resumed"
1752
1753run_test "Session resume using tickets, DTLS: timeout" \
1754 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001755 "$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 +01001756 0 \
1757 -c "client hello, adding session ticket extension" \
1758 -s "found session ticket extension" \
1759 -s "server hello, adding session ticket extension" \
1760 -c "found session_ticket extension" \
1761 -c "parse new session ticket" \
1762 -S "session successfully restored from cache" \
1763 -S "session successfully restored from ticket" \
1764 -S "a session has been resumed" \
1765 -C "a session has been resumed"
1766
1767run_test "Session resume using tickets, DTLS: openssl server" \
1768 "$O_SRV -dtls1" \
1769 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1770 0 \
1771 -c "client hello, adding session ticket extension" \
1772 -c "found session_ticket extension" \
1773 -c "parse new session ticket" \
1774 -c "a session has been resumed"
1775
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001776# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001777# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001778requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001779run_test "Session resume using tickets, DTLS: openssl client" \
1780 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001781 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1782 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001783 rm -f $SESSION )" \
1784 0 \
1785 -s "found session ticket extension" \
1786 -s "server hello, adding session ticket extension" \
1787 -S "session successfully restored from cache" \
1788 -s "session successfully restored from ticket" \
1789 -s "a session has been resumed"
1790
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001791# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001792
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001793run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001794 "$P_SRV debug_level=3 tickets=0" \
1795 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001796 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001797 -c "client hello, adding session ticket extension" \
1798 -s "found session ticket extension" \
1799 -S "server hello, adding session ticket extension" \
1800 -C "found session_ticket extension" \
1801 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001802 -s "session successfully restored from cache" \
1803 -S "session successfully restored from ticket" \
1804 -s "a session has been resumed" \
1805 -c "a session has been resumed"
1806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001807run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_SRV debug_level=3 tickets=1" \
1809 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001810 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001811 -C "client hello, adding session ticket extension" \
1812 -S "found session ticket extension" \
1813 -S "server hello, adding session ticket extension" \
1814 -C "found session_ticket extension" \
1815 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001816 -s "session successfully restored from cache" \
1817 -S "session successfully restored from ticket" \
1818 -s "a session has been resumed" \
1819 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001821run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001822 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1823 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001824 0 \
1825 -S "session successfully restored from cache" \
1826 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001827 -S "a session has been resumed" \
1828 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001830run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001831 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1832 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001833 0 \
1834 -s "session successfully restored from cache" \
1835 -S "session successfully restored from ticket" \
1836 -s "a session has been resumed" \
1837 -c "a session has been resumed"
1838
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001839run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001840 "$P_SRV debug_level=3 tickets=0" \
1841 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001842 0 \
1843 -s "session successfully restored from cache" \
1844 -S "session successfully restored from ticket" \
1845 -s "a session has been resumed" \
1846 -c "a session has been resumed"
1847
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001848run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001849 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1850 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001851 0 \
1852 -S "session successfully restored from cache" \
1853 -S "session successfully restored from ticket" \
1854 -S "a session has been resumed" \
1855 -C "a session has been resumed"
1856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001857run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001858 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1859 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001860 0 \
1861 -s "session successfully restored from cache" \
1862 -S "session successfully restored from ticket" \
1863 -s "a session has been resumed" \
1864 -c "a session has been resumed"
1865
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001866run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001867 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001868 "( $O_CLI -sess_out $SESSION; \
1869 $O_CLI -sess_in $SESSION; \
1870 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001871 0 \
1872 -s "found session ticket extension" \
1873 -S "server hello, adding session ticket extension" \
1874 -s "session successfully restored from cache" \
1875 -S "session successfully restored from ticket" \
1876 -s "a session has been resumed"
1877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001878run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001879 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001880 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001881 0 \
1882 -C "found session_ticket extension" \
1883 -C "parse new session ticket" \
1884 -c "a session has been resumed"
1885
Hanno Becker1d739932018-08-21 13:55:22 +01001886# Tests for Session Resume based on session-ID and cache, DTLS
1887
1888run_test "Session resume using cache, DTLS: tickets enabled on client" \
1889 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001890 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001891 0 \
1892 -c "client hello, adding session ticket extension" \
1893 -s "found session ticket extension" \
1894 -S "server hello, adding session ticket extension" \
1895 -C "found session_ticket extension" \
1896 -C "parse new session ticket" \
1897 -s "session successfully restored from cache" \
1898 -S "session successfully restored from ticket" \
1899 -s "a session has been resumed" \
1900 -c "a session has been resumed"
1901
1902run_test "Session resume using cache, DTLS: tickets enabled on server" \
1903 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001904 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001905 0 \
1906 -C "client hello, adding session ticket extension" \
1907 -S "found session ticket extension" \
1908 -S "server hello, adding session ticket extension" \
1909 -C "found session_ticket extension" \
1910 -C "parse new session ticket" \
1911 -s "session successfully restored from cache" \
1912 -S "session successfully restored from ticket" \
1913 -s "a session has been resumed" \
1914 -c "a session has been resumed"
1915
1916run_test "Session resume using cache, DTLS: cache_max=0" \
1917 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001918 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001919 0 \
1920 -S "session successfully restored from cache" \
1921 -S "session successfully restored from ticket" \
1922 -S "a session has been resumed" \
1923 -C "a session has been resumed"
1924
1925run_test "Session resume using cache, DTLS: cache_max=1" \
1926 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001927 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001928 0 \
1929 -s "session successfully restored from cache" \
1930 -S "session successfully restored from ticket" \
1931 -s "a session has been resumed" \
1932 -c "a session has been resumed"
1933
1934run_test "Session resume using cache, DTLS: timeout > delay" \
1935 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001936 "$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 +01001937 0 \
1938 -s "session successfully restored from cache" \
1939 -S "session successfully restored from ticket" \
1940 -s "a session has been resumed" \
1941 -c "a session has been resumed"
1942
1943run_test "Session resume using cache, DTLS: timeout < delay" \
1944 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001945 "$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 +01001946 0 \
1947 -S "session successfully restored from cache" \
1948 -S "session successfully restored from ticket" \
1949 -S "a session has been resumed" \
1950 -C "a session has been resumed"
1951
1952run_test "Session resume using cache, DTLS: no timeout" \
1953 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001954 "$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 +01001955 0 \
1956 -s "session successfully restored from cache" \
1957 -S "session successfully restored from ticket" \
1958 -s "a session has been resumed" \
1959 -c "a session has been resumed"
1960
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001961# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001962# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001963requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001964run_test "Session resume using cache, DTLS: openssl client" \
1965 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001966 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1967 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001968 rm -f $SESSION )" \
1969 0 \
1970 -s "found session ticket extension" \
1971 -S "server hello, adding session ticket extension" \
1972 -s "session successfully restored from cache" \
1973 -S "session successfully restored from ticket" \
1974 -s "a session has been resumed"
1975
1976run_test "Session resume using cache, DTLS: openssl server" \
1977 "$O_SRV -dtls1" \
1978 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1979 0 \
1980 -C "found session_ticket extension" \
1981 -C "parse new session ticket" \
1982 -c "a session has been resumed"
1983
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001984# Tests for Max Fragment Length extension
1985
Hanno Becker4aed27e2017-09-18 15:00:34 +01001986requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001987run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001988 "$P_SRV debug_level=3" \
1989 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001990 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001991 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1992 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001993 -C "client hello, adding max_fragment_length extension" \
1994 -S "found max fragment length extension" \
1995 -S "server hello, max_fragment_length extension" \
1996 -C "found max_fragment_length extension"
1997
Hanno Becker4aed27e2017-09-18 15:00:34 +01001998requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001999run_test "Max fragment length: enabled, default, larger message" \
2000 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002001 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002002 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002003 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2004 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002005 -C "client hello, adding max_fragment_length extension" \
2006 -S "found max fragment length extension" \
2007 -S "server hello, max_fragment_length extension" \
2008 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002009 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2010 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002011 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002012
2013requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2014run_test "Max fragment length, DTLS: enabled, default, larger message" \
2015 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002016 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002017 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002018 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2019 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002020 -C "client hello, adding max_fragment_length extension" \
2021 -S "found max fragment length extension" \
2022 -S "server hello, max_fragment_length extension" \
2023 -C "found max_fragment_length extension" \
2024 -c "fragment larger than.*maximum "
2025
Angus Grattonc4dd0732018-04-11 16:28:39 +10002026# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2027# (session fragment length will be 16384 regardless of mbedtls
2028# content length configuration.)
2029
Hanno Beckerc5266962017-09-18 15:01:50 +01002030requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2031run_test "Max fragment length: disabled, larger message" \
2032 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002033 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002034 0 \
2035 -C "Maximum fragment length is 16384" \
2036 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002037 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2038 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002039 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002040
2041requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takano2e580ce2021-06-21 19:43:33 +01002042run_test "Max fragment length, DTLS: disabled, larger message" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002043 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002044 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002045 1 \
2046 -C "Maximum fragment length is 16384" \
2047 -S "Maximum fragment length is 16384" \
2048 -c "fragment larger than.*maximum "
2049
Yuto Takano0807e1d2021-07-02 10:10:49 +01002050requires_max_content_len 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01002051requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002052run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002053 "$P_SRV debug_level=3" \
2054 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002055 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002056 -c "Maximum fragment length is 4096" \
2057 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002058 -c "client hello, adding max_fragment_length extension" \
2059 -s "found max fragment length extension" \
2060 -s "server hello, max_fragment_length extension" \
2061 -c "found max_fragment_length extension"
2062
Yuto Takano0807e1d2021-07-02 10:10:49 +01002063requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002064requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002065run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002066 "$P_SRV debug_level=3 max_frag_len=4096" \
2067 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002068 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002069 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002070 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002071 -C "client hello, adding max_fragment_length extension" \
2072 -S "found max fragment length extension" \
2073 -S "server hello, max_fragment_length extension" \
2074 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002075
Yuto Takano0807e1d2021-07-02 10:10:49 +01002076requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002077requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002078requires_gnutls
2079run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002080 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002081 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002082 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002083 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002084 -c "client hello, adding max_fragment_length extension" \
2085 -c "found max_fragment_length extension"
2086
Yuto Takano0807e1d2021-07-02 10:10:49 +01002087requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002088requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002089run_test "Max fragment length: client, message just fits" \
2090 "$P_SRV debug_level=3" \
2091 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2092 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002093 -c "Maximum fragment length is 2048" \
2094 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002095 -c "client hello, adding max_fragment_length extension" \
2096 -s "found max fragment length extension" \
2097 -s "server hello, max_fragment_length extension" \
2098 -c "found max_fragment_length extension" \
2099 -c "2048 bytes written in 1 fragments" \
2100 -s "2048 bytes read"
2101
Yuto Takano0807e1d2021-07-02 10:10:49 +01002102requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002103requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002104run_test "Max fragment length: client, larger message" \
2105 "$P_SRV debug_level=3" \
2106 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2107 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002108 -c "Maximum fragment length is 2048" \
2109 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002110 -c "client hello, adding max_fragment_length extension" \
2111 -s "found max fragment length extension" \
2112 -s "server hello, max_fragment_length extension" \
2113 -c "found max_fragment_length extension" \
2114 -c "2345 bytes written in 2 fragments" \
2115 -s "2048 bytes read" \
2116 -s "297 bytes read"
2117
Yuto Takano0807e1d2021-07-02 10:10:49 +01002118requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002119requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002120run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002121 "$P_SRV debug_level=3 dtls=1" \
2122 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2123 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002124 -c "Maximum fragment length is 2048" \
2125 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002126 -c "client hello, adding max_fragment_length extension" \
2127 -s "found max fragment length extension" \
2128 -s "server hello, max_fragment_length extension" \
2129 -c "found max_fragment_length extension" \
2130 -c "fragment larger than.*maximum"
2131
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002132# Tests for renegotiation
2133
Hanno Becker6a243642017-10-12 15:18:45 +01002134# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002135run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002136 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002137 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002138 0 \
2139 -C "client hello, adding renegotiation extension" \
2140 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2141 -S "found renegotiation extension" \
2142 -s "server hello, secure renegotiation extension" \
2143 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002144 -C "=> renegotiate" \
2145 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002146 -S "write hello request"
2147
Hanno Becker6a243642017-10-12 15:18:45 +01002148requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002150 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002151 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002152 0 \
2153 -c "client hello, adding renegotiation extension" \
2154 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2155 -s "found renegotiation extension" \
2156 -s "server hello, secure renegotiation extension" \
2157 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002158 -c "=> renegotiate" \
2159 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002160 -S "write hello request"
2161
Hanno Becker6a243642017-10-12 15:18:45 +01002162requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002163run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002164 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002165 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002166 0 \
2167 -c "client hello, adding renegotiation extension" \
2168 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2169 -s "found renegotiation extension" \
2170 -s "server hello, secure renegotiation extension" \
2171 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002172 -c "=> renegotiate" \
2173 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002174 -s "write hello request"
2175
Janos Follathb0f148c2017-10-05 12:29:42 +01002176# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2177# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2178# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002179requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002180run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2181 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2182 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2183 0 \
2184 -c "client hello, adding renegotiation extension" \
2185 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2186 -s "found renegotiation extension" \
2187 -s "server hello, secure renegotiation extension" \
2188 -c "found renegotiation extension" \
2189 -c "=> renegotiate" \
2190 -s "=> renegotiate" \
2191 -S "write hello request" \
2192 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2193
2194# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2195# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2196# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002197requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002198run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2199 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2200 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2201 0 \
2202 -c "client hello, adding renegotiation extension" \
2203 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2204 -s "found renegotiation extension" \
2205 -s "server hello, secure renegotiation extension" \
2206 -c "found renegotiation extension" \
2207 -c "=> renegotiate" \
2208 -s "=> renegotiate" \
2209 -s "write hello request" \
2210 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2211
Hanno Becker6a243642017-10-12 15:18:45 +01002212requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002213run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002214 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002215 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002216 0 \
2217 -c "client hello, adding renegotiation extension" \
2218 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2219 -s "found renegotiation extension" \
2220 -s "server hello, secure renegotiation extension" \
2221 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002222 -c "=> renegotiate" \
2223 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002224 -s "write hello request"
2225
Hanno Becker6a243642017-10-12 15:18:45 +01002226requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002227run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002228 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002229 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002230 1 \
2231 -c "client hello, adding renegotiation extension" \
2232 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2233 -S "found renegotiation extension" \
2234 -s "server hello, secure renegotiation extension" \
2235 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002236 -c "=> renegotiate" \
2237 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002238 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002239 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002240 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002241
Hanno Becker6a243642017-10-12 15:18:45 +01002242requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002243run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002244 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002245 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002246 0 \
2247 -C "client hello, adding renegotiation extension" \
2248 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2249 -S "found renegotiation extension" \
2250 -s "server hello, secure renegotiation extension" \
2251 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002252 -C "=> renegotiate" \
2253 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002254 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002255 -S "SSL - An unexpected message was received from our peer" \
2256 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002257
Hanno Becker6a243642017-10-12 15:18:45 +01002258requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002259run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002260 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002261 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002262 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002263 0 \
2264 -C "client hello, adding renegotiation extension" \
2265 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2266 -S "found renegotiation extension" \
2267 -s "server hello, secure renegotiation extension" \
2268 -c "found renegotiation extension" \
2269 -C "=> renegotiate" \
2270 -S "=> renegotiate" \
2271 -s "write hello request" \
2272 -S "SSL - An unexpected message was received from our peer" \
2273 -S "failed"
2274
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002275# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002276requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002277run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002278 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002279 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002280 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002281 0 \
2282 -C "client hello, adding renegotiation extension" \
2283 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2284 -S "found renegotiation extension" \
2285 -s "server hello, secure renegotiation extension" \
2286 -c "found renegotiation extension" \
2287 -C "=> renegotiate" \
2288 -S "=> renegotiate" \
2289 -s "write hello request" \
2290 -S "SSL - An unexpected message was received from our peer" \
2291 -S "failed"
2292
Hanno Becker6a243642017-10-12 15:18:45 +01002293requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002294run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002295 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002296 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002297 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002298 0 \
2299 -C "client hello, adding renegotiation extension" \
2300 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2301 -S "found renegotiation extension" \
2302 -s "server hello, secure renegotiation extension" \
2303 -c "found renegotiation extension" \
2304 -C "=> renegotiate" \
2305 -S "=> renegotiate" \
2306 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002307 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002308
Hanno Becker6a243642017-10-12 15:18:45 +01002309requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002310run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002311 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002312 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002313 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002314 0 \
2315 -c "client hello, adding renegotiation extension" \
2316 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2317 -s "found renegotiation extension" \
2318 -s "server hello, secure renegotiation extension" \
2319 -c "found renegotiation extension" \
2320 -c "=> renegotiate" \
2321 -s "=> renegotiate" \
2322 -s "write hello request" \
2323 -S "SSL - An unexpected message was received from our peer" \
2324 -S "failed"
2325
Hanno Becker6a243642017-10-12 15:18:45 +01002326requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002327run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002328 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002329 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2330 0 \
2331 -C "client hello, adding renegotiation extension" \
2332 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2333 -S "found renegotiation extension" \
2334 -s "server hello, secure renegotiation extension" \
2335 -c "found renegotiation extension" \
2336 -S "record counter limit reached: renegotiate" \
2337 -C "=> renegotiate" \
2338 -S "=> renegotiate" \
2339 -S "write hello request" \
2340 -S "SSL - An unexpected message was received from our peer" \
2341 -S "failed"
2342
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002343# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002344requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002345run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002346 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002347 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002348 0 \
2349 -c "client hello, adding renegotiation extension" \
2350 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2351 -s "found renegotiation extension" \
2352 -s "server hello, secure renegotiation extension" \
2353 -c "found renegotiation extension" \
2354 -s "record counter limit reached: renegotiate" \
2355 -c "=> renegotiate" \
2356 -s "=> renegotiate" \
2357 -s "write hello request" \
2358 -S "SSL - An unexpected message was received from our peer" \
2359 -S "failed"
2360
Hanno Becker6a243642017-10-12 15:18:45 +01002361requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002362run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002363 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002364 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002365 0 \
2366 -c "client hello, adding renegotiation extension" \
2367 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2368 -s "found renegotiation extension" \
2369 -s "server hello, secure renegotiation extension" \
2370 -c "found renegotiation extension" \
2371 -s "record counter limit reached: renegotiate" \
2372 -c "=> renegotiate" \
2373 -s "=> renegotiate" \
2374 -s "write hello request" \
2375 -S "SSL - An unexpected message was received from our peer" \
2376 -S "failed"
2377
Hanno Becker6a243642017-10-12 15:18:45 +01002378requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002379run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002380 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002381 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2382 0 \
2383 -C "client hello, adding renegotiation extension" \
2384 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2385 -S "found renegotiation extension" \
2386 -s "server hello, secure renegotiation extension" \
2387 -c "found renegotiation extension" \
2388 -S "record counter limit reached: renegotiate" \
2389 -C "=> renegotiate" \
2390 -S "=> renegotiate" \
2391 -S "write hello request" \
2392 -S "SSL - An unexpected message was received from our peer" \
2393 -S "failed"
2394
Hanno Becker6a243642017-10-12 15:18:45 +01002395requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002396run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002397 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002398 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002399 0 \
2400 -c "client hello, adding renegotiation extension" \
2401 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2402 -s "found renegotiation extension" \
2403 -s "server hello, secure renegotiation extension" \
2404 -c "found renegotiation extension" \
2405 -c "=> renegotiate" \
2406 -s "=> renegotiate" \
2407 -S "write hello request"
2408
Hanno Becker6a243642017-10-12 15:18:45 +01002409requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002410run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002411 "$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 +02002412 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002413 0 \
2414 -c "client hello, adding renegotiation extension" \
2415 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2416 -s "found renegotiation extension" \
2417 -s "server hello, secure renegotiation extension" \
2418 -c "found renegotiation extension" \
2419 -c "=> renegotiate" \
2420 -s "=> renegotiate" \
2421 -s "write hello request"
2422
Hanno Becker6a243642017-10-12 15:18:45 +01002423requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002424run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002425 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002426 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002427 0 \
2428 -c "client hello, adding renegotiation extension" \
2429 -c "found renegotiation extension" \
2430 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002431 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002432 -C "error" \
2433 -c "HTTP/1.0 200 [Oo][Kk]"
2434
Paul Bakker539d9722015-02-08 16:18:35 +01002435requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002436requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002437run_test "Renegotiation: gnutls server strict, client-initiated" \
2438 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002439 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002440 0 \
2441 -c "client hello, adding renegotiation extension" \
2442 -c "found renegotiation extension" \
2443 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002444 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002445 -C "error" \
2446 -c "HTTP/1.0 200 [Oo][Kk]"
2447
Paul Bakker539d9722015-02-08 16:18:35 +01002448requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002449requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002450run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2451 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2452 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2453 1 \
2454 -c "client hello, adding renegotiation extension" \
2455 -C "found renegotiation extension" \
2456 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002457 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002458 -c "error" \
2459 -C "HTTP/1.0 200 [Oo][Kk]"
2460
Paul Bakker539d9722015-02-08 16:18:35 +01002461requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002462requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002463run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2464 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2465 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2466 allow_legacy=0" \
2467 1 \
2468 -c "client hello, adding renegotiation extension" \
2469 -C "found renegotiation extension" \
2470 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002471 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002472 -c "error" \
2473 -C "HTTP/1.0 200 [Oo][Kk]"
2474
Paul Bakker539d9722015-02-08 16:18:35 +01002475requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002476requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002477run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2478 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2479 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2480 allow_legacy=1" \
2481 0 \
2482 -c "client hello, adding renegotiation extension" \
2483 -C "found renegotiation extension" \
2484 -c "=> renegotiate" \
2485 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002486 -C "error" \
2487 -c "HTTP/1.0 200 [Oo][Kk]"
2488
Hanno Becker6a243642017-10-12 15:18:45 +01002489requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002490run_test "Renegotiation: DTLS, client-initiated" \
2491 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2492 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2493 0 \
2494 -c "client hello, adding renegotiation extension" \
2495 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2496 -s "found renegotiation extension" \
2497 -s "server hello, secure renegotiation extension" \
2498 -c "found renegotiation extension" \
2499 -c "=> renegotiate" \
2500 -s "=> renegotiate" \
2501 -S "write hello request"
2502
Hanno Becker6a243642017-10-12 15:18:45 +01002503requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002504run_test "Renegotiation: DTLS, server-initiated" \
2505 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002506 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2507 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002508 0 \
2509 -c "client hello, adding renegotiation extension" \
2510 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2511 -s "found renegotiation extension" \
2512 -s "server hello, secure renegotiation extension" \
2513 -c "found renegotiation extension" \
2514 -c "=> renegotiate" \
2515 -s "=> renegotiate" \
2516 -s "write hello request"
2517
Hanno Becker6a243642017-10-12 15:18:45 +01002518requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002519run_test "Renegotiation: DTLS, renego_period overflow" \
2520 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2521 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2522 0 \
2523 -c "client hello, adding renegotiation extension" \
2524 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2525 -s "found renegotiation extension" \
2526 -s "server hello, secure renegotiation extension" \
2527 -s "record counter limit reached: renegotiate" \
2528 -c "=> renegotiate" \
2529 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002530 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002531
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002532requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002533requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002534run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2535 "$G_SRV -u --mtu 4096" \
2536 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2537 0 \
2538 -c "client hello, adding renegotiation extension" \
2539 -c "found renegotiation extension" \
2540 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002541 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002542 -C "error" \
2543 -s "Extra-header:"
2544
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002545# Test for the "secure renegotation" extension only (no actual renegotiation)
2546
Paul Bakker539d9722015-02-08 16:18:35 +01002547requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002548run_test "Renego ext: gnutls server strict, client default" \
2549 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2550 "$P_CLI debug_level=3" \
2551 0 \
2552 -c "found renegotiation extension" \
2553 -C "error" \
2554 -c "HTTP/1.0 200 [Oo][Kk]"
2555
Paul Bakker539d9722015-02-08 16:18:35 +01002556requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002557run_test "Renego ext: gnutls server unsafe, client default" \
2558 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2559 "$P_CLI debug_level=3" \
2560 0 \
2561 -C "found renegotiation extension" \
2562 -C "error" \
2563 -c "HTTP/1.0 200 [Oo][Kk]"
2564
Paul Bakker539d9722015-02-08 16:18:35 +01002565requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002566run_test "Renego ext: gnutls server unsafe, client break legacy" \
2567 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2568 "$P_CLI debug_level=3 allow_legacy=-1" \
2569 1 \
2570 -C "found renegotiation extension" \
2571 -c "error" \
2572 -C "HTTP/1.0 200 [Oo][Kk]"
2573
Paul Bakker539d9722015-02-08 16:18:35 +01002574requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002575run_test "Renego ext: gnutls client strict, server default" \
2576 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002577 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002578 0 \
2579 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2580 -s "server hello, secure renegotiation extension"
2581
Paul Bakker539d9722015-02-08 16:18:35 +01002582requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002583run_test "Renego ext: gnutls client unsafe, server default" \
2584 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002585 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002586 0 \
2587 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2588 -S "server hello, secure renegotiation extension"
2589
Paul Bakker539d9722015-02-08 16:18:35 +01002590requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002591run_test "Renego ext: gnutls client unsafe, server break legacy" \
2592 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002593 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002594 1 \
2595 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2596 -S "server hello, secure renegotiation extension"
2597
Janos Follath0b242342016-02-17 10:11:21 +00002598# Tests for silently dropping trailing extra bytes in .der certificates
2599
2600requires_gnutls
2601run_test "DER format: no trailing bytes" \
2602 "$P_SRV crt_file=data_files/server5-der0.crt \
2603 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002604 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002605 0 \
2606 -c "Handshake was completed" \
2607
2608requires_gnutls
2609run_test "DER format: with a trailing zero byte" \
2610 "$P_SRV crt_file=data_files/server5-der1a.crt \
2611 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002612 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002613 0 \
2614 -c "Handshake was completed" \
2615
2616requires_gnutls
2617run_test "DER format: with a trailing random byte" \
2618 "$P_SRV crt_file=data_files/server5-der1b.crt \
2619 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002620 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002621 0 \
2622 -c "Handshake was completed" \
2623
2624requires_gnutls
2625run_test "DER format: with 2 trailing random bytes" \
2626 "$P_SRV crt_file=data_files/server5-der2.crt \
2627 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002628 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002629 0 \
2630 -c "Handshake was completed" \
2631
2632requires_gnutls
2633run_test "DER format: with 4 trailing random bytes" \
2634 "$P_SRV crt_file=data_files/server5-der4.crt \
2635 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002636 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002637 0 \
2638 -c "Handshake was completed" \
2639
2640requires_gnutls
2641run_test "DER format: with 8 trailing random bytes" \
2642 "$P_SRV crt_file=data_files/server5-der8.crt \
2643 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002644 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002645 0 \
2646 -c "Handshake was completed" \
2647
2648requires_gnutls
2649run_test "DER format: with 9 trailing random bytes" \
2650 "$P_SRV crt_file=data_files/server5-der9.crt \
2651 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002652 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002653 0 \
2654 -c "Handshake was completed" \
2655
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002656# Tests for auth_mode
2657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002658run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002659 "$P_SRV crt_file=data_files/server5-badsign.crt \
2660 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002661 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002662 1 \
2663 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002664 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002665 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002666 -c "X509 - Certificate verification failed"
2667
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002668run_test "Authentication: server badcert, client optional" \
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=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002672 0 \
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
Hanno Beckere6706e62017-05-15 16:05:15 +01002678run_test "Authentication: server goodcert, client optional, no trusted CA" \
2679 "$P_SRV" \
2680 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2681 0 \
2682 -c "x509_verify_cert() returned" \
2683 -c "! The certificate is not correctly signed by the trusted CA" \
2684 -c "! Certificate verification flags"\
2685 -C "! mbedtls_ssl_handshake returned" \
2686 -C "X509 - Certificate verification failed" \
2687 -C "SSL - No CA Chain is set, but required to operate"
2688
2689run_test "Authentication: server goodcert, client required, no trusted CA" \
2690 "$P_SRV" \
2691 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2692 1 \
2693 -c "x509_verify_cert() returned" \
2694 -c "! The certificate is not correctly signed by the trusted CA" \
2695 -c "! Certificate verification flags"\
2696 -c "! mbedtls_ssl_handshake returned" \
2697 -c "SSL - No CA Chain is set, but required to operate"
2698
2699# The purpose of the next two tests is to test the client's behaviour when receiving a server
2700# certificate with an unsupported elliptic curve. This should usually not happen because
2701# the client informs the server about the supported curves - it does, though, in the
2702# corner case of a static ECDH suite, because the server doesn't check the curve on that
2703# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2704# different means to have the server ignoring the client's supported curve list.
2705
2706requires_config_enabled MBEDTLS_ECP_C
2707run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2708 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2709 crt_file=data_files/server5.ku-ka.crt" \
2710 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2711 1 \
2712 -c "bad certificate (EC key curve)"\
2713 -c "! Certificate verification flags"\
2714 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2715
2716requires_config_enabled MBEDTLS_ECP_C
2717run_test "Authentication: server ECDH p256v1, client optional, 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=optional 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 only at ECDH params check
2725
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002726run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002727 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002728 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002729 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002730 0 \
2731 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002732 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002733 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002734 -C "X509 - Certificate verification failed"
2735
Simon Butcher99000142016-10-13 17:21:01 +01002736run_test "Authentication: client SHA256, server required" \
2737 "$P_SRV auth_mode=required" \
2738 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2739 key_file=data_files/server6.key \
2740 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2741 0 \
2742 -c "Supported Signature Algorithm found: 4," \
2743 -c "Supported Signature Algorithm found: 5,"
2744
2745run_test "Authentication: client SHA384, server required" \
2746 "$P_SRV auth_mode=required" \
2747 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2748 key_file=data_files/server6.key \
2749 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2750 0 \
2751 -c "Supported Signature Algorithm found: 4," \
2752 -c "Supported Signature Algorithm found: 5,"
2753
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002754requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2755run_test "Authentication: client has no cert, server required (SSLv3)" \
2756 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2757 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2758 key_file=data_files/server5.key" \
2759 1 \
2760 -S "skip write certificate request" \
2761 -C "skip parse certificate request" \
2762 -c "got a certificate request" \
2763 -c "got no certificate to send" \
2764 -S "x509_verify_cert() returned" \
2765 -s "client has no certificate" \
2766 -s "! mbedtls_ssl_handshake returned" \
2767 -c "! mbedtls_ssl_handshake returned" \
2768 -s "No client certification received from the client, but required by the authentication mode"
2769
2770run_test "Authentication: client has no cert, server required (TLS)" \
2771 "$P_SRV debug_level=3 auth_mode=required" \
2772 "$P_CLI debug_level=3 crt_file=none \
2773 key_file=data_files/server5.key" \
2774 1 \
2775 -S "skip write certificate request" \
2776 -C "skip parse certificate request" \
2777 -c "got a certificate request" \
2778 -c "= write certificate$" \
2779 -C "skip write certificate$" \
2780 -S "x509_verify_cert() returned" \
2781 -s "client has no certificate" \
2782 -s "! mbedtls_ssl_handshake returned" \
2783 -c "! mbedtls_ssl_handshake returned" \
2784 -s "No client certification received from the client, but required by the authentication mode"
2785
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002786run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002787 "$P_SRV debug_level=3 auth_mode=required" \
2788 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002789 key_file=data_files/server5.key" \
2790 1 \
2791 -S "skip write certificate request" \
2792 -C "skip parse certificate request" \
2793 -c "got a certificate request" \
2794 -C "skip write certificate" \
2795 -C "skip write certificate verify" \
2796 -S "skip parse certificate verify" \
2797 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002798 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002799 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002800 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002801 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002802 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002803# We don't check that the client receives the alert because it might
2804# detect that its write end of the connection is closed and abort
2805# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002806
Janos Follath89baba22017-04-10 14:34:35 +01002807run_test "Authentication: client cert not trusted, server required" \
2808 "$P_SRV debug_level=3 auth_mode=required" \
2809 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2810 key_file=data_files/server5.key" \
2811 1 \
2812 -S "skip write certificate request" \
2813 -C "skip parse certificate request" \
2814 -c "got a certificate request" \
2815 -C "skip write certificate" \
2816 -C "skip write certificate verify" \
2817 -S "skip parse certificate verify" \
2818 -s "x509_verify_cert() returned" \
2819 -s "! The certificate is not correctly signed by the trusted CA" \
2820 -s "! mbedtls_ssl_handshake returned" \
2821 -c "! mbedtls_ssl_handshake returned" \
2822 -s "X509 - Certificate verification failed"
2823
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002824run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002825 "$P_SRV debug_level=3 auth_mode=optional" \
2826 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002827 key_file=data_files/server5.key" \
2828 0 \
2829 -S "skip write certificate request" \
2830 -C "skip parse certificate request" \
2831 -c "got a certificate request" \
2832 -C "skip write certificate" \
2833 -C "skip write certificate verify" \
2834 -S "skip parse certificate verify" \
2835 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002836 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002837 -S "! mbedtls_ssl_handshake returned" \
2838 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002839 -S "X509 - Certificate verification failed"
2840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002841run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002842 "$P_SRV debug_level=3 auth_mode=none" \
2843 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002844 key_file=data_files/server5.key" \
2845 0 \
2846 -s "skip write certificate request" \
2847 -C "skip parse certificate request" \
2848 -c "got no certificate request" \
2849 -c "skip write certificate" \
2850 -c "skip write certificate verify" \
2851 -s "skip parse certificate verify" \
2852 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002853 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002854 -S "! mbedtls_ssl_handshake returned" \
2855 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002856 -S "X509 - Certificate verification failed"
2857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002858run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002859 "$P_SRV debug_level=3 auth_mode=optional" \
2860 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002861 0 \
2862 -S "skip write certificate request" \
2863 -C "skip parse certificate request" \
2864 -c "got a certificate request" \
2865 -C "skip write certificate$" \
2866 -C "got no certificate to send" \
2867 -S "SSLv3 client has no certificate" \
2868 -c "skip write certificate verify" \
2869 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002870 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002871 -S "! mbedtls_ssl_handshake returned" \
2872 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002873 -S "X509 - Certificate verification failed"
2874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002875run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002876 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002877 "$O_CLI" \
2878 0 \
2879 -S "skip write certificate request" \
2880 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002881 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002882 -S "! 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: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002886 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002887 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002888 0 \
2889 -C "skip parse certificate request" \
2890 -c "got a certificate request" \
2891 -C "skip write certificate$" \
2892 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002893 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002894
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002895run_test "Authentication: client no cert, openssl server required" \
2896 "$O_SRV -Verify 10" \
2897 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2898 1 \
2899 -C "skip parse certificate request" \
2900 -c "got a certificate request" \
2901 -C "skip write certificate$" \
2902 -c "skip write certificate verify" \
2903 -c "! mbedtls_ssl_handshake returned"
2904
Janos Follathe2681a42016-03-07 15:57:05 +00002905requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002906run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002907 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002908 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002909 0 \
2910 -S "skip write certificate request" \
2911 -C "skip parse certificate request" \
2912 -c "got a certificate request" \
2913 -C "skip write certificate$" \
2914 -c "skip write certificate verify" \
2915 -c "got no certificate to send" \
2916 -s "SSLv3 client has no certificate" \
2917 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002918 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002919 -S "! mbedtls_ssl_handshake returned" \
2920 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002921 -S "X509 - Certificate verification failed"
2922
Yuto Takano8df2d252021-07-02 13:05:15 +01002923# This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default
2924# value, defined here as MAX_IM_CA. Some test cases will be skipped if the
2925# library is configured with a different value.
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002926
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002927MAX_IM_CA='8'
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002928
Yuto Takano8df2d252021-07-02 13:05:15 +01002929# The tests for the max_int tests can pass with any number higher than MAX_IM_CA
2930# because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1
2931# tests can pass with any number less than MAX_IM_CA. However, stricter preconditions
2932# are in place so that the semantics are consistent with the test description.
Yuto Takanobc632c22021-07-02 13:10:41 +01002933requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002934requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002935run_test "Authentication: server max_int chain, client default" \
2936 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2937 key_file=data_files/dir-maxpath/09.key" \
2938 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2939 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002940 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002941
Yuto Takanobc632c22021-07-02 13:10:41 +01002942requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002943requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002944run_test "Authentication: server max_int+1 chain, client default" \
2945 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2946 key_file=data_files/dir-maxpath/10.key" \
2947 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2948 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002949 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002950
Yuto Takanobc632c22021-07-02 13:10:41 +01002951requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002952requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002953run_test "Authentication: server max_int+1 chain, client optional" \
2954 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2955 key_file=data_files/dir-maxpath/10.key" \
2956 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2957 auth_mode=optional" \
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 none" \
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=none" \
2968 0 \
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: client max_int+1 chain, server default" \
2974 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2975 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2976 key_file=data_files/dir-maxpath/10.key" \
2977 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002978 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002979
Yuto Takanobc632c22021-07-02 13:10:41 +01002980requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002981requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002982run_test "Authentication: client max_int+1 chain, server optional" \
2983 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2984 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2985 key_file=data_files/dir-maxpath/10.key" \
2986 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002987 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002988
Yuto Takanobc632c22021-07-02 13:10:41 +01002989requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002990requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002991run_test "Authentication: client max_int+1 chain, server required" \
2992 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2993 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2994 key_file=data_files/dir-maxpath/10.key" \
2995 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002996 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002997
Yuto Takanobc632c22021-07-02 13:10:41 +01002998requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002999requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003000run_test "Authentication: client max_int chain, server required" \
3001 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3002 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
3003 key_file=data_files/dir-maxpath/09.key" \
3004 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003005 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003006
Janos Follath89baba22017-04-10 14:34:35 +01003007# Tests for CA list in CertificateRequest messages
3008
3009run_test "Authentication: send CA list in CertificateRequest (default)" \
3010 "$P_SRV debug_level=3 auth_mode=required" \
3011 "$P_CLI crt_file=data_files/server6.crt \
3012 key_file=data_files/server6.key" \
3013 0 \
3014 -s "requested DN"
3015
3016run_test "Authentication: do not send CA list in CertificateRequest" \
3017 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3018 "$P_CLI crt_file=data_files/server6.crt \
3019 key_file=data_files/server6.key" \
3020 0 \
3021 -S "requested DN"
3022
3023run_test "Authentication: send CA list in CertificateRequest, client self signed" \
3024 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3025 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3026 key_file=data_files/server5.key" \
3027 1 \
3028 -S "requested DN" \
3029 -s "x509_verify_cert() returned" \
3030 -s "! The certificate is not correctly signed by the trusted CA" \
3031 -s "! mbedtls_ssl_handshake returned" \
3032 -c "! mbedtls_ssl_handshake returned" \
3033 -s "X509 - Certificate verification failed"
3034
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01003035# Tests for certificate selection based on SHA verson
3036
3037run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3038 "$P_SRV crt_file=data_files/server5.crt \
3039 key_file=data_files/server5.key \
3040 crt_file2=data_files/server5-sha1.crt \
3041 key_file2=data_files/server5.key" \
3042 "$P_CLI force_version=tls1_2" \
3043 0 \
3044 -c "signed using.*ECDSA with SHA256" \
3045 -C "signed using.*ECDSA with SHA1"
3046
3047run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
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_1" \
3053 0 \
3054 -C "signed using.*ECDSA with SHA256" \
3055 -c "signed using.*ECDSA with SHA1"
3056
3057run_test "Certificate hash: client TLS 1.0 -> 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" \
3063 0 \
3064 -C "signed using.*ECDSA with SHA256" \
3065 -c "signed using.*ECDSA with SHA1"
3066
3067run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3068 "$P_SRV crt_file=data_files/server5.crt \
3069 key_file=data_files/server5.key \
3070 crt_file2=data_files/server6.crt \
3071 key_file2=data_files/server6.key" \
3072 "$P_CLI force_version=tls1_1" \
3073 0 \
3074 -c "serial number.*09" \
3075 -c "signed using.*ECDSA with SHA256" \
3076 -C "signed using.*ECDSA with SHA1"
3077
3078run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3079 "$P_SRV crt_file=data_files/server6.crt \
3080 key_file=data_files/server6.key \
3081 crt_file2=data_files/server5.crt \
3082 key_file2=data_files/server5.key" \
3083 "$P_CLI force_version=tls1_1" \
3084 0 \
3085 -c "serial number.*0A" \
3086 -c "signed using.*ECDSA with SHA256" \
3087 -C "signed using.*ECDSA with SHA1"
3088
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003089# tests for SNI
3090
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003091run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003092 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003093 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003094 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003095 0 \
3096 -S "parse ServerName extension" \
3097 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3098 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003099
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003100run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003101 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003102 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003103 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 +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 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 2" \
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=polarssl.example" \
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=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003119
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003120run_test "SNI: no matching cert" \
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=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003125 1 \
3126 -s "parse ServerName extension" \
3127 -s "ssl_sni_wrapper() returned" \
3128 -s "mbedtls_ssl_handshake returned" \
3129 -c "mbedtls_ssl_handshake returned" \
3130 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003131
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003132run_test "SNI: client auth no override: optional" \
3133 "$P_SRV debug_level=3 auth_mode=optional \
3134 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3135 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3136 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003137 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003138 -S "skip write certificate request" \
3139 -C "skip parse certificate request" \
3140 -c "got a certificate request" \
3141 -C "skip write certificate" \
3142 -C "skip write certificate verify" \
3143 -S "skip parse certificate verify"
3144
3145run_test "SNI: client auth override: none -> optional" \
3146 "$P_SRV debug_level=3 auth_mode=none \
3147 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3148 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3149 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003150 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003151 -S "skip write certificate request" \
3152 -C "skip parse certificate request" \
3153 -c "got a certificate request" \
3154 -C "skip write certificate" \
3155 -C "skip write certificate verify" \
3156 -S "skip parse certificate verify"
3157
3158run_test "SNI: client auth override: optional -> none" \
3159 "$P_SRV debug_level=3 auth_mode=optional \
3160 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3161 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3162 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003163 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003164 -s "skip write certificate request" \
3165 -C "skip parse certificate request" \
3166 -c "got no certificate request" \
3167 -c "skip write certificate" \
3168 -c "skip write certificate verify" \
3169 -s "skip parse certificate verify"
3170
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003171run_test "SNI: CA no override" \
3172 "$P_SRV debug_level=3 auth_mode=optional \
3173 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3174 ca_file=data_files/test-ca.crt \
3175 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3176 "$P_CLI debug_level=3 server_name=localhost \
3177 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3178 1 \
3179 -S "skip write certificate request" \
3180 -C "skip parse certificate request" \
3181 -c "got a certificate request" \
3182 -C "skip write certificate" \
3183 -C "skip write certificate verify" \
3184 -S "skip parse certificate verify" \
3185 -s "x509_verify_cert() returned" \
3186 -s "! The certificate is not correctly signed by the trusted CA" \
3187 -S "The certificate has been revoked (is on a CRL)"
3188
3189run_test "SNI: CA override" \
3190 "$P_SRV debug_level=3 auth_mode=optional \
3191 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3192 ca_file=data_files/test-ca.crt \
3193 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3194 "$P_CLI debug_level=3 server_name=localhost \
3195 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3196 0 \
3197 -S "skip write certificate request" \
3198 -C "skip parse certificate request" \
3199 -c "got a certificate request" \
3200 -C "skip write certificate" \
3201 -C "skip write certificate verify" \
3202 -S "skip parse certificate verify" \
3203 -S "x509_verify_cert() returned" \
3204 -S "! The certificate is not correctly signed by the trusted CA" \
3205 -S "The certificate has been revoked (is on a CRL)"
3206
3207run_test "SNI: CA override with CRL" \
3208 "$P_SRV debug_level=3 auth_mode=optional \
3209 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3210 ca_file=data_files/test-ca.crt \
3211 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3212 "$P_CLI debug_level=3 server_name=localhost \
3213 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3214 1 \
3215 -S "skip write certificate request" \
3216 -C "skip parse certificate request" \
3217 -c "got a certificate request" \
3218 -C "skip write certificate" \
3219 -C "skip write certificate verify" \
3220 -S "skip parse certificate verify" \
3221 -s "x509_verify_cert() returned" \
3222 -S "! The certificate is not correctly signed by the trusted CA" \
3223 -s "The certificate has been revoked (is on a CRL)"
3224
Andres AG1a834452016-12-07 10:01:30 +00003225# Tests for SNI and DTLS
3226
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003227run_test "SNI: DTLS, no SNI callback" \
3228 "$P_SRV debug_level=3 dtls=1 \
3229 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3230 "$P_CLI server_name=localhost dtls=1" \
3231 0 \
3232 -S "parse ServerName extension" \
3233 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3234 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3235
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003236run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003237 "$P_SRV debug_level=3 dtls=1 \
3238 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3239 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.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 CA" \
3244 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3245
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003246run_test "SNI: DTLS, matching cert 2" \
3247 "$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=polarssl.example 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=polarssl.example"
3255
3256run_test "SNI: DTLS, no matching cert" \
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=nonesuch.example dtls=1" \
3261 1 \
3262 -s "parse ServerName extension" \
3263 -s "ssl_sni_wrapper() returned" \
3264 -s "mbedtls_ssl_handshake returned" \
3265 -c "mbedtls_ssl_handshake returned" \
3266 -c "SSL - A fatal alert message was received from our peer"
3267
3268run_test "SNI: DTLS, client auth no override: optional" \
3269 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3270 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3271 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3272 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3273 0 \
3274 -S "skip write certificate request" \
3275 -C "skip parse certificate request" \
3276 -c "got a certificate request" \
3277 -C "skip write certificate" \
3278 -C "skip write certificate verify" \
3279 -S "skip parse certificate verify"
3280
3281run_test "SNI: DTLS, client auth override: none -> optional" \
3282 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3283 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3284 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3285 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3286 0 \
3287 -S "skip write certificate request" \
3288 -C "skip parse certificate request" \
3289 -c "got a certificate request" \
3290 -C "skip write certificate" \
3291 -C "skip write certificate verify" \
3292 -S "skip parse certificate verify"
3293
3294run_test "SNI: DTLS, client auth override: optional -> none" \
3295 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3296 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3297 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3298 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3299 0 \
3300 -s "skip write certificate request" \
3301 -C "skip parse certificate request" \
3302 -c "got no certificate request" \
3303 -c "skip write certificate" \
3304 -c "skip write certificate verify" \
3305 -s "skip parse certificate verify"
3306
3307run_test "SNI: DTLS, CA no override" \
3308 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3309 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3310 ca_file=data_files/test-ca.crt \
3311 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3312 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3313 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3314 1 \
3315 -S "skip write certificate request" \
3316 -C "skip parse certificate request" \
3317 -c "got a certificate request" \
3318 -C "skip write certificate" \
3319 -C "skip write certificate verify" \
3320 -S "skip parse certificate verify" \
3321 -s "x509_verify_cert() returned" \
3322 -s "! The certificate is not correctly signed by the trusted CA" \
3323 -S "The certificate has been revoked (is on a CRL)"
3324
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003325run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003326 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3327 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3328 ca_file=data_files/test-ca.crt \
3329 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3330 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3331 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3332 0 \
3333 -S "skip write certificate request" \
3334 -C "skip parse certificate request" \
3335 -c "got a certificate request" \
3336 -C "skip write certificate" \
3337 -C "skip write certificate verify" \
3338 -S "skip parse certificate verify" \
3339 -S "x509_verify_cert() returned" \
3340 -S "! The certificate is not correctly signed by the trusted CA" \
3341 -S "The certificate has been revoked (is on a CRL)"
3342
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003343run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003344 "$P_SRV debug_level=3 auth_mode=optional \
3345 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3346 ca_file=data_files/test-ca.crt \
3347 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3348 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3349 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3350 1 \
3351 -S "skip write certificate request" \
3352 -C "skip parse certificate request" \
3353 -c "got a certificate request" \
3354 -C "skip write certificate" \
3355 -C "skip write certificate verify" \
3356 -S "skip parse certificate verify" \
3357 -s "x509_verify_cert() returned" \
3358 -S "! The certificate is not correctly signed by the trusted CA" \
3359 -s "The certificate has been revoked (is on a CRL)"
3360
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003361# Tests for non-blocking I/O: exercise a variety of handshake flows
3362
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003363run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003364 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3365 "$P_CLI nbio=2 tickets=0" \
3366 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003367 -S "mbedtls_ssl_handshake returned" \
3368 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003369 -c "Read from server: .* bytes read"
3370
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003371run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003372 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3373 "$P_CLI nbio=2 tickets=0" \
3374 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003375 -S "mbedtls_ssl_handshake returned" \
3376 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003377 -c "Read from server: .* bytes read"
3378
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003379run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003380 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3381 "$P_CLI nbio=2 tickets=1" \
3382 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003383 -S "mbedtls_ssl_handshake returned" \
3384 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003385 -c "Read from server: .* bytes read"
3386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003387run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003388 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3389 "$P_CLI nbio=2 tickets=1" \
3390 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003391 -S "mbedtls_ssl_handshake returned" \
3392 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003393 -c "Read from server: .* bytes read"
3394
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003395run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003396 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3397 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3398 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003399 -S "mbedtls_ssl_handshake returned" \
3400 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003401 -c "Read from server: .* bytes read"
3402
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003403run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003404 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3405 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3406 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003407 -S "mbedtls_ssl_handshake returned" \
3408 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003409 -c "Read from server: .* bytes read"
3410
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003411run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003412 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3413 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3414 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003415 -S "mbedtls_ssl_handshake returned" \
3416 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003417 -c "Read from server: .* bytes read"
3418
Hanno Becker00076712017-11-15 16:39:08 +00003419# Tests for event-driven I/O: exercise a variety of handshake flows
3420
3421run_test "Event-driven I/O: basic handshake" \
3422 "$P_SRV event=1 tickets=0 auth_mode=none" \
3423 "$P_CLI event=1 tickets=0" \
3424 0 \
3425 -S "mbedtls_ssl_handshake returned" \
3426 -C "mbedtls_ssl_handshake returned" \
3427 -c "Read from server: .* bytes read"
3428
3429run_test "Event-driven I/O: client auth" \
3430 "$P_SRV event=1 tickets=0 auth_mode=required" \
3431 "$P_CLI event=1 tickets=0" \
3432 0 \
3433 -S "mbedtls_ssl_handshake returned" \
3434 -C "mbedtls_ssl_handshake returned" \
3435 -c "Read from server: .* bytes read"
3436
3437run_test "Event-driven I/O: ticket" \
3438 "$P_SRV event=1 tickets=1 auth_mode=none" \
3439 "$P_CLI event=1 tickets=1" \
3440 0 \
3441 -S "mbedtls_ssl_handshake returned" \
3442 -C "mbedtls_ssl_handshake returned" \
3443 -c "Read from server: .* bytes read"
3444
3445run_test "Event-driven I/O: ticket + client auth" \
3446 "$P_SRV event=1 tickets=1 auth_mode=required" \
3447 "$P_CLI event=1 tickets=1" \
3448 0 \
3449 -S "mbedtls_ssl_handshake returned" \
3450 -C "mbedtls_ssl_handshake returned" \
3451 -c "Read from server: .* bytes read"
3452
3453run_test "Event-driven I/O: ticket + client auth + resume" \
3454 "$P_SRV event=1 tickets=1 auth_mode=required" \
3455 "$P_CLI event=1 tickets=1 reconnect=1" \
3456 0 \
3457 -S "mbedtls_ssl_handshake returned" \
3458 -C "mbedtls_ssl_handshake returned" \
3459 -c "Read from server: .* bytes read"
3460
3461run_test "Event-driven I/O: ticket + resume" \
3462 "$P_SRV event=1 tickets=1 auth_mode=none" \
3463 "$P_CLI event=1 tickets=1 reconnect=1" \
3464 0 \
3465 -S "mbedtls_ssl_handshake returned" \
3466 -C "mbedtls_ssl_handshake returned" \
3467 -c "Read from server: .* bytes read"
3468
3469run_test "Event-driven I/O: session-id resume" \
3470 "$P_SRV event=1 tickets=0 auth_mode=none" \
3471 "$P_CLI event=1 tickets=0 reconnect=1" \
3472 0 \
3473 -S "mbedtls_ssl_handshake returned" \
3474 -C "mbedtls_ssl_handshake returned" \
3475 -c "Read from server: .* bytes read"
3476
Hanno Becker6a33f592018-03-13 11:38:46 +00003477run_test "Event-driven I/O, DTLS: basic handshake" \
3478 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3479 "$P_CLI dtls=1 event=1 tickets=0" \
3480 0 \
3481 -c "Read from server: .* bytes read"
3482
3483run_test "Event-driven I/O, DTLS: client auth" \
3484 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3485 "$P_CLI dtls=1 event=1 tickets=0" \
3486 0 \
3487 -c "Read from server: .* bytes read"
3488
3489run_test "Event-driven I/O, DTLS: ticket" \
3490 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3491 "$P_CLI dtls=1 event=1 tickets=1" \
3492 0 \
3493 -c "Read from server: .* bytes read"
3494
3495run_test "Event-driven I/O, DTLS: ticket + client auth" \
3496 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3497 "$P_CLI dtls=1 event=1 tickets=1" \
3498 0 \
3499 -c "Read from server: .* bytes read"
3500
3501run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3502 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003503 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003504 0 \
3505 -c "Read from server: .* bytes read"
3506
3507run_test "Event-driven I/O, DTLS: ticket + resume" \
3508 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003509 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003510 0 \
3511 -c "Read from server: .* bytes read"
3512
3513run_test "Event-driven I/O, DTLS: session-id resume" \
3514 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003515 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003516 0 \
3517 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003518
3519# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3520# During session resumption, the client will send its ApplicationData record
3521# within the same datagram as the Finished messages. In this situation, the
3522# server MUST NOT idle on the underlying transport after handshake completion,
3523# because the ApplicationData request has already been queued internally.
3524run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003525 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003526 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003527 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003528 0 \
3529 -c "Read from server: .* bytes read"
3530
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003531# Tests for version negotiation
3532
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003533run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003534 "$P_SRV" \
3535 "$P_CLI" \
3536 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003537 -S "mbedtls_ssl_handshake returned" \
3538 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003539 -s "Protocol is TLSv1.2" \
3540 -c "Protocol is TLSv1.2"
3541
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003542run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003543 "$P_SRV" \
3544 "$P_CLI max_version=tls1_1" \
3545 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003546 -S "mbedtls_ssl_handshake returned" \
3547 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003548 -s "Protocol is TLSv1.1" \
3549 -c "Protocol is TLSv1.1"
3550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003551run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003552 "$P_SRV max_version=tls1_1" \
3553 "$P_CLI" \
3554 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003555 -S "mbedtls_ssl_handshake returned" \
3556 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003557 -s "Protocol is TLSv1.1" \
3558 -c "Protocol is TLSv1.1"
3559
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003560run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003561 "$P_SRV max_version=tls1_1" \
3562 "$P_CLI max_version=tls1_1" \
3563 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003564 -S "mbedtls_ssl_handshake returned" \
3565 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003566 -s "Protocol is TLSv1.1" \
3567 -c "Protocol is TLSv1.1"
3568
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003569run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003570 "$P_SRV min_version=tls1_1" \
3571 "$P_CLI max_version=tls1_1" \
3572 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003573 -S "mbedtls_ssl_handshake returned" \
3574 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003575 -s "Protocol is TLSv1.1" \
3576 -c "Protocol is TLSv1.1"
3577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003578run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003579 "$P_SRV max_version=tls1_1" \
3580 "$P_CLI min_version=tls1_1" \
3581 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003582 -S "mbedtls_ssl_handshake returned" \
3583 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003584 -s "Protocol is TLSv1.1" \
3585 -c "Protocol is TLSv1.1"
3586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003587run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003588 "$P_SRV max_version=tls1_1" \
3589 "$P_CLI min_version=tls1_2" \
3590 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003591 -s "mbedtls_ssl_handshake returned" \
3592 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003593 -c "SSL - Handshake protocol not within min/max boundaries"
3594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003595run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003596 "$P_SRV min_version=tls1_2" \
3597 "$P_CLI max_version=tls1_1" \
3598 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003599 -s "mbedtls_ssl_handshake returned" \
3600 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003601 -s "SSL - Handshake protocol not within min/max boundaries"
3602
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003603# Tests for ALPN extension
3604
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003605run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003606 "$P_SRV debug_level=3" \
3607 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003608 0 \
3609 -C "client hello, adding alpn extension" \
3610 -S "found alpn extension" \
3611 -C "got an alert message, type: \\[2:120]" \
3612 -S "server hello, adding alpn extension" \
3613 -C "found alpn extension " \
3614 -C "Application Layer Protocol is" \
3615 -S "Application Layer Protocol is"
3616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003617run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003618 "$P_SRV debug_level=3" \
3619 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003620 0 \
3621 -c "client hello, adding alpn extension" \
3622 -s "found alpn extension" \
3623 -C "got an alert message, type: \\[2:120]" \
3624 -S "server hello, adding alpn extension" \
3625 -C "found alpn extension " \
3626 -c "Application Layer Protocol is (none)" \
3627 -S "Application Layer Protocol is"
3628
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003629run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003630 "$P_SRV debug_level=3 alpn=abc,1234" \
3631 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003632 0 \
3633 -C "client hello, adding alpn extension" \
3634 -S "found alpn extension" \
3635 -C "got an alert message, type: \\[2:120]" \
3636 -S "server hello, adding alpn extension" \
3637 -C "found alpn extension " \
3638 -C "Application Layer Protocol is" \
3639 -s "Application Layer Protocol is (none)"
3640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003641run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003642 "$P_SRV debug_level=3 alpn=abc,1234" \
3643 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003644 0 \
3645 -c "client hello, adding alpn extension" \
3646 -s "found alpn extension" \
3647 -C "got an alert message, type: \\[2:120]" \
3648 -s "server hello, adding alpn extension" \
3649 -c "found alpn extension" \
3650 -c "Application Layer Protocol is abc" \
3651 -s "Application Layer Protocol is abc"
3652
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003653run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003654 "$P_SRV debug_level=3 alpn=abc,1234" \
3655 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003656 0 \
3657 -c "client hello, adding alpn extension" \
3658 -s "found alpn extension" \
3659 -C "got an alert message, type: \\[2:120]" \
3660 -s "server hello, adding alpn extension" \
3661 -c "found alpn extension" \
3662 -c "Application Layer Protocol is abc" \
3663 -s "Application Layer Protocol is abc"
3664
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003665run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003666 "$P_SRV debug_level=3 alpn=abc,1234" \
3667 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003668 0 \
3669 -c "client hello, adding alpn extension" \
3670 -s "found alpn extension" \
3671 -C "got an alert message, type: \\[2:120]" \
3672 -s "server hello, adding alpn extension" \
3673 -c "found alpn extension" \
3674 -c "Application Layer Protocol is 1234" \
3675 -s "Application Layer Protocol is 1234"
3676
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003677run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003678 "$P_SRV debug_level=3 alpn=abc,123" \
3679 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003680 1 \
3681 -c "client hello, adding alpn extension" \
3682 -s "found alpn extension" \
3683 -c "got an alert message, type: \\[2:120]" \
3684 -S "server hello, adding alpn extension" \
3685 -C "found alpn extension" \
3686 -C "Application Layer Protocol is 1234" \
3687 -S "Application Layer Protocol is 1234"
3688
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003689
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003690# Tests for keyUsage in leaf certificates, part 1:
3691# server-side certificate/suite selection
3692
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003693run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003694 "$P_SRV key_file=data_files/server2.key \
3695 crt_file=data_files/server2.ku-ds.crt" \
3696 "$P_CLI" \
3697 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003698 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003699
3700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003701run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003702 "$P_SRV key_file=data_files/server2.key \
3703 crt_file=data_files/server2.ku-ke.crt" \
3704 "$P_CLI" \
3705 0 \
3706 -c "Ciphersuite is TLS-RSA-WITH-"
3707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003708run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003709 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003710 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003711 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003712 1 \
3713 -C "Ciphersuite is "
3714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003715run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003716 "$P_SRV key_file=data_files/server5.key \
3717 crt_file=data_files/server5.ku-ds.crt" \
3718 "$P_CLI" \
3719 0 \
3720 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3721
3722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003723run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003724 "$P_SRV key_file=data_files/server5.key \
3725 crt_file=data_files/server5.ku-ka.crt" \
3726 "$P_CLI" \
3727 0 \
3728 -c "Ciphersuite is TLS-ECDH-"
3729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003730run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003731 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003732 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003733 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003734 1 \
3735 -C "Ciphersuite is "
3736
3737# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003738# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003740run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003741 "$O_SRV -key data_files/server2.key \
3742 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003743 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003744 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3745 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003746 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003747 -C "Processing of the Certificate handshake message failed" \
3748 -c "Ciphersuite is TLS-"
3749
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003750run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-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-DHE-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: KeyEncipherment, 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-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-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, DHE-RSA: fail" \
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-DHE-RSA-WITH-AES-128-CBC-SHA" \
3775 1 \
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é-Gonnarde6efa6f2015-04-20 11:01:48 +01003780run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3781 "$O_SRV -key data_files/server2.key \
3782 -cert data_files/server2.ku-ke.crt" \
3783 "$P_CLI debug_level=1 auth_mode=optional \
3784 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3785 0 \
3786 -c "bad certificate (usage extensions)" \
3787 -C "Processing of the Certificate handshake message failed" \
3788 -c "Ciphersuite is TLS-" \
3789 -c "! Usage does not match the keyUsage extension"
3790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003791run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003792 "$O_SRV -key data_files/server2.key \
3793 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003794 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003795 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3796 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003797 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003798 -C "Processing of the Certificate handshake message failed" \
3799 -c "Ciphersuite is TLS-"
3800
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003801run_test "keyUsage cli: DigitalSignature, RSA: fail" \
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-RSA-WITH-AES-128-CBC-SHA" \
3806 1 \
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é-Gonnarde6efa6f2015-04-20 11:01:48 +01003811run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3812 "$O_SRV -key data_files/server2.key \
3813 -cert data_files/server2.ku-ds.crt" \
3814 "$P_CLI debug_level=1 auth_mode=optional \
3815 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3816 0 \
3817 -c "bad certificate (usage extensions)" \
3818 -C "Processing of the Certificate handshake message failed" \
3819 -c "Ciphersuite is TLS-" \
3820 -c "! Usage does not match the keyUsage extension"
3821
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003822# Tests for keyUsage in leaf certificates, part 3:
3823# server-side checking of client cert
3824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003825run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003826 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003827 "$O_CLI -key data_files/server2.key \
3828 -cert data_files/server2.ku-ds.crt" \
3829 0 \
3830 -S "bad certificate (usage extensions)" \
3831 -S "Processing of the Certificate handshake message failed"
3832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003833run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003834 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003835 "$O_CLI -key data_files/server2.key \
3836 -cert data_files/server2.ku-ke.crt" \
3837 0 \
3838 -s "bad certificate (usage extensions)" \
3839 -S "Processing of the Certificate handshake message failed"
3840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003841run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003842 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003843 "$O_CLI -key data_files/server2.key \
3844 -cert data_files/server2.ku-ke.crt" \
3845 1 \
3846 -s "bad certificate (usage extensions)" \
3847 -s "Processing of the Certificate handshake message failed"
3848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003849run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003850 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003851 "$O_CLI -key data_files/server5.key \
3852 -cert data_files/server5.ku-ds.crt" \
3853 0 \
3854 -S "bad certificate (usage extensions)" \
3855 -S "Processing of the Certificate handshake message failed"
3856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003857run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003858 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003859 "$O_CLI -key data_files/server5.key \
3860 -cert data_files/server5.ku-ka.crt" \
3861 0 \
3862 -s "bad certificate (usage extensions)" \
3863 -S "Processing of the Certificate handshake message failed"
3864
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003865# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003867run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003868 "$P_SRV key_file=data_files/server5.key \
3869 crt_file=data_files/server5.eku-srv.crt" \
3870 "$P_CLI" \
3871 0
3872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003873run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003874 "$P_SRV key_file=data_files/server5.key \
3875 crt_file=data_files/server5.eku-srv.crt" \
3876 "$P_CLI" \
3877 0
3878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003879run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003880 "$P_SRV key_file=data_files/server5.key \
3881 crt_file=data_files/server5.eku-cs_any.crt" \
3882 "$P_CLI" \
3883 0
3884
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003885run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003886 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003887 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003888 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003889 1
3890
3891# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003893run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003894 "$O_SRV -key data_files/server5.key \
3895 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003896 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003897 0 \
3898 -C "bad certificate (usage extensions)" \
3899 -C "Processing of the Certificate handshake message failed" \
3900 -c "Ciphersuite is TLS-"
3901
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003902run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003903 "$O_SRV -key data_files/server5.key \
3904 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003905 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003906 0 \
3907 -C "bad certificate (usage extensions)" \
3908 -C "Processing of the Certificate handshake message failed" \
3909 -c "Ciphersuite is TLS-"
3910
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003911run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003912 "$O_SRV -key data_files/server5.key \
3913 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003914 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003915 0 \
3916 -C "bad certificate (usage extensions)" \
3917 -C "Processing of the Certificate handshake message failed" \
3918 -c "Ciphersuite is TLS-"
3919
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003920run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003921 "$O_SRV -key data_files/server5.key \
3922 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003923 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003924 1 \
3925 -c "bad certificate (usage extensions)" \
3926 -c "Processing of the Certificate handshake message failed" \
3927 -C "Ciphersuite is TLS-"
3928
3929# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003931run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003932 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003933 "$O_CLI -key data_files/server5.key \
3934 -cert data_files/server5.eku-cli.crt" \
3935 0 \
3936 -S "bad certificate (usage extensions)" \
3937 -S "Processing of the Certificate handshake message failed"
3938
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003939run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003940 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003941 "$O_CLI -key data_files/server5.key \
3942 -cert data_files/server5.eku-srv_cli.crt" \
3943 0 \
3944 -S "bad certificate (usage extensions)" \
3945 -S "Processing of the Certificate handshake message failed"
3946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003947run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003948 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003949 "$O_CLI -key data_files/server5.key \
3950 -cert data_files/server5.eku-cs_any.crt" \
3951 0 \
3952 -S "bad certificate (usage extensions)" \
3953 -S "Processing of the Certificate handshake message failed"
3954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003955run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003956 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003957 "$O_CLI -key data_files/server5.key \
3958 -cert data_files/server5.eku-cs.crt" \
3959 0 \
3960 -s "bad certificate (usage extensions)" \
3961 -S "Processing of the Certificate handshake message failed"
3962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003963run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003964 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003965 "$O_CLI -key data_files/server5.key \
3966 -cert data_files/server5.eku-cs.crt" \
3967 1 \
3968 -s "bad certificate (usage extensions)" \
3969 -s "Processing of the Certificate handshake message failed"
3970
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003971# Tests for DHM parameters loading
3972
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003973run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003974 "$P_SRV" \
3975 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3976 debug_level=3" \
3977 0 \
3978 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003979 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003980
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003981run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003982 "$P_SRV dhm_file=data_files/dhparams.pem" \
3983 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3984 debug_level=3" \
3985 0 \
3986 -c "value of 'DHM: P ' (1024 bits)" \
3987 -c "value of 'DHM: G ' (2 bits)"
3988
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003989# Tests for DHM client-side size checking
3990
3991run_test "DHM size: server default, client default, OK" \
3992 "$P_SRV" \
3993 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3994 debug_level=1" \
3995 0 \
3996 -C "DHM prime too short:"
3997
3998run_test "DHM size: server default, client 2048, OK" \
3999 "$P_SRV" \
4000 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4001 debug_level=1 dhmlen=2048" \
4002 0 \
4003 -C "DHM prime too short:"
4004
4005run_test "DHM size: server 1024, client default, OK" \
4006 "$P_SRV dhm_file=data_files/dhparams.pem" \
4007 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4008 debug_level=1" \
4009 0 \
4010 -C "DHM prime too short:"
4011
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004012run_test "DHM size: server 999, client 999, OK" \
4013 "$P_SRV dhm_file=data_files/dh.999.pem" \
4014 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4015 debug_level=1 dhmlen=999" \
4016 0 \
4017 -C "DHM prime too short:"
4018
4019run_test "DHM size: server 1000, client 1000, OK" \
4020 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4021 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4022 debug_level=1 dhmlen=1000" \
4023 0 \
4024 -C "DHM prime too short:"
4025
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004026run_test "DHM size: server 1000, client default, rejected" \
4027 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4028 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4029 debug_level=1" \
4030 1 \
4031 -c "DHM prime too short:"
4032
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004033run_test "DHM size: server 1000, client 1001, rejected" \
4034 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4035 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4036 debug_level=1 dhmlen=1001" \
4037 1 \
4038 -c "DHM prime too short:"
4039
4040run_test "DHM size: server 999, client 1000, rejected" \
4041 "$P_SRV dhm_file=data_files/dh.999.pem" \
4042 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4043 debug_level=1 dhmlen=1000" \
4044 1 \
4045 -c "DHM prime too short:"
4046
4047run_test "DHM size: server 998, client 999, rejected" \
4048 "$P_SRV dhm_file=data_files/dh.998.pem" \
4049 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4050 debug_level=1 dhmlen=999" \
4051 1 \
4052 -c "DHM prime too short:"
4053
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004054run_test "DHM size: server default, client 2049, rejected" \
4055 "$P_SRV" \
4056 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4057 debug_level=1 dhmlen=2049" \
4058 1 \
4059 -c "DHM prime too short:"
4060
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004061# Tests for PSK callback
4062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004063run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004064 "$P_SRV psk=abc123 psk_identity=foo" \
4065 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4066 psk_identity=foo psk=abc123" \
4067 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004068 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004069 -S "SSL - Unknown identity received" \
4070 -S "SSL - Verification of the message MAC failed"
4071
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004072run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004073 "$P_SRV" \
4074 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4075 psk_identity=foo psk=abc123" \
4076 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004077 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004078 -S "SSL - Unknown identity received" \
4079 -S "SSL - Verification of the message MAC failed"
4080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004081run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004082 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4083 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4084 psk_identity=foo psk=abc123" \
4085 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004086 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004087 -s "SSL - Unknown identity received" \
4088 -S "SSL - Verification of the message MAC failed"
4089
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004090run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004091 "$P_SRV psk_list=abc,dead,def,beef" \
4092 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4093 psk_identity=abc psk=dead" \
4094 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004095 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004096 -S "SSL - Unknown identity received" \
4097 -S "SSL - Verification of the message MAC failed"
4098
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004099run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004100 "$P_SRV psk_list=abc,dead,def,beef" \
4101 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4102 psk_identity=def psk=beef" \
4103 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004104 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004105 -S "SSL - Unknown identity received" \
4106 -S "SSL - Verification of the message MAC failed"
4107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004108run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004109 "$P_SRV psk_list=abc,dead,def,beef" \
4110 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4111 psk_identity=ghi psk=beef" \
4112 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004113 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004114 -s "SSL - Unknown identity received" \
4115 -S "SSL - Verification of the message MAC failed"
4116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004117run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004118 "$P_SRV psk_list=abc,dead,def,beef" \
4119 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4120 psk_identity=abc psk=beef" \
4121 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004122 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004123 -S "SSL - Unknown identity received" \
4124 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004125
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004126# Tests for EC J-PAKE
4127
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004128requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004129run_test "ECJPAKE: client not configured" \
4130 "$P_SRV debug_level=3" \
4131 "$P_CLI debug_level=3" \
4132 0 \
4133 -C "add ciphersuite: c0ff" \
4134 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004135 -S "found ecjpake kkpp extension" \
4136 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004137 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004138 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004139 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004140 -S "None of the common ciphersuites is usable"
4141
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004142requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004143run_test "ECJPAKE: server not configured" \
4144 "$P_SRV debug_level=3" \
4145 "$P_CLI debug_level=3 ecjpake_pw=bla \
4146 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4147 1 \
4148 -c "add ciphersuite: c0ff" \
4149 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004150 -s "found ecjpake kkpp extension" \
4151 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004152 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004153 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004154 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004155 -s "None of the common ciphersuites is usable"
4156
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004157requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004158run_test "ECJPAKE: working, TLS" \
4159 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4160 "$P_CLI debug_level=3 ecjpake_pw=bla \
4161 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004162 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004163 -c "add ciphersuite: c0ff" \
4164 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004165 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004166 -s "found ecjpake kkpp extension" \
4167 -S "skip ecjpake kkpp extension" \
4168 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004169 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004170 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004171 -S "None of the common ciphersuites is usable" \
4172 -S "SSL - Verification of the message MAC failed"
4173
Janos Follath74537a62016-09-02 13:45:28 +01004174server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004175requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004176run_test "ECJPAKE: password mismatch, TLS" \
4177 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4178 "$P_CLI debug_level=3 ecjpake_pw=bad \
4179 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4180 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004181 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004182 -s "SSL - Verification of the message MAC failed"
4183
Dave Rodgmancee9e922021-06-29 19:05:34 +01004184requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004185run_test "ECJPAKE: working, DTLS" \
4186 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4187 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4188 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4189 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004190 -c "re-using cached ecjpake parameters" \
4191 -S "SSL - Verification of the message MAC failed"
4192
Dave Rodgmancee9e922021-06-29 19:05:34 +01004193requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004194run_test "ECJPAKE: working, DTLS, no cookie" \
4195 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4196 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4197 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4198 0 \
4199 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004200 -S "SSL - Verification of the message MAC failed"
4201
Janos Follath74537a62016-09-02 13:45:28 +01004202server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004203requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004204run_test "ECJPAKE: password mismatch, DTLS" \
4205 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4206 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4207 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4208 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004209 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004210 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004211
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004212# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004213requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004214run_test "ECJPAKE: working, DTLS, nolog" \
4215 "$P_SRV dtls=1 ecjpake_pw=bla" \
4216 "$P_CLI dtls=1 ecjpake_pw=bla \
4217 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4218 0
4219
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004220# Tests for ciphersuites per version
4221
Janos Follathe2681a42016-03-07 15:57:05 +00004222requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004223requires_config_enabled MBEDTLS_CAMELLIA_C
4224requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004225run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004226 "$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 +02004227 "$P_CLI force_version=ssl3" \
4228 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004229 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004230
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004231requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4232requires_config_enabled MBEDTLS_CAMELLIA_C
4233requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004234run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004235 "$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 +01004236 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004237 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004238 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004239
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004240requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4241requires_config_enabled MBEDTLS_CAMELLIA_C
4242requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004243run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004244 "$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 +02004245 "$P_CLI force_version=tls1_1" \
4246 0 \
4247 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4248
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004249requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4250requires_config_enabled MBEDTLS_CAMELLIA_C
4251requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004252run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004253 "$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 +02004254 "$P_CLI force_version=tls1_2" \
4255 0 \
4256 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4257
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004258# Test for ClientHello without extensions
4259
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004260requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004261run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004262 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004263 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004264 0 \
4265 -s "dumping 'client hello extensions' (0 bytes)"
4266
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004267# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004268
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004269run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004270 "$P_SRV" \
4271 "$P_CLI request_size=100" \
4272 0 \
4273 -s "Read from client: 100 bytes read$"
4274
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004275run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004276 "$P_SRV" \
4277 "$P_CLI request_size=500" \
4278 0 \
4279 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004280
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004281# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004282
Janos Follathe2681a42016-03-07 15:57:05 +00004283requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004284run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004285 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004286 "$P_CLI request_size=1 force_version=ssl3 \
4287 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4288 0 \
4289 -s "Read from client: 1 bytes read"
4290
Janos Follathe2681a42016-03-07 15:57:05 +00004291requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004292run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004293 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004294 "$P_CLI request_size=1 force_version=ssl3 \
4295 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4296 0 \
4297 -s "Read from client: 1 bytes read"
4298
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004299run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004300 "$P_SRV" \
4301 "$P_CLI request_size=1 force_version=tls1 \
4302 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4303 0 \
4304 -s "Read from client: 1 bytes read"
4305
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004306run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004307 "$P_SRV" \
4308 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4309 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4310 0 \
4311 -s "Read from client: 1 bytes read"
4312
Hanno Becker32c55012017-11-10 08:42:54 +00004313requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004314run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004315 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004316 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004317 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004318 0 \
4319 -s "Read from client: 1 bytes read"
4320
Hanno Becker32c55012017-11-10 08:42:54 +00004321requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004322run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004323 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004324 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004325 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004326 0 \
4327 -s "Read from client: 1 bytes read"
4328
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004329run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004330 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004331 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004332 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4333 0 \
4334 -s "Read from client: 1 bytes read"
4335
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004336run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004337 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4338 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004339 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004340 0 \
4341 -s "Read from client: 1 bytes read"
4342
4343requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004344run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004345 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004346 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004347 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004348 0 \
4349 -s "Read from client: 1 bytes read"
4350
Hanno Becker8501f982017-11-10 08:59:04 +00004351requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004352run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004353 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4354 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4355 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004356 0 \
4357 -s "Read from client: 1 bytes read"
4358
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004359run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004360 "$P_SRV" \
4361 "$P_CLI request_size=1 force_version=tls1_1 \
4362 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4363 0 \
4364 -s "Read from client: 1 bytes read"
4365
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004366run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004367 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004368 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004370 0 \
4371 -s "Read from client: 1 bytes read"
4372
4373requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004374run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004375 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004376 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004377 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004378 0 \
4379 -s "Read from client: 1 bytes read"
4380
4381requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004382run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004383 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004384 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004386 0 \
4387 -s "Read from client: 1 bytes read"
4388
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004389run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004390 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004391 "$P_CLI request_size=1 force_version=tls1_1 \
4392 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4393 0 \
4394 -s "Read from client: 1 bytes read"
4395
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004396run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004397 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004398 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004399 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004400 0 \
4401 -s "Read from client: 1 bytes read"
4402
Hanno Becker8501f982017-11-10 08:59:04 +00004403requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004404run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004405 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004406 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004407 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004408 0 \
4409 -s "Read from client: 1 bytes read"
4410
Hanno Becker32c55012017-11-10 08:42:54 +00004411requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004412run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004413 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004414 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004415 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004416 0 \
4417 -s "Read from client: 1 bytes read"
4418
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004419run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004420 "$P_SRV" \
4421 "$P_CLI request_size=1 force_version=tls1_2 \
4422 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4423 0 \
4424 -s "Read from client: 1 bytes read"
4425
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004426run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004427 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004428 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004429 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004430 0 \
4431 -s "Read from client: 1 bytes read"
4432
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004433run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004434 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004435 "$P_CLI request_size=1 force_version=tls1_2 \
4436 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004437 0 \
4438 -s "Read from client: 1 bytes read"
4439
Hanno Becker32c55012017-11-10 08:42:54 +00004440requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004441run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004442 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004443 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004444 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004445 0 \
4446 -s "Read from client: 1 bytes read"
4447
Hanno Becker8501f982017-11-10 08:59:04 +00004448requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004449run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004450 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004451 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004452 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004453 0 \
4454 -s "Read from client: 1 bytes read"
4455
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004456run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004457 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004458 "$P_CLI request_size=1 force_version=tls1_2 \
4459 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4460 0 \
4461 -s "Read from client: 1 bytes read"
4462
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004463run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004464 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004465 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004466 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004467 0 \
4468 -s "Read from client: 1 bytes read"
4469
Hanno Becker32c55012017-11-10 08:42:54 +00004470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004471run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004472 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004473 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004474 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004475 0 \
4476 -s "Read from client: 1 bytes read"
4477
Hanno Becker8501f982017-11-10 08:59:04 +00004478requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004479run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004480 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004481 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004482 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004483 0 \
4484 -s "Read from client: 1 bytes read"
4485
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004486run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004487 "$P_SRV" \
4488 "$P_CLI request_size=1 force_version=tls1_2 \
4489 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4490 0 \
4491 -s "Read from client: 1 bytes read"
4492
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004493run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004494 "$P_SRV" \
4495 "$P_CLI request_size=1 force_version=tls1_2 \
4496 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4497 0 \
4498 -s "Read from client: 1 bytes read"
4499
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004500# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004501
4502requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004503run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004504 "$P_SRV dtls=1 force_version=dtls1" \
4505 "$P_CLI dtls=1 request_size=1 \
4506 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4507 0 \
4508 -s "Read from client: 1 bytes read"
4509
4510requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004511run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004512 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4513 "$P_CLI dtls=1 request_size=1 \
4514 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4515 0 \
4516 -s "Read from client: 1 bytes read"
4517
4518requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4519requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004520run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004521 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4522 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004523 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4524 0 \
4525 -s "Read from client: 1 bytes read"
4526
4527requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4528requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004529run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004530 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004531 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004532 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004533 0 \
4534 -s "Read from client: 1 bytes read"
4535
4536requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004537run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004538 "$P_SRV dtls=1 force_version=dtls1_2" \
4539 "$P_CLI dtls=1 request_size=1 \
4540 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4541 0 \
4542 -s "Read from client: 1 bytes read"
4543
4544requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004545run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004546 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004547 "$P_CLI dtls=1 request_size=1 \
4548 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4549 0 \
4550 -s "Read from client: 1 bytes read"
4551
4552requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4553requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004554run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004555 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004556 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004557 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004558 0 \
4559 -s "Read from client: 1 bytes read"
4560
4561requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4562requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004563run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004564 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004565 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004566 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004567 0 \
4568 -s "Read from client: 1 bytes read"
4569
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004570# Tests for small server packets
4571
4572requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4573run_test "Small server packet SSLv3 BlockCipher" \
4574 "$P_SRV response_size=1 min_version=ssl3" \
4575 "$P_CLI force_version=ssl3 \
4576 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4577 0 \
4578 -c "Read from server: 1 bytes read"
4579
4580requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4581run_test "Small server packet SSLv3 StreamCipher" \
4582 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4583 "$P_CLI force_version=ssl3 \
4584 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4585 0 \
4586 -c "Read from server: 1 bytes read"
4587
4588run_test "Small server packet TLS 1.0 BlockCipher" \
4589 "$P_SRV response_size=1" \
4590 "$P_CLI force_version=tls1 \
4591 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4592 0 \
4593 -c "Read from server: 1 bytes read"
4594
4595run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4596 "$P_SRV response_size=1" \
4597 "$P_CLI force_version=tls1 etm=0 \
4598 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4599 0 \
4600 -c "Read from server: 1 bytes read"
4601
4602requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4603run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4604 "$P_SRV response_size=1 trunc_hmac=1" \
4605 "$P_CLI force_version=tls1 \
4606 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4607 0 \
4608 -c "Read from server: 1 bytes read"
4609
4610requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4611run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4612 "$P_SRV response_size=1 trunc_hmac=1" \
4613 "$P_CLI force_version=tls1 \
4614 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4615 0 \
4616 -c "Read from server: 1 bytes read"
4617
4618run_test "Small server packet TLS 1.0 StreamCipher" \
4619 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4620 "$P_CLI force_version=tls1 \
4621 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4622 0 \
4623 -c "Read from server: 1 bytes read"
4624
4625run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4626 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4627 "$P_CLI force_version=tls1 \
4628 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4629 0 \
4630 -c "Read from server: 1 bytes read"
4631
4632requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4633run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4634 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4635 "$P_CLI force_version=tls1 \
4636 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4637 0 \
4638 -c "Read from server: 1 bytes read"
4639
4640requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4641run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4642 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4643 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4644 trunc_hmac=1 etm=0" \
4645 0 \
4646 -c "Read from server: 1 bytes read"
4647
4648run_test "Small server packet TLS 1.1 BlockCipher" \
4649 "$P_SRV response_size=1" \
4650 "$P_CLI force_version=tls1_1 \
4651 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4652 0 \
4653 -c "Read from server: 1 bytes read"
4654
4655run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4656 "$P_SRV response_size=1" \
4657 "$P_CLI force_version=tls1_1 \
4658 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4659 0 \
4660 -c "Read from server: 1 bytes read"
4661
4662requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4663run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4664 "$P_SRV response_size=1 trunc_hmac=1" \
4665 "$P_CLI force_version=tls1_1 \
4666 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4667 0 \
4668 -c "Read from server: 1 bytes read"
4669
4670requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4671run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4672 "$P_SRV response_size=1 trunc_hmac=1" \
4673 "$P_CLI force_version=tls1_1 \
4674 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4675 0 \
4676 -c "Read from server: 1 bytes read"
4677
4678run_test "Small server packet TLS 1.1 StreamCipher" \
4679 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4680 "$P_CLI force_version=tls1_1 \
4681 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4682 0 \
4683 -c "Read from server: 1 bytes read"
4684
4685run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4686 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4687 "$P_CLI force_version=tls1_1 \
4688 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4689 0 \
4690 -c "Read from server: 1 bytes read"
4691
4692requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4693run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4694 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4695 "$P_CLI force_version=tls1_1 \
4696 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4697 0 \
4698 -c "Read from server: 1 bytes read"
4699
4700requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4701run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4702 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4703 "$P_CLI force_version=tls1_1 \
4704 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4705 0 \
4706 -c "Read from server: 1 bytes read"
4707
4708run_test "Small server packet TLS 1.2 BlockCipher" \
4709 "$P_SRV response_size=1" \
4710 "$P_CLI force_version=tls1_2 \
4711 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4712 0 \
4713 -c "Read from server: 1 bytes read"
4714
4715run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4716 "$P_SRV response_size=1" \
4717 "$P_CLI force_version=tls1_2 \
4718 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4719 0 \
4720 -c "Read from server: 1 bytes read"
4721
4722run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4723 "$P_SRV response_size=1" \
4724 "$P_CLI force_version=tls1_2 \
4725 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4726 0 \
4727 -c "Read from server: 1 bytes read"
4728
4729requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4730run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4731 "$P_SRV response_size=1 trunc_hmac=1" \
4732 "$P_CLI force_version=tls1_2 \
4733 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4734 0 \
4735 -c "Read from server: 1 bytes read"
4736
4737requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4738run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4739 "$P_SRV response_size=1 trunc_hmac=1" \
4740 "$P_CLI force_version=tls1_2 \
4741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4742 0 \
4743 -c "Read from server: 1 bytes read"
4744
4745run_test "Small server packet TLS 1.2 StreamCipher" \
4746 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4747 "$P_CLI force_version=tls1_2 \
4748 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4749 0 \
4750 -c "Read from server: 1 bytes read"
4751
4752run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4753 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4754 "$P_CLI force_version=tls1_2 \
4755 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4756 0 \
4757 -c "Read from server: 1 bytes read"
4758
4759requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4760run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4761 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4762 "$P_CLI force_version=tls1_2 \
4763 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4764 0 \
4765 -c "Read from server: 1 bytes read"
4766
4767requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4768run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4769 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4770 "$P_CLI force_version=tls1_2 \
4771 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4772 0 \
4773 -c "Read from server: 1 bytes read"
4774
4775run_test "Small server packet TLS 1.2 AEAD" \
4776 "$P_SRV response_size=1" \
4777 "$P_CLI force_version=tls1_2 \
4778 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4779 0 \
4780 -c "Read from server: 1 bytes read"
4781
4782run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4783 "$P_SRV response_size=1" \
4784 "$P_CLI force_version=tls1_2 \
4785 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4786 0 \
4787 -c "Read from server: 1 bytes read"
4788
4789# Tests for small server packets in DTLS
4790
4791requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4792run_test "Small server packet DTLS 1.0" \
4793 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4794 "$P_CLI dtls=1 \
4795 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4796 0 \
4797 -c "Read from server: 1 bytes read"
4798
4799requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4800run_test "Small server packet DTLS 1.0, without EtM" \
4801 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4802 "$P_CLI dtls=1 \
4803 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4804 0 \
4805 -c "Read from server: 1 bytes read"
4806
4807requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4808requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4809run_test "Small server packet DTLS 1.0, truncated hmac" \
4810 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4811 "$P_CLI dtls=1 trunc_hmac=1 \
4812 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4813 0 \
4814 -c "Read from server: 1 bytes read"
4815
4816requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4817requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4818run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4819 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4820 "$P_CLI dtls=1 \
4821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4822 0 \
4823 -c "Read from server: 1 bytes read"
4824
4825requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4826run_test "Small server packet DTLS 1.2" \
4827 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4828 "$P_CLI dtls=1 \
4829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4830 0 \
4831 -c "Read from server: 1 bytes read"
4832
4833requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4834run_test "Small server packet DTLS 1.2, without EtM" \
4835 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4836 "$P_CLI dtls=1 \
4837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4838 0 \
4839 -c "Read from server: 1 bytes read"
4840
4841requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4842requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4843run_test "Small server packet DTLS 1.2, truncated hmac" \
4844 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4845 "$P_CLI dtls=1 \
4846 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4847 0 \
4848 -c "Read from server: 1 bytes read"
4849
4850requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4851requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4852run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4853 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4854 "$P_CLI dtls=1 \
4855 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4856 0 \
4857 -c "Read from server: 1 bytes read"
4858
Janos Follath00efff72016-05-06 13:48:23 +01004859# A test for extensions in SSLv3
Yuto Takanoc75df632021-07-08 15:56:33 +01004860requires_max_content_len 4096
Janos Follath00efff72016-05-06 13:48:23 +01004861requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4862run_test "SSLv3 with extensions, server side" \
4863 "$P_SRV min_version=ssl3 debug_level=3" \
4864 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4865 0 \
4866 -S "dumping 'client hello extensions'" \
4867 -S "server hello, total extension length:"
4868
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004869# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004870
Angus Grattonc4dd0732018-04-11 16:28:39 +10004871# How many fragments do we expect to write $1 bytes?
4872fragments_for_write() {
4873 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4874}
4875
Janos Follathe2681a42016-03-07 15:57:05 +00004876requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004877run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004878 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004879 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4881 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004882 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4883 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004884
Janos Follathe2681a42016-03-07 15:57:05 +00004885requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004886run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004887 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004888 "$P_CLI request_size=16384 force_version=ssl3 \
4889 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4890 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004891 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4892 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004893
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004894run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004895 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004896 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004897 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4898 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004899 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4900 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004901
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004902run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004903 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004904 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4906 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004907 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004908
Hanno Becker32c55012017-11-10 08:42:54 +00004909requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004910run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004911 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004912 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004913 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004914 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004915 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4916 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004917
Hanno Becker32c55012017-11-10 08:42:54 +00004918requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004919run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004920 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004921 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004922 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004923 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004924 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004925
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004926run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004927 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004928 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004929 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4930 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004931 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004932
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004933run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004934 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4935 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004936 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004937 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004938 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004939
4940requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004941run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004942 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004943 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004944 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004945 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004946 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004947
Hanno Becker278fc7a2017-11-10 09:16:28 +00004948requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004949run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004950 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004951 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004952 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004954 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4955 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004956
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004957run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004958 "$P_SRV" \
4959 "$P_CLI request_size=16384 force_version=tls1_1 \
4960 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4961 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004962 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4963 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004964
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004965run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004966 "$P_SRV" \
4967 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4968 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004969 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004970 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004971
Hanno Becker32c55012017-11-10 08:42:54 +00004972requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004973run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004974 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004975 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004977 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004978 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004979
Hanno Becker32c55012017-11-10 08:42:54 +00004980requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004981run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004982 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004983 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004985 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004986 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004987
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004988run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004989 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4990 "$P_CLI request_size=16384 force_version=tls1_1 \
4991 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4992 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004993 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4994 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004995
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004996run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004997 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004998 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004999 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005000 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005001 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5002 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005003
Hanno Becker278fc7a2017-11-10 09:16:28 +00005004requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005005run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005006 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005007 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005008 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005009 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005010 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005011
Hanno Becker278fc7a2017-11-10 09:16:28 +00005012requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005013run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005014 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005015 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005016 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005017 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005018 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5019 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005020
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005021run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005022 "$P_SRV" \
5023 "$P_CLI request_size=16384 force_version=tls1_2 \
5024 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5025 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005026 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5027 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005028
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005029run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005030 "$P_SRV" \
5031 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
5032 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5033 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005034 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005035
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005036run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005037 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005038 "$P_CLI request_size=16384 force_version=tls1_2 \
5039 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005040 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005041 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5042 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005043
Hanno Becker32c55012017-11-10 08:42:54 +00005044requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005045run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005046 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005047 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005048 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005049 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005050 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005051
Hanno Becker278fc7a2017-11-10 09:16:28 +00005052requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005053run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005054 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005055 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005056 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005057 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005058 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5059 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005060
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005061run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005062 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005063 "$P_CLI request_size=16384 force_version=tls1_2 \
5064 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5065 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005066 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5067 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005068
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005069run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005070 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005071 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005072 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5073 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005074 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005075
Hanno Becker32c55012017-11-10 08:42:54 +00005076requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005077run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005078 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005079 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005080 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005081 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005082 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005083
Hanno Becker278fc7a2017-11-10 09:16:28 +00005084requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005085run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005086 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005087 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005088 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005089 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005090 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5091 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005092
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005093run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005094 "$P_SRV" \
5095 "$P_CLI request_size=16384 force_version=tls1_2 \
5096 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5097 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005098 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5099 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005100
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005101run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005102 "$P_SRV" \
5103 "$P_CLI request_size=16384 force_version=tls1_2 \
5104 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5105 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005106 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5107 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005108
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005109# Test for large server packets
Yuto Takanoc75df632021-07-08 15:56:33 +01005110# The tests below fail when the server's OUT_CONTENT_LEN is less than 16384.
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005111requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5112run_test "Large server packet SSLv3 StreamCipher" \
5113 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5114 "$P_CLI force_version=ssl3 \
5115 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5116 0 \
5117 -c "Read from server: 16384 bytes read"
5118
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005119# Checking next 4 tests logs for 1n-1 split against BEAST too
5120requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5121run_test "Large server packet SSLv3 BlockCipher" \
5122 "$P_SRV response_size=16384 min_version=ssl3" \
5123 "$P_CLI force_version=ssl3 recsplit=0 \
5124 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5125 0 \
5126 -c "Read from server: 1 bytes read"\
5127 -c "16383 bytes read"\
5128 -C "Read from server: 16384 bytes read"
5129
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005130run_test "Large server packet TLS 1.0 BlockCipher" \
5131 "$P_SRV response_size=16384" \
5132 "$P_CLI force_version=tls1 recsplit=0 \
5133 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5134 0 \
5135 -c "Read from server: 1 bytes read"\
5136 -c "16383 bytes read"\
5137 -C "Read from server: 16384 bytes read"
5138
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005139run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5140 "$P_SRV response_size=16384" \
5141 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5142 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5143 0 \
5144 -c "Read from server: 1 bytes read"\
5145 -c "16383 bytes read"\
5146 -C "Read from server: 16384 bytes read"
5147
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005148requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5149run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5150 "$P_SRV response_size=16384" \
5151 "$P_CLI force_version=tls1 recsplit=0 \
5152 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5153 trunc_hmac=1" \
5154 0 \
5155 -c "Read from server: 1 bytes read"\
5156 -c "16383 bytes read"\
5157 -C "Read from server: 16384 bytes read"
5158
5159requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5160run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5161 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5162 "$P_CLI force_version=tls1 \
5163 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5164 trunc_hmac=1" \
5165 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005166 -s "16384 bytes written in 1 fragments" \
5167 -c "Read from server: 16384 bytes read"
5168
5169run_test "Large server packet TLS 1.0 StreamCipher" \
5170 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5171 "$P_CLI force_version=tls1 \
5172 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5173 0 \
5174 -s "16384 bytes written in 1 fragments" \
5175 -c "Read from server: 16384 bytes read"
5176
5177run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5178 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5179 "$P_CLI force_version=tls1 \
5180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5181 0 \
5182 -s "16384 bytes written in 1 fragments" \
5183 -c "Read from server: 16384 bytes read"
5184
5185requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5186run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5187 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5188 "$P_CLI force_version=tls1 \
5189 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5190 0 \
5191 -s "16384 bytes written in 1 fragments" \
5192 -c "Read from server: 16384 bytes read"
5193
5194requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5195run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5196 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5197 "$P_CLI force_version=tls1 \
5198 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5199 0 \
5200 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005201 -c "Read from server: 16384 bytes read"
5202
5203run_test "Large server packet TLS 1.1 BlockCipher" \
5204 "$P_SRV response_size=16384" \
5205 "$P_CLI force_version=tls1_1 \
5206 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5207 0 \
5208 -c "Read from server: 16384 bytes read"
5209
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005210run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5211 "$P_SRV response_size=16384" \
5212 "$P_CLI force_version=tls1_1 etm=0 \
5213 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005214 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005215 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005216 -c "Read from server: 16384 bytes read"
5217
5218requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5219run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5220 "$P_SRV response_size=16384" \
5221 "$P_CLI force_version=tls1_1 \
5222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5223 trunc_hmac=1" \
5224 0 \
5225 -c "Read from server: 16384 bytes read"
5226
5227requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005228run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5229 "$P_SRV response_size=16384 trunc_hmac=1" \
5230 "$P_CLI force_version=tls1_1 \
5231 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5232 0 \
5233 -s "16384 bytes written in 1 fragments" \
5234 -c "Read from server: 16384 bytes read"
5235
5236run_test "Large server packet TLS 1.1 StreamCipher" \
5237 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5238 "$P_CLI force_version=tls1_1 \
5239 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5240 0 \
5241 -c "Read from server: 16384 bytes read"
5242
5243run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5244 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5245 "$P_CLI force_version=tls1_1 \
5246 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5247 0 \
5248 -s "16384 bytes written in 1 fragments" \
5249 -c "Read from server: 16384 bytes read"
5250
5251requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005252run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5253 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5254 "$P_CLI force_version=tls1_1 \
5255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5256 trunc_hmac=1" \
5257 0 \
5258 -c "Read from server: 16384 bytes read"
5259
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005260run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5261 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5262 "$P_CLI force_version=tls1_1 \
5263 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5264 0 \
5265 -s "16384 bytes written in 1 fragments" \
5266 -c "Read from server: 16384 bytes read"
5267
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005268run_test "Large server packet TLS 1.2 BlockCipher" \
5269 "$P_SRV response_size=16384" \
5270 "$P_CLI force_version=tls1_2 \
5271 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5272 0 \
5273 -c "Read from server: 16384 bytes read"
5274
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005275run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5276 "$P_SRV response_size=16384" \
5277 "$P_CLI force_version=tls1_2 etm=0 \
5278 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5279 0 \
5280 -s "16384 bytes written in 1 fragments" \
5281 -c "Read from server: 16384 bytes read"
5282
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005283run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5284 "$P_SRV response_size=16384" \
5285 "$P_CLI force_version=tls1_2 \
5286 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5287 0 \
5288 -c "Read from server: 16384 bytes read"
5289
5290requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5291run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5292 "$P_SRV response_size=16384" \
5293 "$P_CLI force_version=tls1_2 \
5294 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5295 trunc_hmac=1" \
5296 0 \
5297 -c "Read from server: 16384 bytes read"
5298
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005299run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5300 "$P_SRV response_size=16384 trunc_hmac=1" \
5301 "$P_CLI force_version=tls1_2 \
5302 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5303 0 \
5304 -s "16384 bytes written in 1 fragments" \
5305 -c "Read from server: 16384 bytes read"
5306
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005307run_test "Large server packet TLS 1.2 StreamCipher" \
5308 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5309 "$P_CLI force_version=tls1_2 \
5310 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5311 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005312 -s "16384 bytes written in 1 fragments" \
5313 -c "Read from server: 16384 bytes read"
5314
5315run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5316 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5317 "$P_CLI force_version=tls1_2 \
5318 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5319 0 \
5320 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005321 -c "Read from server: 16384 bytes read"
5322
5323requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5324run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5325 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5326 "$P_CLI force_version=tls1_2 \
5327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5328 trunc_hmac=1" \
5329 0 \
5330 -c "Read from server: 16384 bytes read"
5331
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005332requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5333run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5334 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5335 "$P_CLI force_version=tls1_2 \
5336 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5337 0 \
5338 -s "16384 bytes written in 1 fragments" \
5339 -c "Read from server: 16384 bytes read"
5340
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005341run_test "Large server packet TLS 1.2 AEAD" \
5342 "$P_SRV response_size=16384" \
5343 "$P_CLI force_version=tls1_2 \
5344 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5345 0 \
5346 -c "Read from server: 16384 bytes read"
5347
5348run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5349 "$P_SRV response_size=16384" \
5350 "$P_CLI force_version=tls1_2 \
5351 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5352 0 \
5353 -c "Read from server: 16384 bytes read"
5354
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005355# Tests for restartable ECC
5356
5357requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5358run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005359 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005360 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005361 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005362 debug_level=1" \
5363 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005364 -C "x509_verify_cert.*4b00" \
5365 -C "mbedtls_pk_verify.*4b00" \
5366 -C "mbedtls_ecdh_make_public.*4b00" \
5367 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005368
5369requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5370run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005371 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005372 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005373 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005374 debug_level=1 ec_max_ops=0" \
5375 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005376 -C "x509_verify_cert.*4b00" \
5377 -C "mbedtls_pk_verify.*4b00" \
5378 -C "mbedtls_ecdh_make_public.*4b00" \
5379 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005380
5381requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5382run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005383 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005384 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005385 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005386 debug_level=1 ec_max_ops=65535" \
5387 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005388 -C "x509_verify_cert.*4b00" \
5389 -C "mbedtls_pk_verify.*4b00" \
5390 -C "mbedtls_ecdh_make_public.*4b00" \
5391 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005392
5393requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5394run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005395 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005396 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005397 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005398 debug_level=1 ec_max_ops=1000" \
5399 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005400 -c "x509_verify_cert.*4b00" \
5401 -c "mbedtls_pk_verify.*4b00" \
5402 -c "mbedtls_ecdh_make_public.*4b00" \
5403 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005404
5405requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005406run_test "EC restart: TLS, max_ops=1000, badsign" \
5407 "$P_SRV auth_mode=required \
5408 crt_file=data_files/server5-badsign.crt \
5409 key_file=data_files/server5.key" \
5410 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5411 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5412 debug_level=1 ec_max_ops=1000" \
5413 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005414 -c "x509_verify_cert.*4b00" \
5415 -C "mbedtls_pk_verify.*4b00" \
5416 -C "mbedtls_ecdh_make_public.*4b00" \
5417 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005418 -c "! The certificate is not correctly signed by the trusted CA" \
5419 -c "! mbedtls_ssl_handshake returned" \
5420 -c "X509 - Certificate verification failed"
5421
5422requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5423run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5424 "$P_SRV auth_mode=required \
5425 crt_file=data_files/server5-badsign.crt \
5426 key_file=data_files/server5.key" \
5427 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5428 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5429 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5430 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005431 -c "x509_verify_cert.*4b00" \
5432 -c "mbedtls_pk_verify.*4b00" \
5433 -c "mbedtls_ecdh_make_public.*4b00" \
5434 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005435 -c "! The certificate is not correctly signed by the trusted CA" \
5436 -C "! mbedtls_ssl_handshake returned" \
5437 -C "X509 - Certificate verification failed"
5438
5439requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5440run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5441 "$P_SRV auth_mode=required \
5442 crt_file=data_files/server5-badsign.crt \
5443 key_file=data_files/server5.key" \
5444 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5445 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5446 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5447 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005448 -C "x509_verify_cert.*4b00" \
5449 -c "mbedtls_pk_verify.*4b00" \
5450 -c "mbedtls_ecdh_make_public.*4b00" \
5451 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005452 -C "! The certificate is not correctly signed by the trusted CA" \
5453 -C "! mbedtls_ssl_handshake returned" \
5454 -C "X509 - Certificate verification failed"
5455
5456requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005457run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005458 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005459 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005460 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005461 dtls=1 debug_level=1 ec_max_ops=1000" \
5462 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005463 -c "x509_verify_cert.*4b00" \
5464 -c "mbedtls_pk_verify.*4b00" \
5465 -c "mbedtls_ecdh_make_public.*4b00" \
5466 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005467
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005468requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5469run_test "EC restart: TLS, max_ops=1000 no client auth" \
5470 "$P_SRV" \
5471 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5472 debug_level=1 ec_max_ops=1000" \
5473 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005474 -c "x509_verify_cert.*4b00" \
5475 -c "mbedtls_pk_verify.*4b00" \
5476 -c "mbedtls_ecdh_make_public.*4b00" \
5477 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005478
5479requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5480run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5481 "$P_SRV psk=abc123" \
5482 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5483 psk=abc123 debug_level=1 ec_max_ops=1000" \
5484 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005485 -C "x509_verify_cert.*4b00" \
5486 -C "mbedtls_pk_verify.*4b00" \
5487 -C "mbedtls_ecdh_make_public.*4b00" \
5488 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005489
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005490# Tests of asynchronous private key support in SSL
5491
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005492requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005493run_test "SSL async private: sign, delay=0" \
5494 "$P_SRV \
5495 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005496 "$P_CLI" \
5497 0 \
5498 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005499 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005500
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005501requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005502run_test "SSL async private: sign, delay=1" \
5503 "$P_SRV \
5504 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005505 "$P_CLI" \
5506 0 \
5507 -s "Async sign callback: using key slot " \
5508 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005509 -s "Async resume (slot [0-9]): sign done, status=0"
5510
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005511requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5512run_test "SSL async private: sign, delay=2" \
5513 "$P_SRV \
5514 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5515 "$P_CLI" \
5516 0 \
5517 -s "Async sign callback: using key slot " \
5518 -U "Async sign callback: using key slot " \
5519 -s "Async resume (slot [0-9]): call 1 more times." \
5520 -s "Async resume (slot [0-9]): call 0 more times." \
5521 -s "Async resume (slot [0-9]): sign done, status=0"
5522
Gilles Peskined3268832018-04-26 06:23:59 +02005523# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5524# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5525requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5526requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5527run_test "SSL async private: sign, RSA, TLS 1.1" \
5528 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5529 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5530 "$P_CLI force_version=tls1_1" \
5531 0 \
5532 -s "Async sign callback: using key slot " \
5533 -s "Async resume (slot [0-9]): sign done, status=0"
5534
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005535requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005536run_test "SSL async private: sign, SNI" \
5537 "$P_SRV debug_level=3 \
5538 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5539 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5540 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5541 "$P_CLI server_name=polarssl.example" \
5542 0 \
5543 -s "Async sign callback: using key slot " \
5544 -s "Async resume (slot [0-9]): sign done, status=0" \
5545 -s "parse ServerName extension" \
5546 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5547 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5548
5549requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005550run_test "SSL async private: decrypt, delay=0" \
5551 "$P_SRV \
5552 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5553 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5554 0 \
5555 -s "Async decrypt callback: using key slot " \
5556 -s "Async resume (slot [0-9]): decrypt done, status=0"
5557
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005558requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005559run_test "SSL async private: decrypt, delay=1" \
5560 "$P_SRV \
5561 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5562 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5563 0 \
5564 -s "Async decrypt callback: using key slot " \
5565 -s "Async resume (slot [0-9]): call 0 more times." \
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 RSA-PSK, delay=0" \
5570 "$P_SRV psk=abc123 \
5571 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5572 "$P_CLI psk=abc123 \
5573 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5574 0 \
5575 -s "Async decrypt callback: using key slot " \
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=1" \
5580 "$P_SRV psk=abc123 \
5581 async_operations=d async_private_delay1=1 async_private_delay2=1" \
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]): call 0 more times." \
5587 -s "Async resume (slot [0-9]): decrypt done, status=0"
5588
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005589requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005590run_test "SSL async private: sign callback not present" \
5591 "$P_SRV \
5592 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5593 "$P_CLI; [ \$? -eq 1 ] &&
5594 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5595 0 \
5596 -S "Async sign callback" \
5597 -s "! mbedtls_ssl_handshake returned" \
5598 -s "The own private key or pre-shared key is not set, but needed" \
5599 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5600 -s "Successful connection"
5601
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005602requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005603run_test "SSL async private: decrypt callback not present" \
5604 "$P_SRV debug_level=1 \
5605 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5606 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5607 [ \$? -eq 1 ] && $P_CLI" \
5608 0 \
5609 -S "Async decrypt callback" \
5610 -s "! mbedtls_ssl_handshake returned" \
5611 -s "got no RSA private key" \
5612 -s "Async resume (slot [0-9]): sign done, status=0" \
5613 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005614
5615# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005616requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005617run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005618 "$P_SRV \
5619 async_operations=s async_private_delay1=1 \
5620 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5621 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005622 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5623 0 \
5624 -s "Async sign callback: using key slot 0," \
5625 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005626 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005627
5628# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005629requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005630run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005631 "$P_SRV \
5632 async_operations=s async_private_delay2=1 \
5633 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5634 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005635 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5636 0 \
5637 -s "Async sign callback: using key slot 0," \
5638 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005639 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005640
5641# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005642requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005643run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005644 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005645 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005646 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5647 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005648 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5649 0 \
5650 -s "Async sign callback: using key slot 1," \
5651 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005652 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005653
5654# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005655requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005656run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005657 "$P_SRV \
5658 async_operations=s async_private_delay1=1 \
5659 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5660 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005661 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5662 0 \
5663 -s "Async sign callback: no key matches this certificate."
5664
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005665requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005666run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005667 "$P_SRV \
5668 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5669 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005670 "$P_CLI" \
5671 1 \
5672 -s "Async sign callback: injected error" \
5673 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005674 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005675 -s "! mbedtls_ssl_handshake returned"
5676
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005677requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005678run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005679 "$P_SRV \
5680 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5681 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005682 "$P_CLI" \
5683 1 \
5684 -s "Async sign callback: using key slot " \
5685 -S "Async resume" \
5686 -s "Async cancel"
5687
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005688requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005689run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005690 "$P_SRV \
5691 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5692 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005693 "$P_CLI" \
5694 1 \
5695 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005696 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005697 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005698 -s "! mbedtls_ssl_handshake returned"
5699
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005700requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005701run_test "SSL async private: decrypt, error in start" \
5702 "$P_SRV \
5703 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5704 async_private_error=1" \
5705 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5706 1 \
5707 -s "Async decrypt callback: injected error" \
5708 -S "Async resume" \
5709 -S "Async cancel" \
5710 -s "! mbedtls_ssl_handshake returned"
5711
5712requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5713run_test "SSL async private: decrypt, cancel after start" \
5714 "$P_SRV \
5715 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5716 async_private_error=2" \
5717 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5718 1 \
5719 -s "Async decrypt callback: using key slot " \
5720 -S "Async resume" \
5721 -s "Async cancel"
5722
5723requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5724run_test "SSL async private: decrypt, error in resume" \
5725 "$P_SRV \
5726 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5727 async_private_error=3" \
5728 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5729 1 \
5730 -s "Async decrypt callback: using key slot " \
5731 -s "Async resume callback: decrypt done but injected error" \
5732 -S "Async cancel" \
5733 -s "! mbedtls_ssl_handshake returned"
5734
5735requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005736run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005737 "$P_SRV \
5738 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5739 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005740 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5741 0 \
5742 -s "Async cancel" \
5743 -s "! mbedtls_ssl_handshake returned" \
5744 -s "Async resume" \
5745 -s "Successful connection"
5746
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005747requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005748run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005749 "$P_SRV \
5750 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5751 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005752 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5753 0 \
5754 -s "! mbedtls_ssl_handshake returned" \
5755 -s "Async resume" \
5756 -s "Successful connection"
5757
5758# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005759requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005760run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005761 "$P_SRV \
5762 async_operations=s async_private_delay1=1 async_private_error=-2 \
5763 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5764 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005765 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5766 [ \$? -eq 1 ] &&
5767 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5768 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005769 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005770 -S "Async resume" \
5771 -s "Async cancel" \
5772 -s "! mbedtls_ssl_handshake returned" \
5773 -s "Async sign callback: no key matches this certificate." \
5774 -s "Successful connection"
5775
5776# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005777requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005778run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005779 "$P_SRV \
5780 async_operations=s async_private_delay1=1 async_private_error=-3 \
5781 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5782 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005783 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5784 [ \$? -eq 1 ] &&
5785 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5786 0 \
5787 -s "Async resume" \
5788 -s "! mbedtls_ssl_handshake returned" \
5789 -s "Async sign callback: no key matches this certificate." \
5790 -s "Successful connection"
5791
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005792requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005793requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005794run_test "SSL async private: renegotiation: client-initiated; sign" \
5795 "$P_SRV \
5796 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005797 exchanges=2 renegotiation=1" \
5798 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5799 0 \
5800 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005801 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005802
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005803requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005804requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005805run_test "SSL async private: renegotiation: server-initiated; sign" \
5806 "$P_SRV \
5807 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005808 exchanges=2 renegotiation=1 renegotiate=1" \
5809 "$P_CLI exchanges=2 renegotiation=1" \
5810 0 \
5811 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005812 -s "Async resume (slot [0-9]): sign done, status=0"
5813
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005814requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005815requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5816run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5817 "$P_SRV \
5818 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5819 exchanges=2 renegotiation=1" \
5820 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5821 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5822 0 \
5823 -s "Async decrypt callback: using key slot " \
5824 -s "Async resume (slot [0-9]): decrypt done, status=0"
5825
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005826requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005827requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5828run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5829 "$P_SRV \
5830 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5831 exchanges=2 renegotiation=1 renegotiate=1" \
5832 "$P_CLI exchanges=2 renegotiation=1 \
5833 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5834 0 \
5835 -s "Async decrypt callback: using key slot " \
5836 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005837
Ron Eldor58093c82018-06-28 13:22:05 +03005838# Tests for ECC extensions (rfc 4492)
5839
Ron Eldor643df7c2018-06-28 16:17:00 +03005840requires_config_enabled MBEDTLS_AES_C
5841requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5842requires_config_enabled MBEDTLS_SHA256_C
5843requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005844run_test "Force a non ECC ciphersuite in the client side" \
5845 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005846 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005847 0 \
5848 -C "client hello, adding supported_elliptic_curves extension" \
5849 -C "client hello, adding supported_point_formats extension" \
5850 -S "found supported elliptic curves extension" \
5851 -S "found supported point formats extension"
5852
Ron Eldor643df7c2018-06-28 16:17:00 +03005853requires_config_enabled MBEDTLS_AES_C
5854requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5855requires_config_enabled MBEDTLS_SHA256_C
5856requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005857run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005858 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005859 "$P_CLI debug_level=3" \
5860 0 \
5861 -C "found supported_point_formats extension" \
5862 -S "server hello, supported_point_formats extension"
5863
Ron Eldor643df7c2018-06-28 16:17:00 +03005864requires_config_enabled MBEDTLS_AES_C
5865requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5866requires_config_enabled MBEDTLS_SHA256_C
5867requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005868run_test "Force an ECC ciphersuite in the client side" \
5869 "$P_SRV debug_level=3" \
5870 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5871 0 \
5872 -c "client hello, adding supported_elliptic_curves extension" \
5873 -c "client hello, adding supported_point_formats extension" \
5874 -s "found supported elliptic curves extension" \
5875 -s "found supported point formats extension"
5876
Ron Eldor643df7c2018-06-28 16:17:00 +03005877requires_config_enabled MBEDTLS_AES_C
5878requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5879requires_config_enabled MBEDTLS_SHA256_C
5880requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005881run_test "Force an ECC ciphersuite in the server side" \
5882 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5883 "$P_CLI debug_level=3" \
5884 0 \
5885 -c "found supported_point_formats extension" \
5886 -s "server hello, supported_point_formats extension"
5887
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005888# Tests for DTLS HelloVerifyRequest
5889
5890run_test "DTLS cookie: enabled" \
5891 "$P_SRV dtls=1 debug_level=2" \
5892 "$P_CLI dtls=1 debug_level=2" \
5893 0 \
5894 -s "cookie verification failed" \
5895 -s "cookie verification passed" \
5896 -S "cookie verification skipped" \
5897 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005898 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005899 -S "SSL - The requested feature is not available"
5900
5901run_test "DTLS cookie: disabled" \
5902 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5903 "$P_CLI dtls=1 debug_level=2" \
5904 0 \
5905 -S "cookie verification failed" \
5906 -S "cookie verification passed" \
5907 -s "cookie verification skipped" \
5908 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005909 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005910 -S "SSL - The requested feature is not available"
5911
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005912run_test "DTLS cookie: default (failing)" \
5913 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5914 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5915 1 \
5916 -s "cookie verification failed" \
5917 -S "cookie verification passed" \
5918 -S "cookie verification skipped" \
5919 -C "received hello verify request" \
5920 -S "hello verification requested" \
5921 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005922
5923requires_ipv6
5924run_test "DTLS cookie: enabled, IPv6" \
5925 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5926 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5927 0 \
5928 -s "cookie verification failed" \
5929 -s "cookie verification passed" \
5930 -S "cookie verification skipped" \
5931 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005932 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005933 -S "SSL - The requested feature is not available"
5934
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005935run_test "DTLS cookie: enabled, nbio" \
5936 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5937 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5938 0 \
5939 -s "cookie verification failed" \
5940 -s "cookie verification passed" \
5941 -S "cookie verification skipped" \
5942 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005943 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005944 -S "SSL - The requested feature is not available"
5945
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005946# Tests for client reconnecting from the same port with DTLS
5947
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005948not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005949run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005950 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5951 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005952 0 \
5953 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005954 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005955 -S "Client initiated reconnection from same port"
5956
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005957not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005958run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005959 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5960 "$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 +02005961 0 \
5962 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005963 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005964 -s "Client initiated reconnection from same port"
5965
Paul Bakker362689d2016-05-13 10:33:25 +01005966not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5967run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005968 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5969 "$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 +02005970 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005971 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005972 -s "Client initiated reconnection from same port"
5973
Paul Bakker362689d2016-05-13 10:33:25 +01005974only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5975run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5976 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5977 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5978 0 \
5979 -S "The operation timed out" \
5980 -s "Client initiated reconnection from same port"
5981
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005982run_test "DTLS client reconnect from same port: no cookies" \
5983 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005984 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5985 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005986 -s "The operation timed out" \
5987 -S "Client initiated reconnection from same port"
5988
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005989run_test "DTLS client reconnect from same port: attacker-injected" \
5990 -p "$P_PXY inject_clihlo=1" \
5991 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5992 "$P_CLI dtls=1 exchanges=2" \
5993 0 \
5994 -s "possible client reconnect from the same port" \
5995 -S "Client initiated reconnection from same port"
5996
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005997# Tests for various cases of client authentication with DTLS
5998# (focused on handshake flows and message parsing)
5999
6000run_test "DTLS client auth: required" \
6001 "$P_SRV dtls=1 auth_mode=required" \
6002 "$P_CLI dtls=1" \
6003 0 \
6004 -s "Verifying peer X.509 certificate... ok"
6005
6006run_test "DTLS client auth: optional, client has no cert" \
6007 "$P_SRV dtls=1 auth_mode=optional" \
6008 "$P_CLI dtls=1 crt_file=none key_file=none" \
6009 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006010 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006011
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006012run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006013 "$P_SRV dtls=1 auth_mode=none" \
6014 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
6015 0 \
6016 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006017 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006018
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02006019run_test "DTLS wrong PSK: badmac alert" \
6020 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
6021 "$P_CLI dtls=1 psk=abc124" \
6022 1 \
6023 -s "SSL - Verification of the message MAC failed" \
6024 -c "SSL - A fatal alert message was received from our peer"
6025
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02006026# Tests for receiving fragmented handshake messages with DTLS
6027
6028requires_gnutls
6029run_test "DTLS reassembly: no fragmentation (gnutls server)" \
6030 "$G_SRV -u --mtu 2048 -a" \
6031 "$P_CLI dtls=1 debug_level=2" \
6032 0 \
6033 -C "found fragmented DTLS handshake message" \
6034 -C "error"
6035
6036requires_gnutls
6037run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6038 "$G_SRV -u --mtu 512" \
6039 "$P_CLI dtls=1 debug_level=2" \
6040 0 \
6041 -c "found fragmented DTLS handshake message" \
6042 -C "error"
6043
6044requires_gnutls
6045run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6046 "$G_SRV -u --mtu 128" \
6047 "$P_CLI dtls=1 debug_level=2" \
6048 0 \
6049 -c "found fragmented DTLS handshake message" \
6050 -C "error"
6051
6052requires_gnutls
6053run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6054 "$G_SRV -u --mtu 128" \
6055 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6056 0 \
6057 -c "found fragmented DTLS handshake message" \
6058 -C "error"
6059
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006060requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006061requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006062run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6063 "$G_SRV -u --mtu 256" \
6064 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6065 0 \
6066 -c "found fragmented DTLS handshake message" \
6067 -c "client hello, adding renegotiation extension" \
6068 -c "found renegotiation extension" \
6069 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006070 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006071 -C "error" \
6072 -s "Extra-header:"
6073
6074requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006075requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006076run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6077 "$G_SRV -u --mtu 256" \
6078 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6079 0 \
6080 -c "found fragmented DTLS handshake message" \
6081 -c "client hello, adding renegotiation extension" \
6082 -c "found renegotiation extension" \
6083 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006084 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006085 -C "error" \
6086 -s "Extra-header:"
6087
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006088run_test "DTLS reassembly: no fragmentation (openssl server)" \
6089 "$O_SRV -dtls1 -mtu 2048" \
6090 "$P_CLI dtls=1 debug_level=2" \
6091 0 \
6092 -C "found fragmented DTLS handshake message" \
6093 -C "error"
6094
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006095run_test "DTLS reassembly: some fragmentation (openssl server)" \
6096 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006097 "$P_CLI dtls=1 debug_level=2" \
6098 0 \
6099 -c "found fragmented DTLS handshake message" \
6100 -C "error"
6101
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006102run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006103 "$O_SRV -dtls1 -mtu 256" \
6104 "$P_CLI dtls=1 debug_level=2" \
6105 0 \
6106 -c "found fragmented DTLS handshake message" \
6107 -C "error"
6108
6109run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6110 "$O_SRV -dtls1 -mtu 256" \
6111 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6112 0 \
6113 -c "found fragmented DTLS handshake message" \
6114 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006115
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006116# Tests for sending fragmented handshake messages with DTLS
6117#
6118# Use client auth when we need the client to send large messages,
6119# and use large cert chains on both sides too (the long chains we have all use
6120# both RSA and ECDSA, but ideally we should have long chains with either).
6121# Sizes reached (UDP payload):
6122# - 2037B for server certificate
6123# - 1542B for client certificate
6124# - 1013B for newsessionticket
6125# - all others below 512B
6126# All those tests assume MAX_CONTENT_LEN is at least 2048
6127
6128requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6129requires_config_enabled MBEDTLS_RSA_C
6130requires_config_enabled MBEDTLS_ECDSA_C
6131requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006132requires_max_content_len 4096
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006133run_test "DTLS fragmenting: none (for reference)" \
6134 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6135 crt_file=data_files/server7_int-ca.crt \
6136 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006137 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006138 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006139 "$P_CLI dtls=1 debug_level=2 \
6140 crt_file=data_files/server8_int-ca2.crt \
6141 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006142 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006143 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006144 0 \
6145 -S "found fragmented DTLS handshake message" \
6146 -C "found fragmented DTLS handshake message" \
6147 -C "error"
6148
6149requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6150requires_config_enabled MBEDTLS_RSA_C
6151requires_config_enabled MBEDTLS_ECDSA_C
6152requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006153requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006154run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006155 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6156 crt_file=data_files/server7_int-ca.crt \
6157 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006158 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006159 max_frag_len=1024" \
6160 "$P_CLI dtls=1 debug_level=2 \
6161 crt_file=data_files/server8_int-ca2.crt \
6162 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006163 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006164 max_frag_len=2048" \
6165 0 \
6166 -S "found fragmented DTLS handshake message" \
6167 -c "found fragmented DTLS handshake message" \
6168 -C "error"
6169
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006170# With the MFL extension, the server has no way of forcing
6171# the client to not exceed a certain MTU; hence, the following
6172# test can't be replicated with an MTU proxy such as the one
6173# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006174requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6175requires_config_enabled MBEDTLS_RSA_C
6176requires_config_enabled MBEDTLS_ECDSA_C
6177requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006178requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006179run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006180 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6181 crt_file=data_files/server7_int-ca.crt \
6182 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006183 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006184 max_frag_len=512" \
6185 "$P_CLI dtls=1 debug_level=2 \
6186 crt_file=data_files/server8_int-ca2.crt \
6187 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006188 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006189 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006190 0 \
6191 -S "found fragmented DTLS handshake message" \
6192 -c "found fragmented DTLS handshake message" \
6193 -C "error"
6194
6195requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6196requires_config_enabled MBEDTLS_RSA_C
6197requires_config_enabled MBEDTLS_ECDSA_C
6198requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006199requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006200run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006201 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6202 crt_file=data_files/server7_int-ca.crt \
6203 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006204 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006205 max_frag_len=2048" \
6206 "$P_CLI dtls=1 debug_level=2 \
6207 crt_file=data_files/server8_int-ca2.crt \
6208 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006209 hs_timeout=2500-60000 \
6210 max_frag_len=1024" \
6211 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006212 -S "found fragmented DTLS handshake message" \
6213 -c "found fragmented DTLS handshake message" \
6214 -C "error"
6215
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006216# While not required by the standard defining the MFL extension
6217# (according to which it only applies to records, not to datagrams),
6218# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6219# as otherwise there wouldn't be any means to communicate MTU restrictions
6220# to the peer.
6221# The next test checks that no datagrams significantly larger than the
6222# negotiated MFL are sent.
6223requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6224requires_config_enabled MBEDTLS_RSA_C
6225requires_config_enabled MBEDTLS_ECDSA_C
6226requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006227requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006228run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006229 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006230 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6231 crt_file=data_files/server7_int-ca.crt \
6232 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006233 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006234 max_frag_len=2048" \
6235 "$P_CLI dtls=1 debug_level=2 \
6236 crt_file=data_files/server8_int-ca2.crt \
6237 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006238 hs_timeout=2500-60000 \
6239 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006240 0 \
6241 -S "found fragmented DTLS handshake message" \
6242 -c "found fragmented DTLS handshake message" \
6243 -C "error"
6244
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006245requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6246requires_config_enabled MBEDTLS_RSA_C
6247requires_config_enabled MBEDTLS_ECDSA_C
6248requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006249requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006250run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006251 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6252 crt_file=data_files/server7_int-ca.crt \
6253 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006254 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006255 max_frag_len=2048" \
6256 "$P_CLI dtls=1 debug_level=2 \
6257 crt_file=data_files/server8_int-ca2.crt \
6258 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006259 hs_timeout=2500-60000 \
6260 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006261 0 \
6262 -s "found fragmented DTLS handshake message" \
6263 -c "found fragmented DTLS handshake message" \
6264 -C "error"
6265
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006266# While not required by the standard defining the MFL extension
6267# (according to which it only applies to records, not to datagrams),
6268# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6269# as otherwise there wouldn't be any means to communicate MTU restrictions
6270# to the peer.
6271# The next test checks that no datagrams significantly larger than the
6272# negotiated MFL are sent.
6273requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6274requires_config_enabled MBEDTLS_RSA_C
6275requires_config_enabled MBEDTLS_ECDSA_C
6276requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006277requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006278run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006279 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006280 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6281 crt_file=data_files/server7_int-ca.crt \
6282 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006283 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006284 max_frag_len=2048" \
6285 "$P_CLI dtls=1 debug_level=2 \
6286 crt_file=data_files/server8_int-ca2.crt \
6287 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006288 hs_timeout=2500-60000 \
6289 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006290 0 \
6291 -s "found fragmented DTLS handshake message" \
6292 -c "found fragmented DTLS handshake message" \
6293 -C "error"
6294
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006295requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6296requires_config_enabled MBEDTLS_RSA_C
6297requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006298requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006299run_test "DTLS fragmenting: none (for reference) (MTU)" \
6300 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6301 crt_file=data_files/server7_int-ca.crt \
6302 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006303 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006304 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006305 "$P_CLI dtls=1 debug_level=2 \
6306 crt_file=data_files/server8_int-ca2.crt \
6307 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006308 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006309 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006310 0 \
6311 -S "found fragmented DTLS handshake message" \
6312 -C "found fragmented DTLS handshake message" \
6313 -C "error"
6314
6315requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6316requires_config_enabled MBEDTLS_RSA_C
6317requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006318requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006319run_test "DTLS fragmenting: client (MTU)" \
6320 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6321 crt_file=data_files/server7_int-ca.crt \
6322 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006323 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006324 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006325 "$P_CLI dtls=1 debug_level=2 \
6326 crt_file=data_files/server8_int-ca2.crt \
6327 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006328 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006329 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006330 0 \
6331 -s "found fragmented DTLS handshake message" \
6332 -C "found fragmented DTLS handshake message" \
6333 -C "error"
6334
6335requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6336requires_config_enabled MBEDTLS_RSA_C
6337requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006338requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006339run_test "DTLS fragmenting: server (MTU)" \
6340 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6341 crt_file=data_files/server7_int-ca.crt \
6342 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006343 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006344 mtu=512" \
6345 "$P_CLI dtls=1 debug_level=2 \
6346 crt_file=data_files/server8_int-ca2.crt \
6347 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006348 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006349 mtu=2048" \
6350 0 \
6351 -S "found fragmented DTLS handshake message" \
6352 -c "found fragmented DTLS handshake message" \
6353 -C "error"
6354
6355requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6356requires_config_enabled MBEDTLS_RSA_C
6357requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006358requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006359run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006360 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006361 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6362 crt_file=data_files/server7_int-ca.crt \
6363 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006364 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006365 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006366 "$P_CLI dtls=1 debug_level=2 \
6367 crt_file=data_files/server8_int-ca2.crt \
6368 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006369 hs_timeout=2500-60000 \
6370 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006371 0 \
6372 -s "found fragmented DTLS handshake message" \
6373 -c "found fragmented DTLS handshake message" \
6374 -C "error"
6375
Andrzej Kurek77826052018-10-11 07:34:08 -04006376# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006377requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6378requires_config_enabled MBEDTLS_RSA_C
6379requires_config_enabled MBEDTLS_ECDSA_C
6380requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006381requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006382requires_config_enabled MBEDTLS_AES_C
6383requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006384requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006385run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006386 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006387 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6388 crt_file=data_files/server7_int-ca.crt \
6389 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006390 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006391 mtu=512" \
6392 "$P_CLI dtls=1 debug_level=2 \
6393 crt_file=data_files/server8_int-ca2.crt \
6394 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006395 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6396 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006397 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006398 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006399 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006400 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006401 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006402
Andrzej Kurek7311c782018-10-11 06:49:41 -04006403# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006404# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006405# The ratio of max/min timeout should ideally equal 4 to accept two
6406# retransmissions, but in some cases (like both the server and client using
6407# fragmentation and auto-reduction) an extra retransmission might occur,
6408# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006409not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006410requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6411requires_config_enabled MBEDTLS_RSA_C
6412requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006413requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006414requires_config_enabled MBEDTLS_AES_C
6415requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006416requires_max_content_len 2048
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006417run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6418 -p "$P_PXY mtu=508" \
6419 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6420 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006421 key_file=data_files/server7.key \
6422 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006423 "$P_CLI dtls=1 debug_level=2 \
6424 crt_file=data_files/server8_int-ca2.crt \
6425 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006426 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6427 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006428 0 \
6429 -s "found fragmented DTLS handshake message" \
6430 -c "found fragmented DTLS handshake message" \
6431 -C "error"
6432
Andrzej Kurek77826052018-10-11 07:34:08 -04006433# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006434only_with_valgrind
6435requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6436requires_config_enabled MBEDTLS_RSA_C
6437requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006438requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006439requires_config_enabled MBEDTLS_AES_C
6440requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006441requires_max_content_len 2048
Hanno Becker108992e2018-08-29 17:04:18 +01006442run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6443 -p "$P_PXY mtu=508" \
6444 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6445 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006446 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006447 hs_timeout=250-10000" \
6448 "$P_CLI dtls=1 debug_level=2 \
6449 crt_file=data_files/server8_int-ca2.crt \
6450 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006451 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006452 hs_timeout=250-10000" \
6453 0 \
6454 -s "found fragmented DTLS handshake message" \
6455 -c "found fragmented DTLS handshake message" \
6456 -C "error"
6457
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006458# 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 +02006459# OTOH the client might resend if the server is to slow to reset after sending
6460# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006461not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006462requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6463requires_config_enabled MBEDTLS_RSA_C
6464requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006465requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006466run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006467 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006468 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6469 crt_file=data_files/server7_int-ca.crt \
6470 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006471 hs_timeout=10000-60000 \
6472 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006473 "$P_CLI dtls=1 debug_level=2 \
6474 crt_file=data_files/server8_int-ca2.crt \
6475 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006476 hs_timeout=10000-60000 \
6477 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006478 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006479 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006480 -s "found fragmented DTLS handshake message" \
6481 -c "found fragmented DTLS handshake message" \
6482 -C "error"
6483
Andrzej Kurek77826052018-10-11 07:34:08 -04006484# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006485# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6486# OTOH the client might resend if the server is to slow to reset after sending
6487# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006488not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006489requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6490requires_config_enabled MBEDTLS_RSA_C
6491requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006492requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006493requires_config_enabled MBEDTLS_AES_C
6494requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006495requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006496run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006497 -p "$P_PXY mtu=512" \
6498 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6499 crt_file=data_files/server7_int-ca.crt \
6500 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006501 hs_timeout=10000-60000 \
6502 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006503 "$P_CLI dtls=1 debug_level=2 \
6504 crt_file=data_files/server8_int-ca2.crt \
6505 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006506 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6507 hs_timeout=10000-60000 \
6508 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006509 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006510 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006511 -s "found fragmented DTLS handshake message" \
6512 -c "found fragmented DTLS handshake message" \
6513 -C "error"
6514
Andrzej Kurek7311c782018-10-11 06:49:41 -04006515not_with_valgrind # spurious autoreduction due to timeout
6516requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6517requires_config_enabled MBEDTLS_RSA_C
6518requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006519requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006520run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006521 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006522 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6523 crt_file=data_files/server7_int-ca.crt \
6524 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006525 hs_timeout=10000-60000 \
6526 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006527 "$P_CLI dtls=1 debug_level=2 \
6528 crt_file=data_files/server8_int-ca2.crt \
6529 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006530 hs_timeout=10000-60000 \
6531 mtu=1024 nbio=2" \
6532 0 \
6533 -S "autoreduction" \
6534 -s "found fragmented DTLS handshake message" \
6535 -c "found fragmented DTLS handshake message" \
6536 -C "error"
6537
Andrzej Kurek77826052018-10-11 07:34:08 -04006538# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006539not_with_valgrind # spurious autoreduction due to timeout
6540requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6541requires_config_enabled MBEDTLS_RSA_C
6542requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006543requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006544requires_config_enabled MBEDTLS_AES_C
6545requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006546requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006547run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6548 -p "$P_PXY mtu=512" \
6549 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6550 crt_file=data_files/server7_int-ca.crt \
6551 key_file=data_files/server7.key \
6552 hs_timeout=10000-60000 \
6553 mtu=512 nbio=2" \
6554 "$P_CLI dtls=1 debug_level=2 \
6555 crt_file=data_files/server8_int-ca2.crt \
6556 key_file=data_files/server8.key \
6557 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6558 hs_timeout=10000-60000 \
6559 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006560 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006561 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006562 -s "found fragmented DTLS handshake message" \
6563 -c "found fragmented DTLS handshake message" \
6564 -C "error"
6565
Andrzej Kurek77826052018-10-11 07:34:08 -04006566# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006567# This ensures things still work after session_reset().
6568# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006569# Since we don't support reading fragmented ClientHello yet,
6570# up the MTU to 1450 (larger than ClientHello with session ticket,
6571# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006572# An autoreduction on the client-side might happen if the server is
6573# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006574# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006575# resumed listening, which would result in a spurious autoreduction.
6576not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006577requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6578requires_config_enabled MBEDTLS_RSA_C
6579requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006580requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006581requires_config_enabled MBEDTLS_AES_C
6582requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006583requires_max_content_len 2048
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006584run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6585 -p "$P_PXY mtu=1450" \
6586 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6587 crt_file=data_files/server7_int-ca.crt \
6588 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006589 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006590 mtu=1450" \
6591 "$P_CLI dtls=1 debug_level=2 \
6592 crt_file=data_files/server8_int-ca2.crt \
6593 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006594 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006595 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006596 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006597 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006598 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006599 -s "found fragmented DTLS handshake message" \
6600 -c "found fragmented DTLS handshake message" \
6601 -C "error"
6602
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006603# An autoreduction on the client-side might happen if the server is
6604# slow to reset, therefore omitting '-C "autoreduction"' below.
6605not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006606requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6607requires_config_enabled MBEDTLS_RSA_C
6608requires_config_enabled MBEDTLS_ECDSA_C
6609requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006610requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006611requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6612requires_config_enabled MBEDTLS_CHACHAPOLY_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006613requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006614run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6615 -p "$P_PXY mtu=512" \
6616 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6617 crt_file=data_files/server7_int-ca.crt \
6618 key_file=data_files/server7.key \
6619 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006620 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006621 mtu=512" \
6622 "$P_CLI dtls=1 debug_level=2 \
6623 crt_file=data_files/server8_int-ca2.crt \
6624 key_file=data_files/server8.key \
6625 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006626 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006627 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006628 mtu=512" \
6629 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006630 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006631 -s "found fragmented DTLS handshake message" \
6632 -c "found fragmented DTLS handshake message" \
6633 -C "error"
6634
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006635# An autoreduction on the client-side might happen if the server is
6636# slow to reset, therefore omitting '-C "autoreduction"' below.
6637not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006638requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6639requires_config_enabled MBEDTLS_RSA_C
6640requires_config_enabled MBEDTLS_ECDSA_C
6641requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006642requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006643requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6644requires_config_enabled MBEDTLS_AES_C
6645requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006646requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006647run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6648 -p "$P_PXY mtu=512" \
6649 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6650 crt_file=data_files/server7_int-ca.crt \
6651 key_file=data_files/server7.key \
6652 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006653 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006654 mtu=512" \
6655 "$P_CLI dtls=1 debug_level=2 \
6656 crt_file=data_files/server8_int-ca2.crt \
6657 key_file=data_files/server8.key \
6658 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006659 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006660 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006661 mtu=512" \
6662 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006663 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006664 -s "found fragmented DTLS handshake message" \
6665 -c "found fragmented DTLS handshake message" \
6666 -C "error"
6667
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006668# An autoreduction on the client-side might happen if the server is
6669# slow to reset, therefore omitting '-C "autoreduction"' below.
6670not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006671requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6672requires_config_enabled MBEDTLS_RSA_C
6673requires_config_enabled MBEDTLS_ECDSA_C
6674requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006675requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006676requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6677requires_config_enabled MBEDTLS_AES_C
6678requires_config_enabled MBEDTLS_CCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006679requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006680run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006681 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006682 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6683 crt_file=data_files/server7_int-ca.crt \
6684 key_file=data_files/server7.key \
6685 exchanges=2 renegotiation=1 \
6686 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006687 hs_timeout=10000-60000 \
6688 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006689 "$P_CLI dtls=1 debug_level=2 \
6690 crt_file=data_files/server8_int-ca2.crt \
6691 key_file=data_files/server8.key \
6692 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006693 hs_timeout=10000-60000 \
6694 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006695 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006696 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006697 -s "found fragmented DTLS handshake message" \
6698 -c "found fragmented DTLS handshake message" \
6699 -C "error"
6700
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006701# An autoreduction on the client-side might happen if the server is
6702# slow to reset, therefore omitting '-C "autoreduction"' below.
6703not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006704requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6705requires_config_enabled MBEDTLS_RSA_C
6706requires_config_enabled MBEDTLS_ECDSA_C
6707requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006708requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006709requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6710requires_config_enabled MBEDTLS_AES_C
6711requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6712requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
Yuto Takanoc75df632021-07-08 15:56:33 +01006713requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006714run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006715 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006716 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6717 crt_file=data_files/server7_int-ca.crt \
6718 key_file=data_files/server7.key \
6719 exchanges=2 renegotiation=1 \
6720 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006721 hs_timeout=10000-60000 \
6722 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006723 "$P_CLI dtls=1 debug_level=2 \
6724 crt_file=data_files/server8_int-ca2.crt \
6725 key_file=data_files/server8.key \
6726 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006727 hs_timeout=10000-60000 \
6728 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006729 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006730 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006731 -s "found fragmented DTLS handshake message" \
6732 -c "found fragmented DTLS handshake message" \
6733 -C "error"
6734
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006735# An autoreduction on the client-side might happen if the server is
6736# slow to reset, therefore omitting '-C "autoreduction"' below.
6737not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006738requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6739requires_config_enabled MBEDTLS_RSA_C
6740requires_config_enabled MBEDTLS_ECDSA_C
6741requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006742requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006743requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6744requires_config_enabled MBEDTLS_AES_C
6745requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
Yuto Takanoc75df632021-07-08 15:56:33 +01006746requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006747run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006748 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006749 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6750 crt_file=data_files/server7_int-ca.crt \
6751 key_file=data_files/server7.key \
6752 exchanges=2 renegotiation=1 \
6753 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006754 hs_timeout=10000-60000 \
6755 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006756 "$P_CLI dtls=1 debug_level=2 \
6757 crt_file=data_files/server8_int-ca2.crt \
6758 key_file=data_files/server8.key \
6759 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006760 hs_timeout=10000-60000 \
6761 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006762 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006763 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006764 -s "found fragmented DTLS handshake message" \
6765 -c "found fragmented DTLS handshake message" \
6766 -C "error"
6767
Andrzej Kurek77826052018-10-11 07:34:08 -04006768# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006769requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6770requires_config_enabled MBEDTLS_RSA_C
6771requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006772requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006773requires_config_enabled MBEDTLS_AES_C
6774requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006775client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006776requires_max_content_len 2048
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006777run_test "DTLS fragmenting: proxy MTU + 3d" \
6778 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006779 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006780 crt_file=data_files/server7_int-ca.crt \
6781 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006782 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006783 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006784 crt_file=data_files/server8_int-ca2.crt \
6785 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006786 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006787 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006788 0 \
6789 -s "found fragmented DTLS handshake message" \
6790 -c "found fragmented DTLS handshake message" \
6791 -C "error"
6792
Andrzej Kurek77826052018-10-11 07:34:08 -04006793# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006794requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6795requires_config_enabled MBEDTLS_RSA_C
6796requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006797requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006798requires_config_enabled MBEDTLS_AES_C
6799requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006800client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006801requires_max_content_len 2048
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006802run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6803 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6804 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6805 crt_file=data_files/server7_int-ca.crt \
6806 key_file=data_files/server7.key \
6807 hs_timeout=250-10000 mtu=512 nbio=2" \
6808 "$P_CLI dtls=1 debug_level=2 \
6809 crt_file=data_files/server8_int-ca2.crt \
6810 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006811 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006812 hs_timeout=250-10000 mtu=512 nbio=2" \
6813 0 \
6814 -s "found fragmented DTLS handshake message" \
6815 -c "found fragmented DTLS handshake message" \
6816 -C "error"
6817
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006818# interop tests for DTLS fragmentating with reliable connection
6819#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006820# here and below we just want to test that the we fragment in a way that
6821# pleases other implementations, so we don't need the peer to fragment
6822requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6823requires_config_enabled MBEDTLS_RSA_C
6824requires_config_enabled MBEDTLS_ECDSA_C
6825requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006826requires_gnutls
Yuto Takanoc75df632021-07-08 15:56:33 +01006827requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006828run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6829 "$G_SRV -u" \
6830 "$P_CLI dtls=1 debug_level=2 \
6831 crt_file=data_files/server8_int-ca2.crt \
6832 key_file=data_files/server8.key \
6833 mtu=512 force_version=dtls1_2" \
6834 0 \
6835 -c "fragmenting handshake message" \
6836 -C "error"
6837
6838requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6839requires_config_enabled MBEDTLS_RSA_C
6840requires_config_enabled MBEDTLS_ECDSA_C
6841requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006842requires_gnutls
Yuto Takanoc75df632021-07-08 15:56:33 +01006843requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006844run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6845 "$G_SRV -u" \
6846 "$P_CLI dtls=1 debug_level=2 \
6847 crt_file=data_files/server8_int-ca2.crt \
6848 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006849 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006850 0 \
6851 -c "fragmenting handshake message" \
6852 -C "error"
6853
Hanno Beckerb9a00862018-08-28 10:20:22 +01006854# We use --insecure for the GnuTLS client because it expects
6855# the hostname / IP it connects to to be the name used in the
6856# certificate obtained from the server. Here, however, it
6857# connects to 127.0.0.1 while our test certificates use 'localhost'
6858# as the server name in the certificate. This will make the
6859# certifiate validation fail, but passing --insecure makes
6860# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006861requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6862requires_config_enabled MBEDTLS_RSA_C
6863requires_config_enabled MBEDTLS_ECDSA_C
6864requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006865requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006866requires_not_i686
Yuto Takanoc75df632021-07-08 15:56:33 +01006867requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006868run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006869 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006870 crt_file=data_files/server7_int-ca.crt \
6871 key_file=data_files/server7.key \
6872 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006873 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006874 0 \
6875 -s "fragmenting handshake message"
6876
Hanno Beckerb9a00862018-08-28 10:20:22 +01006877# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006878requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6879requires_config_enabled MBEDTLS_RSA_C
6880requires_config_enabled MBEDTLS_ECDSA_C
6881requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006882requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006883requires_not_i686
Yuto Takanoc75df632021-07-08 15:56:33 +01006884requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006885run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006886 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006887 crt_file=data_files/server7_int-ca.crt \
6888 key_file=data_files/server7.key \
6889 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006890 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006891 0 \
6892 -s "fragmenting handshake message"
6893
6894requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6895requires_config_enabled MBEDTLS_RSA_C
6896requires_config_enabled MBEDTLS_ECDSA_C
6897requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Yuto Takanoc75df632021-07-08 15:56:33 +01006898requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006899run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6900 "$O_SRV -dtls1_2 -verify 10" \
6901 "$P_CLI dtls=1 debug_level=2 \
6902 crt_file=data_files/server8_int-ca2.crt \
6903 key_file=data_files/server8.key \
6904 mtu=512 force_version=dtls1_2" \
6905 0 \
6906 -c "fragmenting handshake message" \
6907 -C "error"
6908
6909requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6910requires_config_enabled MBEDTLS_RSA_C
6911requires_config_enabled MBEDTLS_ECDSA_C
6912requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006913requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006914run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6915 "$O_SRV -dtls1 -verify 10" \
6916 "$P_CLI dtls=1 debug_level=2 \
6917 crt_file=data_files/server8_int-ca2.crt \
6918 key_file=data_files/server8.key \
6919 mtu=512 force_version=dtls1" \
6920 0 \
6921 -c "fragmenting handshake message" \
6922 -C "error"
6923
6924requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6925requires_config_enabled MBEDTLS_RSA_C
6926requires_config_enabled MBEDTLS_ECDSA_C
6927requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Yuto Takanoc75df632021-07-08 15:56:33 +01006928requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006929run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6930 "$P_SRV dtls=1 debug_level=2 \
6931 crt_file=data_files/server7_int-ca.crt \
6932 key_file=data_files/server7.key \
6933 mtu=512 force_version=dtls1_2" \
6934 "$O_CLI -dtls1_2" \
6935 0 \
6936 -s "fragmenting handshake message"
6937
6938requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6939requires_config_enabled MBEDTLS_RSA_C
6940requires_config_enabled MBEDTLS_ECDSA_C
6941requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006942requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006943run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6944 "$P_SRV dtls=1 debug_level=2 \
6945 crt_file=data_files/server7_int-ca.crt \
6946 key_file=data_files/server7.key \
6947 mtu=512 force_version=dtls1" \
6948 "$O_CLI -dtls1" \
6949 0 \
6950 -s "fragmenting handshake message"
6951
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006952# interop tests for DTLS fragmentating with unreliable connection
6953#
6954# again we just want to test that the we fragment in a way that
6955# pleases other implementations, so we don't need the peer to fragment
6956requires_gnutls_next
6957requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6958requires_config_enabled MBEDTLS_RSA_C
6959requires_config_enabled MBEDTLS_ECDSA_C
6960requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006961client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006962requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006963run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6964 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6965 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006966 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006967 crt_file=data_files/server8_int-ca2.crt \
6968 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006969 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006970 0 \
6971 -c "fragmenting handshake message" \
6972 -C "error"
6973
6974requires_gnutls_next
6975requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6976requires_config_enabled MBEDTLS_RSA_C
6977requires_config_enabled MBEDTLS_ECDSA_C
6978requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006979client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006980requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006981run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6982 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6983 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006984 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006985 crt_file=data_files/server8_int-ca2.crt \
6986 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006987 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006988 0 \
6989 -c "fragmenting handshake message" \
6990 -C "error"
6991
k-stachowiakabb843e2019-02-18 16:14:03 +01006992requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006993requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6994requires_config_enabled MBEDTLS_RSA_C
6995requires_config_enabled MBEDTLS_ECDSA_C
6996requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6997client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006998requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006999run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
7000 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7001 "$P_SRV dtls=1 debug_level=2 \
7002 crt_file=data_files/server7_int-ca.crt \
7003 key_file=data_files/server7.key \
7004 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007005 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007006 0 \
7007 -s "fragmenting handshake message"
7008
k-stachowiakabb843e2019-02-18 16:14:03 +01007009requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007010requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7011requires_config_enabled MBEDTLS_RSA_C
7012requires_config_enabled MBEDTLS_ECDSA_C
7013requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7014client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007015requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007016run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
7017 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7018 "$P_SRV dtls=1 debug_level=2 \
7019 crt_file=data_files/server7_int-ca.crt \
7020 key_file=data_files/server7.key \
7021 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007022 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007023 0 \
7024 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007025
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007026## Interop test with OpenSSL might trigger a bug in recent versions (including
7027## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007028## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007029## They should be re-enabled once a fixed version of OpenSSL is available
7030## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007031skip_next_test
7032requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7033requires_config_enabled MBEDTLS_RSA_C
7034requires_config_enabled MBEDTLS_ECDSA_C
7035requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7036client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007037requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007038run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
7039 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7040 "$O_SRV -dtls1_2 -verify 10" \
7041 "$P_CLI dtls=1 debug_level=2 \
7042 crt_file=data_files/server8_int-ca2.crt \
7043 key_file=data_files/server8.key \
7044 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7045 0 \
7046 -c "fragmenting handshake message" \
7047 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007048
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007049skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007050requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7051requires_config_enabled MBEDTLS_RSA_C
7052requires_config_enabled MBEDTLS_ECDSA_C
7053requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007054client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007055requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007056run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
7057 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007058 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007059 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007060 crt_file=data_files/server8_int-ca2.crt \
7061 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007062 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007063 0 \
7064 -c "fragmenting handshake message" \
7065 -C "error"
7066
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007067skip_next_test
7068requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7069requires_config_enabled MBEDTLS_RSA_C
7070requires_config_enabled MBEDTLS_ECDSA_C
7071requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7072client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007073requires_max_content_len 2048
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007074run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
7075 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7076 "$P_SRV dtls=1 debug_level=2 \
7077 crt_file=data_files/server7_int-ca.crt \
7078 key_file=data_files/server7.key \
7079 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7080 "$O_CLI -dtls1_2" \
7081 0 \
7082 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007083
7084# -nbio is added to prevent s_client from blocking in case of duplicated
7085# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007086skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007087requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7088requires_config_enabled MBEDTLS_RSA_C
7089requires_config_enabled MBEDTLS_ECDSA_C
7090requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007091client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007092requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007093run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7094 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007095 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007096 crt_file=data_files/server7_int-ca.crt \
7097 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007098 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007099 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007100 0 \
7101 -s "fragmenting handshake message"
7102
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007103# Tests for specific things with "unreliable" UDP connection
7104
7105not_with_valgrind # spurious resend due to timeout
7106run_test "DTLS proxy: reference" \
7107 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007108 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7109 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007110 0 \
7111 -C "replayed record" \
7112 -S "replayed record" \
7113 -C "record from another epoch" \
7114 -S "record from another epoch" \
7115 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007116 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007117 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007118 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007119 -c "HTTP/1.0 200 OK"
7120
7121not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007122run_test "DTLS proxy: duplicate every packet" \
7123 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007124 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7125 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007126 0 \
7127 -c "replayed record" \
7128 -s "replayed record" \
7129 -c "record from another epoch" \
7130 -s "record from another epoch" \
7131 -S "resend" \
7132 -s "Extra-header:" \
7133 -c "HTTP/1.0 200 OK"
7134
7135run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7136 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007137 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7138 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007139 0 \
7140 -c "replayed record" \
7141 -S "replayed record" \
7142 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007143 -s "record from another epoch" \
7144 -c "resend" \
7145 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007146 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007147 -c "HTTP/1.0 200 OK"
7148
7149run_test "DTLS proxy: multiple records in same datagram" \
7150 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007151 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7152 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007153 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007154 -c "next record in same datagram" \
7155 -s "next record in same datagram"
7156
7157run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7158 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007159 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7160 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007161 0 \
7162 -c "next record in same datagram" \
7163 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007164
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007165run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7166 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007167 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7168 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007169 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007170 -c "discarding invalid record (mac)" \
7171 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007172 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007173 -c "HTTP/1.0 200 OK" \
7174 -S "too many records with bad MAC" \
7175 -S "Verification of the message MAC failed"
7176
7177run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7178 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007179 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7180 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007181 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007182 -C "discarding invalid record (mac)" \
7183 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007184 -S "Extra-header:" \
7185 -C "HTTP/1.0 200 OK" \
7186 -s "too many records with bad MAC" \
7187 -s "Verification of the message MAC failed"
7188
7189run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7190 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007191 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7192 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007193 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007194 -c "discarding invalid record (mac)" \
7195 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007196 -s "Extra-header:" \
7197 -c "HTTP/1.0 200 OK" \
7198 -S "too many records with bad MAC" \
7199 -S "Verification of the message MAC failed"
7200
7201run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7202 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007203 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7204 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007205 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007206 -c "discarding invalid record (mac)" \
7207 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007208 -s "Extra-header:" \
7209 -c "HTTP/1.0 200 OK" \
7210 -s "too many records with bad MAC" \
7211 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007212
7213run_test "DTLS proxy: delay ChangeCipherSpec" \
7214 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007215 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7216 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007217 0 \
7218 -c "record from another epoch" \
7219 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007220 -s "Extra-header:" \
7221 -c "HTTP/1.0 200 OK"
7222
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007223# Tests for reordering support with DTLS
7224
Hanno Becker56cdfd12018-08-17 13:42:15 +01007225run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7226 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007227 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7228 hs_timeout=2500-60000" \
7229 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7230 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007231 0 \
7232 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007233 -c "Next handshake message has been buffered - load"\
7234 -S "Buffering HS message" \
7235 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007236 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007237 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007238 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007239 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007240
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007241run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7242 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007243 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7244 hs_timeout=2500-60000" \
7245 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7246 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007247 0 \
7248 -c "Buffering HS message" \
7249 -c "found fragmented DTLS handshake message"\
7250 -c "Next handshake message 1 not or only partially bufffered" \
7251 -c "Next handshake message has been buffered - load"\
7252 -S "Buffering HS message" \
7253 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007254 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007255 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007256 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007257 -S "Remember CCS message"
7258
Hanno Beckera1adcca2018-08-24 14:41:07 +01007259# The client buffers the ServerKeyExchange before receiving the fragmented
7260# Certificate message; at the time of writing, together these are aroudn 1200b
7261# in size, so that the bound below ensures that the certificate can be reassembled
7262# while keeping the ServerKeyExchange.
7263requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7264run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007265 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007266 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7267 hs_timeout=2500-60000" \
7268 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7269 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007270 0 \
7271 -c "Buffering HS message" \
7272 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007273 -C "attempt to make space by freeing buffered messages" \
7274 -S "Buffering HS message" \
7275 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007276 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007277 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007278 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007279 -S "Remember CCS message"
7280
7281# The size constraints ensure that the delayed certificate message can't
7282# be reassembled while keeping the ServerKeyExchange message, but it can
7283# when dropping it first.
7284requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7285requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7286run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7287 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007288 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7289 hs_timeout=2500-60000" \
7290 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7291 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007292 0 \
7293 -c "Buffering HS message" \
7294 -c "attempt to make space by freeing buffered future messages" \
7295 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007296 -S "Buffering HS message" \
7297 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007298 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007299 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007300 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007301 -S "Remember CCS message"
7302
Hanno Becker56cdfd12018-08-17 13:42:15 +01007303run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7304 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007305 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7306 hs_timeout=2500-60000" \
7307 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7308 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007309 0 \
7310 -C "Buffering HS message" \
7311 -C "Next handshake message has been buffered - load"\
7312 -s "Buffering HS message" \
7313 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007314 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007315 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007316 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007317 -S "Remember CCS message"
7318
7319run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7320 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007321 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7322 hs_timeout=2500-60000" \
7323 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7324 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007325 0 \
7326 -C "Buffering HS message" \
7327 -C "Next handshake message has been buffered - load"\
7328 -S "Buffering HS message" \
7329 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007330 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007331 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007332 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007333 -S "Remember CCS message"
7334
7335run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7336 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007337 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7338 hs_timeout=2500-60000" \
7339 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7340 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007341 0 \
7342 -C "Buffering HS message" \
7343 -C "Next handshake message has been buffered - load"\
7344 -S "Buffering HS message" \
7345 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007346 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007347 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007348 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007349 -s "Remember CCS message"
7350
Hanno Beckera1adcca2018-08-24 14:41:07 +01007351run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007352 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007353 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7354 hs_timeout=2500-60000" \
7355 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7356 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007357 0 \
7358 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007359 -s "Found buffered record from current epoch - load" \
7360 -c "Buffer record from epoch 1" \
7361 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007362
Hanno Beckera1adcca2018-08-24 14:41:07 +01007363# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7364# from the server are delayed, so that the encrypted Finished message
7365# is received and buffered. When the fragmented NewSessionTicket comes
7366# in afterwards, the encrypted Finished message must be freed in order
7367# to make space for the NewSessionTicket to be reassembled.
7368# This works only in very particular circumstances:
7369# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7370# of the NewSessionTicket, but small enough to also allow buffering of
7371# the encrypted Finished message.
7372# - The MTU setting on the server must be so small that the NewSessionTicket
7373# needs to be fragmented.
7374# - All messages sent by the server must be small enough to be either sent
7375# without fragmentation or be reassembled within the bounds of
7376# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7377# handshake, omitting CRTs.
7378requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7379requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7380run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7381 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7382 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7383 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7384 0 \
7385 -s "Buffer record from epoch 1" \
7386 -s "Found buffered record from current epoch - load" \
7387 -c "Buffer record from epoch 1" \
7388 -C "Found buffered record from current epoch - load" \
7389 -c "Enough space available after freeing future epoch record"
7390
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007391# Tests for "randomly unreliable connection": try a variety of flows and peers
7392
7393client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007394run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7395 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007396 "$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 +02007397 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007398 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007399 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7400 0 \
7401 -s "Extra-header:" \
7402 -c "HTTP/1.0 200 OK"
7403
Janos Follath74537a62016-09-02 13:45:28 +01007404client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007405run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7406 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007407 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7408 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007409 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
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\" (no ticket, no cli_auth) FS 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 0 \
7420 -s "Extra-header:" \
7421 -c "HTTP/1.0 200 OK"
7422
Janos Follath74537a62016-09-02 13:45:28 +01007423client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007424run_test "DTLS proxy: 3d, FS, client auth" \
7425 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007426 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7427 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007428 0 \
7429 -s "Extra-header:" \
7430 -c "HTTP/1.0 200 OK"
7431
Janos Follath74537a62016-09-02 13:45:28 +01007432client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007433run_test "DTLS proxy: 3d, FS, ticket" \
7434 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007435 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7436 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007437 0 \
7438 -s "Extra-header:" \
7439 -c "HTTP/1.0 200 OK"
7440
Janos Follath74537a62016-09-02 13:45:28 +01007441client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007442run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7443 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007444 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7445 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007446 0 \
7447 -s "Extra-header:" \
7448 -c "HTTP/1.0 200 OK"
7449
Janos Follath74537a62016-09-02 13:45:28 +01007450client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007451run_test "DTLS proxy: 3d, max handshake, nbio" \
7452 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007453 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007454 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007455 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +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 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007461run_test "DTLS proxy: 3d, min handshake, resumption" \
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 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007464 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007465 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007466 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007467 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7468 0 \
7469 -s "a session has been resumed" \
7470 -c "a session has been resumed" \
7471 -s "Extra-header:" \
7472 -c "HTTP/1.0 200 OK"
7473
Janos Follath74537a62016-09-02 13:45:28 +01007474client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007475run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7476 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007477 "$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 +02007478 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007479 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007480 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007481 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7482 0 \
7483 -s "a session has been resumed" \
7484 -c "a session has been resumed" \
7485 -s "Extra-header:" \
7486 -c "HTTP/1.0 200 OK"
7487
Janos Follath74537a62016-09-02 13:45:28 +01007488client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007489requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007490run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007491 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007492 "$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 +02007493 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007494 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007495 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007496 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7497 0 \
7498 -c "=> renegotiate" \
7499 -s "=> renegotiate" \
7500 -s "Extra-header:" \
7501 -c "HTTP/1.0 200 OK"
7502
Janos Follath74537a62016-09-02 13:45:28 +01007503client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007504requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007505run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7506 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007507 "$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 +02007508 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007509 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007510 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007511 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7512 0 \
7513 -c "=> renegotiate" \
7514 -s "=> renegotiate" \
7515 -s "Extra-header:" \
7516 -c "HTTP/1.0 200 OK"
7517
Janos Follath74537a62016-09-02 13:45:28 +01007518client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007519requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007520run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007521 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007522 "$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 +02007523 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007524 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007525 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007526 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007527 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7528 0 \
7529 -c "=> renegotiate" \
7530 -s "=> renegotiate" \
7531 -s "Extra-header:" \
7532 -c "HTTP/1.0 200 OK"
7533
Janos Follath74537a62016-09-02 13:45:28 +01007534client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007535requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007536run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007537 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007538 "$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 +02007539 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007540 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007541 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007542 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007543 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7544 0 \
7545 -c "=> renegotiate" \
7546 -s "=> renegotiate" \
7547 -s "Extra-header:" \
7548 -c "HTTP/1.0 200 OK"
7549
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007550## Interop tests with OpenSSL might trigger a bug in recent versions (including
7551## all versions installed on the CI machines), reported here:
7552## Bug report: https://github.com/openssl/openssl/issues/6902
7553## They should be re-enabled once a fixed version of OpenSSL is available
7554## (this should happen in some 1.1.1_ release according to the ticket).
7555skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007556client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007557not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007558run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007559 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7560 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007561 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007562 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007563 -c "HTTP/1.0 200 OK"
7564
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007565skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007566client_needs_more_time 8
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, fragmentation" \
7569 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7570 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007571 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007572 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +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é-Gonnard6093d812014-09-29 17:52:57 +02007578run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
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 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007582 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007583 -c "HTTP/1.0 200 OK"
7584
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007585requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007586client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007587not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007588run_test "DTLS proxy: 3d, gnutls server" \
7589 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7590 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007591 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007592 0 \
7593 -s "Extra-header:" \
7594 -c "Extra-header:"
7595
k-stachowiakabb843e2019-02-18 16:14:03 +01007596requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007597client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007598not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007599run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7600 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007601 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007602 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007603 0 \
7604 -s "Extra-header:" \
7605 -c "Extra-header:"
7606
k-stachowiakabb843e2019-02-18 16:14:03 +01007607requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007608client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007609not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007610run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7611 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007612 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007613 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007614 0 \
7615 -s "Extra-header:" \
7616 -c "Extra-header:"
7617
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007618# Final report
7619
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007620echo "------------------------------------------------------------------------"
7621
7622if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007623 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007624else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007625 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007626fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007627PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007628echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007629
7630exit $FAILS