blob: b3bcfbb389ad232c376a2fdb124f1415c3940af4 [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.
Paul Elliott355a1f42021-10-19 17:56:39 +0100523 while true; do
524 SERVER_PIDS=$(lsof -a -n -b -i "$proto:$1" -F p | cut -c2-)
525 SERVER_FOUND=false
526 # When proxies are used, more than one PID can be listening on
527 # the same port. Each PID will be on its own line.
528 while read -r PID; do
529 if [[ $PID == $2 ]]; then
530 SERVER_FOUND=true
531 break
532 fi
533 done <<< "$SERVER_PIDS"
534
535 if ($SERVER_FOUND == true); then
536 break
537 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100538 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400539 echo "$3 START TIMEOUT"
540 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100541 break
542 fi
543 # Linux and *BSD support decimal arguments to sleep. On other
544 # OSes this may be a tight loop.
545 sleep 0.1 2>/dev/null || true
546 done
547 }
548else
Unknown43dc0d62019-09-02 10:42:57 -0400549 echo "Warning: lsof not available, wait_app_start = sleep"
550 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200551 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100552 }
553fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200554
Unknown43dc0d62019-09-02 10:42:57 -0400555# Wait for server process $2 to be listening on port $1.
556wait_server_start() {
557 wait_app_start $1 $2 "SERVER" $SRV_OUT
558}
559
560# Wait for proxy process $2 to be listening on port $1.
561wait_proxy_start() {
562 wait_app_start $1 $2 "PROXY" $PXY_OUT
563}
564
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100565# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100566# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100567# acceptable bounds
568check_server_hello_time() {
569 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100570 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100571 # Get the Unix timestamp for now
572 CUR_TIME=$(date +'%s')
573 THRESHOLD_IN_SECS=300
574
575 # Check if the ServerHello time was printed
576 if [ -z "$SERVER_HELLO_TIME" ]; then
577 return 1
578 fi
579
580 # Check the time in ServerHello is within acceptable bounds
581 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
582 # The time in ServerHello is at least 5 minutes before now
583 return 1
584 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100585 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100586 return 1
587 else
588 return 0
589 fi
590}
591
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200592# wait for client to terminate and set CLI_EXIT
593# must be called right after starting the client
594wait_client_done() {
595 CLI_PID=$!
596
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200597 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
598 CLI_DELAY_FACTOR=1
599
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200600 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200601 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200602
603 wait $CLI_PID
604 CLI_EXIT=$?
605
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200606 kill $DOG_PID >/dev/null 2>&1
607 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200608
609 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100610
611 sleep $SRV_DELAY_SECONDS
612 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200613}
614
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200615# check if the given command uses dtls and sets global variable DTLS
616detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200617 case "$1" in
Paul Elliott316a6aa2021-10-12 16:02:55 +0100618 *dtls=1*|*-dtls*|*-u*) DTLS=1;;
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200619 *) DTLS=0;;
620 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200621}
622
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200623# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100624# Options: -s pattern pattern that must be present in server output
625# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100626# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100627# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100628# -S pattern pattern that must be absent in server output
629# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100630# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100631# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100632run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100633 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200634 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100635
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200636 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200637 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100638 return
639 fi
640
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100641 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100642
Paul Bakkerb7584a52016-05-10 10:50:43 +0100643 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200644 if [ -n "$RUN_TEST_NUMBER" ]; then
645 case ",$RUN_TEST_NUMBER," in
646 *",$TESTS,"*) :;;
647 *) SKIP_NEXT="YES";;
648 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100649 fi
650
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200651 # should we skip?
652 if [ "X$SKIP_NEXT" = "XYES" ]; then
653 SKIP_NEXT="NO"
654 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200655 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200656 return
657 fi
658
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200659 # does this test use a proxy?
660 if [ "X$1" = "X-p" ]; then
661 PXY_CMD="$2"
662 shift 2
663 else
664 PXY_CMD=""
665 fi
666
667 # get commands and client output
668 SRV_CMD="$1"
669 CLI_CMD="$2"
670 CLI_EXPECT="$3"
671 shift 3
672
Hanno Becker7a11e722019-05-10 14:38:42 +0100673 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200674 case "$SRV_CMD $CLI_CMD" in
675 *data_files/*)
676 requires_config_enabled MBEDTLS_FS_IO;;
677 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100678
679 # should we skip?
680 if [ "X$SKIP_NEXT" = "XYES" ]; then
681 SKIP_NEXT="NO"
682 echo "SKIP"
683 SKIPS=$(( $SKIPS + 1 ))
684 return
685 fi
686
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200687 # update DTLS variable
688 detect_dtls "$SRV_CMD"
689
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200690 # if the test uses DTLS but no custom proxy, add a simple proxy
691 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200692 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200693 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200694 case " $SRV_CMD " in
695 *' server_addr=::1 '*)
696 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
697 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200698 fi
699
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200700 # fix client port
701 if [ -n "$PXY_CMD" ]; then
702 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
703 else
704 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
705 fi
706
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100707 # prepend valgrind to our commands if active
708 if [ "$MEMCHECK" -gt 0 ]; then
709 if is_polar "$SRV_CMD"; then
710 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
711 fi
712 if is_polar "$CLI_CMD"; then
713 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
714 fi
715 fi
716
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200717 TIMES_LEFT=2
718 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200719 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200720
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200721 # run the commands
722 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200723 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200724 $PXY_CMD >> $PXY_OUT 2>&1 &
725 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400726 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200727 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200728
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200729 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200730 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200731 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
732 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100733 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200734
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200735 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200736 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
737 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100738
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100739 sleep 0.05
740
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200741 # terminate the server (and the proxy)
742 kill $SRV_PID
743 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100744 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100745
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200746 if [ -n "$PXY_CMD" ]; then
747 kill $PXY_PID >/dev/null 2>&1
748 wait $PXY_PID
749 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100750
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200751 # retry only on timeouts
752 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
753 printf "RETRY "
754 else
755 TIMES_LEFT=0
756 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200757 done
758
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100759 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200760 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100761 # expected client exit to incorrectly succeed in case of catastrophic
762 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100763 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200764 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100765 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100766 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100767 return
768 fi
769 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100770 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200771 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100772 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100773 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100774 return
775 fi
776 fi
777
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100778 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
779 # exit with status 0 when interrupted by a signal, and we don't really
780 # care anyway), in case e.g. the server reports a memory leak.
781 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100782 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100783 return
784 fi
785
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100786 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100787 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
788 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100789 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200790 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100791 return
792 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100793
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100794 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200795 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100796 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100797 while [ $# -gt 0 ]
798 do
799 case $1 in
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 :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100802 fail "pattern '$2' MUST 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 :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100809 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100810 return
811 fi
812 ;;
813
814 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100815 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 +0100816 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100817 return
818 fi
819 ;;
820
821 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100822 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 +0100823 fail "pattern '$2' MUST NOT be present in the Client output"
824 return
825 fi
826 ;;
827
828 # The filtering in the following two options (-u and -U) do the following
829 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100830 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100831 # - keep one of each non-unique line
832 # - count how many lines remain
833 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
834 # if there were no duplicates.
835 "-U")
836 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
837 fail "lines following pattern '$2' must be unique in Server output"
838 return
839 fi
840 ;;
841
842 "-u")
843 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
844 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100845 return
846 fi
847 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100848 "-F")
849 if ! $2 "$SRV_OUT"; then
850 fail "function call to '$2' failed on Server output"
851 return
852 fi
853 ;;
854 "-f")
855 if ! $2 "$CLI_OUT"; then
856 fail "function call to '$2' failed on Client output"
857 return
858 fi
859 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100860
861 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200862 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100863 exit 1
864 esac
865 shift 2
866 done
867
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100868 # check valgrind's results
869 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200870 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100871 fail "Server has memory errors"
872 return
873 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200874 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100875 fail "Client has memory errors"
876 return
877 fi
878 fi
879
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100880 # if we're here, everything is ok
881 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100882 if [ "$PRESERVE_LOGS" -gt 0 ]; then
883 mv $SRV_OUT o-srv-${TESTS}.log
884 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100885 if [ -n "$PXY_CMD" ]; then
886 mv $PXY_OUT o-pxy-${TESTS}.log
887 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100888 fi
889
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200890 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100891}
892
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100893cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200894 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200895 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
896 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
897 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
898 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100899 exit 1
900}
901
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100902#
903# MAIN
904#
905
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100906get_options "$@"
907
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200908# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
909# patterns rather than regular expressions, use a case statement instead
910# of calling grep. To keep the optimizer simple, it is incomplete and only
911# detects simple cases: plain substring, everything, nothing.
912#
913# As an exception, the character '.' is treated as an ordinary character
914# if it is the only special character in the string. This is because it's
915# rare to need "any one character", but needing a literal '.' is common
916# (e.g. '-f "DTLS 1.2"').
917need_grep=
918case "$FILTER" in
919 '^$') simple_filter=;;
920 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200921 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200922 need_grep=1;;
923 *) # No regexp or shell-pattern special character
924 simple_filter="*$FILTER*";;
925esac
926case "$EXCLUDE" in
927 '^$') simple_exclude=;;
928 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200929 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200930 need_grep=1;;
931 *) # No regexp or shell-pattern special character
932 simple_exclude="*$EXCLUDE*";;
933esac
934if [ -n "$need_grep" ]; then
935 is_excluded () {
936 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
937 }
938else
939 is_excluded () {
940 case "$1" in
941 $simple_exclude) true;;
942 $simple_filter) false;;
943 *) true;;
944 esac
945 }
946fi
947
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100948# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100949P_SRV_BIN="${P_SRV%%[ ]*}"
950P_CLI_BIN="${P_CLI%%[ ]*}"
951P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100952if [ ! -x "$P_SRV_BIN" ]; then
953 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100954 exit 1
955fi
Hanno Becker17c04932017-10-10 14:44:53 +0100956if [ ! -x "$P_CLI_BIN" ]; then
957 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100958 exit 1
959fi
Hanno Becker17c04932017-10-10 14:44:53 +0100960if [ ! -x "$P_PXY_BIN" ]; then
961 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200962 exit 1
963fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100964if [ "$MEMCHECK" -gt 0 ]; then
965 if which valgrind >/dev/null 2>&1; then :; else
966 echo "Memcheck not possible. Valgrind not found"
967 exit 1
968 fi
969fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100970if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
971 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100972 exit 1
973fi
974
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200975# used by watchdog
976MAIN_PID="$$"
977
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100978# We use somewhat arbitrary delays for tests:
979# - how long do we wait for the server to start (when lsof not available)?
980# - how long do we allow for the client to finish?
981# (not to check performance, just to avoid waiting indefinitely)
982# Things are slower with valgrind, so give extra time here.
983#
984# Note: without lsof, there is a trade-off between the running time of this
985# script and the risk of spurious errors because we didn't wait long enough.
986# The watchdog delay on the other hand doesn't affect normal running time of
987# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200988if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100989 START_DELAY=6
990 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200991else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100992 START_DELAY=2
993 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200994fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100995
996# some particular tests need more time:
997# - for the client, we multiply the usual watchdog limit by a factor
998# - for the server, we sleep for a number of seconds after the client exits
999# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001000CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001001SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001002
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001003# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001004# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Paul Elliott0ab79412021-10-12 16:10:37 +01001005# Note: Using 'localhost' rather than 127.0.0.1 here is unwise, as on many
1006# machines that will resolve to ::1, and we don't want ipv6 here.
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001007P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1008P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001009P_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 +02001010O_SRV="$O_SRV -accept $SRV_PORT"
Paul Elliott0ab79412021-10-12 16:10:37 +01001011O_CLI="$O_CLI -connect 127.0.0.1:+SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001012G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001013G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001014
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001015if [ -n "${OPENSSL_LEGACY:-}" ]; then
1016 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Paul Elliott0ab79412021-10-12 16:10:37 +01001017 O_LEGACY_CLI="$O_LEGACY_CLI -connect 127.0.0.1:+SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001018fi
1019
Paul Elliott19f1f782021-10-13 18:31:07 +01001020if [ -n "${OPENSSL_NEXT:-}" ]; then
1021 O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT"
Paul Elliott0ab79412021-10-12 16:10:37 +01001022 O_NEXT_CLI="$O_NEXT_CLI -connect 127.0.0.1:+SRV_PORT"
Paul Elliott19f1f782021-10-13 18:31:07 +01001023fi
1024
Hanno Becker58e9dc32018-08-17 15:53:21 +01001025if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001026 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1027fi
1028
Hanno Becker58e9dc32018-08-17 15:53:21 +01001029if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001030 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001031fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001032
Gilles Peskine62469d92017-05-10 10:13:59 +02001033# Allow SHA-1, because many of our test certificates use it
1034P_SRV="$P_SRV allow_sha1=1"
1035P_CLI="$P_CLI allow_sha1=1"
1036
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001037# Also pick a unique name for intermediate files
1038SRV_OUT="srv_out.$$"
1039CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001040PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001041SESSION="session.$$"
1042
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001043SKIP_NEXT="NO"
1044
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001045trap cleanup INT TERM HUP
1046
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001047# Basic test
1048
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001049# Checks that:
1050# - things work with all ciphersuites active (used with config-full in all.sh)
1051# - the expected (highest security) parameters are selected
1052# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001053run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001054 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001055 "$P_CLI" \
1056 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001057 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001058 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001059 -s "client hello v3, signature_algorithm ext: 6" \
1060 -s "ECDHE curve: secp521r1" \
1061 -S "error" \
1062 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001063
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001064run_test "Default, DTLS" \
1065 "$P_SRV dtls=1" \
1066 "$P_CLI dtls=1" \
1067 0 \
1068 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001069 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001070
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001071requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1072run_test "Default (compression enabled)" \
1073 "$P_SRV debug_level=3" \
1074 "$P_CLI debug_level=3" \
1075 0 \
1076 -s "Allocating compression buffer" \
1077 -c "Allocating compression buffer" \
1078 -s "Record expansion is unknown (compression)" \
1079 -c "Record expansion is unknown (compression)" \
1080 -S "error" \
1081 -C "error"
1082
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001083# Test current time in ServerHello
1084requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001085run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001086 "$P_SRV debug_level=3" \
1087 "$P_CLI debug_level=3" \
1088 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001089 -f "check_server_hello_time" \
1090 -F "check_server_hello_time"
1091
Simon Butcher8e004102016-10-14 00:48:33 +01001092# Test for uniqueness of IVs in AEAD ciphersuites
1093run_test "Unique IV in GCM" \
1094 "$P_SRV exchanges=20 debug_level=4" \
1095 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1096 0 \
1097 -u "IV used" \
1098 -U "IV used"
1099
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001100# Tests for rc4 option
1101
Simon Butchera410af52016-05-19 22:12:18 +01001102requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001103run_test "RC4: server disabled, client enabled" \
1104 "$P_SRV" \
1105 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1106 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001107 -s "SSL - The server has no ciphersuites in common"
1108
Simon Butchera410af52016-05-19 22:12:18 +01001109requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001110run_test "RC4: server half, client enabled" \
1111 "$P_SRV arc4=1" \
1112 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1113 1 \
1114 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001115
1116run_test "RC4: server enabled, client disabled" \
1117 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1118 "$P_CLI" \
1119 1 \
1120 -s "SSL - The server has no ciphersuites in common"
1121
1122run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001123 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001124 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1125 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001126 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001127 -S "SSL - The server has no ciphersuites in common"
1128
Hanno Beckerd26bb202018-08-17 09:54:10 +01001129# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1130
1131requires_gnutls
1132requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1133run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1134 "$G_SRV"\
1135 "$P_CLI force_version=tls1_1" \
1136 0
1137
1138requires_gnutls
1139requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1140run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1141 "$G_SRV"\
1142 "$P_CLI force_version=tls1" \
1143 0
1144
Gilles Peskinebc70a182017-05-09 15:59:24 +02001145# Tests for SHA-1 support
1146
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001147requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001148run_test "SHA-1 forbidden by default in server certificate" \
1149 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1150 "$P_CLI debug_level=2 allow_sha1=0" \
1151 1 \
1152 -c "The certificate is signed with an unacceptable hash"
1153
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001154requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1155run_test "SHA-1 forbidden by default in server certificate" \
1156 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1157 "$P_CLI debug_level=2 allow_sha1=0" \
1158 0
1159
Gilles Peskinebc70a182017-05-09 15:59:24 +02001160run_test "SHA-1 explicitly allowed in server certificate" \
1161 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1162 "$P_CLI allow_sha1=1" \
1163 0
1164
1165run_test "SHA-256 allowed by default in server certificate" \
1166 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1167 "$P_CLI allow_sha1=0" \
1168 0
1169
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001170requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001171run_test "SHA-1 forbidden by default in client certificate" \
1172 "$P_SRV auth_mode=required allow_sha1=0" \
1173 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1174 1 \
1175 -s "The certificate is signed with an unacceptable hash"
1176
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001177requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1178run_test "SHA-1 forbidden by default in client certificate" \
1179 "$P_SRV auth_mode=required allow_sha1=0" \
1180 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1181 0
1182
Gilles Peskinebc70a182017-05-09 15:59:24 +02001183run_test "SHA-1 explicitly allowed in client certificate" \
1184 "$P_SRV auth_mode=required allow_sha1=1" \
1185 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1186 0
1187
1188run_test "SHA-256 allowed by default in client certificate" \
1189 "$P_SRV auth_mode=required allow_sha1=0" \
1190 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1191 0
1192
Hanno Becker7ae8a762018-08-14 15:43:35 +01001193# Tests for datagram packing
1194run_test "DTLS: multiple records in same datagram, client and server" \
1195 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1196 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1197 0 \
1198 -c "next record in same datagram" \
1199 -s "next record in same datagram"
1200
1201run_test "DTLS: multiple records in same datagram, client only" \
1202 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1203 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1204 0 \
1205 -s "next record in same datagram" \
1206 -C "next record in same datagram"
1207
1208run_test "DTLS: multiple records in same datagram, server only" \
1209 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1210 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1211 0 \
1212 -S "next record in same datagram" \
1213 -c "next record in same datagram"
1214
1215run_test "DTLS: multiple records in same datagram, neither client nor server" \
1216 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1217 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1218 0 \
1219 -S "next record in same datagram" \
1220 -C "next record in same datagram"
1221
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001222# Tests for Truncated HMAC extension
1223
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001224run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001225 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001226 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001227 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001228 -s "dumping 'expected mac' (20 bytes)" \
1229 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001230
Hanno Becker32c55012017-11-10 08:42:54 +00001231requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001232run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001233 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001234 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001235 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001236 -s "dumping 'expected mac' (20 bytes)" \
1237 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001238
Hanno Becker32c55012017-11-10 08:42:54 +00001239requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001240run_test "Truncated HMAC: client enabled, server default" \
1241 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001242 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001243 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001244 -s "dumping 'expected mac' (20 bytes)" \
1245 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001246
Hanno Becker32c55012017-11-10 08:42:54 +00001247requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001248run_test "Truncated HMAC: client enabled, server disabled" \
1249 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001250 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001251 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001252 -s "dumping 'expected mac' (20 bytes)" \
1253 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001254
Hanno Becker32c55012017-11-10 08:42:54 +00001255requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001256run_test "Truncated HMAC: client disabled, server enabled" \
1257 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001258 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001259 0 \
1260 -s "dumping 'expected mac' (20 bytes)" \
1261 -S "dumping 'expected mac' (10 bytes)"
1262
1263requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001264run_test "Truncated HMAC: client enabled, server enabled" \
1265 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001266 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001267 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001268 -S "dumping 'expected mac' (20 bytes)" \
1269 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001270
Hanno Becker4c4f4102017-11-10 09:16:05 +00001271run_test "Truncated HMAC, DTLS: client default, server default" \
1272 "$P_SRV dtls=1 debug_level=4" \
1273 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1274 0 \
1275 -s "dumping 'expected mac' (20 bytes)" \
1276 -S "dumping 'expected mac' (10 bytes)"
1277
1278requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1279run_test "Truncated HMAC, DTLS: client disabled, server default" \
1280 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001281 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001282 0 \
1283 -s "dumping 'expected mac' (20 bytes)" \
1284 -S "dumping 'expected mac' (10 bytes)"
1285
1286requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1287run_test "Truncated HMAC, DTLS: client enabled, server default" \
1288 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001289 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001290 0 \
1291 -s "dumping 'expected mac' (20 bytes)" \
1292 -S "dumping 'expected mac' (10 bytes)"
1293
1294requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1295run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1296 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001297 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001298 0 \
1299 -s "dumping 'expected mac' (20 bytes)" \
1300 -S "dumping 'expected mac' (10 bytes)"
1301
1302requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1303run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1304 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001305 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001306 0 \
1307 -s "dumping 'expected mac' (20 bytes)" \
1308 -S "dumping 'expected mac' (10 bytes)"
1309
1310requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1311run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1312 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001313 "$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 +01001314 0 \
1315 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001316 -s "dumping 'expected mac' (10 bytes)"
1317
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001318# Tests for Encrypt-then-MAC extension
1319
1320run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001321 "$P_SRV debug_level=3 \
1322 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001323 "$P_CLI debug_level=3" \
1324 0 \
1325 -c "client hello, adding encrypt_then_mac extension" \
1326 -s "found encrypt then mac extension" \
1327 -s "server hello, adding encrypt then mac extension" \
1328 -c "found encrypt_then_mac extension" \
1329 -c "using encrypt then mac" \
1330 -s "using encrypt then mac"
1331
1332run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001333 "$P_SRV debug_level=3 etm=0 \
1334 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001335 "$P_CLI debug_level=3 etm=1" \
1336 0 \
1337 -c "client hello, adding encrypt_then_mac extension" \
1338 -s "found encrypt then mac extension" \
1339 -S "server hello, adding encrypt then mac extension" \
1340 -C "found encrypt_then_mac extension" \
1341 -C "using encrypt then mac" \
1342 -S "using encrypt then mac"
1343
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001344run_test "Encrypt then MAC: client enabled, aead cipher" \
1345 "$P_SRV debug_level=3 etm=1 \
1346 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1347 "$P_CLI debug_level=3 etm=1" \
1348 0 \
1349 -c "client hello, adding encrypt_then_mac extension" \
1350 -s "found encrypt then mac extension" \
1351 -S "server hello, adding encrypt then mac extension" \
1352 -C "found encrypt_then_mac extension" \
1353 -C "using encrypt then mac" \
1354 -S "using encrypt then mac"
1355
1356run_test "Encrypt then MAC: client enabled, stream cipher" \
1357 "$P_SRV debug_level=3 etm=1 \
1358 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001359 "$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 +01001360 0 \
1361 -c "client hello, adding encrypt_then_mac extension" \
1362 -s "found encrypt then mac extension" \
1363 -S "server hello, adding encrypt then mac extension" \
1364 -C "found encrypt_then_mac extension" \
1365 -C "using encrypt then mac" \
1366 -S "using encrypt then mac"
1367
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001368run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001369 "$P_SRV debug_level=3 etm=1 \
1370 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001371 "$P_CLI debug_level=3 etm=0" \
1372 0 \
1373 -C "client hello, adding encrypt_then_mac extension" \
1374 -S "found encrypt then mac extension" \
1375 -S "server hello, adding encrypt then mac extension" \
1376 -C "found encrypt_then_mac extension" \
1377 -C "using encrypt then mac" \
1378 -S "using encrypt then mac"
1379
Janos Follathe2681a42016-03-07 15:57:05 +00001380requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001381run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001382 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001383 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001384 "$P_CLI debug_level=3 force_version=ssl3" \
1385 0 \
1386 -C "client hello, adding encrypt_then_mac extension" \
1387 -S "found encrypt then mac extension" \
1388 -S "server hello, adding encrypt then mac extension" \
1389 -C "found encrypt_then_mac extension" \
1390 -C "using encrypt then mac" \
1391 -S "using encrypt then mac"
1392
Janos Follathe2681a42016-03-07 15:57:05 +00001393requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001394run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001395 "$P_SRV debug_level=3 force_version=ssl3 \
1396 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001397 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001398 0 \
1399 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001400 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001401 -S "server hello, adding encrypt then mac extension" \
1402 -C "found encrypt_then_mac extension" \
1403 -C "using encrypt then mac" \
1404 -S "using encrypt then mac"
1405
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001406# Tests for Extended Master Secret extension
1407
1408run_test "Extended Master Secret: default" \
1409 "$P_SRV debug_level=3" \
1410 "$P_CLI debug_level=3" \
1411 0 \
1412 -c "client hello, adding extended_master_secret extension" \
1413 -s "found extended master secret extension" \
1414 -s "server hello, adding extended master secret extension" \
1415 -c "found extended_master_secret extension" \
1416 -c "using extended master secret" \
1417 -s "using extended master secret"
1418
1419run_test "Extended Master Secret: client enabled, server disabled" \
1420 "$P_SRV debug_level=3 extended_ms=0" \
1421 "$P_CLI debug_level=3 extended_ms=1" \
1422 0 \
1423 -c "client hello, adding extended_master_secret extension" \
1424 -s "found extended master secret extension" \
1425 -S "server hello, adding extended master secret extension" \
1426 -C "found extended_master_secret extension" \
1427 -C "using extended master secret" \
1428 -S "using extended master secret"
1429
1430run_test "Extended Master Secret: client disabled, server enabled" \
1431 "$P_SRV debug_level=3 extended_ms=1" \
1432 "$P_CLI debug_level=3 extended_ms=0" \
1433 0 \
1434 -C "client hello, adding extended_master_secret extension" \
1435 -S "found extended master secret extension" \
1436 -S "server hello, adding extended master secret extension" \
1437 -C "found extended_master_secret extension" \
1438 -C "using extended master secret" \
1439 -S "using extended master secret"
1440
Janos Follathe2681a42016-03-07 15:57:05 +00001441requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001442run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001443 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001444 "$P_CLI debug_level=3 force_version=ssl3" \
1445 0 \
1446 -C "client hello, adding extended_master_secret extension" \
1447 -S "found extended master secret extension" \
1448 -S "server hello, adding extended master secret extension" \
1449 -C "found extended_master_secret extension" \
1450 -C "using extended master secret" \
1451 -S "using extended master secret"
1452
Janos Follathe2681a42016-03-07 15:57:05 +00001453requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001454run_test "Extended Master Secret: client enabled, server SSLv3" \
1455 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001456 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001457 0 \
1458 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001459 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001460 -S "server hello, adding extended master secret extension" \
1461 -C "found extended_master_secret extension" \
1462 -C "using extended master secret" \
1463 -S "using extended master secret"
1464
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001465# Tests for FALLBACK_SCSV
1466
1467run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001468 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001469 "$P_CLI debug_level=3 force_version=tls1_1" \
1470 0 \
1471 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001472 -S "received FALLBACK_SCSV" \
1473 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001474 -C "is a fatal alert message (msg 86)"
1475
1476run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001477 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001478 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1479 0 \
1480 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001481 -S "received FALLBACK_SCSV" \
1482 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001483 -C "is a fatal alert message (msg 86)"
1484
1485run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001486 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001487 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001488 1 \
1489 -c "adding FALLBACK_SCSV" \
1490 -s "received FALLBACK_SCSV" \
1491 -s "inapropriate fallback" \
1492 -c "is a fatal alert message (msg 86)"
1493
1494run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001495 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001496 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001497 0 \
1498 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001499 -s "received FALLBACK_SCSV" \
1500 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001501 -C "is a fatal alert message (msg 86)"
1502
1503requires_openssl_with_fallback_scsv
1504run_test "Fallback SCSV: default, openssl server" \
1505 "$O_SRV" \
1506 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1507 0 \
1508 -C "adding FALLBACK_SCSV" \
1509 -C "is a fatal alert message (msg 86)"
1510
1511requires_openssl_with_fallback_scsv
1512run_test "Fallback SCSV: enabled, openssl server" \
1513 "$O_SRV" \
1514 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1515 1 \
1516 -c "adding FALLBACK_SCSV" \
1517 -c "is a fatal alert message (msg 86)"
1518
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001519requires_openssl_with_fallback_scsv
1520run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001521 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001522 "$O_CLI -tls1_1" \
1523 0 \
1524 -S "received FALLBACK_SCSV" \
1525 -S "inapropriate fallback"
1526
1527requires_openssl_with_fallback_scsv
1528run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001529 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001530 "$O_CLI -tls1_1 -fallback_scsv" \
1531 1 \
1532 -s "received FALLBACK_SCSV" \
1533 -s "inapropriate fallback"
1534
1535requires_openssl_with_fallback_scsv
1536run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001537 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001538 "$O_CLI -fallback_scsv" \
1539 0 \
1540 -s "received FALLBACK_SCSV" \
1541 -S "inapropriate fallback"
1542
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001543# Test sending and receiving empty application data records
1544
1545run_test "Encrypt then MAC: empty application data record" \
1546 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1547 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1548 0 \
1549 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1550 -s "dumping 'input payload after decrypt' (0 bytes)" \
1551 -c "0 bytes written in 1 fragments"
1552
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001553run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001554 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1555 "$P_CLI auth_mode=none etm=0 request_size=0" \
1556 0 \
1557 -s "dumping 'input payload after decrypt' (0 bytes)" \
1558 -c "0 bytes written in 1 fragments"
1559
1560run_test "Encrypt then MAC, DTLS: empty application data record" \
1561 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1562 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1563 0 \
1564 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1565 -s "dumping 'input payload after decrypt' (0 bytes)" \
1566 -c "0 bytes written in 1 fragments"
1567
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001568run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001569 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1570 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1571 0 \
1572 -s "dumping 'input payload after decrypt' (0 bytes)" \
1573 -c "0 bytes written in 1 fragments"
1574
Gilles Peskined50177f2017-05-16 17:53:03 +02001575## ClientHello generated with
1576## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1577## then manually twiddling the ciphersuite list.
1578## The ClientHello content is spelled out below as a hex string as
1579## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1580## The expected response is an inappropriate_fallback alert.
1581requires_openssl_with_fallback_scsv
1582run_test "Fallback SCSV: beginning of list" \
1583 "$P_SRV debug_level=2" \
1584 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1585 0 \
1586 -s "received FALLBACK_SCSV" \
1587 -s "inapropriate fallback"
1588
1589requires_openssl_with_fallback_scsv
1590run_test "Fallback SCSV: end of list" \
1591 "$P_SRV debug_level=2" \
1592 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1593 0 \
1594 -s "received FALLBACK_SCSV" \
1595 -s "inapropriate fallback"
1596
1597## Here the expected response is a valid ServerHello prefix, up to the random.
1598requires_openssl_with_fallback_scsv
1599run_test "Fallback SCSV: not in list" \
1600 "$P_SRV debug_level=2" \
1601 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1602 0 \
1603 -S "received FALLBACK_SCSV" \
1604 -S "inapropriate fallback"
1605
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001606# Tests for CBC 1/n-1 record splitting
1607
1608run_test "CBC Record splitting: TLS 1.2, no splitting" \
1609 "$P_SRV" \
1610 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1611 request_size=123 force_version=tls1_2" \
1612 0 \
1613 -s "Read from client: 123 bytes read" \
1614 -S "Read from client: 1 bytes read" \
1615 -S "122 bytes read"
1616
1617run_test "CBC Record splitting: TLS 1.1, no splitting" \
1618 "$P_SRV" \
1619 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1620 request_size=123 force_version=tls1_1" \
1621 0 \
1622 -s "Read from client: 123 bytes read" \
1623 -S "Read from client: 1 bytes read" \
1624 -S "122 bytes read"
1625
1626run_test "CBC Record splitting: TLS 1.0, splitting" \
1627 "$P_SRV" \
1628 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1629 request_size=123 force_version=tls1" \
1630 0 \
1631 -S "Read from client: 123 bytes read" \
1632 -s "Read from client: 1 bytes read" \
1633 -s "122 bytes read"
1634
Janos Follathe2681a42016-03-07 15:57:05 +00001635requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001636run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001637 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001638 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1639 request_size=123 force_version=ssl3" \
1640 0 \
1641 -S "Read from client: 123 bytes read" \
1642 -s "Read from client: 1 bytes read" \
1643 -s "122 bytes read"
1644
1645run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001646 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001647 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1648 request_size=123 force_version=tls1" \
1649 0 \
1650 -s "Read from client: 123 bytes read" \
1651 -S "Read from client: 1 bytes read" \
1652 -S "122 bytes read"
1653
1654run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1655 "$P_SRV" \
1656 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1657 request_size=123 force_version=tls1 recsplit=0" \
1658 0 \
1659 -s "Read from client: 123 bytes read" \
1660 -S "Read from client: 1 bytes read" \
1661 -S "122 bytes read"
1662
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001663run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1664 "$P_SRV nbio=2" \
1665 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1666 request_size=123 force_version=tls1" \
1667 0 \
1668 -S "Read from client: 123 bytes read" \
1669 -s "Read from client: 1 bytes read" \
1670 -s "122 bytes read"
1671
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001672# Tests for Session Tickets
1673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001674run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001675 "$P_SRV debug_level=3 tickets=1" \
1676 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001677 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001678 -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" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001683 -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: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001689 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1690 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
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: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001703 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1704 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001705 0 \
1706 -c "client hello, adding session ticket extension" \
1707 -s "found session ticket extension" \
1708 -s "server hello, adding session ticket extension" \
1709 -c "found session_ticket extension" \
1710 -c "parse new session ticket" \
1711 -S "session successfully restored from cache" \
1712 -S "session successfully restored from ticket" \
1713 -S "a session has been resumed" \
1714 -C "a session has been resumed"
1715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001716run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001717 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001718 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001719 0 \
1720 -c "client hello, adding session ticket extension" \
1721 -c "found session_ticket extension" \
1722 -c "parse new session ticket" \
1723 -c "a session has been resumed"
1724
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001725run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001726 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001727 "( $O_CLI -sess_out $SESSION; \
1728 $O_CLI -sess_in $SESSION; \
1729 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001730 0 \
1731 -s "found session ticket extension" \
1732 -s "server hello, adding session ticket extension" \
1733 -S "session successfully restored from cache" \
1734 -s "session successfully restored from ticket" \
1735 -s "a session has been resumed"
1736
Hanno Becker1d739932018-08-21 13:55:22 +01001737# Tests for Session Tickets with DTLS
1738
1739run_test "Session resume using tickets, DTLS: basic" \
1740 "$P_SRV debug_level=3 dtls=1 tickets=1" \
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: cache disabled" \
1754 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
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" \
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: timeout" \
1768 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001769 "$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 +01001770 0 \
1771 -c "client hello, adding session ticket extension" \
1772 -s "found session ticket extension" \
1773 -s "server hello, adding session ticket extension" \
1774 -c "found session_ticket extension" \
1775 -c "parse new session ticket" \
1776 -S "session successfully restored from cache" \
1777 -S "session successfully restored from ticket" \
1778 -S "a session has been resumed" \
1779 -C "a session has been resumed"
1780
1781run_test "Session resume using tickets, DTLS: openssl server" \
1782 "$O_SRV -dtls1" \
1783 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1784 0 \
1785 -c "client hello, adding session ticket extension" \
1786 -c "found session_ticket extension" \
1787 -c "parse new session ticket" \
1788 -c "a session has been resumed"
1789
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001790# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001791# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001792requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001793run_test "Session resume using tickets, DTLS: openssl client" \
1794 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001795 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1796 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001797 rm -f $SESSION )" \
1798 0 \
1799 -s "found session ticket extension" \
1800 -s "server hello, adding session ticket extension" \
1801 -S "session successfully restored from cache" \
1802 -s "session successfully restored from ticket" \
1803 -s "a session has been resumed"
1804
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001805# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001806
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001807run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001808 "$P_SRV debug_level=3 tickets=0" \
1809 "$P_CLI debug_level=3 tickets=1 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"
1820
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001821run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001822 "$P_SRV debug_level=3 tickets=1" \
1823 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001824 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001825 -C "client hello, adding session ticket extension" \
1826 -S "found session ticket extension" \
1827 -S "server hello, adding session ticket extension" \
1828 -C "found session_ticket extension" \
1829 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001830 -s "session successfully restored from cache" \
1831 -S "session successfully restored from ticket" \
1832 -s "a session has been resumed" \
1833 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001835run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001836 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1837 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001838 0 \
1839 -S "session successfully restored from cache" \
1840 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001841 -S "a session has been resumed" \
1842 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001843
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001844run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001845 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1846 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001847 0 \
1848 -s "session successfully restored from cache" \
1849 -S "session successfully restored from ticket" \
1850 -s "a session has been resumed" \
1851 -c "a session has been resumed"
1852
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001853run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001854 "$P_SRV debug_level=3 tickets=0" \
1855 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001856 0 \
1857 -s "session successfully restored from cache" \
1858 -S "session successfully restored from ticket" \
1859 -s "a session has been resumed" \
1860 -c "a session has been resumed"
1861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001862run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001863 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1864 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001865 0 \
1866 -S "session successfully restored from cache" \
1867 -S "session successfully restored from ticket" \
1868 -S "a session has been resumed" \
1869 -C "a session has been resumed"
1870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001871run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001872 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1873 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001874 0 \
1875 -s "session successfully restored from cache" \
1876 -S "session successfully restored from ticket" \
1877 -s "a session has been resumed" \
1878 -c "a session has been resumed"
1879
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001880run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001881 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001882 "( $O_CLI -sess_out $SESSION; \
1883 $O_CLI -sess_in $SESSION; \
1884 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001885 0 \
1886 -s "found session ticket extension" \
1887 -S "server hello, adding session ticket extension" \
1888 -s "session successfully restored from cache" \
1889 -S "session successfully restored from ticket" \
1890 -s "a session has been resumed"
1891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001892run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001893 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001894 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001895 0 \
1896 -C "found session_ticket extension" \
1897 -C "parse new session ticket" \
1898 -c "a session has been resumed"
1899
Hanno Becker1d739932018-08-21 13:55:22 +01001900# Tests for Session Resume based on session-ID and cache, DTLS
1901
1902run_test "Session resume using cache, DTLS: tickets enabled on client" \
1903 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001904 "$P_CLI dtls=1 debug_level=3 tickets=1 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: tickets enabled on server" \
1917 "$P_SRV dtls=1 debug_level=3 tickets=1" \
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 -C "client hello, adding session ticket extension" \
1921 -S "found session ticket extension" \
1922 -S "server hello, adding session ticket extension" \
1923 -C "found session_ticket extension" \
1924 -C "parse new session ticket" \
1925 -s "session successfully restored from cache" \
1926 -S "session successfully restored from ticket" \
1927 -s "a session has been resumed" \
1928 -c "a session has been resumed"
1929
1930run_test "Session resume using cache, DTLS: cache_max=0" \
1931 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001932 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001933 0 \
1934 -S "session successfully restored from cache" \
1935 -S "session successfully restored from ticket" \
1936 -S "a session has been resumed" \
1937 -C "a session has been resumed"
1938
1939run_test "Session resume using cache, DTLS: cache_max=1" \
1940 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001941 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001942 0 \
1943 -s "session successfully restored from cache" \
1944 -S "session successfully restored from ticket" \
1945 -s "a session has been resumed" \
1946 -c "a session has been resumed"
1947
1948run_test "Session resume using cache, DTLS: timeout > delay" \
1949 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001950 "$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 +01001951 0 \
1952 -s "session successfully restored from cache" \
1953 -S "session successfully restored from ticket" \
1954 -s "a session has been resumed" \
1955 -c "a session has been resumed"
1956
1957run_test "Session resume using cache, DTLS: timeout < delay" \
1958 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001959 "$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 +01001960 0 \
1961 -S "session successfully restored from cache" \
1962 -S "session successfully restored from ticket" \
1963 -S "a session has been resumed" \
1964 -C "a session has been resumed"
1965
1966run_test "Session resume using cache, DTLS: no timeout" \
1967 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001968 "$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 +01001969 0 \
1970 -s "session successfully restored from cache" \
1971 -S "session successfully restored from ticket" \
1972 -s "a session has been resumed" \
1973 -c "a session has been resumed"
1974
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001975# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001976# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001977requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001978run_test "Session resume using cache, DTLS: openssl client" \
1979 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001980 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1981 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001982 rm -f $SESSION )" \
1983 0 \
1984 -s "found session ticket extension" \
1985 -S "server hello, adding session ticket extension" \
1986 -s "session successfully restored from cache" \
1987 -S "session successfully restored from ticket" \
1988 -s "a session has been resumed"
1989
1990run_test "Session resume using cache, DTLS: openssl server" \
1991 "$O_SRV -dtls1" \
1992 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1993 0 \
1994 -C "found session_ticket extension" \
1995 -C "parse new session ticket" \
1996 -c "a session has been resumed"
1997
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001998# Tests for Max Fragment Length extension
1999
Hanno Becker4aed27e2017-09-18 15:00:34 +01002000requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002001run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002002 "$P_SRV debug_level=3" \
2003 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002004 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002005 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2006 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002007 -C "client hello, adding max_fragment_length extension" \
2008 -S "found max fragment length extension" \
2009 -S "server hello, max_fragment_length extension" \
2010 -C "found max_fragment_length extension"
2011
Hanno Becker4aed27e2017-09-18 15:00:34 +01002012requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002013run_test "Max fragment length: enabled, default, larger message" \
2014 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002015 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002016 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002017 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2018 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002019 -C "client hello, adding max_fragment_length extension" \
2020 -S "found max fragment length extension" \
2021 -S "server hello, max_fragment_length extension" \
2022 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002023 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2024 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002025 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002026
2027requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2028run_test "Max fragment length, DTLS: enabled, default, larger message" \
2029 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002030 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002031 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002032 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2033 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002034 -C "client hello, adding max_fragment_length extension" \
2035 -S "found max fragment length extension" \
2036 -S "server hello, max_fragment_length extension" \
2037 -C "found max_fragment_length extension" \
2038 -c "fragment larger than.*maximum "
2039
Angus Grattonc4dd0732018-04-11 16:28:39 +10002040# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2041# (session fragment length will be 16384 regardless of mbedtls
2042# content length configuration.)
2043
Hanno Beckerc5266962017-09-18 15:01:50 +01002044requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2045run_test "Max fragment length: disabled, larger message" \
2046 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002047 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002048 0 \
2049 -C "Maximum fragment length is 16384" \
2050 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002051 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2052 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002053 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002054
2055requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takano2e580ce2021-06-21 19:43:33 +01002056run_test "Max fragment length, DTLS: disabled, larger message" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002057 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002058 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002059 1 \
2060 -C "Maximum fragment length is 16384" \
2061 -S "Maximum fragment length is 16384" \
2062 -c "fragment larger than.*maximum "
2063
Yuto Takano0807e1d2021-07-02 10:10:49 +01002064requires_max_content_len 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01002065requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002066run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002067 "$P_SRV debug_level=3" \
2068 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002069 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002070 -c "Maximum fragment length is 4096" \
2071 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002072 -c "client hello, adding max_fragment_length extension" \
2073 -s "found max fragment length extension" \
2074 -s "server hello, max_fragment_length extension" \
2075 -c "found max_fragment_length extension"
2076
Yuto Takano0807e1d2021-07-02 10:10:49 +01002077requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002078requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002079run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002080 "$P_SRV debug_level=3 max_frag_len=4096" \
2081 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002082 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002083 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002084 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002085 -C "client hello, adding max_fragment_length extension" \
2086 -S "found max fragment length extension" \
2087 -S "server hello, max_fragment_length extension" \
2088 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002089
Yuto Takano0807e1d2021-07-02 10:10:49 +01002090requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002091requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002092requires_gnutls
2093run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002094 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002095 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002096 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002097 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002098 -c "client hello, adding max_fragment_length extension" \
2099 -c "found max_fragment_length extension"
2100
Yuto Takano0807e1d2021-07-02 10:10:49 +01002101requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002102requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002103run_test "Max fragment length: client, message just fits" \
2104 "$P_SRV debug_level=3" \
2105 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2106 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002107 -c "Maximum fragment length is 2048" \
2108 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002109 -c "client hello, adding max_fragment_length extension" \
2110 -s "found max fragment length extension" \
2111 -s "server hello, max_fragment_length extension" \
2112 -c "found max_fragment_length extension" \
2113 -c "2048 bytes written in 1 fragments" \
2114 -s "2048 bytes read"
2115
Yuto Takano0807e1d2021-07-02 10:10:49 +01002116requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002117requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002118run_test "Max fragment length: client, larger message" \
2119 "$P_SRV debug_level=3" \
2120 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2121 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002122 -c "Maximum fragment length is 2048" \
2123 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002124 -c "client hello, adding max_fragment_length extension" \
2125 -s "found max fragment length extension" \
2126 -s "server hello, max_fragment_length extension" \
2127 -c "found max_fragment_length extension" \
2128 -c "2345 bytes written in 2 fragments" \
2129 -s "2048 bytes read" \
2130 -s "297 bytes read"
2131
Yuto Takano0807e1d2021-07-02 10:10:49 +01002132requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002133requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002134run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002135 "$P_SRV debug_level=3 dtls=1" \
2136 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2137 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002138 -c "Maximum fragment length is 2048" \
2139 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002140 -c "client hello, adding max_fragment_length extension" \
2141 -s "found max fragment length extension" \
2142 -s "server hello, max_fragment_length extension" \
2143 -c "found max_fragment_length extension" \
2144 -c "fragment larger than.*maximum"
2145
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002146# Tests for renegotiation
2147
Hanno Becker6a243642017-10-12 15:18:45 +01002148# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002149run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002150 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002151 "$P_CLI debug_level=3 exchanges=2" \
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: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002164 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002165 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=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
Hanno Becker6a243642017-10-12 15:18:45 +01002176requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002177run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002178 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002179 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002180 0 \
2181 -c "client hello, adding renegotiation extension" \
2182 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2183 -s "found renegotiation extension" \
2184 -s "server hello, secure renegotiation extension" \
2185 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002186 -c "=> renegotiate" \
2187 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002188 -s "write hello request"
2189
Janos Follathb0f148c2017-10-05 12:29:42 +01002190# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2191# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2192# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002193requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002194run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2195 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2196 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2197 0 \
2198 -c "client hello, adding renegotiation extension" \
2199 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2200 -s "found renegotiation extension" \
2201 -s "server hello, secure renegotiation extension" \
2202 -c "found renegotiation extension" \
2203 -c "=> renegotiate" \
2204 -s "=> renegotiate" \
2205 -S "write hello request" \
2206 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2207
2208# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2209# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2210# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002211requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002212run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2213 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2214 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2215 0 \
2216 -c "client hello, adding renegotiation extension" \
2217 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2218 -s "found renegotiation extension" \
2219 -s "server hello, secure renegotiation extension" \
2220 -c "found renegotiation extension" \
2221 -c "=> renegotiate" \
2222 -s "=> renegotiate" \
2223 -s "write hello request" \
2224 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
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: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002228 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
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 0 \
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é-Gonnard780d6712014-02-20 17:19:59 +01002238 -s "write hello request"
2239
Hanno Becker6a243642017-10-12 15:18:45 +01002240requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002241run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002242 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002243 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002244 1 \
2245 -c "client hello, adding renegotiation extension" \
2246 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2247 -S "found renegotiation extension" \
2248 -s "server hello, secure renegotiation extension" \
2249 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002250 -c "=> renegotiate" \
2251 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002252 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002253 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002254 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002255
Hanno Becker6a243642017-10-12 15:18:45 +01002256requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002257run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002258 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002259 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002260 0 \
2261 -C "client hello, adding renegotiation extension" \
2262 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2263 -S "found renegotiation extension" \
2264 -s "server hello, secure renegotiation extension" \
2265 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002266 -C "=> renegotiate" \
2267 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002268 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002269 -S "SSL - An unexpected message was received from our peer" \
2270 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002271
Hanno Becker6a243642017-10-12 15:18:45 +01002272requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002273run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002274 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002275 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002276 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002277 0 \
2278 -C "client hello, adding renegotiation extension" \
2279 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2280 -S "found renegotiation extension" \
2281 -s "server hello, secure renegotiation extension" \
2282 -c "found renegotiation extension" \
2283 -C "=> renegotiate" \
2284 -S "=> renegotiate" \
2285 -s "write hello request" \
2286 -S "SSL - An unexpected message was received from our peer" \
2287 -S "failed"
2288
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002289# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002290requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002291run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002292 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002293 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002294 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002295 0 \
2296 -C "client hello, adding renegotiation extension" \
2297 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2298 -S "found renegotiation extension" \
2299 -s "server hello, secure renegotiation extension" \
2300 -c "found renegotiation extension" \
2301 -C "=> renegotiate" \
2302 -S "=> renegotiate" \
2303 -s "write hello request" \
2304 -S "SSL - An unexpected message was received from our peer" \
2305 -S "failed"
2306
Hanno Becker6a243642017-10-12 15:18:45 +01002307requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002309 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002310 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002311 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002312 0 \
2313 -C "client hello, adding renegotiation extension" \
2314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2315 -S "found renegotiation extension" \
2316 -s "server hello, secure renegotiation extension" \
2317 -c "found renegotiation extension" \
2318 -C "=> renegotiate" \
2319 -S "=> renegotiate" \
2320 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002321 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002322
Hanno Becker6a243642017-10-12 15:18:45 +01002323requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002324run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002325 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002326 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002327 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002328 0 \
2329 -c "client hello, adding renegotiation extension" \
2330 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2331 -s "found renegotiation extension" \
2332 -s "server hello, secure renegotiation extension" \
2333 -c "found renegotiation extension" \
2334 -c "=> renegotiate" \
2335 -s "=> renegotiate" \
2336 -s "write hello request" \
2337 -S "SSL - An unexpected message was received from our peer" \
2338 -S "failed"
2339
Hanno Becker6a243642017-10-12 15:18:45 +01002340requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002341run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002342 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002343 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2344 0 \
2345 -C "client hello, adding renegotiation extension" \
2346 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2347 -S "found renegotiation extension" \
2348 -s "server hello, secure renegotiation extension" \
2349 -c "found renegotiation extension" \
2350 -S "record counter limit reached: renegotiate" \
2351 -C "=> renegotiate" \
2352 -S "=> renegotiate" \
2353 -S "write hello request" \
2354 -S "SSL - An unexpected message was received from our peer" \
2355 -S "failed"
2356
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002357# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002358requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002359run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002360 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002361 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002362 0 \
2363 -c "client hello, adding renegotiation extension" \
2364 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2365 -s "found renegotiation extension" \
2366 -s "server hello, secure renegotiation extension" \
2367 -c "found renegotiation extension" \
2368 -s "record counter limit reached: renegotiate" \
2369 -c "=> renegotiate" \
2370 -s "=> renegotiate" \
2371 -s "write hello request" \
2372 -S "SSL - An unexpected message was received from our peer" \
2373 -S "failed"
2374
Hanno Becker6a243642017-10-12 15:18:45 +01002375requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002376run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002377 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002378 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002379 0 \
2380 -c "client hello, adding renegotiation extension" \
2381 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2382 -s "found renegotiation extension" \
2383 -s "server hello, secure renegotiation extension" \
2384 -c "found renegotiation extension" \
2385 -s "record counter limit reached: renegotiate" \
2386 -c "=> renegotiate" \
2387 -s "=> renegotiate" \
2388 -s "write hello request" \
2389 -S "SSL - An unexpected message was received from our peer" \
2390 -S "failed"
2391
Hanno Becker6a243642017-10-12 15:18:45 +01002392requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002393run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002394 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002395 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2396 0 \
2397 -C "client hello, adding renegotiation extension" \
2398 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2399 -S "found renegotiation extension" \
2400 -s "server hello, secure renegotiation extension" \
2401 -c "found renegotiation extension" \
2402 -S "record counter limit reached: renegotiate" \
2403 -C "=> renegotiate" \
2404 -S "=> renegotiate" \
2405 -S "write hello request" \
2406 -S "SSL - An unexpected message was received from our peer" \
2407 -S "failed"
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, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002411 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=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 renegotiate=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: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002425 "$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 +02002426 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002427 0 \
2428 -c "client hello, adding renegotiation extension" \
2429 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2430 -s "found renegotiation extension" \
2431 -s "server hello, secure renegotiation extension" \
2432 -c "found renegotiation extension" \
2433 -c "=> renegotiate" \
2434 -s "=> renegotiate" \
2435 -s "write hello request"
2436
Hanno Becker6a243642017-10-12 15:18:45 +01002437requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002438run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002439 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002440 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002441 0 \
2442 -c "client hello, adding renegotiation extension" \
2443 -c "found renegotiation extension" \
2444 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002445 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002446 -C "error" \
2447 -c "HTTP/1.0 200 [Oo][Kk]"
2448
Paul Bakker539d9722015-02-08 16:18:35 +01002449requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002450requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002451run_test "Renegotiation: gnutls server strict, client-initiated" \
2452 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002453 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002454 0 \
2455 -c "client hello, adding renegotiation extension" \
2456 -c "found renegotiation extension" \
2457 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002458 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002459 -C "error" \
2460 -c "HTTP/1.0 200 [Oo][Kk]"
2461
Paul Bakker539d9722015-02-08 16:18:35 +01002462requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002463requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002464run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2465 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2466 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
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 no legacy" \
2478 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2479 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2480 allow_legacy=0" \
2481 1 \
2482 -c "client hello, adding renegotiation extension" \
2483 -C "found renegotiation extension" \
2484 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002485 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002486 -c "error" \
2487 -C "HTTP/1.0 200 [Oo][Kk]"
2488
Paul Bakker539d9722015-02-08 16:18:35 +01002489requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002490requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002491run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2492 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2493 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2494 allow_legacy=1" \
2495 0 \
2496 -c "client hello, adding renegotiation extension" \
2497 -C "found renegotiation extension" \
2498 -c "=> renegotiate" \
2499 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002500 -C "error" \
2501 -c "HTTP/1.0 200 [Oo][Kk]"
2502
Hanno Becker6a243642017-10-12 15:18:45 +01002503requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002504run_test "Renegotiation: DTLS, client-initiated" \
2505 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2506 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2507 0 \
2508 -c "client hello, adding renegotiation extension" \
2509 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2510 -s "found renegotiation extension" \
2511 -s "server hello, secure renegotiation extension" \
2512 -c "found renegotiation extension" \
2513 -c "=> renegotiate" \
2514 -s "=> renegotiate" \
2515 -S "write hello request"
2516
Hanno Becker6a243642017-10-12 15:18:45 +01002517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002518run_test "Renegotiation: DTLS, server-initiated" \
2519 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002520 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2521 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002522 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 -c "found renegotiation extension" \
2528 -c "=> renegotiate" \
2529 -s "=> renegotiate" \
2530 -s "write hello request"
2531
Hanno Becker6a243642017-10-12 15:18:45 +01002532requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002533run_test "Renegotiation: DTLS, renego_period overflow" \
2534 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2535 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2536 0 \
2537 -c "client hello, adding renegotiation extension" \
2538 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2539 -s "found renegotiation extension" \
2540 -s "server hello, secure renegotiation extension" \
2541 -s "record counter limit reached: renegotiate" \
2542 -c "=> renegotiate" \
2543 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002544 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002545
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002546requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002547requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002548run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2549 "$G_SRV -u --mtu 4096" \
2550 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2551 0 \
2552 -c "client hello, adding renegotiation extension" \
2553 -c "found renegotiation extension" \
2554 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002555 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002556 -C "error" \
2557 -s "Extra-header:"
2558
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002559# Test for the "secure renegotation" extension only (no actual renegotiation)
2560
Paul Bakker539d9722015-02-08 16:18:35 +01002561requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002562run_test "Renego ext: gnutls server strict, client default" \
2563 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2564 "$P_CLI debug_level=3" \
2565 0 \
2566 -c "found renegotiation extension" \
2567 -C "error" \
2568 -c "HTTP/1.0 200 [Oo][Kk]"
2569
Paul Bakker539d9722015-02-08 16:18:35 +01002570requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002571run_test "Renego ext: gnutls server unsafe, client default" \
2572 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2573 "$P_CLI debug_level=3" \
2574 0 \
2575 -C "found renegotiation extension" \
2576 -C "error" \
2577 -c "HTTP/1.0 200 [Oo][Kk]"
2578
Paul Bakker539d9722015-02-08 16:18:35 +01002579requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002580run_test "Renego ext: gnutls server unsafe, client break legacy" \
2581 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2582 "$P_CLI debug_level=3 allow_legacy=-1" \
2583 1 \
2584 -C "found renegotiation extension" \
2585 -c "error" \
2586 -C "HTTP/1.0 200 [Oo][Kk]"
2587
Paul Bakker539d9722015-02-08 16:18:35 +01002588requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002589run_test "Renego ext: gnutls client strict, server default" \
2590 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002591 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002592 0 \
2593 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2594 -s "server hello, secure renegotiation extension"
2595
Paul Bakker539d9722015-02-08 16:18:35 +01002596requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002597run_test "Renego ext: gnutls client unsafe, server default" \
2598 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002599 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002600 0 \
2601 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2602 -S "server hello, secure renegotiation extension"
2603
Paul Bakker539d9722015-02-08 16:18:35 +01002604requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002605run_test "Renego ext: gnutls client unsafe, server break legacy" \
2606 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002607 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002608 1 \
2609 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2610 -S "server hello, secure renegotiation extension"
2611
Janos Follath0b242342016-02-17 10:11:21 +00002612# Tests for silently dropping trailing extra bytes in .der certificates
2613
2614requires_gnutls
2615run_test "DER format: no trailing bytes" \
2616 "$P_SRV crt_file=data_files/server5-der0.crt \
2617 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002618 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002619 0 \
2620 -c "Handshake was completed" \
2621
2622requires_gnutls
2623run_test "DER format: with a trailing zero byte" \
2624 "$P_SRV crt_file=data_files/server5-der1a.crt \
2625 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002626 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002627 0 \
2628 -c "Handshake was completed" \
2629
2630requires_gnutls
2631run_test "DER format: with a trailing random byte" \
2632 "$P_SRV crt_file=data_files/server5-der1b.crt \
2633 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002634 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002635 0 \
2636 -c "Handshake was completed" \
2637
2638requires_gnutls
2639run_test "DER format: with 2 trailing random bytes" \
2640 "$P_SRV crt_file=data_files/server5-der2.crt \
2641 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002642 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002643 0 \
2644 -c "Handshake was completed" \
2645
2646requires_gnutls
2647run_test "DER format: with 4 trailing random bytes" \
2648 "$P_SRV crt_file=data_files/server5-der4.crt \
2649 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002650 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002651 0 \
2652 -c "Handshake was completed" \
2653
2654requires_gnutls
2655run_test "DER format: with 8 trailing random bytes" \
2656 "$P_SRV crt_file=data_files/server5-der8.crt \
2657 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002658 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002659 0 \
2660 -c "Handshake was completed" \
2661
2662requires_gnutls
2663run_test "DER format: with 9 trailing random bytes" \
2664 "$P_SRV crt_file=data_files/server5-der9.crt \
2665 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002666 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002667 0 \
2668 -c "Handshake was completed" \
2669
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002670# Tests for auth_mode
2671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002672run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002673 "$P_SRV crt_file=data_files/server5-badsign.crt \
2674 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002675 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002676 1 \
2677 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002678 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002679 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002680 -c "X509 - Certificate verification failed"
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002683 "$P_SRV crt_file=data_files/server5-badsign.crt \
2684 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002685 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002686 0 \
2687 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002688 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002689 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002690 -C "X509 - Certificate verification failed"
2691
Hanno Beckere6706e62017-05-15 16:05:15 +01002692run_test "Authentication: server goodcert, client optional, no trusted CA" \
2693 "$P_SRV" \
2694 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2695 0 \
2696 -c "x509_verify_cert() returned" \
2697 -c "! The certificate is not correctly signed by the trusted CA" \
2698 -c "! Certificate verification flags"\
2699 -C "! mbedtls_ssl_handshake returned" \
2700 -C "X509 - Certificate verification failed" \
2701 -C "SSL - No CA Chain is set, but required to operate"
2702
2703run_test "Authentication: server goodcert, client required, no trusted CA" \
2704 "$P_SRV" \
2705 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2706 1 \
2707 -c "x509_verify_cert() returned" \
2708 -c "! The certificate is not correctly signed by the trusted CA" \
2709 -c "! Certificate verification flags"\
2710 -c "! mbedtls_ssl_handshake returned" \
2711 -c "SSL - No CA Chain is set, but required to operate"
2712
2713# The purpose of the next two tests is to test the client's behaviour when receiving a server
2714# certificate with an unsupported elliptic curve. This should usually not happen because
2715# the client informs the server about the supported curves - it does, though, in the
2716# corner case of a static ECDH suite, because the server doesn't check the curve on that
2717# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2718# different means to have the server ignoring the client's supported curve list.
2719
2720requires_config_enabled MBEDTLS_ECP_C
2721run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2722 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2723 crt_file=data_files/server5.ku-ka.crt" \
2724 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2725 1 \
2726 -c "bad certificate (EC key curve)"\
2727 -c "! Certificate verification flags"\
2728 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2729
2730requires_config_enabled MBEDTLS_ECP_C
2731run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2732 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2733 crt_file=data_files/server5.ku-ka.crt" \
2734 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2735 1 \
2736 -c "bad certificate (EC key curve)"\
2737 -c "! Certificate verification flags"\
2738 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2739
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002740run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002741 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002742 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002743 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002744 0 \
2745 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002746 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002747 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002748 -C "X509 - Certificate verification failed"
2749
Simon Butcher99000142016-10-13 17:21:01 +01002750run_test "Authentication: client SHA256, server required" \
2751 "$P_SRV auth_mode=required" \
2752 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2753 key_file=data_files/server6.key \
2754 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2755 0 \
2756 -c "Supported Signature Algorithm found: 4," \
2757 -c "Supported Signature Algorithm found: 5,"
2758
2759run_test "Authentication: client SHA384, server required" \
2760 "$P_SRV auth_mode=required" \
2761 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2762 key_file=data_files/server6.key \
2763 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2764 0 \
2765 -c "Supported Signature Algorithm found: 4," \
2766 -c "Supported Signature Algorithm found: 5,"
2767
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002768requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2769run_test "Authentication: client has no cert, server required (SSLv3)" \
2770 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2771 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2772 key_file=data_files/server5.key" \
2773 1 \
2774 -S "skip write certificate request" \
2775 -C "skip parse certificate request" \
2776 -c "got a certificate request" \
2777 -c "got no certificate to send" \
2778 -S "x509_verify_cert() returned" \
2779 -s "client has no certificate" \
2780 -s "! mbedtls_ssl_handshake returned" \
2781 -c "! mbedtls_ssl_handshake returned" \
2782 -s "No client certification received from the client, but required by the authentication mode"
2783
2784run_test "Authentication: client has no cert, server required (TLS)" \
2785 "$P_SRV debug_level=3 auth_mode=required" \
2786 "$P_CLI debug_level=3 crt_file=none \
2787 key_file=data_files/server5.key" \
2788 1 \
2789 -S "skip write certificate request" \
2790 -C "skip parse certificate request" \
2791 -c "got a certificate request" \
2792 -c "= write certificate$" \
2793 -C "skip write certificate$" \
2794 -S "x509_verify_cert() returned" \
2795 -s "client has no certificate" \
2796 -s "! mbedtls_ssl_handshake returned" \
2797 -c "! mbedtls_ssl_handshake returned" \
2798 -s "No client certification received from the client, but required by the authentication mode"
2799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002801 "$P_SRV debug_level=3 auth_mode=required" \
2802 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002803 key_file=data_files/server5.key" \
2804 1 \
2805 -S "skip write certificate request" \
2806 -C "skip parse certificate request" \
2807 -c "got a certificate request" \
2808 -C "skip write certificate" \
2809 -C "skip write certificate verify" \
2810 -S "skip parse certificate verify" \
2811 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002812 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002813 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002814 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002815 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002816 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002817# We don't check that the client receives the alert because it might
2818# detect that its write end of the connection is closed and abort
2819# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002820
Janos Follath89baba22017-04-10 14:34:35 +01002821run_test "Authentication: client cert not trusted, server required" \
2822 "$P_SRV debug_level=3 auth_mode=required" \
2823 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2824 key_file=data_files/server5.key" \
2825 1 \
2826 -S "skip write certificate request" \
2827 -C "skip parse certificate request" \
2828 -c "got a certificate request" \
2829 -C "skip write certificate" \
2830 -C "skip write certificate verify" \
2831 -S "skip parse certificate verify" \
2832 -s "x509_verify_cert() returned" \
2833 -s "! The certificate is not correctly signed by the trusted CA" \
2834 -s "! mbedtls_ssl_handshake returned" \
2835 -c "! mbedtls_ssl_handshake returned" \
2836 -s "X509 - Certificate verification failed"
2837
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002838run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002839 "$P_SRV debug_level=3 auth_mode=optional" \
2840 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002841 key_file=data_files/server5.key" \
2842 0 \
2843 -S "skip write certificate request" \
2844 -C "skip parse certificate request" \
2845 -c "got a certificate request" \
2846 -C "skip write certificate" \
2847 -C "skip write certificate verify" \
2848 -S "skip parse certificate verify" \
2849 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002850 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002851 -S "! mbedtls_ssl_handshake returned" \
2852 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002853 -S "X509 - Certificate verification failed"
2854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002855run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002856 "$P_SRV debug_level=3 auth_mode=none" \
2857 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002858 key_file=data_files/server5.key" \
2859 0 \
2860 -s "skip write certificate request" \
2861 -C "skip parse certificate request" \
2862 -c "got no certificate request" \
2863 -c "skip write certificate" \
2864 -c "skip write certificate verify" \
2865 -s "skip parse certificate verify" \
2866 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002867 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002868 -S "! mbedtls_ssl_handshake returned" \
2869 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002870 -S "X509 - Certificate verification failed"
2871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002872run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002873 "$P_SRV debug_level=3 auth_mode=optional" \
2874 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002875 0 \
2876 -S "skip write certificate request" \
2877 -C "skip parse certificate request" \
2878 -c "got a certificate request" \
2879 -C "skip write certificate$" \
2880 -C "got no certificate to send" \
2881 -S "SSLv3 client has no certificate" \
2882 -c "skip write certificate verify" \
2883 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002884 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002885 -S "! mbedtls_ssl_handshake returned" \
2886 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002887 -S "X509 - Certificate verification failed"
2888
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002889run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002890 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002891 "$O_CLI" \
2892 0 \
2893 -S "skip write certificate request" \
2894 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002895 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002896 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002897 -S "X509 - Certificate verification failed"
2898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002899run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002900 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002901 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002902 0 \
2903 -C "skip parse certificate request" \
2904 -c "got a certificate request" \
2905 -C "skip write certificate$" \
2906 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002907 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002908
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002909run_test "Authentication: client no cert, openssl server required" \
2910 "$O_SRV -Verify 10" \
2911 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2912 1 \
2913 -C "skip parse certificate request" \
2914 -c "got a certificate request" \
2915 -C "skip write certificate$" \
2916 -c "skip write certificate verify" \
2917 -c "! mbedtls_ssl_handshake returned"
2918
Janos Follathe2681a42016-03-07 15:57:05 +00002919requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002920run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002921 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002922 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002923 0 \
2924 -S "skip write certificate request" \
2925 -C "skip parse certificate request" \
2926 -c "got a certificate request" \
2927 -C "skip write certificate$" \
2928 -c "skip write certificate verify" \
2929 -c "got no certificate to send" \
2930 -s "SSLv3 client has no certificate" \
2931 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002932 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002933 -S "! mbedtls_ssl_handshake returned" \
2934 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002935 -S "X509 - Certificate verification failed"
2936
Yuto Takano8df2d252021-07-02 13:05:15 +01002937# This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default
2938# value, defined here as MAX_IM_CA. Some test cases will be skipped if the
2939# library is configured with a different value.
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002940
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002941MAX_IM_CA='8'
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002942
Yuto Takano8df2d252021-07-02 13:05:15 +01002943# The tests for the max_int tests can pass with any number higher than MAX_IM_CA
2944# because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1
2945# tests can pass with any number less than MAX_IM_CA. However, stricter preconditions
2946# are in place so that the semantics are consistent with the test description.
Yuto Takanobc632c22021-07-02 13:10:41 +01002947requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002948requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002949run_test "Authentication: server max_int chain, client default" \
2950 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2951 key_file=data_files/dir-maxpath/09.key" \
2952 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2953 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002954 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002955
Yuto Takanobc632c22021-07-02 13:10:41 +01002956requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002957requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002958run_test "Authentication: server max_int+1 chain, client default" \
2959 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2960 key_file=data_files/dir-maxpath/10.key" \
2961 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2962 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002963 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002964
Yuto Takanobc632c22021-07-02 13:10:41 +01002965requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002966requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002967run_test "Authentication: server max_int+1 chain, client optional" \
2968 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2969 key_file=data_files/dir-maxpath/10.key" \
2970 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2971 auth_mode=optional" \
2972 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002973 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002974
Yuto Takanobc632c22021-07-02 13:10:41 +01002975requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002976requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002977run_test "Authentication: server max_int+1 chain, client none" \
2978 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2979 key_file=data_files/dir-maxpath/10.key" \
2980 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2981 auth_mode=none" \
2982 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002983 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002984
Yuto Takanobc632c22021-07-02 13:10:41 +01002985requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002986requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002987run_test "Authentication: client max_int+1 chain, server default" \
2988 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2989 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2990 key_file=data_files/dir-maxpath/10.key" \
2991 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002992 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002993
Yuto Takanobc632c22021-07-02 13:10:41 +01002994requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002995requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002996run_test "Authentication: client max_int+1 chain, server optional" \
2997 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2998 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2999 key_file=data_files/dir-maxpath/10.key" \
3000 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003001 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003002
Yuto Takanobc632c22021-07-02 13:10:41 +01003003requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10003004requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003005run_test "Authentication: client max_int+1 chain, server required" \
3006 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3007 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3008 key_file=data_files/dir-maxpath/10.key" \
3009 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003010 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003011
Yuto Takanobc632c22021-07-02 13:10:41 +01003012requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10003013requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003014run_test "Authentication: client max_int chain, server required" \
3015 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3016 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
3017 key_file=data_files/dir-maxpath/09.key" \
3018 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003019 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003020
Janos Follath89baba22017-04-10 14:34:35 +01003021# Tests for CA list in CertificateRequest messages
3022
3023run_test "Authentication: send CA list in CertificateRequest (default)" \
3024 "$P_SRV debug_level=3 auth_mode=required" \
3025 "$P_CLI crt_file=data_files/server6.crt \
3026 key_file=data_files/server6.key" \
3027 0 \
3028 -s "requested DN"
3029
3030run_test "Authentication: do not send CA list in CertificateRequest" \
3031 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3032 "$P_CLI crt_file=data_files/server6.crt \
3033 key_file=data_files/server6.key" \
3034 0 \
3035 -S "requested DN"
3036
3037run_test "Authentication: send CA list in CertificateRequest, client self signed" \
3038 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3039 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3040 key_file=data_files/server5.key" \
3041 1 \
3042 -S "requested DN" \
3043 -s "x509_verify_cert() returned" \
3044 -s "! The certificate is not correctly signed by the trusted CA" \
3045 -s "! mbedtls_ssl_handshake returned" \
3046 -c "! mbedtls_ssl_handshake returned" \
3047 -s "X509 - Certificate verification failed"
3048
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01003049# Tests for certificate selection based on SHA verson
3050
3051run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3052 "$P_SRV crt_file=data_files/server5.crt \
3053 key_file=data_files/server5.key \
3054 crt_file2=data_files/server5-sha1.crt \
3055 key_file2=data_files/server5.key" \
3056 "$P_CLI force_version=tls1_2" \
3057 0 \
3058 -c "signed using.*ECDSA with SHA256" \
3059 -C "signed using.*ECDSA with SHA1"
3060
3061run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3062 "$P_SRV crt_file=data_files/server5.crt \
3063 key_file=data_files/server5.key \
3064 crt_file2=data_files/server5-sha1.crt \
3065 key_file2=data_files/server5.key" \
3066 "$P_CLI force_version=tls1_1" \
3067 0 \
3068 -C "signed using.*ECDSA with SHA256" \
3069 -c "signed using.*ECDSA with SHA1"
3070
3071run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3072 "$P_SRV crt_file=data_files/server5.crt \
3073 key_file=data_files/server5.key \
3074 crt_file2=data_files/server5-sha1.crt \
3075 key_file2=data_files/server5.key" \
3076 "$P_CLI force_version=tls1" \
3077 0 \
3078 -C "signed using.*ECDSA with SHA256" \
3079 -c "signed using.*ECDSA with SHA1"
3080
3081run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3082 "$P_SRV crt_file=data_files/server5.crt \
3083 key_file=data_files/server5.key \
3084 crt_file2=data_files/server6.crt \
3085 key_file2=data_files/server6.key" \
3086 "$P_CLI force_version=tls1_1" \
3087 0 \
3088 -c "serial number.*09" \
3089 -c "signed using.*ECDSA with SHA256" \
3090 -C "signed using.*ECDSA with SHA1"
3091
3092run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3093 "$P_SRV crt_file=data_files/server6.crt \
3094 key_file=data_files/server6.key \
3095 crt_file2=data_files/server5.crt \
3096 key_file2=data_files/server5.key" \
3097 "$P_CLI force_version=tls1_1" \
3098 0 \
3099 -c "serial number.*0A" \
3100 -c "signed using.*ECDSA with SHA256" \
3101 -C "signed using.*ECDSA with SHA1"
3102
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003103# tests for SNI
3104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003105run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003106 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003107 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003108 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003109 0 \
3110 -S "parse ServerName extension" \
3111 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3112 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003113
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003114run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003115 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003116 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003117 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 +02003118 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003119 0 \
3120 -s "parse ServerName extension" \
3121 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3122 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003123
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003124run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003125 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003126 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003127 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 +02003128 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003129 0 \
3130 -s "parse ServerName extension" \
3131 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3132 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003133
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003134run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003135 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003136 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003137 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 +02003138 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003139 1 \
3140 -s "parse ServerName extension" \
3141 -s "ssl_sni_wrapper() returned" \
3142 -s "mbedtls_ssl_handshake returned" \
3143 -c "mbedtls_ssl_handshake returned" \
3144 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003145
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003146run_test "SNI: client auth no override: optional" \
3147 "$P_SRV debug_level=3 auth_mode=optional \
3148 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3149 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3150 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003151 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003152 -S "skip write certificate request" \
3153 -C "skip parse certificate request" \
3154 -c "got a certificate request" \
3155 -C "skip write certificate" \
3156 -C "skip write certificate verify" \
3157 -S "skip parse certificate verify"
3158
3159run_test "SNI: client auth override: none -> optional" \
3160 "$P_SRV debug_level=3 auth_mode=none \
3161 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3162 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3163 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003164 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003165 -S "skip write certificate request" \
3166 -C "skip parse certificate request" \
3167 -c "got a certificate request" \
3168 -C "skip write certificate" \
3169 -C "skip write certificate verify" \
3170 -S "skip parse certificate verify"
3171
3172run_test "SNI: client auth override: optional -> none" \
3173 "$P_SRV debug_level=3 auth_mode=optional \
3174 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3175 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3176 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003177 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003178 -s "skip write certificate request" \
3179 -C "skip parse certificate request" \
3180 -c "got no certificate request" \
3181 -c "skip write certificate" \
3182 -c "skip write certificate verify" \
3183 -s "skip parse certificate verify"
3184
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003185run_test "SNI: CA no override" \
3186 "$P_SRV debug_level=3 auth_mode=optional \
3187 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3188 ca_file=data_files/test-ca.crt \
3189 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3190 "$P_CLI debug_level=3 server_name=localhost \
3191 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3192 1 \
3193 -S "skip write certificate request" \
3194 -C "skip parse certificate request" \
3195 -c "got a certificate request" \
3196 -C "skip write certificate" \
3197 -C "skip write certificate verify" \
3198 -S "skip parse certificate verify" \
3199 -s "x509_verify_cert() returned" \
3200 -s "! The certificate is not correctly signed by the trusted CA" \
3201 -S "The certificate has been revoked (is on a CRL)"
3202
3203run_test "SNI: CA override" \
3204 "$P_SRV debug_level=3 auth_mode=optional \
3205 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3206 ca_file=data_files/test-ca.crt \
3207 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3208 "$P_CLI debug_level=3 server_name=localhost \
3209 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3210 0 \
3211 -S "skip write certificate request" \
3212 -C "skip parse certificate request" \
3213 -c "got a certificate request" \
3214 -C "skip write certificate" \
3215 -C "skip write certificate verify" \
3216 -S "skip parse certificate verify" \
3217 -S "x509_verify_cert() returned" \
3218 -S "! The certificate is not correctly signed by the trusted CA" \
3219 -S "The certificate has been revoked (is on a CRL)"
3220
3221run_test "SNI: CA override with CRL" \
3222 "$P_SRV debug_level=3 auth_mode=optional \
3223 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3224 ca_file=data_files/test-ca.crt \
3225 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3226 "$P_CLI debug_level=3 server_name=localhost \
3227 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3228 1 \
3229 -S "skip write certificate request" \
3230 -C "skip parse certificate request" \
3231 -c "got a certificate request" \
3232 -C "skip write certificate" \
3233 -C "skip write certificate verify" \
3234 -S "skip parse certificate verify" \
3235 -s "x509_verify_cert() returned" \
3236 -S "! The certificate is not correctly signed by the trusted CA" \
3237 -s "The certificate has been revoked (is on a CRL)"
3238
Andres AG1a834452016-12-07 10:01:30 +00003239# Tests for SNI and DTLS
3240
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003241run_test "SNI: DTLS, no SNI callback" \
3242 "$P_SRV debug_level=3 dtls=1 \
3243 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3244 "$P_CLI server_name=localhost dtls=1" \
3245 0 \
3246 -S "parse ServerName extension" \
3247 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3248 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3249
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003250run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003251 "$P_SRV debug_level=3 dtls=1 \
3252 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3253 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3254 "$P_CLI server_name=localhost dtls=1" \
3255 0 \
3256 -s "parse ServerName extension" \
3257 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3258 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3259
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003260run_test "SNI: DTLS, matching cert 2" \
3261 "$P_SRV debug_level=3 dtls=1 \
3262 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3263 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3264 "$P_CLI server_name=polarssl.example dtls=1" \
3265 0 \
3266 -s "parse ServerName extension" \
3267 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3268 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3269
3270run_test "SNI: DTLS, no matching cert" \
3271 "$P_SRV debug_level=3 dtls=1 \
3272 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3273 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3274 "$P_CLI server_name=nonesuch.example dtls=1" \
3275 1 \
3276 -s "parse ServerName extension" \
3277 -s "ssl_sni_wrapper() returned" \
3278 -s "mbedtls_ssl_handshake returned" \
3279 -c "mbedtls_ssl_handshake returned" \
3280 -c "SSL - A fatal alert message was received from our peer"
3281
3282run_test "SNI: DTLS, client auth no override: optional" \
3283 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3284 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3285 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3286 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3287 0 \
3288 -S "skip write certificate request" \
3289 -C "skip parse certificate request" \
3290 -c "got a certificate request" \
3291 -C "skip write certificate" \
3292 -C "skip write certificate verify" \
3293 -S "skip parse certificate verify"
3294
3295run_test "SNI: DTLS, client auth override: none -> optional" \
3296 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3297 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3298 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3299 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3300 0 \
3301 -S "skip write certificate request" \
3302 -C "skip parse certificate request" \
3303 -c "got a certificate request" \
3304 -C "skip write certificate" \
3305 -C "skip write certificate verify" \
3306 -S "skip parse certificate verify"
3307
3308run_test "SNI: DTLS, client auth override: optional -> none" \
3309 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3310 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3311 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3312 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3313 0 \
3314 -s "skip write certificate request" \
3315 -C "skip parse certificate request" \
3316 -c "got no certificate request" \
3317 -c "skip write certificate" \
3318 -c "skip write certificate verify" \
3319 -s "skip parse certificate verify"
3320
3321run_test "SNI: DTLS, CA no override" \
3322 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3323 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3324 ca_file=data_files/test-ca.crt \
3325 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3326 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3327 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3328 1 \
3329 -S "skip write certificate request" \
3330 -C "skip parse certificate request" \
3331 -c "got a certificate request" \
3332 -C "skip write certificate" \
3333 -C "skip write certificate verify" \
3334 -S "skip parse certificate verify" \
3335 -s "x509_verify_cert() returned" \
3336 -s "! The certificate is not correctly signed by the trusted CA" \
3337 -S "The certificate has been revoked (is on a CRL)"
3338
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003339run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003340 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3341 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3342 ca_file=data_files/test-ca.crt \
3343 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3344 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3345 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3346 0 \
3347 -S "skip write certificate request" \
3348 -C "skip parse certificate request" \
3349 -c "got a certificate request" \
3350 -C "skip write certificate" \
3351 -C "skip write certificate verify" \
3352 -S "skip parse certificate verify" \
3353 -S "x509_verify_cert() returned" \
3354 -S "! The certificate is not correctly signed by the trusted CA" \
3355 -S "The certificate has been revoked (is on a CRL)"
3356
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003357run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003358 "$P_SRV debug_level=3 auth_mode=optional \
3359 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3360 ca_file=data_files/test-ca.crt \
3361 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3362 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3363 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3364 1 \
3365 -S "skip write certificate request" \
3366 -C "skip parse certificate request" \
3367 -c "got a certificate request" \
3368 -C "skip write certificate" \
3369 -C "skip write certificate verify" \
3370 -S "skip parse certificate verify" \
3371 -s "x509_verify_cert() returned" \
3372 -S "! The certificate is not correctly signed by the trusted CA" \
3373 -s "The certificate has been revoked (is on a CRL)"
3374
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003375# Tests for non-blocking I/O: exercise a variety of handshake flows
3376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003377run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003378 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3379 "$P_CLI nbio=2 tickets=0" \
3380 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003381 -S "mbedtls_ssl_handshake returned" \
3382 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003383 -c "Read from server: .* bytes read"
3384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003385run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003386 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3387 "$P_CLI nbio=2 tickets=0" \
3388 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003389 -S "mbedtls_ssl_handshake returned" \
3390 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003391 -c "Read from server: .* bytes read"
3392
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003393run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003394 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3395 "$P_CLI nbio=2 tickets=1" \
3396 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003397 -S "mbedtls_ssl_handshake returned" \
3398 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003399 -c "Read from server: .* bytes read"
3400
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003401run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003402 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3403 "$P_CLI nbio=2 tickets=1" \
3404 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003405 -S "mbedtls_ssl_handshake returned" \
3406 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003407 -c "Read from server: .* bytes read"
3408
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003409run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003410 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3411 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3412 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003413 -S "mbedtls_ssl_handshake returned" \
3414 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003415 -c "Read from server: .* bytes read"
3416
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003417run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003418 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3419 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3420 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003421 -S "mbedtls_ssl_handshake returned" \
3422 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003423 -c "Read from server: .* bytes read"
3424
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003425run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003426 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3427 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3428 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003429 -S "mbedtls_ssl_handshake returned" \
3430 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003431 -c "Read from server: .* bytes read"
3432
Hanno Becker00076712017-11-15 16:39:08 +00003433# Tests for event-driven I/O: exercise a variety of handshake flows
3434
3435run_test "Event-driven I/O: basic handshake" \
3436 "$P_SRV event=1 tickets=0 auth_mode=none" \
3437 "$P_CLI event=1 tickets=0" \
3438 0 \
3439 -S "mbedtls_ssl_handshake returned" \
3440 -C "mbedtls_ssl_handshake returned" \
3441 -c "Read from server: .* bytes read"
3442
3443run_test "Event-driven I/O: client auth" \
3444 "$P_SRV event=1 tickets=0 auth_mode=required" \
3445 "$P_CLI event=1 tickets=0" \
3446 0 \
3447 -S "mbedtls_ssl_handshake returned" \
3448 -C "mbedtls_ssl_handshake returned" \
3449 -c "Read from server: .* bytes read"
3450
3451run_test "Event-driven I/O: ticket" \
3452 "$P_SRV event=1 tickets=1 auth_mode=none" \
3453 "$P_CLI event=1 tickets=1" \
3454 0 \
3455 -S "mbedtls_ssl_handshake returned" \
3456 -C "mbedtls_ssl_handshake returned" \
3457 -c "Read from server: .* bytes read"
3458
3459run_test "Event-driven I/O: ticket + client auth" \
3460 "$P_SRV event=1 tickets=1 auth_mode=required" \
3461 "$P_CLI event=1 tickets=1" \
3462 0 \
3463 -S "mbedtls_ssl_handshake returned" \
3464 -C "mbedtls_ssl_handshake returned" \
3465 -c "Read from server: .* bytes read"
3466
3467run_test "Event-driven I/O: ticket + client auth + resume" \
3468 "$P_SRV event=1 tickets=1 auth_mode=required" \
3469 "$P_CLI event=1 tickets=1 reconnect=1" \
3470 0 \
3471 -S "mbedtls_ssl_handshake returned" \
3472 -C "mbedtls_ssl_handshake returned" \
3473 -c "Read from server: .* bytes read"
3474
3475run_test "Event-driven I/O: ticket + resume" \
3476 "$P_SRV event=1 tickets=1 auth_mode=none" \
3477 "$P_CLI event=1 tickets=1 reconnect=1" \
3478 0 \
3479 -S "mbedtls_ssl_handshake returned" \
3480 -C "mbedtls_ssl_handshake returned" \
3481 -c "Read from server: .* bytes read"
3482
3483run_test "Event-driven I/O: session-id resume" \
3484 "$P_SRV event=1 tickets=0 auth_mode=none" \
3485 "$P_CLI event=1 tickets=0 reconnect=1" \
3486 0 \
3487 -S "mbedtls_ssl_handshake returned" \
3488 -C "mbedtls_ssl_handshake returned" \
3489 -c "Read from server: .* bytes read"
3490
Hanno Becker6a33f592018-03-13 11:38:46 +00003491run_test "Event-driven I/O, DTLS: basic handshake" \
3492 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3493 "$P_CLI dtls=1 event=1 tickets=0" \
3494 0 \
3495 -c "Read from server: .* bytes read"
3496
3497run_test "Event-driven I/O, DTLS: client auth" \
3498 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3499 "$P_CLI dtls=1 event=1 tickets=0" \
3500 0 \
3501 -c "Read from server: .* bytes read"
3502
3503run_test "Event-driven I/O, DTLS: ticket" \
3504 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3505 "$P_CLI dtls=1 event=1 tickets=1" \
3506 0 \
3507 -c "Read from server: .* bytes read"
3508
3509run_test "Event-driven I/O, DTLS: ticket + client auth" \
3510 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3511 "$P_CLI dtls=1 event=1 tickets=1" \
3512 0 \
3513 -c "Read from server: .* bytes read"
3514
3515run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3516 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003517 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003518 0 \
3519 -c "Read from server: .* bytes read"
3520
3521run_test "Event-driven I/O, DTLS: ticket + resume" \
3522 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003523 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003524 0 \
3525 -c "Read from server: .* bytes read"
3526
3527run_test "Event-driven I/O, DTLS: session-id resume" \
3528 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003529 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003530 0 \
3531 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003532
3533# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3534# During session resumption, the client will send its ApplicationData record
3535# within the same datagram as the Finished messages. In this situation, the
3536# server MUST NOT idle on the underlying transport after handshake completion,
3537# because the ApplicationData request has already been queued internally.
3538run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003539 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003540 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003541 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003542 0 \
3543 -c "Read from server: .* bytes read"
3544
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003545# Tests for version negotiation
3546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003547run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003548 "$P_SRV" \
3549 "$P_CLI" \
3550 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003551 -S "mbedtls_ssl_handshake returned" \
3552 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003553 -s "Protocol is TLSv1.2" \
3554 -c "Protocol is TLSv1.2"
3555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003556run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003557 "$P_SRV" \
3558 "$P_CLI max_version=tls1_1" \
3559 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003560 -S "mbedtls_ssl_handshake returned" \
3561 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003562 -s "Protocol is TLSv1.1" \
3563 -c "Protocol is TLSv1.1"
3564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003565run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003566 "$P_SRV max_version=tls1_1" \
3567 "$P_CLI" \
3568 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003569 -S "mbedtls_ssl_handshake returned" \
3570 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003571 -s "Protocol is TLSv1.1" \
3572 -c "Protocol is TLSv1.1"
3573
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003574run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003575 "$P_SRV max_version=tls1_1" \
3576 "$P_CLI max_version=tls1_1" \
3577 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003578 -S "mbedtls_ssl_handshake returned" \
3579 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003580 -s "Protocol is TLSv1.1" \
3581 -c "Protocol is TLSv1.1"
3582
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003583run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003584 "$P_SRV min_version=tls1_1" \
3585 "$P_CLI max_version=tls1_1" \
3586 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003587 -S "mbedtls_ssl_handshake returned" \
3588 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003589 -s "Protocol is TLSv1.1" \
3590 -c "Protocol is TLSv1.1"
3591
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003592run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003593 "$P_SRV max_version=tls1_1" \
3594 "$P_CLI min_version=tls1_1" \
3595 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003596 -S "mbedtls_ssl_handshake returned" \
3597 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003598 -s "Protocol is TLSv1.1" \
3599 -c "Protocol is TLSv1.1"
3600
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003601run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003602 "$P_SRV max_version=tls1_1" \
3603 "$P_CLI min_version=tls1_2" \
3604 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003605 -s "mbedtls_ssl_handshake returned" \
3606 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003607 -c "SSL - Handshake protocol not within min/max boundaries"
3608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003609run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003610 "$P_SRV min_version=tls1_2" \
3611 "$P_CLI max_version=tls1_1" \
3612 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003613 -s "mbedtls_ssl_handshake returned" \
3614 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003615 -s "SSL - Handshake protocol not within min/max boundaries"
3616
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003617# Tests for ALPN extension
3618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003619run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003620 "$P_SRV debug_level=3" \
3621 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003622 0 \
3623 -C "client hello, adding alpn extension" \
3624 -S "found alpn extension" \
3625 -C "got an alert message, type: \\[2:120]" \
3626 -S "server hello, adding alpn extension" \
3627 -C "found alpn extension " \
3628 -C "Application Layer Protocol is" \
3629 -S "Application Layer Protocol is"
3630
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003631run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003632 "$P_SRV debug_level=3" \
3633 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003634 0 \
3635 -c "client hello, adding alpn extension" \
3636 -s "found alpn extension" \
3637 -C "got an alert message, type: \\[2:120]" \
3638 -S "server hello, adding alpn extension" \
3639 -C "found alpn extension " \
3640 -c "Application Layer Protocol is (none)" \
3641 -S "Application Layer Protocol is"
3642
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003643run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003644 "$P_SRV debug_level=3 alpn=abc,1234" \
3645 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003646 0 \
3647 -C "client hello, adding alpn extension" \
3648 -S "found alpn extension" \
3649 -C "got an alert message, type: \\[2:120]" \
3650 -S "server hello, adding alpn extension" \
3651 -C "found alpn extension " \
3652 -C "Application Layer Protocol is" \
3653 -s "Application Layer Protocol is (none)"
3654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003655run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003656 "$P_SRV debug_level=3 alpn=abc,1234" \
3657 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003658 0 \
3659 -c "client hello, adding alpn extension" \
3660 -s "found alpn extension" \
3661 -C "got an alert message, type: \\[2:120]" \
3662 -s "server hello, adding alpn extension" \
3663 -c "found alpn extension" \
3664 -c "Application Layer Protocol is abc" \
3665 -s "Application Layer Protocol is abc"
3666
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003667run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003668 "$P_SRV debug_level=3 alpn=abc,1234" \
3669 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003670 0 \
3671 -c "client hello, adding alpn extension" \
3672 -s "found alpn extension" \
3673 -C "got an alert message, type: \\[2:120]" \
3674 -s "server hello, adding alpn extension" \
3675 -c "found alpn extension" \
3676 -c "Application Layer Protocol is abc" \
3677 -s "Application Layer Protocol is abc"
3678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003679run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003680 "$P_SRV debug_level=3 alpn=abc,1234" \
3681 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003682 0 \
3683 -c "client hello, adding alpn extension" \
3684 -s "found alpn extension" \
3685 -C "got an alert message, type: \\[2:120]" \
3686 -s "server hello, adding alpn extension" \
3687 -c "found alpn extension" \
3688 -c "Application Layer Protocol is 1234" \
3689 -s "Application Layer Protocol is 1234"
3690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003691run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003692 "$P_SRV debug_level=3 alpn=abc,123" \
3693 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003694 1 \
3695 -c "client hello, adding alpn extension" \
3696 -s "found alpn extension" \
3697 -c "got an alert message, type: \\[2:120]" \
3698 -S "server hello, adding alpn extension" \
3699 -C "found alpn extension" \
3700 -C "Application Layer Protocol is 1234" \
3701 -S "Application Layer Protocol is 1234"
3702
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003703
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003704# Tests for keyUsage in leaf certificates, part 1:
3705# server-side certificate/suite selection
3706
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003707run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003708 "$P_SRV key_file=data_files/server2.key \
3709 crt_file=data_files/server2.ku-ds.crt" \
3710 "$P_CLI" \
3711 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003712 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003713
3714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003715run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003716 "$P_SRV key_file=data_files/server2.key \
3717 crt_file=data_files/server2.ku-ke.crt" \
3718 "$P_CLI" \
3719 0 \
3720 -c "Ciphersuite is TLS-RSA-WITH-"
3721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003722run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003723 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003724 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003725 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003726 1 \
3727 -C "Ciphersuite is "
3728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003729run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003730 "$P_SRV key_file=data_files/server5.key \
3731 crt_file=data_files/server5.ku-ds.crt" \
3732 "$P_CLI" \
3733 0 \
3734 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3735
3736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003737run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003738 "$P_SRV key_file=data_files/server5.key \
3739 crt_file=data_files/server5.ku-ka.crt" \
3740 "$P_CLI" \
3741 0 \
3742 -c "Ciphersuite is TLS-ECDH-"
3743
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003744run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003745 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003746 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003747 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003748 1 \
3749 -C "Ciphersuite is "
3750
3751# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003752# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003754run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003755 "$O_SRV -key data_files/server2.key \
3756 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003757 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003758 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3759 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003760 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003761 -C "Processing of the Certificate handshake message failed" \
3762 -c "Ciphersuite is TLS-"
3763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003764run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003765 "$O_SRV -key data_files/server2.key \
3766 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003767 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003768 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3769 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003770 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003771 -C "Processing of the Certificate handshake message failed" \
3772 -c "Ciphersuite is TLS-"
3773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003774run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003775 "$O_SRV -key data_files/server2.key \
3776 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003777 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003778 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3779 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003780 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003781 -C "Processing of the Certificate handshake message failed" \
3782 -c "Ciphersuite is TLS-"
3783
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003784run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003785 "$O_SRV -key data_files/server2.key \
3786 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003787 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003788 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3789 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003790 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003791 -c "Processing of the Certificate handshake message failed" \
3792 -C "Ciphersuite is TLS-"
3793
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003794run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3795 "$O_SRV -key data_files/server2.key \
3796 -cert data_files/server2.ku-ke.crt" \
3797 "$P_CLI debug_level=1 auth_mode=optional \
3798 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3799 0 \
3800 -c "bad certificate (usage extensions)" \
3801 -C "Processing of the Certificate handshake message failed" \
3802 -c "Ciphersuite is TLS-" \
3803 -c "! Usage does not match the keyUsage extension"
3804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003805run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003806 "$O_SRV -key data_files/server2.key \
3807 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003808 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003809 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3810 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003811 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003812 -C "Processing of the Certificate handshake message failed" \
3813 -c "Ciphersuite is TLS-"
3814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003815run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003816 "$O_SRV -key data_files/server2.key \
3817 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003818 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003819 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3820 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003821 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003822 -c "Processing of the Certificate handshake message failed" \
3823 -C "Ciphersuite is TLS-"
3824
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003825run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3826 "$O_SRV -key data_files/server2.key \
3827 -cert data_files/server2.ku-ds.crt" \
3828 "$P_CLI debug_level=1 auth_mode=optional \
3829 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3830 0 \
3831 -c "bad certificate (usage extensions)" \
3832 -C "Processing of the Certificate handshake message failed" \
3833 -c "Ciphersuite is TLS-" \
3834 -c "! Usage does not match the keyUsage extension"
3835
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003836# Tests for keyUsage in leaf certificates, part 3:
3837# server-side checking of client cert
3838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003839run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003840 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003841 "$O_CLI -key data_files/server2.key \
3842 -cert data_files/server2.ku-ds.crt" \
3843 0 \
3844 -S "bad certificate (usage extensions)" \
3845 -S "Processing of the Certificate handshake message failed"
3846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003847run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003848 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003849 "$O_CLI -key data_files/server2.key \
3850 -cert data_files/server2.ku-ke.crt" \
3851 0 \
3852 -s "bad certificate (usage extensions)" \
3853 -S "Processing of the Certificate handshake message failed"
3854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003855run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003856 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003857 "$O_CLI -key data_files/server2.key \
3858 -cert data_files/server2.ku-ke.crt" \
3859 1 \
3860 -s "bad certificate (usage extensions)" \
3861 -s "Processing of the Certificate handshake message failed"
3862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003863run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003864 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003865 "$O_CLI -key data_files/server5.key \
3866 -cert data_files/server5.ku-ds.crt" \
3867 0 \
3868 -S "bad certificate (usage extensions)" \
3869 -S "Processing of the Certificate handshake message failed"
3870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003872 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003873 "$O_CLI -key data_files/server5.key \
3874 -cert data_files/server5.ku-ka.crt" \
3875 0 \
3876 -s "bad certificate (usage extensions)" \
3877 -S "Processing of the Certificate handshake message failed"
3878
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003879# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3880
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003881run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003882 "$P_SRV key_file=data_files/server5.key \
3883 crt_file=data_files/server5.eku-srv.crt" \
3884 "$P_CLI" \
3885 0
3886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003887run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003888 "$P_SRV key_file=data_files/server5.key \
3889 crt_file=data_files/server5.eku-srv.crt" \
3890 "$P_CLI" \
3891 0
3892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003893run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003894 "$P_SRV key_file=data_files/server5.key \
3895 crt_file=data_files/server5.eku-cs_any.crt" \
3896 "$P_CLI" \
3897 0
3898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003899run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003900 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003901 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003902 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003903 1
3904
3905# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3906
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003907run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003908 "$O_SRV -key data_files/server5.key \
3909 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003910 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003911 0 \
3912 -C "bad certificate (usage extensions)" \
3913 -C "Processing of the Certificate handshake message failed" \
3914 -c "Ciphersuite is TLS-"
3915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003916run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003917 "$O_SRV -key data_files/server5.key \
3918 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003919 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003920 0 \
3921 -C "bad certificate (usage extensions)" \
3922 -C "Processing of the Certificate handshake message failed" \
3923 -c "Ciphersuite is TLS-"
3924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003925run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003926 "$O_SRV -key data_files/server5.key \
3927 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003928 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003929 0 \
3930 -C "bad certificate (usage extensions)" \
3931 -C "Processing of the Certificate handshake message failed" \
3932 -c "Ciphersuite is TLS-"
3933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003934run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003935 "$O_SRV -key data_files/server5.key \
3936 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003937 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003938 1 \
3939 -c "bad certificate (usage extensions)" \
3940 -c "Processing of the Certificate handshake message failed" \
3941 -C "Ciphersuite is TLS-"
3942
3943# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003945run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003946 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003947 "$O_CLI -key data_files/server5.key \
3948 -cert data_files/server5.eku-cli.crt" \
3949 0 \
3950 -S "bad certificate (usage extensions)" \
3951 -S "Processing of the Certificate handshake message failed"
3952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003953run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003954 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003955 "$O_CLI -key data_files/server5.key \
3956 -cert data_files/server5.eku-srv_cli.crt" \
3957 0 \
3958 -S "bad certificate (usage extensions)" \
3959 -S "Processing of the Certificate handshake message failed"
3960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003961run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003962 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003963 "$O_CLI -key data_files/server5.key \
3964 -cert data_files/server5.eku-cs_any.crt" \
3965 0 \
3966 -S "bad certificate (usage extensions)" \
3967 -S "Processing of the Certificate handshake message failed"
3968
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003969run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003970 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003971 "$O_CLI -key data_files/server5.key \
3972 -cert data_files/server5.eku-cs.crt" \
3973 0 \
3974 -s "bad certificate (usage extensions)" \
3975 -S "Processing of the Certificate handshake message failed"
3976
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003977run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003978 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003979 "$O_CLI -key data_files/server5.key \
3980 -cert data_files/server5.eku-cs.crt" \
3981 1 \
3982 -s "bad certificate (usage extensions)" \
3983 -s "Processing of the Certificate handshake message failed"
3984
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003985# Tests for DHM parameters loading
3986
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003987run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003988 "$P_SRV" \
3989 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3990 debug_level=3" \
3991 0 \
3992 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003993 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003995run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003996 "$P_SRV dhm_file=data_files/dhparams.pem" \
3997 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3998 debug_level=3" \
3999 0 \
4000 -c "value of 'DHM: P ' (1024 bits)" \
4001 -c "value of 'DHM: G ' (2 bits)"
4002
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004003# Tests for DHM client-side size checking
4004
4005run_test "DHM size: server default, client default, OK" \
4006 "$P_SRV" \
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
4012run_test "DHM size: server default, client 2048, OK" \
4013 "$P_SRV" \
4014 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4015 debug_level=1 dhmlen=2048" \
4016 0 \
4017 -C "DHM prime too short:"
4018
4019run_test "DHM size: server 1024, client default, OK" \
4020 "$P_SRV dhm_file=data_files/dhparams.pem" \
4021 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4022 debug_level=1" \
4023 0 \
4024 -C "DHM prime too short:"
4025
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004026run_test "DHM size: server 999, client 999, OK" \
4027 "$P_SRV dhm_file=data_files/dh.999.pem" \
4028 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4029 debug_level=1 dhmlen=999" \
4030 0 \
4031 -C "DHM prime too short:"
4032
4033run_test "DHM size: server 1000, client 1000, OK" \
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=1000" \
4037 0 \
4038 -C "DHM prime too short:"
4039
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004040run_test "DHM size: server 1000, client default, rejected" \
4041 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4042 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4043 debug_level=1" \
4044 1 \
4045 -c "DHM prime too short:"
4046
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004047run_test "DHM size: server 1000, client 1001, rejected" \
4048 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4049 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4050 debug_level=1 dhmlen=1001" \
4051 1 \
4052 -c "DHM prime too short:"
4053
4054run_test "DHM size: server 999, client 1000, rejected" \
4055 "$P_SRV dhm_file=data_files/dh.999.pem" \
4056 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4057 debug_level=1 dhmlen=1000" \
4058 1 \
4059 -c "DHM prime too short:"
4060
4061run_test "DHM size: server 998, client 999, rejected" \
4062 "$P_SRV dhm_file=data_files/dh.998.pem" \
4063 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4064 debug_level=1 dhmlen=999" \
4065 1 \
4066 -c "DHM prime too short:"
4067
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004068run_test "DHM size: server default, client 2049, rejected" \
4069 "$P_SRV" \
4070 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4071 debug_level=1 dhmlen=2049" \
4072 1 \
4073 -c "DHM prime too short:"
4074
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004075# Tests for PSK callback
4076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004077run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004078 "$P_SRV psk=abc123 psk_identity=foo" \
4079 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4080 psk_identity=foo psk=abc123" \
4081 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004082 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004083 -S "SSL - Unknown identity received" \
4084 -S "SSL - Verification of the message MAC failed"
4085
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004086run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004087 "$P_SRV" \
4088 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4089 psk_identity=foo psk=abc123" \
4090 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004091 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004092 -S "SSL - Unknown identity received" \
4093 -S "SSL - Verification of the message MAC failed"
4094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004095run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004096 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4097 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4098 psk_identity=foo psk=abc123" \
4099 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004100 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004101 -s "SSL - Unknown identity received" \
4102 -S "SSL - Verification of the message MAC failed"
4103
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004104run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004105 "$P_SRV psk_list=abc,dead,def,beef" \
4106 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4107 psk_identity=abc psk=dead" \
4108 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004109 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004110 -S "SSL - Unknown identity received" \
4111 -S "SSL - Verification of the message MAC failed"
4112
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004113run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004114 "$P_SRV psk_list=abc,dead,def,beef" \
4115 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4116 psk_identity=def psk=beef" \
4117 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004118 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004119 -S "SSL - Unknown identity received" \
4120 -S "SSL - Verification of the message MAC failed"
4121
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004122run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004123 "$P_SRV psk_list=abc,dead,def,beef" \
4124 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4125 psk_identity=ghi psk=beef" \
4126 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004127 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004128 -s "SSL - Unknown identity received" \
4129 -S "SSL - Verification of the message MAC failed"
4130
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004131run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004132 "$P_SRV psk_list=abc,dead,def,beef" \
4133 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4134 psk_identity=abc psk=beef" \
4135 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004136 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004137 -S "SSL - Unknown identity received" \
4138 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004139
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004140# Tests for EC J-PAKE
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: client not configured" \
4144 "$P_SRV debug_level=3" \
4145 "$P_CLI debug_level=3" \
4146 0 \
4147 -C "add ciphersuite: c0ff" \
4148 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004149 -S "found ecjpake kkpp extension" \
4150 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004151 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004152 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004153 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004154 -S "None of the common ciphersuites is usable"
4155
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004156requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004157run_test "ECJPAKE: server not configured" \
4158 "$P_SRV debug_level=3" \
4159 "$P_CLI debug_level=3 ecjpake_pw=bla \
4160 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4161 1 \
4162 -c "add ciphersuite: c0ff" \
4163 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004164 -s "found ecjpake kkpp extension" \
4165 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004166 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004167 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004168 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004169 -s "None of the common ciphersuites is usable"
4170
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004171requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004172run_test "ECJPAKE: working, TLS" \
4173 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4174 "$P_CLI debug_level=3 ecjpake_pw=bla \
4175 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004176 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004177 -c "add ciphersuite: c0ff" \
4178 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004179 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004180 -s "found ecjpake kkpp extension" \
4181 -S "skip ecjpake kkpp extension" \
4182 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004183 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004184 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004185 -S "None of the common ciphersuites is usable" \
4186 -S "SSL - Verification of the message MAC failed"
4187
Janos Follath74537a62016-09-02 13:45:28 +01004188server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004189requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004190run_test "ECJPAKE: password mismatch, TLS" \
4191 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4192 "$P_CLI debug_level=3 ecjpake_pw=bad \
4193 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4194 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004195 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004196 -s "SSL - Verification of the message MAC failed"
4197
Dave Rodgmancee9e922021-06-29 19:05:34 +01004198requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004199run_test "ECJPAKE: working, DTLS" \
4200 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4201 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4202 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4203 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004204 -c "re-using cached ecjpake parameters" \
4205 -S "SSL - Verification of the message MAC failed"
4206
Dave Rodgmancee9e922021-06-29 19:05:34 +01004207requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004208run_test "ECJPAKE: working, DTLS, no cookie" \
4209 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4210 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4211 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4212 0 \
4213 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004214 -S "SSL - Verification of the message MAC failed"
4215
Janos Follath74537a62016-09-02 13:45:28 +01004216server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004217requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004218run_test "ECJPAKE: password mismatch, DTLS" \
4219 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4220 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4221 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4222 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004223 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004224 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004225
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004226# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004227requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004228run_test "ECJPAKE: working, DTLS, nolog" \
4229 "$P_SRV dtls=1 ecjpake_pw=bla" \
4230 "$P_CLI dtls=1 ecjpake_pw=bla \
4231 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4232 0
4233
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004234# Tests for ciphersuites per version
4235
Janos Follathe2681a42016-03-07 15:57:05 +00004236requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004237requires_config_enabled MBEDTLS_CAMELLIA_C
4238requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004239run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004240 "$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 +02004241 "$P_CLI force_version=ssl3" \
4242 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004243 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004244
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004245requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4246requires_config_enabled MBEDTLS_CAMELLIA_C
4247requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004248run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004249 "$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 +01004250 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004251 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004252 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004253
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004254requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4255requires_config_enabled MBEDTLS_CAMELLIA_C
4256requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004257run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004258 "$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 +02004259 "$P_CLI force_version=tls1_1" \
4260 0 \
4261 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4262
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004263requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4264requires_config_enabled MBEDTLS_CAMELLIA_C
4265requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004266run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004267 "$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 +02004268 "$P_CLI force_version=tls1_2" \
4269 0 \
4270 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4271
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004272# Test for ClientHello without extensions
4273
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004274requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004275run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004276 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004277 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004278 0 \
4279 -s "dumping 'client hello extensions' (0 bytes)"
4280
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004281# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004282
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004283run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004284 "$P_SRV" \
4285 "$P_CLI request_size=100" \
4286 0 \
4287 -s "Read from client: 100 bytes read$"
4288
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004289run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004290 "$P_SRV" \
4291 "$P_CLI request_size=500" \
4292 0 \
4293 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004294
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004295# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004296
Janos Follathe2681a42016-03-07 15:57:05 +00004297requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004298run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004299 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004300 "$P_CLI request_size=1 force_version=ssl3 \
4301 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4302 0 \
4303 -s "Read from client: 1 bytes read"
4304
Janos Follathe2681a42016-03-07 15:57:05 +00004305requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004306run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004307 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004308 "$P_CLI request_size=1 force_version=ssl3 \
4309 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4310 0 \
4311 -s "Read from client: 1 bytes read"
4312
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004313run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004314 "$P_SRV" \
4315 "$P_CLI request_size=1 force_version=tls1 \
4316 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4317 0 \
4318 -s "Read from client: 1 bytes read"
4319
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004320run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004321 "$P_SRV" \
4322 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4323 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4324 0 \
4325 -s "Read from client: 1 bytes read"
4326
Hanno Becker32c55012017-11-10 08:42:54 +00004327requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004328run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004329 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004330 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004331 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004332 0 \
4333 -s "Read from client: 1 bytes read"
4334
Hanno Becker32c55012017-11-10 08:42:54 +00004335requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004336run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004337 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004338 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004339 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004340 0 \
4341 -s "Read from client: 1 bytes read"
4342
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004343run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004344 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004345 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004346 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4347 0 \
4348 -s "Read from client: 1 bytes read"
4349
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004350run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004351 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4352 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004353 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004354 0 \
4355 -s "Read from client: 1 bytes read"
4356
4357requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004358run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004359 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004360 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004361 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004362 0 \
4363 -s "Read from client: 1 bytes read"
4364
Hanno Becker8501f982017-11-10 08:59:04 +00004365requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004366run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004367 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4368 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4369 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004370 0 \
4371 -s "Read from client: 1 bytes read"
4372
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004373run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004374 "$P_SRV" \
4375 "$P_CLI request_size=1 force_version=tls1_1 \
4376 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4377 0 \
4378 -s "Read from client: 1 bytes read"
4379
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004380run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004381 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004382 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004383 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004384 0 \
4385 -s "Read from client: 1 bytes read"
4386
4387requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004388run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004389 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004390 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004391 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004392 0 \
4393 -s "Read from client: 1 bytes read"
4394
4395requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004396run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004397 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004398 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004400 0 \
4401 -s "Read from client: 1 bytes read"
4402
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004403run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004404 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004405 "$P_CLI request_size=1 force_version=tls1_1 \
4406 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4407 0 \
4408 -s "Read from client: 1 bytes read"
4409
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004410run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004411 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004412 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004413 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004414 0 \
4415 -s "Read from client: 1 bytes read"
4416
Hanno Becker8501f982017-11-10 08:59:04 +00004417requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004418run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004419 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004420 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004421 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004422 0 \
4423 -s "Read from client: 1 bytes read"
4424
Hanno Becker32c55012017-11-10 08:42:54 +00004425requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004426run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004427 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004428 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004429 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004430 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" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004434 "$P_SRV" \
4435 "$P_CLI request_size=1 force_version=tls1_2 \
4436 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4437 0 \
4438 -s "Read from client: 1 bytes read"
4439
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004440run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004441 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004442 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004443 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004444 0 \
4445 -s "Read from client: 1 bytes read"
4446
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004447run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004448 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004449 "$P_CLI request_size=1 force_version=tls1_2 \
4450 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004451 0 \
4452 -s "Read from client: 1 bytes read"
4453
Hanno Becker32c55012017-11-10 08:42:54 +00004454requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004455run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004456 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004457 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004458 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004459 0 \
4460 -s "Read from client: 1 bytes read"
4461
Hanno Becker8501f982017-11-10 08:59:04 +00004462requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004463run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004464 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004465 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004466 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004467 0 \
4468 -s "Read from client: 1 bytes read"
4469
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004470run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004471 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004472 "$P_CLI request_size=1 force_version=tls1_2 \
4473 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4474 0 \
4475 -s "Read from client: 1 bytes read"
4476
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004477run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004478 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004479 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004480 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004481 0 \
4482 -s "Read from client: 1 bytes read"
4483
Hanno Becker32c55012017-11-10 08:42:54 +00004484requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004485run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004486 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004487 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004488 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004489 0 \
4490 -s "Read from client: 1 bytes read"
4491
Hanno Becker8501f982017-11-10 08:59:04 +00004492requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004493run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004494 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004495 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004496 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004497 0 \
4498 -s "Read from client: 1 bytes read"
4499
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004500run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004501 "$P_SRV" \
4502 "$P_CLI request_size=1 force_version=tls1_2 \
4503 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4504 0 \
4505 -s "Read from client: 1 bytes read"
4506
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004507run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004508 "$P_SRV" \
4509 "$P_CLI request_size=1 force_version=tls1_2 \
4510 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4511 0 \
4512 -s "Read from client: 1 bytes read"
4513
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004514# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004515
4516requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004517run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004518 "$P_SRV dtls=1 force_version=dtls1" \
4519 "$P_CLI dtls=1 request_size=1 \
4520 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4521 0 \
4522 -s "Read from client: 1 bytes read"
4523
4524requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004525run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004526 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4527 "$P_CLI dtls=1 request_size=1 \
4528 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4529 0 \
4530 -s "Read from client: 1 bytes read"
4531
4532requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4533requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004534run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004535 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4536 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004537 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4538 0 \
4539 -s "Read from client: 1 bytes read"
4540
4541requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4542requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004543run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004544 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004545 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004546 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004547 0 \
4548 -s "Read from client: 1 bytes read"
4549
4550requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004551run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004552 "$P_SRV dtls=1 force_version=dtls1_2" \
4553 "$P_CLI dtls=1 request_size=1 \
4554 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4555 0 \
4556 -s "Read from client: 1 bytes read"
4557
4558requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004559run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004560 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004561 "$P_CLI dtls=1 request_size=1 \
4562 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4563 0 \
4564 -s "Read from client: 1 bytes read"
4565
4566requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4567requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004568run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004569 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004570 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004571 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004572 0 \
4573 -s "Read from client: 1 bytes read"
4574
4575requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4576requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004577run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004578 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004579 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004581 0 \
4582 -s "Read from client: 1 bytes read"
4583
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004584# Tests for small server packets
4585
4586requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4587run_test "Small server packet SSLv3 BlockCipher" \
4588 "$P_SRV response_size=1 min_version=ssl3" \
4589 "$P_CLI force_version=ssl3 \
4590 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4591 0 \
4592 -c "Read from server: 1 bytes read"
4593
4594requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4595run_test "Small server packet SSLv3 StreamCipher" \
4596 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4597 "$P_CLI force_version=ssl3 \
4598 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4599 0 \
4600 -c "Read from server: 1 bytes read"
4601
4602run_test "Small server packet TLS 1.0 BlockCipher" \
4603 "$P_SRV response_size=1" \
4604 "$P_CLI force_version=tls1 \
4605 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4606 0 \
4607 -c "Read from server: 1 bytes read"
4608
4609run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4610 "$P_SRV response_size=1" \
4611 "$P_CLI force_version=tls1 etm=0 \
4612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4613 0 \
4614 -c "Read from server: 1 bytes read"
4615
4616requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4617run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4618 "$P_SRV response_size=1 trunc_hmac=1" \
4619 "$P_CLI force_version=tls1 \
4620 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4621 0 \
4622 -c "Read from server: 1 bytes read"
4623
4624requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4625run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4626 "$P_SRV response_size=1 trunc_hmac=1" \
4627 "$P_CLI force_version=tls1 \
4628 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4629 0 \
4630 -c "Read from server: 1 bytes read"
4631
4632run_test "Small server packet TLS 1.0 StreamCipher" \
4633 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4634 "$P_CLI force_version=tls1 \
4635 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4636 0 \
4637 -c "Read from server: 1 bytes read"
4638
4639run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4640 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4641 "$P_CLI force_version=tls1 \
4642 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4643 0 \
4644 -c "Read from server: 1 bytes read"
4645
4646requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4647run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4648 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4649 "$P_CLI force_version=tls1 \
4650 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4651 0 \
4652 -c "Read from server: 1 bytes read"
4653
4654requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4655run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4656 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4657 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4658 trunc_hmac=1 etm=0" \
4659 0 \
4660 -c "Read from server: 1 bytes read"
4661
4662run_test "Small server packet TLS 1.1 BlockCipher" \
4663 "$P_SRV response_size=1" \
4664 "$P_CLI force_version=tls1_1 \
4665 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4666 0 \
4667 -c "Read from server: 1 bytes read"
4668
4669run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4670 "$P_SRV response_size=1" \
4671 "$P_CLI force_version=tls1_1 \
4672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4673 0 \
4674 -c "Read from server: 1 bytes read"
4675
4676requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4677run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4678 "$P_SRV response_size=1 trunc_hmac=1" \
4679 "$P_CLI force_version=tls1_1 \
4680 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4681 0 \
4682 -c "Read from server: 1 bytes read"
4683
4684requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4685run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4686 "$P_SRV response_size=1 trunc_hmac=1" \
4687 "$P_CLI force_version=tls1_1 \
4688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4689 0 \
4690 -c "Read from server: 1 bytes read"
4691
4692run_test "Small server packet TLS 1.1 StreamCipher" \
4693 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4694 "$P_CLI force_version=tls1_1 \
4695 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4696 0 \
4697 -c "Read from server: 1 bytes read"
4698
4699run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4700 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4701 "$P_CLI force_version=tls1_1 \
4702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4703 0 \
4704 -c "Read from server: 1 bytes read"
4705
4706requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4707run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4708 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4709 "$P_CLI force_version=tls1_1 \
4710 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4711 0 \
4712 -c "Read from server: 1 bytes read"
4713
4714requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4715run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4716 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4717 "$P_CLI force_version=tls1_1 \
4718 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4719 0 \
4720 -c "Read from server: 1 bytes read"
4721
4722run_test "Small server packet TLS 1.2 BlockCipher" \
4723 "$P_SRV response_size=1" \
4724 "$P_CLI force_version=tls1_2 \
4725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4726 0 \
4727 -c "Read from server: 1 bytes read"
4728
4729run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4730 "$P_SRV response_size=1" \
4731 "$P_CLI force_version=tls1_2 \
4732 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4733 0 \
4734 -c "Read from server: 1 bytes read"
4735
4736run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4737 "$P_SRV response_size=1" \
4738 "$P_CLI force_version=tls1_2 \
4739 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4740 0 \
4741 -c "Read from server: 1 bytes read"
4742
4743requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4744run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4745 "$P_SRV response_size=1 trunc_hmac=1" \
4746 "$P_CLI force_version=tls1_2 \
4747 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4748 0 \
4749 -c "Read from server: 1 bytes read"
4750
4751requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4752run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4753 "$P_SRV response_size=1 trunc_hmac=1" \
4754 "$P_CLI force_version=tls1_2 \
4755 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4756 0 \
4757 -c "Read from server: 1 bytes read"
4758
4759run_test "Small server packet TLS 1.2 StreamCipher" \
4760 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4761 "$P_CLI force_version=tls1_2 \
4762 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4763 0 \
4764 -c "Read from server: 1 bytes read"
4765
4766run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4767 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4768 "$P_CLI force_version=tls1_2 \
4769 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4770 0 \
4771 -c "Read from server: 1 bytes read"
4772
4773requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4774run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4775 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4776 "$P_CLI force_version=tls1_2 \
4777 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4778 0 \
4779 -c "Read from server: 1 bytes read"
4780
4781requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4782run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4783 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4784 "$P_CLI force_version=tls1_2 \
4785 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4786 0 \
4787 -c "Read from server: 1 bytes read"
4788
4789run_test "Small server packet TLS 1.2 AEAD" \
4790 "$P_SRV response_size=1" \
4791 "$P_CLI force_version=tls1_2 \
4792 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4793 0 \
4794 -c "Read from server: 1 bytes read"
4795
4796run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4797 "$P_SRV response_size=1" \
4798 "$P_CLI force_version=tls1_2 \
4799 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4800 0 \
4801 -c "Read from server: 1 bytes read"
4802
4803# Tests for small server packets in DTLS
4804
4805requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4806run_test "Small server packet DTLS 1.0" \
4807 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4808 "$P_CLI dtls=1 \
4809 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4810 0 \
4811 -c "Read from server: 1 bytes read"
4812
4813requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4814run_test "Small server packet DTLS 1.0, without EtM" \
4815 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4816 "$P_CLI dtls=1 \
4817 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4818 0 \
4819 -c "Read from server: 1 bytes read"
4820
4821requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4822requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4823run_test "Small server packet DTLS 1.0, truncated hmac" \
4824 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4825 "$P_CLI dtls=1 trunc_hmac=1 \
4826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4827 0 \
4828 -c "Read from server: 1 bytes read"
4829
4830requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4831requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4832run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4833 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4834 "$P_CLI dtls=1 \
4835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4836 0 \
4837 -c "Read from server: 1 bytes read"
4838
4839requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4840run_test "Small server packet DTLS 1.2" \
4841 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4842 "$P_CLI dtls=1 \
4843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4844 0 \
4845 -c "Read from server: 1 bytes read"
4846
4847requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4848run_test "Small server packet DTLS 1.2, without EtM" \
4849 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4850 "$P_CLI dtls=1 \
4851 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4852 0 \
4853 -c "Read from server: 1 bytes read"
4854
4855requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4857run_test "Small server packet DTLS 1.2, truncated hmac" \
4858 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4859 "$P_CLI dtls=1 \
4860 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4861 0 \
4862 -c "Read from server: 1 bytes read"
4863
4864requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4865requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4866run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4867 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4868 "$P_CLI dtls=1 \
4869 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4870 0 \
4871 -c "Read from server: 1 bytes read"
4872
Janos Follath00efff72016-05-06 13:48:23 +01004873# A test for extensions in SSLv3
Yuto Takanoc75df632021-07-08 15:56:33 +01004874requires_max_content_len 4096
Janos Follath00efff72016-05-06 13:48:23 +01004875requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4876run_test "SSLv3 with extensions, server side" \
4877 "$P_SRV min_version=ssl3 debug_level=3" \
4878 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4879 0 \
4880 -S "dumping 'client hello extensions'" \
4881 -S "server hello, total extension length:"
4882
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004883# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004884
Angus Grattonc4dd0732018-04-11 16:28:39 +10004885# How many fragments do we expect to write $1 bytes?
4886fragments_for_write() {
4887 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4888}
4889
Janos Follathe2681a42016-03-07 15:57:05 +00004890requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004891run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004892 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004893 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004894 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4895 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004896 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4897 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004898
Janos Follathe2681a42016-03-07 15:57:05 +00004899requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004900run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004901 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004902 "$P_CLI request_size=16384 force_version=ssl3 \
4903 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4904 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004905 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4906 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004907
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004908run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004909 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004910 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4912 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004913 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4914 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004915
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004916run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004917 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004918 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4919 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4920 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004921 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004922
Hanno Becker32c55012017-11-10 08:42:54 +00004923requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004924run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004925 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004926 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004927 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004928 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004929 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4930 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004931
Hanno Becker32c55012017-11-10 08:42:54 +00004932requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004933run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004934 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004935 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004936 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
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
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004940run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004942 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004943 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4944 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004945 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004946
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004947run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004948 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4949 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004950 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004951 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004952 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004953
4954requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004955run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004956 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004957 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004958 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004959 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004960 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004961
Hanno Becker278fc7a2017-11-10 09:16:28 +00004962requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004963run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004964 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004965 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004966 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004967 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004968 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4969 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004970
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004971run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004972 "$P_SRV" \
4973 "$P_CLI request_size=16384 force_version=tls1_1 \
4974 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4975 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004976 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4977 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004978
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004979run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004980 "$P_SRV" \
4981 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004983 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004984 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004985
Hanno Becker32c55012017-11-10 08:42:54 +00004986requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004987run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004988 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004989 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004990 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004991 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004992 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004993
Hanno Becker32c55012017-11-10 08:42:54 +00004994requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004995run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004996 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004997 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004998 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004999 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005000 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005001
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005002run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005003 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5004 "$P_CLI request_size=16384 force_version=tls1_1 \
5005 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5006 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005007 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5008 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005009
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005010run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005011 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005012 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005013 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005014 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005015 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5016 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005017
Hanno Becker278fc7a2017-11-10 09:16:28 +00005018requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005019run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005020 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005021 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005022 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005023 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005024 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005025
Hanno Becker278fc7a2017-11-10 09:16:28 +00005026requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005027run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005028 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005029 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005030 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005031 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005032 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5033 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005034
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005035run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005036 "$P_SRV" \
5037 "$P_CLI request_size=16384 force_version=tls1_2 \
5038 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5039 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005040 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5041 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005042
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005043run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005044 "$P_SRV" \
5045 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
5046 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5047 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005048 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005049
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005050run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005051 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005052 "$P_CLI request_size=16384 force_version=tls1_2 \
5053 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005054 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005055 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5056 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005057
Hanno Becker32c55012017-11-10 08:42:54 +00005058requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005059run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005060 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005061 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005062 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005063 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005064 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005065
Hanno Becker278fc7a2017-11-10 09:16:28 +00005066requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005067run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005068 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005069 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005070 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005071 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005072 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5073 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005074
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005075run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005076 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005077 "$P_CLI request_size=16384 force_version=tls1_2 \
5078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5079 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005080 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5081 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005082
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005083run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005084 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005085 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005086 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5087 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005088 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005089
Hanno Becker32c55012017-11-10 08:42:54 +00005090requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005091run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005092 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005093 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005094 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005095 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005096 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005097
Hanno Becker278fc7a2017-11-10 09:16:28 +00005098requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005099run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005100 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005101 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005102 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005103 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005104 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5105 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005106
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005107run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005108 "$P_SRV" \
5109 "$P_CLI request_size=16384 force_version=tls1_2 \
5110 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5111 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005112 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5113 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005114
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005115run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005116 "$P_SRV" \
5117 "$P_CLI request_size=16384 force_version=tls1_2 \
5118 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5119 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005120 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5121 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005122
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005123# Test for large server packets
Yuto Takanoc75df632021-07-08 15:56:33 +01005124# The tests below fail when the server's OUT_CONTENT_LEN is less than 16384.
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005125requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5126run_test "Large server packet SSLv3 StreamCipher" \
5127 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5128 "$P_CLI force_version=ssl3 \
5129 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5130 0 \
5131 -c "Read from server: 16384 bytes read"
5132
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005133# Checking next 4 tests logs for 1n-1 split against BEAST too
5134requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5135run_test "Large server packet SSLv3 BlockCipher" \
5136 "$P_SRV response_size=16384 min_version=ssl3" \
5137 "$P_CLI force_version=ssl3 recsplit=0 \
5138 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5139 0 \
5140 -c "Read from server: 1 bytes read"\
5141 -c "16383 bytes read"\
5142 -C "Read from server: 16384 bytes read"
5143
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005144run_test "Large server packet TLS 1.0 BlockCipher" \
5145 "$P_SRV response_size=16384" \
5146 "$P_CLI force_version=tls1 recsplit=0 \
5147 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5148 0 \
5149 -c "Read from server: 1 bytes read"\
5150 -c "16383 bytes read"\
5151 -C "Read from server: 16384 bytes read"
5152
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005153run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5154 "$P_SRV response_size=16384" \
5155 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5156 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5157 0 \
5158 -c "Read from server: 1 bytes read"\
5159 -c "16383 bytes read"\
5160 -C "Read from server: 16384 bytes read"
5161
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005162requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5163run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5164 "$P_SRV response_size=16384" \
5165 "$P_CLI force_version=tls1 recsplit=0 \
5166 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5167 trunc_hmac=1" \
5168 0 \
5169 -c "Read from server: 1 bytes read"\
5170 -c "16383 bytes read"\
5171 -C "Read from server: 16384 bytes read"
5172
5173requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5174run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5175 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5176 "$P_CLI force_version=tls1 \
5177 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5178 trunc_hmac=1" \
5179 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005180 -s "16384 bytes written in 1 fragments" \
5181 -c "Read from server: 16384 bytes read"
5182
5183run_test "Large server packet TLS 1.0 StreamCipher" \
5184 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5185 "$P_CLI force_version=tls1 \
5186 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5187 0 \
5188 -s "16384 bytes written in 1 fragments" \
5189 -c "Read from server: 16384 bytes read"
5190
5191run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5192 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5193 "$P_CLI force_version=tls1 \
5194 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5195 0 \
5196 -s "16384 bytes written in 1 fragments" \
5197 -c "Read from server: 16384 bytes read"
5198
5199requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5200run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5201 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5202 "$P_CLI force_version=tls1 \
5203 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5204 0 \
5205 -s "16384 bytes written in 1 fragments" \
5206 -c "Read from server: 16384 bytes read"
5207
5208requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5209run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5210 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5211 "$P_CLI force_version=tls1 \
5212 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5213 0 \
5214 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005215 -c "Read from server: 16384 bytes read"
5216
5217run_test "Large server packet TLS 1.1 BlockCipher" \
5218 "$P_SRV response_size=16384" \
5219 "$P_CLI force_version=tls1_1 \
5220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5221 0 \
5222 -c "Read from server: 16384 bytes read"
5223
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005224run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5225 "$P_SRV response_size=16384" \
5226 "$P_CLI force_version=tls1_1 etm=0 \
5227 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005228 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005229 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005230 -c "Read from server: 16384 bytes read"
5231
5232requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5233run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5234 "$P_SRV response_size=16384" \
5235 "$P_CLI force_version=tls1_1 \
5236 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5237 trunc_hmac=1" \
5238 0 \
5239 -c "Read from server: 16384 bytes read"
5240
5241requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005242run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5243 "$P_SRV response_size=16384 trunc_hmac=1" \
5244 "$P_CLI force_version=tls1_1 \
5245 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5246 0 \
5247 -s "16384 bytes written in 1 fragments" \
5248 -c "Read from server: 16384 bytes read"
5249
5250run_test "Large server packet TLS 1.1 StreamCipher" \
5251 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5252 "$P_CLI force_version=tls1_1 \
5253 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5254 0 \
5255 -c "Read from server: 16384 bytes read"
5256
5257run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5258 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5259 "$P_CLI force_version=tls1_1 \
5260 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5261 0 \
5262 -s "16384 bytes written in 1 fragments" \
5263 -c "Read from server: 16384 bytes read"
5264
5265requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005266run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5267 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5268 "$P_CLI force_version=tls1_1 \
5269 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5270 trunc_hmac=1" \
5271 0 \
5272 -c "Read from server: 16384 bytes read"
5273
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005274run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5275 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5276 "$P_CLI force_version=tls1_1 \
5277 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5278 0 \
5279 -s "16384 bytes written in 1 fragments" \
5280 -c "Read from server: 16384 bytes read"
5281
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005282run_test "Large server packet TLS 1.2 BlockCipher" \
5283 "$P_SRV response_size=16384" \
5284 "$P_CLI force_version=tls1_2 \
5285 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5286 0 \
5287 -c "Read from server: 16384 bytes read"
5288
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005289run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5290 "$P_SRV response_size=16384" \
5291 "$P_CLI force_version=tls1_2 etm=0 \
5292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5293 0 \
5294 -s "16384 bytes written in 1 fragments" \
5295 -c "Read from server: 16384 bytes read"
5296
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005297run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5298 "$P_SRV response_size=16384" \
5299 "$P_CLI force_version=tls1_2 \
5300 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5301 0 \
5302 -c "Read from server: 16384 bytes read"
5303
5304requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5305run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5306 "$P_SRV response_size=16384" \
5307 "$P_CLI force_version=tls1_2 \
5308 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5309 trunc_hmac=1" \
5310 0 \
5311 -c "Read from server: 16384 bytes read"
5312
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005313run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5314 "$P_SRV response_size=16384 trunc_hmac=1" \
5315 "$P_CLI force_version=tls1_2 \
5316 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5317 0 \
5318 -s "16384 bytes written in 1 fragments" \
5319 -c "Read from server: 16384 bytes read"
5320
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005321run_test "Large server packet TLS 1.2 StreamCipher" \
5322 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5323 "$P_CLI force_version=tls1_2 \
5324 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5325 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005326 -s "16384 bytes written in 1 fragments" \
5327 -c "Read from server: 16384 bytes read"
5328
5329run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5330 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5331 "$P_CLI force_version=tls1_2 \
5332 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5333 0 \
5334 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005335 -c "Read from server: 16384 bytes read"
5336
5337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5338run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5339 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5340 "$P_CLI force_version=tls1_2 \
5341 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5342 trunc_hmac=1" \
5343 0 \
5344 -c "Read from server: 16384 bytes read"
5345
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005346requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5347run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5348 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5349 "$P_CLI force_version=tls1_2 \
5350 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5351 0 \
5352 -s "16384 bytes written in 1 fragments" \
5353 -c "Read from server: 16384 bytes read"
5354
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005355run_test "Large server packet TLS 1.2 AEAD" \
5356 "$P_SRV response_size=16384" \
5357 "$P_CLI force_version=tls1_2 \
5358 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5359 0 \
5360 -c "Read from server: 16384 bytes read"
5361
5362run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5363 "$P_SRV response_size=16384" \
5364 "$P_CLI force_version=tls1_2 \
5365 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5366 0 \
5367 -c "Read from server: 16384 bytes read"
5368
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005369# Tests for restartable ECC
5370
5371requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5372run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005373 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005374 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005375 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005376 debug_level=1" \
5377 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005378 -C "x509_verify_cert.*4b00" \
5379 -C "mbedtls_pk_verify.*4b00" \
5380 -C "mbedtls_ecdh_make_public.*4b00" \
5381 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005382
5383requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5384run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005385 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005386 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005387 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005388 debug_level=1 ec_max_ops=0" \
5389 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005390 -C "x509_verify_cert.*4b00" \
5391 -C "mbedtls_pk_verify.*4b00" \
5392 -C "mbedtls_ecdh_make_public.*4b00" \
5393 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005394
5395requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5396run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005397 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005398 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005399 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005400 debug_level=1 ec_max_ops=65535" \
5401 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005402 -C "x509_verify_cert.*4b00" \
5403 -C "mbedtls_pk_verify.*4b00" \
5404 -C "mbedtls_ecdh_make_public.*4b00" \
5405 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005406
5407requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5408run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005409 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005410 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005411 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005412 debug_level=1 ec_max_ops=1000" \
5413 0 \
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é-Gonnard2350b4e2017-05-16 09:26:48 +02005418
5419requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005420run_test "EC restart: TLS, max_ops=1000, badsign" \
5421 "$P_SRV auth_mode=required \
5422 crt_file=data_files/server5-badsign.crt \
5423 key_file=data_files/server5.key" \
5424 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5425 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5426 debug_level=1 ec_max_ops=1000" \
5427 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005428 -c "x509_verify_cert.*4b00" \
5429 -C "mbedtls_pk_verify.*4b00" \
5430 -C "mbedtls_ecdh_make_public.*4b00" \
5431 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005432 -c "! The certificate is not correctly signed by the trusted CA" \
5433 -c "! mbedtls_ssl_handshake returned" \
5434 -c "X509 - Certificate verification failed"
5435
5436requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5437run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5438 "$P_SRV auth_mode=required \
5439 crt_file=data_files/server5-badsign.crt \
5440 key_file=data_files/server5.key" \
5441 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5442 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5443 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5444 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005445 -c "x509_verify_cert.*4b00" \
5446 -c "mbedtls_pk_verify.*4b00" \
5447 -c "mbedtls_ecdh_make_public.*4b00" \
5448 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005449 -c "! The certificate is not correctly signed by the trusted CA" \
5450 -C "! mbedtls_ssl_handshake returned" \
5451 -C "X509 - Certificate verification failed"
5452
5453requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5454run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5455 "$P_SRV auth_mode=required \
5456 crt_file=data_files/server5-badsign.crt \
5457 key_file=data_files/server5.key" \
5458 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5459 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5460 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5461 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005462 -C "x509_verify_cert.*4b00" \
5463 -c "mbedtls_pk_verify.*4b00" \
5464 -c "mbedtls_ecdh_make_public.*4b00" \
5465 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005466 -C "! The certificate is not correctly signed by the trusted CA" \
5467 -C "! mbedtls_ssl_handshake returned" \
5468 -C "X509 - Certificate verification failed"
5469
5470requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005471run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005472 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005473 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005474 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005475 dtls=1 debug_level=1 ec_max_ops=1000" \
5476 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005477 -c "x509_verify_cert.*4b00" \
5478 -c "mbedtls_pk_verify.*4b00" \
5479 -c "mbedtls_ecdh_make_public.*4b00" \
5480 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005481
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005482requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5483run_test "EC restart: TLS, max_ops=1000 no client auth" \
5484 "$P_SRV" \
5485 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5486 debug_level=1 ec_max_ops=1000" \
5487 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005488 -c "x509_verify_cert.*4b00" \
5489 -c "mbedtls_pk_verify.*4b00" \
5490 -c "mbedtls_ecdh_make_public.*4b00" \
5491 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005492
5493requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5494run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5495 "$P_SRV psk=abc123" \
5496 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5497 psk=abc123 debug_level=1 ec_max_ops=1000" \
5498 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005499 -C "x509_verify_cert.*4b00" \
5500 -C "mbedtls_pk_verify.*4b00" \
5501 -C "mbedtls_ecdh_make_public.*4b00" \
5502 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005503
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005504# Tests of asynchronous private key support in SSL
5505
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005506requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005507run_test "SSL async private: sign, delay=0" \
5508 "$P_SRV \
5509 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005510 "$P_CLI" \
5511 0 \
5512 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005513 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005514
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005515requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005516run_test "SSL async private: sign, delay=1" \
5517 "$P_SRV \
5518 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005519 "$P_CLI" \
5520 0 \
5521 -s "Async sign callback: using key slot " \
5522 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005523 -s "Async resume (slot [0-9]): sign done, status=0"
5524
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005525requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5526run_test "SSL async private: sign, delay=2" \
5527 "$P_SRV \
5528 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5529 "$P_CLI" \
5530 0 \
5531 -s "Async sign callback: using key slot " \
5532 -U "Async sign callback: using key slot " \
5533 -s "Async resume (slot [0-9]): call 1 more times." \
5534 -s "Async resume (slot [0-9]): call 0 more times." \
5535 -s "Async resume (slot [0-9]): sign done, status=0"
5536
Gilles Peskined3268832018-04-26 06:23:59 +02005537# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5538# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5539requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5540requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5541run_test "SSL async private: sign, RSA, TLS 1.1" \
5542 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5543 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5544 "$P_CLI force_version=tls1_1" \
5545 0 \
5546 -s "Async sign callback: using key slot " \
5547 -s "Async resume (slot [0-9]): sign done, status=0"
5548
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005549requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005550run_test "SSL async private: sign, SNI" \
5551 "$P_SRV debug_level=3 \
5552 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5553 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5554 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5555 "$P_CLI server_name=polarssl.example" \
5556 0 \
5557 -s "Async sign callback: using key slot " \
5558 -s "Async resume (slot [0-9]): sign done, status=0" \
5559 -s "parse ServerName extension" \
5560 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5561 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5562
5563requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005564run_test "SSL async private: decrypt, delay=0" \
5565 "$P_SRV \
5566 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5567 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5568 0 \
5569 -s "Async decrypt callback: using key slot " \
5570 -s "Async resume (slot [0-9]): decrypt done, status=0"
5571
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005572requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005573run_test "SSL async private: decrypt, delay=1" \
5574 "$P_SRV \
5575 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5576 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5577 0 \
5578 -s "Async decrypt callback: using key slot " \
5579 -s "Async resume (slot [0-9]): call 0 more times." \
5580 -s "Async resume (slot [0-9]): decrypt done, status=0"
5581
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005582requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005583run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5584 "$P_SRV psk=abc123 \
5585 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5586 "$P_CLI psk=abc123 \
5587 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5588 0 \
5589 -s "Async decrypt callback: using key slot " \
5590 -s "Async resume (slot [0-9]): decrypt done, status=0"
5591
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005592requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005593run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5594 "$P_SRV psk=abc123 \
5595 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5596 "$P_CLI psk=abc123 \
5597 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5598 0 \
5599 -s "Async decrypt callback: using key slot " \
5600 -s "Async resume (slot [0-9]): call 0 more times." \
5601 -s "Async resume (slot [0-9]): decrypt done, status=0"
5602
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005603requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005604run_test "SSL async private: sign callback not present" \
5605 "$P_SRV \
5606 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5607 "$P_CLI; [ \$? -eq 1 ] &&
5608 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5609 0 \
5610 -S "Async sign callback" \
5611 -s "! mbedtls_ssl_handshake returned" \
5612 -s "The own private key or pre-shared key is not set, but needed" \
5613 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5614 -s "Successful connection"
5615
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005616requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005617run_test "SSL async private: decrypt callback not present" \
5618 "$P_SRV debug_level=1 \
5619 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5620 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5621 [ \$? -eq 1 ] && $P_CLI" \
5622 0 \
5623 -S "Async decrypt callback" \
5624 -s "! mbedtls_ssl_handshake returned" \
5625 -s "got no RSA private key" \
5626 -s "Async resume (slot [0-9]): sign done, status=0" \
5627 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005628
5629# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005630requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005631run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005632 "$P_SRV \
5633 async_operations=s async_private_delay1=1 \
5634 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5635 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005636 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5637 0 \
5638 -s "Async sign callback: using key slot 0," \
5639 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005640 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005641
5642# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005643requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005644run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005645 "$P_SRV \
5646 async_operations=s async_private_delay2=1 \
5647 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5648 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005649 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5650 0 \
5651 -s "Async sign callback: using key slot 0," \
5652 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005653 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005654
5655# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005656requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005657run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005658 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005659 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005660 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5661 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005662 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5663 0 \
5664 -s "Async sign callback: using key slot 1," \
5665 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005666 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005667
5668# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005669requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005670run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005671 "$P_SRV \
5672 async_operations=s async_private_delay1=1 \
5673 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5674 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005675 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5676 0 \
5677 -s "Async sign callback: no key matches this certificate."
5678
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005679requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005680run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005681 "$P_SRV \
5682 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5683 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005684 "$P_CLI" \
5685 1 \
5686 -s "Async sign callback: injected error" \
5687 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005688 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005689 -s "! mbedtls_ssl_handshake returned"
5690
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005691requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005692run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005693 "$P_SRV \
5694 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5695 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005696 "$P_CLI" \
5697 1 \
5698 -s "Async sign callback: using key slot " \
5699 -S "Async resume" \
5700 -s "Async cancel"
5701
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005702requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005703run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005704 "$P_SRV \
5705 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5706 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005707 "$P_CLI" \
5708 1 \
5709 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005710 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005711 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005712 -s "! mbedtls_ssl_handshake returned"
5713
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005714requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005715run_test "SSL async private: decrypt, error in start" \
5716 "$P_SRV \
5717 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5718 async_private_error=1" \
5719 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5720 1 \
5721 -s "Async decrypt callback: injected error" \
5722 -S "Async resume" \
5723 -S "Async cancel" \
5724 -s "! mbedtls_ssl_handshake returned"
5725
5726requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5727run_test "SSL async private: decrypt, cancel after start" \
5728 "$P_SRV \
5729 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5730 async_private_error=2" \
5731 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5732 1 \
5733 -s "Async decrypt callback: using key slot " \
5734 -S "Async resume" \
5735 -s "Async cancel"
5736
5737requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5738run_test "SSL async private: decrypt, error in resume" \
5739 "$P_SRV \
5740 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5741 async_private_error=3" \
5742 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5743 1 \
5744 -s "Async decrypt callback: using key slot " \
5745 -s "Async resume callback: decrypt done but injected error" \
5746 -S "Async cancel" \
5747 -s "! mbedtls_ssl_handshake returned"
5748
5749requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005750run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005751 "$P_SRV \
5752 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5753 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005754 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5755 0 \
5756 -s "Async cancel" \
5757 -s "! mbedtls_ssl_handshake returned" \
5758 -s "Async resume" \
5759 -s "Successful connection"
5760
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005761requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005762run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005763 "$P_SRV \
5764 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5765 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005766 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5767 0 \
5768 -s "! mbedtls_ssl_handshake returned" \
5769 -s "Async resume" \
5770 -s "Successful connection"
5771
5772# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005773requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005774run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005775 "$P_SRV \
5776 async_operations=s async_private_delay1=1 async_private_error=-2 \
5777 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5778 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005779 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5780 [ \$? -eq 1 ] &&
5781 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5782 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005783 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005784 -S "Async resume" \
5785 -s "Async cancel" \
5786 -s "! mbedtls_ssl_handshake returned" \
5787 -s "Async sign callback: no key matches this certificate." \
5788 -s "Successful connection"
5789
5790# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005791requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005792run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005793 "$P_SRV \
5794 async_operations=s async_private_delay1=1 async_private_error=-3 \
5795 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5796 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005797 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5798 [ \$? -eq 1 ] &&
5799 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5800 0 \
5801 -s "Async resume" \
5802 -s "! mbedtls_ssl_handshake returned" \
5803 -s "Async sign callback: no key matches this certificate." \
5804 -s "Successful connection"
5805
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005806requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005807requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005808run_test "SSL async private: renegotiation: client-initiated; sign" \
5809 "$P_SRV \
5810 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005811 exchanges=2 renegotiation=1" \
5812 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5813 0 \
5814 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005815 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005816
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005817requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005818requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005819run_test "SSL async private: renegotiation: server-initiated; sign" \
5820 "$P_SRV \
5821 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005822 exchanges=2 renegotiation=1 renegotiate=1" \
5823 "$P_CLI exchanges=2 renegotiation=1" \
5824 0 \
5825 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005826 -s "Async resume (slot [0-9]): sign done, status=0"
5827
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005828requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005829requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5830run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5831 "$P_SRV \
5832 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5833 exchanges=2 renegotiation=1" \
5834 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5835 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5836 0 \
5837 -s "Async decrypt callback: using key slot " \
5838 -s "Async resume (slot [0-9]): decrypt done, status=0"
5839
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005840requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005841requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5842run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5843 "$P_SRV \
5844 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5845 exchanges=2 renegotiation=1 renegotiate=1" \
5846 "$P_CLI exchanges=2 renegotiation=1 \
5847 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5848 0 \
5849 -s "Async decrypt callback: using key slot " \
5850 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005851
Ron Eldor58093c82018-06-28 13:22:05 +03005852# Tests for ECC extensions (rfc 4492)
5853
Ron Eldor643df7c2018-06-28 16:17:00 +03005854requires_config_enabled MBEDTLS_AES_C
5855requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5856requires_config_enabled MBEDTLS_SHA256_C
5857requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005858run_test "Force a non ECC ciphersuite in the client side" \
5859 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005860 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005861 0 \
5862 -C "client hello, adding supported_elliptic_curves extension" \
5863 -C "client hello, adding supported_point_formats extension" \
5864 -S "found supported elliptic curves extension" \
5865 -S "found supported point formats extension"
5866
Ron Eldor643df7c2018-06-28 16:17:00 +03005867requires_config_enabled MBEDTLS_AES_C
5868requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5869requires_config_enabled MBEDTLS_SHA256_C
5870requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005871run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005872 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005873 "$P_CLI debug_level=3" \
5874 0 \
5875 -C "found supported_point_formats extension" \
5876 -S "server hello, supported_point_formats extension"
5877
Ron Eldor643df7c2018-06-28 16:17:00 +03005878requires_config_enabled MBEDTLS_AES_C
5879requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5880requires_config_enabled MBEDTLS_SHA256_C
5881requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005882run_test "Force an ECC ciphersuite in the client side" \
5883 "$P_SRV debug_level=3" \
5884 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5885 0 \
5886 -c "client hello, adding supported_elliptic_curves extension" \
5887 -c "client hello, adding supported_point_formats extension" \
5888 -s "found supported elliptic curves extension" \
5889 -s "found supported point formats extension"
5890
Ron Eldor643df7c2018-06-28 16:17:00 +03005891requires_config_enabled MBEDTLS_AES_C
5892requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5893requires_config_enabled MBEDTLS_SHA256_C
5894requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005895run_test "Force an ECC ciphersuite in the server side" \
5896 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5897 "$P_CLI debug_level=3" \
5898 0 \
5899 -c "found supported_point_formats extension" \
5900 -s "server hello, supported_point_formats extension"
5901
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005902# Tests for DTLS HelloVerifyRequest
5903
5904run_test "DTLS cookie: enabled" \
5905 "$P_SRV dtls=1 debug_level=2" \
5906 "$P_CLI dtls=1 debug_level=2" \
5907 0 \
5908 -s "cookie verification failed" \
5909 -s "cookie verification passed" \
5910 -S "cookie verification skipped" \
5911 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005912 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005913 -S "SSL - The requested feature is not available"
5914
5915run_test "DTLS cookie: disabled" \
5916 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5917 "$P_CLI dtls=1 debug_level=2" \
5918 0 \
5919 -S "cookie verification failed" \
5920 -S "cookie verification passed" \
5921 -s "cookie verification skipped" \
5922 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005923 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005924 -S "SSL - The requested feature is not available"
5925
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005926run_test "DTLS cookie: default (failing)" \
5927 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5928 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5929 1 \
5930 -s "cookie verification failed" \
5931 -S "cookie verification passed" \
5932 -S "cookie verification skipped" \
5933 -C "received hello verify request" \
5934 -S "hello verification requested" \
5935 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005936
5937requires_ipv6
5938run_test "DTLS cookie: enabled, IPv6" \
5939 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5940 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5941 0 \
5942 -s "cookie verification failed" \
5943 -s "cookie verification passed" \
5944 -S "cookie verification skipped" \
5945 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005946 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005947 -S "SSL - The requested feature is not available"
5948
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005949run_test "DTLS cookie: enabled, nbio" \
5950 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5951 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5952 0 \
5953 -s "cookie verification failed" \
5954 -s "cookie verification passed" \
5955 -S "cookie verification skipped" \
5956 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005957 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005958 -S "SSL - The requested feature is not available"
5959
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005960# Tests for client reconnecting from the same port with DTLS
5961
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005962not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005963run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005964 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5965 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005966 0 \
5967 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005968 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005969 -S "Client initiated reconnection from same port"
5970
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005971not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005972run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005973 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5974 "$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 +02005975 0 \
5976 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005977 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005978 -s "Client initiated reconnection from same port"
5979
Paul Bakker362689d2016-05-13 10:33:25 +01005980not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5981run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005982 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5983 "$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 +02005984 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005985 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005986 -s "Client initiated reconnection from same port"
5987
Paul Bakker362689d2016-05-13 10:33:25 +01005988only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5989run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5990 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5991 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5992 0 \
5993 -S "The operation timed out" \
5994 -s "Client initiated reconnection from same port"
5995
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005996run_test "DTLS client reconnect from same port: no cookies" \
5997 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005998 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5999 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006000 -s "The operation timed out" \
6001 -S "Client initiated reconnection from same port"
6002
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01006003run_test "DTLS client reconnect from same port: attacker-injected" \
6004 -p "$P_PXY inject_clihlo=1" \
6005 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
6006 "$P_CLI dtls=1 exchanges=2" \
6007 0 \
6008 -s "possible client reconnect from the same port" \
6009 -S "Client initiated reconnection from same port"
6010
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006011# Tests for various cases of client authentication with DTLS
6012# (focused on handshake flows and message parsing)
6013
6014run_test "DTLS client auth: required" \
6015 "$P_SRV dtls=1 auth_mode=required" \
6016 "$P_CLI dtls=1" \
6017 0 \
6018 -s "Verifying peer X.509 certificate... ok"
6019
6020run_test "DTLS client auth: optional, client has no cert" \
6021 "$P_SRV dtls=1 auth_mode=optional" \
6022 "$P_CLI dtls=1 crt_file=none key_file=none" \
6023 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006024 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006025
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006026run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006027 "$P_SRV dtls=1 auth_mode=none" \
6028 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
6029 0 \
6030 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006031 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006032
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02006033run_test "DTLS wrong PSK: badmac alert" \
6034 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
6035 "$P_CLI dtls=1 psk=abc124" \
6036 1 \
6037 -s "SSL - Verification of the message MAC failed" \
6038 -c "SSL - A fatal alert message was received from our peer"
6039
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02006040# Tests for receiving fragmented handshake messages with DTLS
6041
6042requires_gnutls
6043run_test "DTLS reassembly: no fragmentation (gnutls server)" \
6044 "$G_SRV -u --mtu 2048 -a" \
6045 "$P_CLI dtls=1 debug_level=2" \
6046 0 \
6047 -C "found fragmented DTLS handshake message" \
6048 -C "error"
6049
6050requires_gnutls
6051run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6052 "$G_SRV -u --mtu 512" \
6053 "$P_CLI dtls=1 debug_level=2" \
6054 0 \
6055 -c "found fragmented DTLS handshake message" \
6056 -C "error"
6057
6058requires_gnutls
6059run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6060 "$G_SRV -u --mtu 128" \
6061 "$P_CLI dtls=1 debug_level=2" \
6062 0 \
6063 -c "found fragmented DTLS handshake message" \
6064 -C "error"
6065
6066requires_gnutls
6067run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6068 "$G_SRV -u --mtu 128" \
6069 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6070 0 \
6071 -c "found fragmented DTLS handshake message" \
6072 -C "error"
6073
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006074requires_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, renego (gnutls server)" \
6077 "$G_SRV -u --mtu 256" \
6078 "$P_CLI debug_level=3 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
6088requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006089requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006090run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6091 "$G_SRV -u --mtu 256" \
6092 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6093 0 \
6094 -c "found fragmented DTLS handshake message" \
6095 -c "client hello, adding renegotiation extension" \
6096 -c "found renegotiation extension" \
6097 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006098 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006099 -C "error" \
6100 -s "Extra-header:"
6101
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006102run_test "DTLS reassembly: no fragmentation (openssl server)" \
6103 "$O_SRV -dtls1 -mtu 2048" \
6104 "$P_CLI dtls=1 debug_level=2" \
6105 0 \
6106 -C "found fragmented DTLS handshake message" \
6107 -C "error"
6108
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006109run_test "DTLS reassembly: some fragmentation (openssl server)" \
6110 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006111 "$P_CLI dtls=1 debug_level=2" \
6112 0 \
6113 -c "found fragmented DTLS handshake message" \
6114 -C "error"
6115
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006116run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006117 "$O_SRV -dtls1 -mtu 256" \
6118 "$P_CLI dtls=1 debug_level=2" \
6119 0 \
6120 -c "found fragmented DTLS handshake message" \
6121 -C "error"
6122
6123run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6124 "$O_SRV -dtls1 -mtu 256" \
6125 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6126 0 \
6127 -c "found fragmented DTLS handshake message" \
6128 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006129
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006130# Tests for sending fragmented handshake messages with DTLS
6131#
6132# Use client auth when we need the client to send large messages,
6133# and use large cert chains on both sides too (the long chains we have all use
6134# both RSA and ECDSA, but ideally we should have long chains with either).
6135# Sizes reached (UDP payload):
6136# - 2037B for server certificate
6137# - 1542B for client certificate
6138# - 1013B for newsessionticket
6139# - all others below 512B
6140# All those tests assume MAX_CONTENT_LEN is at least 2048
6141
6142requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6143requires_config_enabled MBEDTLS_RSA_C
6144requires_config_enabled MBEDTLS_ECDSA_C
6145requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006146requires_max_content_len 4096
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006147run_test "DTLS fragmenting: none (for reference)" \
6148 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6149 crt_file=data_files/server7_int-ca.crt \
6150 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006151 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006152 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006153 "$P_CLI dtls=1 debug_level=2 \
6154 crt_file=data_files/server8_int-ca2.crt \
6155 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006156 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006157 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006158 0 \
6159 -S "found fragmented DTLS handshake message" \
6160 -C "found fragmented DTLS handshake message" \
6161 -C "error"
6162
6163requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6164requires_config_enabled MBEDTLS_RSA_C
6165requires_config_enabled MBEDTLS_ECDSA_C
6166requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006167requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006168run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006169 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6170 crt_file=data_files/server7_int-ca.crt \
6171 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006172 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006173 max_frag_len=1024" \
6174 "$P_CLI dtls=1 debug_level=2 \
6175 crt_file=data_files/server8_int-ca2.crt \
6176 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006177 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006178 max_frag_len=2048" \
6179 0 \
6180 -S "found fragmented DTLS handshake message" \
6181 -c "found fragmented DTLS handshake message" \
6182 -C "error"
6183
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006184# With the MFL extension, the server has no way of forcing
6185# the client to not exceed a certain MTU; hence, the following
6186# test can't be replicated with an MTU proxy such as the one
6187# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006188requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6189requires_config_enabled MBEDTLS_RSA_C
6190requires_config_enabled MBEDTLS_ECDSA_C
6191requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006192requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006193run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006194 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6195 crt_file=data_files/server7_int-ca.crt \
6196 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006197 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006198 max_frag_len=512" \
6199 "$P_CLI dtls=1 debug_level=2 \
6200 crt_file=data_files/server8_int-ca2.crt \
6201 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006202 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006203 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006204 0 \
6205 -S "found fragmented DTLS handshake message" \
6206 -c "found fragmented DTLS handshake message" \
6207 -C "error"
6208
6209requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6210requires_config_enabled MBEDTLS_RSA_C
6211requires_config_enabled MBEDTLS_ECDSA_C
6212requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006213requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006214run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006215 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6216 crt_file=data_files/server7_int-ca.crt \
6217 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006218 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006219 max_frag_len=2048" \
6220 "$P_CLI dtls=1 debug_level=2 \
6221 crt_file=data_files/server8_int-ca2.crt \
6222 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006223 hs_timeout=2500-60000 \
6224 max_frag_len=1024" \
6225 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006226 -S "found fragmented DTLS handshake message" \
6227 -c "found fragmented DTLS handshake message" \
6228 -C "error"
6229
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006230# While not required by the standard defining the MFL extension
6231# (according to which it only applies to records, not to datagrams),
6232# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6233# as otherwise there wouldn't be any means to communicate MTU restrictions
6234# to the peer.
6235# The next test checks that no datagrams significantly larger than the
6236# negotiated MFL are sent.
6237requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6238requires_config_enabled MBEDTLS_RSA_C
6239requires_config_enabled MBEDTLS_ECDSA_C
6240requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006241requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006242run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006243 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006244 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6245 crt_file=data_files/server7_int-ca.crt \
6246 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006247 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006248 max_frag_len=2048" \
6249 "$P_CLI dtls=1 debug_level=2 \
6250 crt_file=data_files/server8_int-ca2.crt \
6251 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006252 hs_timeout=2500-60000 \
6253 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006254 0 \
6255 -S "found fragmented DTLS handshake message" \
6256 -c "found fragmented DTLS handshake message" \
6257 -C "error"
6258
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006259requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6260requires_config_enabled MBEDTLS_RSA_C
6261requires_config_enabled MBEDTLS_ECDSA_C
6262requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006263requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006264run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006265 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6266 crt_file=data_files/server7_int-ca.crt \
6267 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006268 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006269 max_frag_len=2048" \
6270 "$P_CLI dtls=1 debug_level=2 \
6271 crt_file=data_files/server8_int-ca2.crt \
6272 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006273 hs_timeout=2500-60000 \
6274 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006275 0 \
6276 -s "found fragmented DTLS handshake message" \
6277 -c "found fragmented DTLS handshake message" \
6278 -C "error"
6279
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006280# While not required by the standard defining the MFL extension
6281# (according to which it only applies to records, not to datagrams),
6282# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6283# as otherwise there wouldn't be any means to communicate MTU restrictions
6284# to the peer.
6285# The next test checks that no datagrams significantly larger than the
6286# negotiated MFL are sent.
6287requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6288requires_config_enabled MBEDTLS_RSA_C
6289requires_config_enabled MBEDTLS_ECDSA_C
6290requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006291requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006292run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006293 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006294 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6295 crt_file=data_files/server7_int-ca.crt \
6296 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006297 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006298 max_frag_len=2048" \
6299 "$P_CLI dtls=1 debug_level=2 \
6300 crt_file=data_files/server8_int-ca2.crt \
6301 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006302 hs_timeout=2500-60000 \
6303 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006304 0 \
6305 -s "found fragmented DTLS handshake message" \
6306 -c "found fragmented DTLS handshake message" \
6307 -C "error"
6308
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006309requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6310requires_config_enabled MBEDTLS_RSA_C
6311requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006312requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006313run_test "DTLS fragmenting: none (for reference) (MTU)" \
6314 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6315 crt_file=data_files/server7_int-ca.crt \
6316 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006317 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006318 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006319 "$P_CLI dtls=1 debug_level=2 \
6320 crt_file=data_files/server8_int-ca2.crt \
6321 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006322 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006323 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006324 0 \
6325 -S "found fragmented DTLS handshake message" \
6326 -C "found fragmented DTLS handshake message" \
6327 -C "error"
6328
6329requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6330requires_config_enabled MBEDTLS_RSA_C
6331requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006332requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006333run_test "DTLS fragmenting: client (MTU)" \
6334 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6335 crt_file=data_files/server7_int-ca.crt \
6336 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006337 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006338 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006339 "$P_CLI dtls=1 debug_level=2 \
6340 crt_file=data_files/server8_int-ca2.crt \
6341 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006342 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006343 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006344 0 \
6345 -s "found fragmented DTLS handshake message" \
6346 -C "found fragmented DTLS handshake message" \
6347 -C "error"
6348
6349requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6350requires_config_enabled MBEDTLS_RSA_C
6351requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006352requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006353run_test "DTLS fragmenting: server (MTU)" \
6354 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6355 crt_file=data_files/server7_int-ca.crt \
6356 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006357 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006358 mtu=512" \
6359 "$P_CLI dtls=1 debug_level=2 \
6360 crt_file=data_files/server8_int-ca2.crt \
6361 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006362 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006363 mtu=2048" \
6364 0 \
6365 -S "found fragmented DTLS handshake message" \
6366 -c "found fragmented DTLS handshake message" \
6367 -C "error"
6368
6369requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6370requires_config_enabled MBEDTLS_RSA_C
6371requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006372requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006373run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006374 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006375 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6376 crt_file=data_files/server7_int-ca.crt \
6377 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006378 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006379 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006380 "$P_CLI dtls=1 debug_level=2 \
6381 crt_file=data_files/server8_int-ca2.crt \
6382 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006383 hs_timeout=2500-60000 \
6384 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006385 0 \
6386 -s "found fragmented DTLS handshake message" \
6387 -c "found fragmented DTLS handshake message" \
6388 -C "error"
6389
Andrzej Kurek77826052018-10-11 07:34:08 -04006390# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006391requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6392requires_config_enabled MBEDTLS_RSA_C
6393requires_config_enabled MBEDTLS_ECDSA_C
6394requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006395requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006396requires_config_enabled MBEDTLS_AES_C
6397requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006398requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006399run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006400 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006401 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6402 crt_file=data_files/server7_int-ca.crt \
6403 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006404 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006405 mtu=512" \
6406 "$P_CLI dtls=1 debug_level=2 \
6407 crt_file=data_files/server8_int-ca2.crt \
6408 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006409 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6410 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006411 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006412 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006413 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006414 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006415 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006416
Andrzej Kurek7311c782018-10-11 06:49:41 -04006417# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006418# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006419# The ratio of max/min timeout should ideally equal 4 to accept two
6420# retransmissions, but in some cases (like both the server and client using
6421# fragmentation and auto-reduction) an extra retransmission might occur,
6422# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006423not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006424requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6425requires_config_enabled MBEDTLS_RSA_C
6426requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006427requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006428requires_config_enabled MBEDTLS_AES_C
6429requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006430requires_max_content_len 2048
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006431run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6432 -p "$P_PXY mtu=508" \
6433 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6434 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006435 key_file=data_files/server7.key \
6436 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006437 "$P_CLI dtls=1 debug_level=2 \
6438 crt_file=data_files/server8_int-ca2.crt \
6439 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006440 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6441 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006442 0 \
6443 -s "found fragmented DTLS handshake message" \
6444 -c "found fragmented DTLS handshake message" \
6445 -C "error"
6446
Andrzej Kurek77826052018-10-11 07:34:08 -04006447# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006448only_with_valgrind
6449requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6450requires_config_enabled MBEDTLS_RSA_C
6451requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006452requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006453requires_config_enabled MBEDTLS_AES_C
6454requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006455requires_max_content_len 2048
Hanno Becker108992e2018-08-29 17:04:18 +01006456run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6457 -p "$P_PXY mtu=508" \
6458 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6459 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006460 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006461 hs_timeout=250-10000" \
6462 "$P_CLI dtls=1 debug_level=2 \
6463 crt_file=data_files/server8_int-ca2.crt \
6464 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006465 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006466 hs_timeout=250-10000" \
6467 0 \
6468 -s "found fragmented DTLS handshake message" \
6469 -c "found fragmented DTLS handshake message" \
6470 -C "error"
6471
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006472# 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 +02006473# OTOH the client might resend if the server is to slow to reset after sending
6474# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006475not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006476requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6477requires_config_enabled MBEDTLS_RSA_C
6478requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006479requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006480run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006481 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006482 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6483 crt_file=data_files/server7_int-ca.crt \
6484 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006485 hs_timeout=10000-60000 \
6486 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006487 "$P_CLI dtls=1 debug_level=2 \
6488 crt_file=data_files/server8_int-ca2.crt \
6489 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006490 hs_timeout=10000-60000 \
6491 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006492 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006493 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006494 -s "found fragmented DTLS handshake message" \
6495 -c "found fragmented DTLS handshake message" \
6496 -C "error"
6497
Andrzej Kurek77826052018-10-11 07:34:08 -04006498# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006499# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6500# OTOH the client might resend if the server is to slow to reset after sending
6501# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006502not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006503requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6504requires_config_enabled MBEDTLS_RSA_C
6505requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006506requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006507requires_config_enabled MBEDTLS_AES_C
6508requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006509requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006510run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006511 -p "$P_PXY mtu=512" \
6512 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6513 crt_file=data_files/server7_int-ca.crt \
6514 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006515 hs_timeout=10000-60000 \
6516 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006517 "$P_CLI dtls=1 debug_level=2 \
6518 crt_file=data_files/server8_int-ca2.crt \
6519 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006520 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6521 hs_timeout=10000-60000 \
6522 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006523 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006524 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006525 -s "found fragmented DTLS handshake message" \
6526 -c "found fragmented DTLS handshake message" \
6527 -C "error"
6528
Andrzej Kurek7311c782018-10-11 06:49:41 -04006529not_with_valgrind # spurious autoreduction due to timeout
6530requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6531requires_config_enabled MBEDTLS_RSA_C
6532requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006533requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006534run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006535 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006536 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6537 crt_file=data_files/server7_int-ca.crt \
6538 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006539 hs_timeout=10000-60000 \
6540 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006541 "$P_CLI dtls=1 debug_level=2 \
6542 crt_file=data_files/server8_int-ca2.crt \
6543 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006544 hs_timeout=10000-60000 \
6545 mtu=1024 nbio=2" \
6546 0 \
6547 -S "autoreduction" \
6548 -s "found fragmented DTLS handshake message" \
6549 -c "found fragmented DTLS handshake message" \
6550 -C "error"
6551
Andrzej Kurek77826052018-10-11 07:34:08 -04006552# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006553not_with_valgrind # spurious autoreduction due to timeout
6554requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6555requires_config_enabled MBEDTLS_RSA_C
6556requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006557requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006558requires_config_enabled MBEDTLS_AES_C
6559requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006560requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006561run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6562 -p "$P_PXY mtu=512" \
6563 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6564 crt_file=data_files/server7_int-ca.crt \
6565 key_file=data_files/server7.key \
6566 hs_timeout=10000-60000 \
6567 mtu=512 nbio=2" \
6568 "$P_CLI dtls=1 debug_level=2 \
6569 crt_file=data_files/server8_int-ca2.crt \
6570 key_file=data_files/server8.key \
6571 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6572 hs_timeout=10000-60000 \
6573 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006574 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006575 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006576 -s "found fragmented DTLS handshake message" \
6577 -c "found fragmented DTLS handshake message" \
6578 -C "error"
6579
Andrzej Kurek77826052018-10-11 07:34:08 -04006580# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006581# This ensures things still work after session_reset().
6582# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006583# Since we don't support reading fragmented ClientHello yet,
6584# up the MTU to 1450 (larger than ClientHello with session ticket,
6585# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006586# An autoreduction on the client-side might happen if the server is
6587# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006588# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006589# resumed listening, which would result in a spurious autoreduction.
6590not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006591requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6592requires_config_enabled MBEDTLS_RSA_C
6593requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006594requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006595requires_config_enabled MBEDTLS_AES_C
6596requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006597requires_max_content_len 2048
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006598run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6599 -p "$P_PXY mtu=1450" \
6600 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6601 crt_file=data_files/server7_int-ca.crt \
6602 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006603 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006604 mtu=1450" \
6605 "$P_CLI dtls=1 debug_level=2 \
6606 crt_file=data_files/server8_int-ca2.crt \
6607 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006608 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006609 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006610 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006611 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006612 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006613 -s "found fragmented DTLS handshake message" \
6614 -c "found fragmented DTLS handshake message" \
6615 -C "error"
6616
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006617# An autoreduction on the client-side might happen if the server is
6618# slow to reset, therefore omitting '-C "autoreduction"' below.
6619not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006620requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6621requires_config_enabled MBEDTLS_RSA_C
6622requires_config_enabled MBEDTLS_ECDSA_C
6623requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006624requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006625requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6626requires_config_enabled MBEDTLS_CHACHAPOLY_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006627requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006628run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6629 -p "$P_PXY mtu=512" \
6630 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6631 crt_file=data_files/server7_int-ca.crt \
6632 key_file=data_files/server7.key \
6633 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006634 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006635 mtu=512" \
6636 "$P_CLI dtls=1 debug_level=2 \
6637 crt_file=data_files/server8_int-ca2.crt \
6638 key_file=data_files/server8.key \
6639 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006640 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006641 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006642 mtu=512" \
6643 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006644 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006645 -s "found fragmented DTLS handshake message" \
6646 -c "found fragmented DTLS handshake message" \
6647 -C "error"
6648
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006649# An autoreduction on the client-side might happen if the server is
6650# slow to reset, therefore omitting '-C "autoreduction"' below.
6651not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006652requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6653requires_config_enabled MBEDTLS_RSA_C
6654requires_config_enabled MBEDTLS_ECDSA_C
6655requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006656requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006657requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6658requires_config_enabled MBEDTLS_AES_C
6659requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006660requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006661run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6662 -p "$P_PXY mtu=512" \
6663 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6664 crt_file=data_files/server7_int-ca.crt \
6665 key_file=data_files/server7.key \
6666 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006667 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006668 mtu=512" \
6669 "$P_CLI dtls=1 debug_level=2 \
6670 crt_file=data_files/server8_int-ca2.crt \
6671 key_file=data_files/server8.key \
6672 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006673 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006674 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006675 mtu=512" \
6676 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006677 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006678 -s "found fragmented DTLS handshake message" \
6679 -c "found fragmented DTLS handshake message" \
6680 -C "error"
6681
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006682# An autoreduction on the client-side might happen if the server is
6683# slow to reset, therefore omitting '-C "autoreduction"' below.
6684not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006685requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6686requires_config_enabled MBEDTLS_RSA_C
6687requires_config_enabled MBEDTLS_ECDSA_C
6688requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006689requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006690requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6691requires_config_enabled MBEDTLS_AES_C
6692requires_config_enabled MBEDTLS_CCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006693requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006694run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006695 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006696 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6697 crt_file=data_files/server7_int-ca.crt \
6698 key_file=data_files/server7.key \
6699 exchanges=2 renegotiation=1 \
6700 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006701 hs_timeout=10000-60000 \
6702 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006703 "$P_CLI dtls=1 debug_level=2 \
6704 crt_file=data_files/server8_int-ca2.crt \
6705 key_file=data_files/server8.key \
6706 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006707 hs_timeout=10000-60000 \
6708 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006709 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006710 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006711 -s "found fragmented DTLS handshake message" \
6712 -c "found fragmented DTLS handshake message" \
6713 -C "error"
6714
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006715# An autoreduction on the client-side might happen if the server is
6716# slow to reset, therefore omitting '-C "autoreduction"' below.
6717not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006718requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6719requires_config_enabled MBEDTLS_RSA_C
6720requires_config_enabled MBEDTLS_ECDSA_C
6721requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006722requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006723requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6724requires_config_enabled MBEDTLS_AES_C
6725requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6726requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
Yuto Takanoc75df632021-07-08 15:56:33 +01006727requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006728run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006729 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006730 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6731 crt_file=data_files/server7_int-ca.crt \
6732 key_file=data_files/server7.key \
6733 exchanges=2 renegotiation=1 \
6734 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006735 hs_timeout=10000-60000 \
6736 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006737 "$P_CLI dtls=1 debug_level=2 \
6738 crt_file=data_files/server8_int-ca2.crt \
6739 key_file=data_files/server8.key \
6740 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006741 hs_timeout=10000-60000 \
6742 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006743 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006744 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006745 -s "found fragmented DTLS handshake message" \
6746 -c "found fragmented DTLS handshake message" \
6747 -C "error"
6748
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006749# An autoreduction on the client-side might happen if the server is
6750# slow to reset, therefore omitting '-C "autoreduction"' below.
6751not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006752requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6753requires_config_enabled MBEDTLS_RSA_C
6754requires_config_enabled MBEDTLS_ECDSA_C
6755requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006756requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006757requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6758requires_config_enabled MBEDTLS_AES_C
6759requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
Yuto Takanoc75df632021-07-08 15:56:33 +01006760requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006761run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006762 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006763 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6764 crt_file=data_files/server7_int-ca.crt \
6765 key_file=data_files/server7.key \
6766 exchanges=2 renegotiation=1 \
6767 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006768 hs_timeout=10000-60000 \
6769 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006770 "$P_CLI dtls=1 debug_level=2 \
6771 crt_file=data_files/server8_int-ca2.crt \
6772 key_file=data_files/server8.key \
6773 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006774 hs_timeout=10000-60000 \
6775 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006776 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006777 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006778 -s "found fragmented DTLS handshake message" \
6779 -c "found fragmented DTLS handshake message" \
6780 -C "error"
6781
Andrzej Kurek77826052018-10-11 07:34:08 -04006782# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006783requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6784requires_config_enabled MBEDTLS_RSA_C
6785requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006786requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006787requires_config_enabled MBEDTLS_AES_C
6788requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006789client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006790requires_max_content_len 2048
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006791run_test "DTLS fragmenting: proxy MTU + 3d" \
6792 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006793 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006794 crt_file=data_files/server7_int-ca.crt \
6795 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006796 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006797 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006798 crt_file=data_files/server8_int-ca2.crt \
6799 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006800 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006801 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006802 0 \
6803 -s "found fragmented DTLS handshake message" \
6804 -c "found fragmented DTLS handshake message" \
6805 -C "error"
6806
Andrzej Kurek77826052018-10-11 07:34:08 -04006807# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006808requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6809requires_config_enabled MBEDTLS_RSA_C
6810requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006811requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006812requires_config_enabled MBEDTLS_AES_C
6813requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006814client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006815requires_max_content_len 2048
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006816run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6817 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6818 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6819 crt_file=data_files/server7_int-ca.crt \
6820 key_file=data_files/server7.key \
6821 hs_timeout=250-10000 mtu=512 nbio=2" \
6822 "$P_CLI dtls=1 debug_level=2 \
6823 crt_file=data_files/server8_int-ca2.crt \
6824 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006825 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006826 hs_timeout=250-10000 mtu=512 nbio=2" \
6827 0 \
6828 -s "found fragmented DTLS handshake message" \
6829 -c "found fragmented DTLS handshake message" \
6830 -C "error"
6831
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006832# interop tests for DTLS fragmentating with reliable connection
6833#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006834# here and below we just want to test that the we fragment in a way that
6835# pleases other implementations, so we don't need the peer to fragment
6836requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6837requires_config_enabled MBEDTLS_RSA_C
6838requires_config_enabled MBEDTLS_ECDSA_C
6839requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006840requires_gnutls
Yuto Takanoc75df632021-07-08 15:56:33 +01006841requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006842run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6843 "$G_SRV -u" \
6844 "$P_CLI dtls=1 debug_level=2 \
6845 crt_file=data_files/server8_int-ca2.crt \
6846 key_file=data_files/server8.key \
6847 mtu=512 force_version=dtls1_2" \
6848 0 \
6849 -c "fragmenting handshake message" \
6850 -C "error"
6851
6852requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6853requires_config_enabled MBEDTLS_RSA_C
6854requires_config_enabled MBEDTLS_ECDSA_C
6855requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006856requires_gnutls
Yuto Takanoc75df632021-07-08 15:56:33 +01006857requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006858run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6859 "$G_SRV -u" \
6860 "$P_CLI dtls=1 debug_level=2 \
6861 crt_file=data_files/server8_int-ca2.crt \
6862 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006863 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006864 0 \
6865 -c "fragmenting handshake message" \
6866 -C "error"
6867
Hanno Beckerb9a00862018-08-28 10:20:22 +01006868# We use --insecure for the GnuTLS client because it expects
6869# the hostname / IP it connects to to be the name used in the
6870# certificate obtained from the server. Here, however, it
6871# connects to 127.0.0.1 while our test certificates use 'localhost'
6872# as the server name in the certificate. This will make the
6873# certifiate validation fail, but passing --insecure makes
6874# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006875requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6876requires_config_enabled MBEDTLS_RSA_C
6877requires_config_enabled MBEDTLS_ECDSA_C
6878requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006879requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006880requires_not_i686
Yuto Takanoc75df632021-07-08 15:56:33 +01006881requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006882run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006883 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006884 crt_file=data_files/server7_int-ca.crt \
6885 key_file=data_files/server7.key \
6886 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006887 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006888 0 \
6889 -s "fragmenting handshake message"
6890
Hanno Beckerb9a00862018-08-28 10:20:22 +01006891# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006892requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6893requires_config_enabled MBEDTLS_RSA_C
6894requires_config_enabled MBEDTLS_ECDSA_C
6895requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006896requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006897requires_not_i686
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: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006900 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006901 crt_file=data_files/server7_int-ca.crt \
6902 key_file=data_files/server7.key \
6903 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006904 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006905 0 \
6906 -s "fragmenting handshake message"
6907
6908requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6909requires_config_enabled MBEDTLS_RSA_C
6910requires_config_enabled MBEDTLS_ECDSA_C
6911requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Yuto Takanoc75df632021-07-08 15:56:33 +01006912requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006913run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6914 "$O_SRV -dtls1_2 -verify 10" \
6915 "$P_CLI dtls=1 debug_level=2 \
6916 crt_file=data_files/server8_int-ca2.crt \
6917 key_file=data_files/server8.key \
6918 mtu=512 force_version=dtls1_2" \
6919 0 \
6920 -c "fragmenting handshake message" \
6921 -C "error"
6922
6923requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6924requires_config_enabled MBEDTLS_RSA_C
6925requires_config_enabled MBEDTLS_ECDSA_C
6926requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006927requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006928run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6929 "$O_SRV -dtls1 -verify 10" \
6930 "$P_CLI dtls=1 debug_level=2 \
6931 crt_file=data_files/server8_int-ca2.crt \
6932 key_file=data_files/server8.key \
6933 mtu=512 force_version=dtls1" \
6934 0 \
6935 -c "fragmenting handshake message" \
6936 -C "error"
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_2
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.2" \
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_2" \
6948 "$O_CLI -dtls1_2" \
6949 0 \
6950 -s "fragmenting handshake message"
6951
6952requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6953requires_config_enabled MBEDTLS_RSA_C
6954requires_config_enabled MBEDTLS_ECDSA_C
6955requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006956requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006957run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6958 "$P_SRV dtls=1 debug_level=2 \
6959 crt_file=data_files/server7_int-ca.crt \
6960 key_file=data_files/server7.key \
6961 mtu=512 force_version=dtls1" \
6962 "$O_CLI -dtls1" \
6963 0 \
6964 -s "fragmenting handshake message"
6965
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006966# interop tests for DTLS fragmentating with unreliable connection
6967#
6968# again we just want to test that the we fragment in a way that
6969# pleases other implementations, so we don't need the peer to fragment
6970requires_gnutls_next
6971requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6972requires_config_enabled MBEDTLS_RSA_C
6973requires_config_enabled MBEDTLS_ECDSA_C
6974requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006975client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006976requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006977run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6978 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6979 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006980 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006981 crt_file=data_files/server8_int-ca2.crt \
6982 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006983 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006984 0 \
6985 -c "fragmenting handshake message" \
6986 -C "error"
6987
6988requires_gnutls_next
6989requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6990requires_config_enabled MBEDTLS_RSA_C
6991requires_config_enabled MBEDTLS_ECDSA_C
6992requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006993client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006994requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006995run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6996 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6997 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006998 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006999 crt_file=data_files/server8_int-ca2.crt \
7000 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007001 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007002 0 \
7003 -c "fragmenting handshake message" \
7004 -C "error"
7005
k-stachowiakabb843e2019-02-18 16:14:03 +01007006requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007007requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7008requires_config_enabled MBEDTLS_RSA_C
7009requires_config_enabled MBEDTLS_ECDSA_C
7010requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7011client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007012requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007013run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
7014 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7015 "$P_SRV dtls=1 debug_level=2 \
7016 crt_file=data_files/server7_int-ca.crt \
7017 key_file=data_files/server7.key \
7018 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007019 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007020 0 \
7021 -s "fragmenting handshake message"
7022
k-stachowiakabb843e2019-02-18 16:14:03 +01007023requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007024requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7025requires_config_enabled MBEDTLS_RSA_C
7026requires_config_enabled MBEDTLS_ECDSA_C
7027requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7028client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007029requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007030run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
7031 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7032 "$P_SRV dtls=1 debug_level=2 \
7033 crt_file=data_files/server7_int-ca.crt \
7034 key_file=data_files/server7.key \
7035 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007036 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007037 0 \
7038 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007039
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007040## Interop test with OpenSSL might trigger a bug in recent versions (including
7041## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007042## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007043## They should be re-enabled once a fixed version of OpenSSL is available
7044## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007045skip_next_test
7046requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7047requires_config_enabled MBEDTLS_RSA_C
7048requires_config_enabled MBEDTLS_ECDSA_C
7049requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7050client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007051requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007052run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
7053 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7054 "$O_SRV -dtls1_2 -verify 10" \
7055 "$P_CLI dtls=1 debug_level=2 \
7056 crt_file=data_files/server8_int-ca2.crt \
7057 key_file=data_files/server8.key \
7058 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7059 0 \
7060 -c "fragmenting handshake message" \
7061 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007062
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007063skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007064requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7065requires_config_enabled MBEDTLS_RSA_C
7066requires_config_enabled MBEDTLS_ECDSA_C
7067requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007068client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007069requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007070run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
7071 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007072 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007073 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007074 crt_file=data_files/server8_int-ca2.crt \
7075 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007076 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007077 0 \
7078 -c "fragmenting handshake message" \
7079 -C "error"
7080
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007081skip_next_test
7082requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7083requires_config_enabled MBEDTLS_RSA_C
7084requires_config_enabled MBEDTLS_ECDSA_C
7085requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7086client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007087requires_max_content_len 2048
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007088run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
7089 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7090 "$P_SRV dtls=1 debug_level=2 \
7091 crt_file=data_files/server7_int-ca.crt \
7092 key_file=data_files/server7.key \
7093 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7094 "$O_CLI -dtls1_2" \
7095 0 \
7096 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007097
7098# -nbio is added to prevent s_client from blocking in case of duplicated
7099# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007100skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007101requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7102requires_config_enabled MBEDTLS_RSA_C
7103requires_config_enabled MBEDTLS_ECDSA_C
7104requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007105client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007106requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007107run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7108 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007109 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007110 crt_file=data_files/server7_int-ca.crt \
7111 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007112 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007113 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007114 0 \
7115 -s "fragmenting handshake message"
7116
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007117# Tests for specific things with "unreliable" UDP connection
7118
7119not_with_valgrind # spurious resend due to timeout
7120run_test "DTLS proxy: reference" \
7121 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007122 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7123 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007124 0 \
7125 -C "replayed record" \
7126 -S "replayed record" \
7127 -C "record from another epoch" \
7128 -S "record from another epoch" \
7129 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007130 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007131 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007132 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007133 -c "HTTP/1.0 200 OK"
7134
7135not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007136run_test "DTLS proxy: duplicate every packet" \
7137 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007138 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7139 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007140 0 \
7141 -c "replayed record" \
7142 -s "replayed record" \
7143 -c "record from another epoch" \
7144 -s "record from another epoch" \
7145 -S "resend" \
7146 -s "Extra-header:" \
7147 -c "HTTP/1.0 200 OK"
7148
7149run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7150 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007151 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7152 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007153 0 \
7154 -c "replayed record" \
7155 -S "replayed record" \
7156 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007157 -s "record from another epoch" \
7158 -c "resend" \
7159 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007160 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007161 -c "HTTP/1.0 200 OK"
7162
7163run_test "DTLS proxy: multiple records in same datagram" \
7164 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007165 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7166 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007167 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007168 -c "next record in same datagram" \
7169 -s "next record in same datagram"
7170
7171run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7172 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007173 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7174 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007175 0 \
7176 -c "next record in same datagram" \
7177 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007178
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007179run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7180 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007181 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7182 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007183 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007184 -c "discarding invalid record (mac)" \
7185 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007186 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007187 -c "HTTP/1.0 200 OK" \
7188 -S "too many records with bad MAC" \
7189 -S "Verification of the message MAC failed"
7190
7191run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7192 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007193 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7194 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007195 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007196 -C "discarding invalid record (mac)" \
7197 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007198 -S "Extra-header:" \
7199 -C "HTTP/1.0 200 OK" \
7200 -s "too many records with bad MAC" \
7201 -s "Verification of the message MAC failed"
7202
7203run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7204 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007205 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7206 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007207 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007208 -c "discarding invalid record (mac)" \
7209 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007210 -s "Extra-header:" \
7211 -c "HTTP/1.0 200 OK" \
7212 -S "too many records with bad MAC" \
7213 -S "Verification of the message MAC failed"
7214
7215run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7216 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007217 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7218 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007219 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007220 -c "discarding invalid record (mac)" \
7221 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007222 -s "Extra-header:" \
7223 -c "HTTP/1.0 200 OK" \
7224 -s "too many records with bad MAC" \
7225 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007226
7227run_test "DTLS proxy: delay ChangeCipherSpec" \
7228 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007229 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7230 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007231 0 \
7232 -c "record from another epoch" \
7233 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007234 -s "Extra-header:" \
7235 -c "HTTP/1.0 200 OK"
7236
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007237# Tests for reordering support with DTLS
7238
Hanno Becker56cdfd12018-08-17 13:42:15 +01007239run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7240 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007241 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7242 hs_timeout=2500-60000" \
7243 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7244 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007245 0 \
7246 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007247 -c "Next handshake message has been buffered - load"\
7248 -S "Buffering HS message" \
7249 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007250 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007251 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007252 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007253 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007254
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007255run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7256 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007257 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7258 hs_timeout=2500-60000" \
7259 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7260 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007261 0 \
7262 -c "Buffering HS message" \
7263 -c "found fragmented DTLS handshake message"\
7264 -c "Next handshake message 1 not or only partially bufffered" \
7265 -c "Next handshake message has been buffered - load"\
7266 -S "Buffering HS message" \
7267 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007268 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007269 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007270 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007271 -S "Remember CCS message"
7272
Hanno Beckera1adcca2018-08-24 14:41:07 +01007273# The client buffers the ServerKeyExchange before receiving the fragmented
7274# Certificate message; at the time of writing, together these are aroudn 1200b
7275# in size, so that the bound below ensures that the certificate can be reassembled
7276# while keeping the ServerKeyExchange.
7277requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7278run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007279 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007280 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7281 hs_timeout=2500-60000" \
7282 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7283 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007284 0 \
7285 -c "Buffering HS message" \
7286 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007287 -C "attempt to make space by freeing buffered messages" \
7288 -S "Buffering HS message" \
7289 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007290 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007291 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007292 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007293 -S "Remember CCS message"
7294
7295# The size constraints ensure that the delayed certificate message can't
7296# be reassembled while keeping the ServerKeyExchange message, but it can
7297# when dropping it first.
7298requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7299requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7300run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7301 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007302 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7303 hs_timeout=2500-60000" \
7304 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7305 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007306 0 \
7307 -c "Buffering HS message" \
7308 -c "attempt to make space by freeing buffered future messages" \
7309 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007310 -S "Buffering HS message" \
7311 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007312 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007313 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007314 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007315 -S "Remember CCS message"
7316
Hanno Becker56cdfd12018-08-17 13:42:15 +01007317run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7318 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007319 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7320 hs_timeout=2500-60000" \
7321 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7322 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007323 0 \
7324 -C "Buffering HS message" \
7325 -C "Next handshake message has been buffered - load"\
7326 -s "Buffering HS message" \
7327 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007328 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007329 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007330 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007331 -S "Remember CCS message"
7332
7333run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7334 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007335 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7336 hs_timeout=2500-60000" \
7337 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7338 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007339 0 \
7340 -C "Buffering HS message" \
7341 -C "Next handshake message has been buffered - load"\
7342 -S "Buffering HS message" \
7343 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007344 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007345 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007346 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007347 -S "Remember CCS message"
7348
7349run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7350 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007351 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7352 hs_timeout=2500-60000" \
7353 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7354 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007355 0 \
7356 -C "Buffering HS message" \
7357 -C "Next handshake message has been buffered - load"\
7358 -S "Buffering HS message" \
7359 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007360 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007361 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007362 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007363 -s "Remember CCS message"
7364
Hanno Beckera1adcca2018-08-24 14:41:07 +01007365run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007366 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007367 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7368 hs_timeout=2500-60000" \
7369 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7370 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007371 0 \
7372 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007373 -s "Found buffered record from current epoch - load" \
7374 -c "Buffer record from epoch 1" \
7375 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007376
Hanno Beckera1adcca2018-08-24 14:41:07 +01007377# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7378# from the server are delayed, so that the encrypted Finished message
7379# is received and buffered. When the fragmented NewSessionTicket comes
7380# in afterwards, the encrypted Finished message must be freed in order
7381# to make space for the NewSessionTicket to be reassembled.
7382# This works only in very particular circumstances:
7383# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7384# of the NewSessionTicket, but small enough to also allow buffering of
7385# the encrypted Finished message.
7386# - The MTU setting on the server must be so small that the NewSessionTicket
7387# needs to be fragmented.
7388# - All messages sent by the server must be small enough to be either sent
7389# without fragmentation or be reassembled within the bounds of
7390# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7391# handshake, omitting CRTs.
7392requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7393requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7394run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7395 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7396 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7397 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7398 0 \
7399 -s "Buffer record from epoch 1" \
7400 -s "Found buffered record from current epoch - load" \
7401 -c "Buffer record from epoch 1" \
7402 -C "Found buffered record from current epoch - load" \
7403 -c "Enough space available after freeing future epoch record"
7404
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007405# Tests for "randomly unreliable connection": try a variety of flows and peers
7406
7407client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007408run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7409 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007410 "$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 +02007411 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007412 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007413 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7414 0 \
7415 -s "Extra-header:" \
7416 -c "HTTP/1.0 200 OK"
7417
Janos Follath74537a62016-09-02 13:45:28 +01007418client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007419run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7420 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007421 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7422 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007423 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7424 0 \
7425 -s "Extra-header:" \
7426 -c "HTTP/1.0 200 OK"
7427
Janos Follath74537a62016-09-02 13:45:28 +01007428client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007429run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7430 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007431 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7432 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007433 0 \
7434 -s "Extra-header:" \
7435 -c "HTTP/1.0 200 OK"
7436
Janos Follath74537a62016-09-02 13:45:28 +01007437client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007438run_test "DTLS proxy: 3d, FS, client auth" \
7439 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007440 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7441 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007442 0 \
7443 -s "Extra-header:" \
7444 -c "HTTP/1.0 200 OK"
7445
Janos Follath74537a62016-09-02 13:45:28 +01007446client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007447run_test "DTLS proxy: 3d, FS, ticket" \
7448 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007449 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7450 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007451 0 \
7452 -s "Extra-header:" \
7453 -c "HTTP/1.0 200 OK"
7454
Janos Follath74537a62016-09-02 13:45:28 +01007455client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007456run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7457 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007458 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7459 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007460 0 \
7461 -s "Extra-header:" \
7462 -c "HTTP/1.0 200 OK"
7463
Janos Follath74537a62016-09-02 13:45:28 +01007464client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007465run_test "DTLS proxy: 3d, max handshake, nbio" \
7466 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007467 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007468 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007469 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007470 0 \
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é-Gonnard7a26d732014-10-02 14:50:46 +02007475run_test "DTLS proxy: 3d, min handshake, resumption" \
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é-Gonnard7a26d732014-10-02 14:50:46 +02007478 psk=abc123 debug_level=3" \
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é-Gonnard7a26d732014-10-02 14:50:46 +02007481 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
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
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007489run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7490 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007491 "$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 +02007492 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007493 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007494 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007495 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7496 0 \
7497 -s "a session has been resumed" \
7498 -c "a session has been resumed" \
7499 -s "Extra-header:" \
7500 -c "HTTP/1.0 200 OK"
7501
Janos Follath74537a62016-09-02 13:45:28 +01007502client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007503requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007504run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007505 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007506 "$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 +02007507 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007508 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007509 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007510 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7511 0 \
7512 -c "=> renegotiate" \
7513 -s "=> renegotiate" \
7514 -s "Extra-header:" \
7515 -c "HTTP/1.0 200 OK"
7516
Janos Follath74537a62016-09-02 13:45:28 +01007517client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007518requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007519run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7520 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007521 "$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 +02007522 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007523 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007524 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007525 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7526 0 \
7527 -c "=> renegotiate" \
7528 -s "=> renegotiate" \
7529 -s "Extra-header:" \
7530 -c "HTTP/1.0 200 OK"
7531
Janos Follath74537a62016-09-02 13:45:28 +01007532client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007533requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007534run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007535 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007536 "$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 +02007537 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007538 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007539 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007540 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007541 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7542 0 \
7543 -c "=> renegotiate" \
7544 -s "=> renegotiate" \
7545 -s "Extra-header:" \
7546 -c "HTTP/1.0 200 OK"
7547
Janos Follath74537a62016-09-02 13:45:28 +01007548client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007550run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007551 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007552 "$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 +02007553 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007554 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007555 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007556 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007557 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7558 0 \
7559 -c "=> renegotiate" \
7560 -s "=> renegotiate" \
7561 -s "Extra-header:" \
7562 -c "HTTP/1.0 200 OK"
7563
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007564## Interop tests with OpenSSL might trigger a bug in recent versions (including
7565## all versions installed on the CI machines), reported here:
7566## Bug report: https://github.com/openssl/openssl/issues/6902
7567## They should be re-enabled once a fixed version of OpenSSL is available
7568## (this should happen in some 1.1.1_ release according to the ticket).
7569skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007570client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007571not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007572run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007573 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7574 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007575 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007576 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007577 -c "HTTP/1.0 200 OK"
7578
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007579skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007580client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007581not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007582run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7583 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7584 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007585 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007586 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007587 -c "HTTP/1.0 200 OK"
7588
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007589skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007590client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007591not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007592run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7593 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7594 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007595 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007596 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007597 -c "HTTP/1.0 200 OK"
7598
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007599requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007600client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007601not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007602run_test "DTLS proxy: 3d, gnutls server" \
7603 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7604 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007605 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007606 0 \
7607 -s "Extra-header:" \
7608 -c "Extra-header:"
7609
k-stachowiakabb843e2019-02-18 16:14:03 +01007610requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007611client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007612not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007613run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7614 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007615 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007616 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007617 0 \
7618 -s "Extra-header:" \
7619 -c "Extra-header:"
7620
k-stachowiakabb843e2019-02-18 16:14:03 +01007621requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007622client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007623not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007624run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7625 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007626 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007627 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007628 0 \
7629 -s "Extra-header:" \
7630 -c "Extra-header:"
7631
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007632# Final report
7633
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007634echo "------------------------------------------------------------------------"
7635
7636if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007637 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007638else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007639 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007640fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007641PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007642echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007643
7644exit $FAILS