blob: ba39aa6fdf68d9b78179aa428d200d6e8dc46529 [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Bence Szépkútia2947ac2020-08-19 16:37:36 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkútif744bd72020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Simon Butcher58eddef2016-05-19 23:43:11 +010047# Purpose
48#
49# Executes tests to prove various TLS/SSL options and extensions.
50#
51# The goal is not to cover every ciphersuite/version, but instead to cover
52# specific options (max fragment length, truncated hmac, etc) or procedures
53# (session resumption from cache or ticket, renego, etc).
54#
55# The tests assume a build with default options, with exceptions expressed
56# with a dependency. The tests focus on functionality and do not consider
57# performance.
58#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010059
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010060set -u
61
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010062# Limit the size of each log to 10 GiB, in case of failures with this script
63# where it may output seemingly unlimited length error logs.
64ulimit -f 20971520
65
Angus Grattonc4dd0732018-04-11 16:28:39 +100066if cd $( dirname $0 ); then :; else
67 echo "cd $( dirname $0 ) failed" >&2
68 exit 1
69fi
70
Antonin Décimod5f47592019-01-23 15:24:37 +010071# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010072: ${P_SRV:=../programs/ssl/ssl_server2}
73: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020074: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010075: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020076: ${GNUTLS_CLI:=gnutls-cli}
77: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020078: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010079
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020080O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010081O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020082G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010083G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020084TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010085
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020086# alternative versions of OpenSSL and GnuTLS (no default path)
87
88if [ -n "${OPENSSL_LEGACY:-}" ]; then
89 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
90 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
91else
92 O_LEGACY_SRV=false
93 O_LEGACY_CLI=false
94fi
95
Paul Elliott19f1f782021-10-13 18:31:07 +010096if [ -n "${OPENSSL_NEXT:-}" ]; then
97 O_NEXT_SRV="$OPENSSL_NEXT s_server -www -cert data_files/server5.crt -key data_files/server5.key"
98 O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client"
99else
100 O_NEXT_SRV=false
101 O_NEXT_CLI=false
102fi
103
Hanno Becker58e9dc32018-08-17 15:53:21 +0100104if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200105 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
106else
107 G_NEXT_SRV=false
108fi
109
Hanno Becker58e9dc32018-08-17 15:53:21 +0100110if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200111 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
112else
113 G_NEXT_CLI=false
114fi
115
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100116TESTS=0
117FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200118SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100119
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000120CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200121
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100122MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100123FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200124EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100125
Paul Bakkere20310a2016-05-10 11:18:17 +0100126SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100127RUN_TEST_NUMBER=''
128
Paul Bakkeracaac852016-05-10 11:47:13 +0100129PRESERVE_LOGS=0
130
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200131# Pick a "unique" server port in the range 10000-19999, and a proxy
132# port which is this plus 10000. Each port number may be independently
133# overridden by a command line option.
134SRV_PORT=$(($$ % 10000 + 10000))
135PXY_PORT=$((SRV_PORT + 10000))
136
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100137print_usage() {
138 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100139 printf " -h|--help\tPrint this help.\n"
140 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200141 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
142 printf " -e|--exclude\tMatching tests are excluded (substring or BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100143 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100144 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100145 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200146 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
147 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100148 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100149}
150
151get_options() {
152 while [ $# -gt 0 ]; do
153 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100154 -f|--filter)
155 shift; FILTER=$1
156 ;;
157 -e|--exclude)
158 shift; EXCLUDE=$1
159 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100160 -m|--memcheck)
161 MEMCHECK=1
162 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100163 -n|--number)
164 shift; RUN_TEST_NUMBER=$1
165 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100166 -s|--show-numbers)
167 SHOW_TEST_NUMBER=1
168 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100169 -p|--preserve-logs)
170 PRESERVE_LOGS=1
171 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200172 --port)
173 shift; SRV_PORT=$1
174 ;;
175 --proxy-port)
176 shift; PXY_PORT=$1
177 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100178 --seed)
179 shift; SEED="$1"
180 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100181 -h|--help)
182 print_usage
183 exit 0
184 ;;
185 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200186 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100187 print_usage
188 exit 1
189 ;;
190 esac
191 shift
192 done
193}
194
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200195# Read boolean configuration options from config.h for easy and quick
196# testing. Skip non-boolean options (with something other than spaces
197# and a comment after "#define SYMBOL"). The variable contains a
198# space-separated list of symbols.
199CONFIGS_ENABLED=" $(<"$CONFIG_H" \
200 sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
201 tr '\n' ' ')"
202
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100203# Skip next test; use this macro to skip tests which are legitimate
204# in theory and expected to be re-introduced at some point, but
205# aren't expected to succeed at the moment due to problems outside
206# our control (such as bugs in other TLS implementations).
207skip_next_test() {
208 SKIP_NEXT="YES"
209}
210
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100211# skip next test if the flag is not enabled in config.h
212requires_config_enabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200213 case $CONFIGS_ENABLED in
214 *" $1 "*) :;;
215 *) SKIP_NEXT="YES";;
216 esac
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100217}
218
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200219# skip next test if the flag is enabled in config.h
220requires_config_disabled() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200221 case $CONFIGS_ENABLED in
222 *" $1 "*) SKIP_NEXT="YES";;
223 esac
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200224}
225
Hanno Becker7c48dd12018-08-28 16:09:22 +0100226get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100227 # This function uses the query_config command line option to query the
228 # required Mbed TLS compile time configuration from the ssl_server2
229 # program. The command will always return a success value if the
230 # configuration is defined and the value will be printed to stdout.
231 #
232 # Note that if the configuration is not defined or is defined to nothing,
233 # the output of this function will be an empty string.
234 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100235}
236
237requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100238 VAL="$( get_config_value_or_default "$1" )"
239 if [ -z "$VAL" ]; then
240 # Should never happen
241 echo "Mbed TLS configuration $1 is not defined"
242 exit 1
243 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100244 SKIP_NEXT="YES"
245 fi
246}
247
248requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100249 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100250 if [ -z "$VAL" ]; then
251 # Should never happen
252 echo "Mbed TLS configuration $1 is not defined"
253 exit 1
254 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100255 SKIP_NEXT="YES"
256 fi
257}
258
Yuto Takanobc632c22021-07-02 13:10:41 +0100259requires_config_value_equals() {
260 VAL=$( get_config_value_or_default "$1" )
261 if [ -z "$VAL" ]; then
262 # Should never happen
263 echo "Mbed TLS configuration $1 is not defined"
264 exit 1
265 elif [ "$VAL" -ne "$2" ]; then
266 SKIP_NEXT="YES"
267 fi
268}
269
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200270# skip next test if OpenSSL doesn't support FALLBACK_SCSV
271requires_openssl_with_fallback_scsv() {
272 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
273 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
274 then
275 OPENSSL_HAS_FBSCSV="YES"
276 else
277 OPENSSL_HAS_FBSCSV="NO"
278 fi
279 fi
280 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
281 SKIP_NEXT="YES"
282 fi
283}
284
Yuto Takano0807e1d2021-07-02 10:10:49 +0100285# skip next test if either IN_CONTENT_LEN or MAX_CONTENT_LEN are below a value
286requires_max_content_len() {
287 requires_config_value_at_least "MBEDTLS_SSL_IN_CONTENT_LEN" $1
288 requires_config_value_at_least "MBEDTLS_SSL_OUT_CONTENT_LEN" $1
289}
290
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200291# skip next test if GnuTLS isn't available
292requires_gnutls() {
293 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200294 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200295 GNUTLS_AVAILABLE="YES"
296 else
297 GNUTLS_AVAILABLE="NO"
298 fi
299 fi
300 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
301 SKIP_NEXT="YES"
302 fi
303}
304
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200305# skip next test if GnuTLS-next isn't available
306requires_gnutls_next() {
307 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
308 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
309 GNUTLS_NEXT_AVAILABLE="YES"
310 else
311 GNUTLS_NEXT_AVAILABLE="NO"
312 fi
313 fi
314 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
315 SKIP_NEXT="YES"
316 fi
317}
318
319# skip next test if OpenSSL-legacy isn't available
320requires_openssl_legacy() {
321 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
322 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
323 OPENSSL_LEGACY_AVAILABLE="YES"
324 else
325 OPENSSL_LEGACY_AVAILABLE="NO"
326 fi
327 fi
328 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
329 SKIP_NEXT="YES"
330 fi
331}
332
Paul Elliott19f1f782021-10-13 18:31:07 +0100333requires_openssl_next() {
334 if [ -z "${OPENSSL_NEXT_AVAILABLE:-}" ]; then
335 if which "${OPENSSL_NEXT:-}" >/dev/null 2>&1; then
336 OPENSSL_NEXT_AVAILABLE="YES"
337 else
338 OPENSSL_NEXT_AVAILABLE="NO"
339 fi
340 fi
341 if [ "$OPENSSL_NEXT_AVAILABLE" = "NO" ]; then
342 SKIP_NEXT="YES"
343 fi
344}
345
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200346# skip next test if IPv6 isn't available on this host
347requires_ipv6() {
348 if [ -z "${HAS_IPV6:-}" ]; then
349 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
350 SRV_PID=$!
351 sleep 1
352 kill $SRV_PID >/dev/null 2>&1
353 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
354 HAS_IPV6="NO"
355 else
356 HAS_IPV6="YES"
357 fi
358 rm -r $SRV_OUT
359 fi
360
361 if [ "$HAS_IPV6" = "NO" ]; then
362 SKIP_NEXT="YES"
363 fi
364}
365
Andrzej Kurekb4593462018-10-11 08:43:30 -0400366# skip next test if it's i686 or uname is not available
367requires_not_i686() {
368 if [ -z "${IS_I686:-}" ]; then
369 IS_I686="YES"
370 if which "uname" >/dev/null 2>&1; then
371 if [ -z "$(uname -a | grep i686)" ]; then
372 IS_I686="NO"
373 fi
374 fi
375 fi
376 if [ "$IS_I686" = "YES" ]; then
377 SKIP_NEXT="YES"
378 fi
379}
380
Angus Grattonc4dd0732018-04-11 16:28:39 +1000381# Calculate the input & output maximum content lengths set in the config
Yuto Takanobbf657a2021-06-22 07:16:40 +0100382MAX_CONTENT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_MAX_CONTENT_LEN" )
383MAX_IN_LEN=$( get_config_value_or_default "MBEDTLS_SSL_IN_CONTENT_LEN" )
384MAX_OUT_LEN=$( get_config_value_or_default "MBEDTLS_SSL_OUT_CONTENT_LEN" )
Angus Grattonc4dd0732018-04-11 16:28:39 +1000385
Yuto Takano2e580ce2021-06-21 19:43:33 +0100386# Calculate the maximum content length that fits both
Angus Grattonc4dd0732018-04-11 16:28:39 +1000387if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
388 MAX_CONTENT_LEN="$MAX_IN_LEN"
389fi
390if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
391 MAX_CONTENT_LEN="$MAX_OUT_LEN"
392fi
393
394# skip the next test if the SSL output buffer is less than 16KB
395requires_full_size_output_buffer() {
396 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
397 SKIP_NEXT="YES"
398 fi
399}
400
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200401# skip the next test if valgrind is in use
402not_with_valgrind() {
403 if [ "$MEMCHECK" -gt 0 ]; then
404 SKIP_NEXT="YES"
405 fi
406}
407
Paul Bakker362689d2016-05-13 10:33:25 +0100408# skip the next test if valgrind is NOT in use
409only_with_valgrind() {
410 if [ "$MEMCHECK" -eq 0 ]; then
411 SKIP_NEXT="YES"
412 fi
413}
414
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200415# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100416client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200417 CLI_DELAY_FACTOR=$1
418}
419
Janos Follath74537a62016-09-02 13:45:28 +0100420# wait for the given seconds after the client finished in the next test
421server_needs_more_time() {
422 SRV_DELAY_SECONDS=$1
423}
424
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100425# print_name <name>
426print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100427 TESTS=$(( $TESTS + 1 ))
428 LINE=""
429
430 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
431 LINE="$TESTS "
432 fi
433
434 LINE="$LINE$1"
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200435 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100436 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100437 for i in `seq 1 $LEN`; do printf '.'; done
438 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100439
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100440}
441
442# fail <message>
443fail() {
444 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100445 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100446
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200447 mv $SRV_OUT o-srv-${TESTS}.log
448 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200449 if [ -n "$PXY_CMD" ]; then
450 mv $PXY_OUT o-pxy-${TESTS}.log
451 fi
452 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100453
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200454 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200455 echo " ! server output:"
456 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200457 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200458 echo " ! client output:"
459 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200460 if [ -n "$PXY_CMD" ]; then
461 echo " ! ========================================================"
462 echo " ! proxy output:"
463 cat o-pxy-${TESTS}.log
464 fi
465 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200466 fi
467
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200468 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100469}
470
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100471# is_polar <cmd_line>
472is_polar() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200473 case "$1" in
474 *ssl_client2*) true;;
475 *ssl_server2*) true;;
476 *) false;;
477 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100478}
479
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200480# openssl s_server doesn't have -www with DTLS
481check_osrv_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200482 case "$SRV_CMD" in
483 *s_server*-dtls*)
484 NEEDS_INPUT=1
485 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
486 *) NEEDS_INPUT=0;;
487 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200488}
489
490# provide input to commands that need it
491provide_input() {
492 if [ $NEEDS_INPUT -eq 0 ]; then
493 return
494 fi
495
496 while true; do
497 echo "HTTP/1.0 200 OK"
498 sleep 1
499 done
500}
501
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100502# has_mem_err <log_file_name>
503has_mem_err() {
504 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
505 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
506 then
507 return 1 # false: does not have errors
508 else
509 return 0 # true: has errors
510 fi
511}
512
Unknown43dc0d62019-09-02 10:42:57 -0400513# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100514if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400515 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100516 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200517 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100518 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200519 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100520 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200521 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100522 # Make a tight loop, server normally takes less than 1s to start.
523 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
524 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400525 echo "$3 START TIMEOUT"
526 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100527 break
528 fi
529 # Linux and *BSD support decimal arguments to sleep. On other
530 # OSes this may be a tight loop.
531 sleep 0.1 2>/dev/null || true
532 done
533 }
534else
Unknown43dc0d62019-09-02 10:42:57 -0400535 echo "Warning: lsof not available, wait_app_start = sleep"
536 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200537 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100538 }
539fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200540
Unknown43dc0d62019-09-02 10:42:57 -0400541# Wait for server process $2 to be listening on port $1.
542wait_server_start() {
543 wait_app_start $1 $2 "SERVER" $SRV_OUT
544}
545
546# Wait for proxy process $2 to be listening on port $1.
547wait_proxy_start() {
548 wait_app_start $1 $2 "PROXY" $PXY_OUT
549}
550
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100551# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100552# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100553# acceptable bounds
554check_server_hello_time() {
555 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100556 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100557 # Get the Unix timestamp for now
558 CUR_TIME=$(date +'%s')
559 THRESHOLD_IN_SECS=300
560
561 # Check if the ServerHello time was printed
562 if [ -z "$SERVER_HELLO_TIME" ]; then
563 return 1
564 fi
565
566 # Check the time in ServerHello is within acceptable bounds
567 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
568 # The time in ServerHello is at least 5 minutes before now
569 return 1
570 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100571 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100572 return 1
573 else
574 return 0
575 fi
576}
577
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200578# wait for client to terminate and set CLI_EXIT
579# must be called right after starting the client
580wait_client_done() {
581 CLI_PID=$!
582
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200583 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
584 CLI_DELAY_FACTOR=1
585
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200586 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200587 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200588
589 wait $CLI_PID
590 CLI_EXIT=$?
591
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200592 kill $DOG_PID >/dev/null 2>&1
593 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200594
595 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100596
597 sleep $SRV_DELAY_SECONDS
598 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200599}
600
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200601# check if the given command uses dtls and sets global variable DTLS
602detect_dtls() {
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200603 case "$1" in
Paul Elliott316a6aa2021-10-12 16:02:55 +0100604 *dtls=1*|*-dtls*|*-u*) DTLS=1;;
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200605 *) DTLS=0;;
606 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200607}
608
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200609# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100610# Options: -s pattern pattern that must be present in server output
611# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100612# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100613# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100614# -S pattern pattern that must be absent in server output
615# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100616# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100617# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100618run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100619 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200620 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100621
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200622 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200623 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100624 return
625 fi
626
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100627 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100628
Paul Bakkerb7584a52016-05-10 10:50:43 +0100629 # Do we only run numbered tests?
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200630 if [ -n "$RUN_TEST_NUMBER" ]; then
631 case ",$RUN_TEST_NUMBER," in
632 *",$TESTS,"*) :;;
633 *) SKIP_NEXT="YES";;
634 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100635 fi
636
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200637 # should we skip?
638 if [ "X$SKIP_NEXT" = "XYES" ]; then
639 SKIP_NEXT="NO"
640 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200641 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200642 return
643 fi
644
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200645 # does this test use a proxy?
646 if [ "X$1" = "X-p" ]; then
647 PXY_CMD="$2"
648 shift 2
649 else
650 PXY_CMD=""
651 fi
652
653 # get commands and client output
654 SRV_CMD="$1"
655 CLI_CMD="$2"
656 CLI_EXPECT="$3"
657 shift 3
658
Hanno Becker7a11e722019-05-10 14:38:42 +0100659 # Check if test uses files
Gilles Peskine5bf15b62020-08-26 21:53:33 +0200660 case "$SRV_CMD $CLI_CMD" in
661 *data_files/*)
662 requires_config_enabled MBEDTLS_FS_IO;;
663 esac
Hanno Becker7a11e722019-05-10 14:38:42 +0100664
665 # should we skip?
666 if [ "X$SKIP_NEXT" = "XYES" ]; then
667 SKIP_NEXT="NO"
668 echo "SKIP"
669 SKIPS=$(( $SKIPS + 1 ))
670 return
671 fi
672
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200673 # update DTLS variable
674 detect_dtls "$SRV_CMD"
675
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200676 # if the test uses DTLS but no custom proxy, add a simple proxy
677 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200678 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200679 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200680 case " $SRV_CMD " in
681 *' server_addr=::1 '*)
682 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
683 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200684 fi
685
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200686 # fix client port
687 if [ -n "$PXY_CMD" ]; then
688 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
689 else
690 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
691 fi
692
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100693 # prepend valgrind to our commands if active
694 if [ "$MEMCHECK" -gt 0 ]; then
695 if is_polar "$SRV_CMD"; then
696 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
697 fi
698 if is_polar "$CLI_CMD"; then
699 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
700 fi
701 fi
702
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200703 TIMES_LEFT=2
704 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200705 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200706
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200707 # run the commands
708 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda1919ad2020-07-27 09:45:32 +0200709 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200710 $PXY_CMD >> $PXY_OUT 2>&1 &
711 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400712 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200713 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200714
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200715 check_osrv_dtls
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200716 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200717 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
718 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100719 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200720
Gilles Peskineffdcadf2020-08-26 20:05:11 +0200721 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200722 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
723 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100724
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100725 sleep 0.05
726
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200727 # terminate the server (and the proxy)
728 kill $SRV_PID
729 wait $SRV_PID
Gilles Peskine634fe272021-02-02 23:29:03 +0100730 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100731
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200732 if [ -n "$PXY_CMD" ]; then
733 kill $PXY_PID >/dev/null 2>&1
734 wait $PXY_PID
735 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100736
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200737 # retry only on timeouts
738 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
739 printf "RETRY "
740 else
741 TIMES_LEFT=0
742 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200743 done
744
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100745 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200746 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100747 # expected client exit to incorrectly succeed in case of catastrophic
748 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100749 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200750 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100751 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100752 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100753 return
754 fi
755 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100756 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200757 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100758 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100759 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100760 return
761 fi
762 fi
763
Gilles Peskine2cf44b62021-02-09 21:01:33 +0100764 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
765 # exit with status 0 when interrupted by a signal, and we don't really
766 # care anyway), in case e.g. the server reports a memory leak.
767 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine634fe272021-02-02 23:29:03 +0100768 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100769 return
770 fi
771
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100772 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100773 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
774 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100775 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200776 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100777 return
778 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100779
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100780 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200781 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100782 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100783 while [ $# -gt 0 ]
784 do
785 case $1 in
786 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100787 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100788 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100789 return
790 fi
791 ;;
792
793 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100794 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then :; else
Simon Butcher8e004102016-10-14 00:48:33 +0100795 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100796 return
797 fi
798 ;;
799
800 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100801 if grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100802 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100803 return
804 fi
805 ;;
806
807 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100808 if grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep "$2" >/dev/null; then
Simon Butcher8e004102016-10-14 00:48:33 +0100809 fail "pattern '$2' MUST NOT be present in the Client output"
810 return
811 fi
812 ;;
813
814 # The filtering in the following two options (-u and -U) do the following
815 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100816 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100817 # - keep one of each non-unique line
818 # - count how many lines remain
819 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
820 # if there were no duplicates.
821 "-U")
822 if [ $(grep -v '^==' $SRV_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
823 fail "lines following pattern '$2' must be unique in Server output"
824 return
825 fi
826 ;;
827
828 "-u")
829 if [ $(grep -v '^==' $CLI_OUT | grep -v 'Serious error when reading debug info' | grep -A1 "$2" | grep -v "$2" | sort | uniq -d | wc -l) -gt 1 ]; then
830 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100831 return
832 fi
833 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100834 "-F")
835 if ! $2 "$SRV_OUT"; then
836 fail "function call to '$2' failed on Server output"
837 return
838 fi
839 ;;
840 "-f")
841 if ! $2 "$CLI_OUT"; then
842 fail "function call to '$2' failed on Client output"
843 return
844 fi
845 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100846
847 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200848 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100849 exit 1
850 esac
851 shift 2
852 done
853
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100854 # check valgrind's results
855 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200856 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100857 fail "Server has memory errors"
858 return
859 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200860 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100861 fail "Client has memory errors"
862 return
863 fi
864 fi
865
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100866 # if we're here, everything is ok
867 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100868 if [ "$PRESERVE_LOGS" -gt 0 ]; then
869 mv $SRV_OUT o-srv-${TESTS}.log
870 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100871 if [ -n "$PXY_CMD" ]; then
872 mv $PXY_OUT o-pxy-${TESTS}.log
873 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100874 fi
875
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200876 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100877}
878
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100879cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200880 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200881 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
882 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
883 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
884 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100885 exit 1
886}
887
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100888#
889# MAIN
890#
891
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100892get_options "$@"
893
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200894# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
895# patterns rather than regular expressions, use a case statement instead
896# of calling grep. To keep the optimizer simple, it is incomplete and only
897# detects simple cases: plain substring, everything, nothing.
898#
899# As an exception, the character '.' is treated as an ordinary character
900# if it is the only special character in the string. This is because it's
901# rare to need "any one character", but needing a literal '.' is common
902# (e.g. '-f "DTLS 1.2"').
903need_grep=
904case "$FILTER" in
905 '^$') simple_filter=;;
906 '.*') simple_filter='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200907 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200908 need_grep=1;;
909 *) # No regexp or shell-pattern special character
910 simple_filter="*$FILTER*";;
911esac
912case "$EXCLUDE" in
913 '^$') simple_exclude=;;
914 '.*') simple_exclude='*';;
Gilles Peskinec5714bb2020-09-29 23:48:39 +0200915 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskineb7bb068b2020-08-26 22:35:46 +0200916 need_grep=1;;
917 *) # No regexp or shell-pattern special character
918 simple_exclude="*$EXCLUDE*";;
919esac
920if [ -n "$need_grep" ]; then
921 is_excluded () {
922 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
923 }
924else
925 is_excluded () {
926 case "$1" in
927 $simple_exclude) true;;
928 $simple_filter) false;;
929 *) true;;
930 esac
931 }
932fi
933
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100934# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100935P_SRV_BIN="${P_SRV%%[ ]*}"
936P_CLI_BIN="${P_CLI%%[ ]*}"
937P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100938if [ ! -x "$P_SRV_BIN" ]; then
939 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100940 exit 1
941fi
Hanno Becker17c04932017-10-10 14:44:53 +0100942if [ ! -x "$P_CLI_BIN" ]; then
943 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100944 exit 1
945fi
Hanno Becker17c04932017-10-10 14:44:53 +0100946if [ ! -x "$P_PXY_BIN" ]; then
947 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200948 exit 1
949fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100950if [ "$MEMCHECK" -gt 0 ]; then
951 if which valgrind >/dev/null 2>&1; then :; else
952 echo "Memcheck not possible. Valgrind not found"
953 exit 1
954 fi
955fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100956if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
957 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100958 exit 1
959fi
960
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200961# used by watchdog
962MAIN_PID="$$"
963
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100964# We use somewhat arbitrary delays for tests:
965# - how long do we wait for the server to start (when lsof not available)?
966# - how long do we allow for the client to finish?
967# (not to check performance, just to avoid waiting indefinitely)
968# Things are slower with valgrind, so give extra time here.
969#
970# Note: without lsof, there is a trade-off between the running time of this
971# script and the risk of spurious errors because we didn't wait long enough.
972# The watchdog delay on the other hand doesn't affect normal running time of
973# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200974if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100975 START_DELAY=6
976 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200977else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100978 START_DELAY=2
979 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200980fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100981
982# some particular tests need more time:
983# - for the client, we multiply the usual watchdog limit by a factor
984# - for the server, we sleep for a number of seconds after the client exits
985# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200986CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100987SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200988
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200989# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000990# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200991P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
992P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100993P_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 +0200994O_SRV="$O_SRV -accept $SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200995O_CLI="$O_CLI -connect localhost:+SRV_PORT"
996G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200997G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200998
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200999if [ -n "${OPENSSL_LEGACY:-}" ]; then
1000 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1001 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1002fi
1003
Paul Elliott19f1f782021-10-13 18:31:07 +01001004if [ -n "${OPENSSL_NEXT:-}" ]; then
1005 O_NEXT_SRV="$O_NEXT_SRV -accept $SRV_PORT"
1006 O_NEXT_CLI="$O_NEXT_CLI -connect localhost:+SRV_PORT"
1007fi
1008
Hanno Becker58e9dc32018-08-17 15:53:21 +01001009if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001010 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1011fi
1012
Hanno Becker58e9dc32018-08-17 15:53:21 +01001013if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001014 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001015fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001016
Gilles Peskine62469d92017-05-10 10:13:59 +02001017# Allow SHA-1, because many of our test certificates use it
1018P_SRV="$P_SRV allow_sha1=1"
1019P_CLI="$P_CLI allow_sha1=1"
1020
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001021# Also pick a unique name for intermediate files
1022SRV_OUT="srv_out.$$"
1023CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001024PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001025SESSION="session.$$"
1026
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001027SKIP_NEXT="NO"
1028
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001029trap cleanup INT TERM HUP
1030
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001031# Basic test
1032
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001033# Checks that:
1034# - things work with all ciphersuites active (used with config-full in all.sh)
1035# - the expected (highest security) parameters are selected
1036# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001037run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001038 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001039 "$P_CLI" \
1040 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001041 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001042 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001043 -s "client hello v3, signature_algorithm ext: 6" \
1044 -s "ECDHE curve: secp521r1" \
1045 -S "error" \
1046 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001047
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001048run_test "Default, DTLS" \
1049 "$P_SRV dtls=1" \
1050 "$P_CLI dtls=1" \
1051 0 \
1052 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001053 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001054
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +01001055requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1056run_test "Default (compression enabled)" \
1057 "$P_SRV debug_level=3" \
1058 "$P_CLI debug_level=3" \
1059 0 \
1060 -s "Allocating compression buffer" \
1061 -c "Allocating compression buffer" \
1062 -s "Record expansion is unknown (compression)" \
1063 -c "Record expansion is unknown (compression)" \
1064 -S "error" \
1065 -C "error"
1066
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001067# Test current time in ServerHello
1068requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001069run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001070 "$P_SRV debug_level=3" \
1071 "$P_CLI debug_level=3" \
1072 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001073 -f "check_server_hello_time" \
1074 -F "check_server_hello_time"
1075
Simon Butcher8e004102016-10-14 00:48:33 +01001076# Test for uniqueness of IVs in AEAD ciphersuites
1077run_test "Unique IV in GCM" \
1078 "$P_SRV exchanges=20 debug_level=4" \
1079 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1080 0 \
1081 -u "IV used" \
1082 -U "IV used"
1083
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001084# Tests for rc4 option
1085
Simon Butchera410af52016-05-19 22:12:18 +01001086requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001087run_test "RC4: server disabled, client enabled" \
1088 "$P_SRV" \
1089 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1090 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001091 -s "SSL - The server has no ciphersuites in common"
1092
Simon Butchera410af52016-05-19 22:12:18 +01001093requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001094run_test "RC4: server half, client enabled" \
1095 "$P_SRV arc4=1" \
1096 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1097 1 \
1098 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001099
1100run_test "RC4: server enabled, client disabled" \
1101 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1102 "$P_CLI" \
1103 1 \
1104 -s "SSL - The server has no ciphersuites in common"
1105
1106run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001107 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001108 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1109 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001110 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001111 -S "SSL - The server has no ciphersuites in common"
1112
Hanno Beckerd26bb202018-08-17 09:54:10 +01001113# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1114
1115requires_gnutls
1116requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1117run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1118 "$G_SRV"\
1119 "$P_CLI force_version=tls1_1" \
1120 0
1121
1122requires_gnutls
1123requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1124run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1125 "$G_SRV"\
1126 "$P_CLI force_version=tls1" \
1127 0
1128
Gilles Peskinebc70a182017-05-09 15:59:24 +02001129# Tests for SHA-1 support
1130
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001131requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001132run_test "SHA-1 forbidden by default in server certificate" \
1133 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1134 "$P_CLI debug_level=2 allow_sha1=0" \
1135 1 \
1136 -c "The certificate is signed with an unacceptable hash"
1137
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001138requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1139run_test "SHA-1 forbidden by default in server certificate" \
1140 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1141 "$P_CLI debug_level=2 allow_sha1=0" \
1142 0
1143
Gilles Peskinebc70a182017-05-09 15:59:24 +02001144run_test "SHA-1 explicitly allowed in server certificate" \
1145 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1146 "$P_CLI allow_sha1=1" \
1147 0
1148
1149run_test "SHA-256 allowed by default in server certificate" \
1150 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1151 "$P_CLI allow_sha1=0" \
1152 0
1153
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001154requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001155run_test "SHA-1 forbidden by default in client certificate" \
1156 "$P_SRV auth_mode=required allow_sha1=0" \
1157 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1158 1 \
1159 -s "The certificate is signed with an unacceptable hash"
1160
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001161requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1162run_test "SHA-1 forbidden by default in client certificate" \
1163 "$P_SRV auth_mode=required allow_sha1=0" \
1164 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1165 0
1166
Gilles Peskinebc70a182017-05-09 15:59:24 +02001167run_test "SHA-1 explicitly allowed in client certificate" \
1168 "$P_SRV auth_mode=required allow_sha1=1" \
1169 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1170 0
1171
1172run_test "SHA-256 allowed by default in client certificate" \
1173 "$P_SRV auth_mode=required allow_sha1=0" \
1174 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1175 0
1176
Hanno Becker7ae8a762018-08-14 15:43:35 +01001177# Tests for datagram packing
1178run_test "DTLS: multiple records in same datagram, client and server" \
1179 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1180 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1181 0 \
1182 -c "next record in same datagram" \
1183 -s "next record in same datagram"
1184
1185run_test "DTLS: multiple records in same datagram, client only" \
1186 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1187 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1188 0 \
1189 -s "next record in same datagram" \
1190 -C "next record in same datagram"
1191
1192run_test "DTLS: multiple records in same datagram, server only" \
1193 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1194 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1195 0 \
1196 -S "next record in same datagram" \
1197 -c "next record in same datagram"
1198
1199run_test "DTLS: multiple records in same datagram, neither client nor server" \
1200 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1201 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1202 0 \
1203 -S "next record in same datagram" \
1204 -C "next record in same datagram"
1205
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001206# Tests for Truncated HMAC extension
1207
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001208run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001209 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001210 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001211 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001212 -s "dumping 'expected mac' (20 bytes)" \
1213 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001214
Hanno Becker32c55012017-11-10 08:42:54 +00001215requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001216run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001217 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001218 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001219 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001220 -s "dumping 'expected mac' (20 bytes)" \
1221 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001222
Hanno Becker32c55012017-11-10 08:42:54 +00001223requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001224run_test "Truncated HMAC: client enabled, server default" \
1225 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001226 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +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é-Gonnarde117a8f2015-01-09 12:39:35 +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 enabled, server disabled" \
1233 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001234 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +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
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001240run_test "Truncated HMAC: client disabled, server enabled" \
1241 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001242 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001243 0 \
1244 -s "dumping 'expected mac' (20 bytes)" \
1245 -S "dumping 'expected mac' (10 bytes)"
1246
1247requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001248run_test "Truncated HMAC: client enabled, server enabled" \
1249 "$P_SRV debug_level=4 trunc_hmac=1" \
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é-Gonnardf7c52012014-02-20 11:43:46 +01001254
Hanno Becker4c4f4102017-11-10 09:16:05 +00001255run_test "Truncated HMAC, DTLS: client default, server default" \
1256 "$P_SRV dtls=1 debug_level=4" \
1257 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1258 0 \
1259 -s "dumping 'expected mac' (20 bytes)" \
1260 -S "dumping 'expected mac' (10 bytes)"
1261
1262requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1263run_test "Truncated HMAC, DTLS: client disabled, server default" \
1264 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001265 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001266 0 \
1267 -s "dumping 'expected mac' (20 bytes)" \
1268 -S "dumping 'expected mac' (10 bytes)"
1269
1270requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1271run_test "Truncated HMAC, DTLS: client enabled, server default" \
1272 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001273 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001274 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 enabled, server disabled" \
1280 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001281 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
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 disabled, server enabled" \
1288 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001289 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
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 enabled" \
1296 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001297 "$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 +01001298 0 \
1299 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001300 -s "dumping 'expected mac' (10 bytes)"
1301
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001302# Tests for Encrypt-then-MAC extension
1303
1304run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001305 "$P_SRV debug_level=3 \
1306 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001307 "$P_CLI debug_level=3" \
1308 0 \
1309 -c "client hello, adding encrypt_then_mac extension" \
1310 -s "found encrypt then mac extension" \
1311 -s "server hello, adding encrypt then mac extension" \
1312 -c "found encrypt_then_mac extension" \
1313 -c "using encrypt then mac" \
1314 -s "using encrypt then mac"
1315
1316run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001317 "$P_SRV debug_level=3 etm=0 \
1318 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001319 "$P_CLI debug_level=3 etm=1" \
1320 0 \
1321 -c "client hello, adding encrypt_then_mac extension" \
1322 -s "found encrypt then mac extension" \
1323 -S "server hello, adding encrypt then mac extension" \
1324 -C "found encrypt_then_mac extension" \
1325 -C "using encrypt then mac" \
1326 -S "using encrypt then mac"
1327
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001328run_test "Encrypt then MAC: client enabled, aead cipher" \
1329 "$P_SRV debug_level=3 etm=1 \
1330 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1331 "$P_CLI debug_level=3 etm=1" \
1332 0 \
1333 -c "client hello, adding encrypt_then_mac extension" \
1334 -s "found encrypt then mac extension" \
1335 -S "server hello, adding encrypt then mac extension" \
1336 -C "found encrypt_then_mac extension" \
1337 -C "using encrypt then mac" \
1338 -S "using encrypt then mac"
1339
1340run_test "Encrypt then MAC: client enabled, stream cipher" \
1341 "$P_SRV debug_level=3 etm=1 \
1342 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001343 "$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 +01001344 0 \
1345 -c "client hello, adding encrypt_then_mac extension" \
1346 -s "found encrypt then mac extension" \
1347 -S "server hello, adding encrypt then mac extension" \
1348 -C "found encrypt_then_mac extension" \
1349 -C "using encrypt then mac" \
1350 -S "using encrypt then mac"
1351
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001352run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001353 "$P_SRV debug_level=3 etm=1 \
1354 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001355 "$P_CLI debug_level=3 etm=0" \
1356 0 \
1357 -C "client hello, adding encrypt_then_mac extension" \
1358 -S "found encrypt then mac extension" \
1359 -S "server hello, adding encrypt then mac extension" \
1360 -C "found encrypt_then_mac extension" \
1361 -C "using encrypt then mac" \
1362 -S "using encrypt then mac"
1363
Janos Follathe2681a42016-03-07 15:57:05 +00001364requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001365run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001366 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001367 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001368 "$P_CLI debug_level=3 force_version=ssl3" \
1369 0 \
1370 -C "client hello, adding encrypt_then_mac extension" \
1371 -S "found encrypt then mac extension" \
1372 -S "server hello, adding encrypt then mac extension" \
1373 -C "found encrypt_then_mac extension" \
1374 -C "using encrypt then mac" \
1375 -S "using encrypt then mac"
1376
Janos Follathe2681a42016-03-07 15:57:05 +00001377requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001378run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001379 "$P_SRV debug_level=3 force_version=ssl3 \
1380 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001381 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001382 0 \
1383 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001384 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001385 -S "server hello, adding encrypt then mac extension" \
1386 -C "found encrypt_then_mac extension" \
1387 -C "using encrypt then mac" \
1388 -S "using encrypt then mac"
1389
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001390# Tests for Extended Master Secret extension
1391
1392run_test "Extended Master Secret: default" \
1393 "$P_SRV debug_level=3" \
1394 "$P_CLI debug_level=3" \
1395 0 \
1396 -c "client hello, adding extended_master_secret extension" \
1397 -s "found extended master secret extension" \
1398 -s "server hello, adding extended master secret extension" \
1399 -c "found extended_master_secret extension" \
1400 -c "using extended master secret" \
1401 -s "using extended master secret"
1402
1403run_test "Extended Master Secret: client enabled, server disabled" \
1404 "$P_SRV debug_level=3 extended_ms=0" \
1405 "$P_CLI debug_level=3 extended_ms=1" \
1406 0 \
1407 -c "client hello, adding extended_master_secret extension" \
1408 -s "found extended master secret extension" \
1409 -S "server hello, adding extended master secret extension" \
1410 -C "found extended_master_secret extension" \
1411 -C "using extended master secret" \
1412 -S "using extended master secret"
1413
1414run_test "Extended Master Secret: client disabled, server enabled" \
1415 "$P_SRV debug_level=3 extended_ms=1" \
1416 "$P_CLI debug_level=3 extended_ms=0" \
1417 0 \
1418 -C "client hello, adding extended_master_secret extension" \
1419 -S "found extended master secret extension" \
1420 -S "server hello, adding extended master secret extension" \
1421 -C "found extended_master_secret extension" \
1422 -C "using extended master secret" \
1423 -S "using extended master secret"
1424
Janos Follathe2681a42016-03-07 15:57:05 +00001425requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001426run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001427 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001428 "$P_CLI debug_level=3 force_version=ssl3" \
1429 0 \
1430 -C "client hello, adding extended_master_secret extension" \
1431 -S "found extended master secret extension" \
1432 -S "server hello, adding extended master secret extension" \
1433 -C "found extended_master_secret extension" \
1434 -C "using extended master secret" \
1435 -S "using extended master secret"
1436
Janos Follathe2681a42016-03-07 15:57:05 +00001437requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001438run_test "Extended Master Secret: client enabled, server SSLv3" \
1439 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001440 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001441 0 \
1442 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001443 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001444 -S "server hello, adding extended master secret extension" \
1445 -C "found extended_master_secret extension" \
1446 -C "using extended master secret" \
1447 -S "using extended master secret"
1448
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001449# Tests for FALLBACK_SCSV
1450
1451run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001452 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001453 "$P_CLI debug_level=3 force_version=tls1_1" \
1454 0 \
1455 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001456 -S "received FALLBACK_SCSV" \
1457 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001458 -C "is a fatal alert message (msg 86)"
1459
1460run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001461 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001462 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1463 0 \
1464 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001465 -S "received FALLBACK_SCSV" \
1466 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001467 -C "is a fatal alert message (msg 86)"
1468
1469run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001470 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001471 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001472 1 \
1473 -c "adding FALLBACK_SCSV" \
1474 -s "received FALLBACK_SCSV" \
1475 -s "inapropriate fallback" \
1476 -c "is a fatal alert message (msg 86)"
1477
1478run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001479 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001480 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001481 0 \
1482 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001483 -s "received FALLBACK_SCSV" \
1484 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001485 -C "is a fatal alert message (msg 86)"
1486
1487requires_openssl_with_fallback_scsv
1488run_test "Fallback SCSV: default, openssl server" \
1489 "$O_SRV" \
1490 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1491 0 \
1492 -C "adding FALLBACK_SCSV" \
1493 -C "is a fatal alert message (msg 86)"
1494
1495requires_openssl_with_fallback_scsv
1496run_test "Fallback SCSV: enabled, openssl server" \
1497 "$O_SRV" \
1498 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1499 1 \
1500 -c "adding FALLBACK_SCSV" \
1501 -c "is a fatal alert message (msg 86)"
1502
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001503requires_openssl_with_fallback_scsv
1504run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001505 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001506 "$O_CLI -tls1_1" \
1507 0 \
1508 -S "received FALLBACK_SCSV" \
1509 -S "inapropriate fallback"
1510
1511requires_openssl_with_fallback_scsv
1512run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001513 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001514 "$O_CLI -tls1_1 -fallback_scsv" \
1515 1 \
1516 -s "received FALLBACK_SCSV" \
1517 -s "inapropriate fallback"
1518
1519requires_openssl_with_fallback_scsv
1520run_test "Fallback SCSV: enabled, max version, 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 -fallback_scsv" \
1523 0 \
1524 -s "received FALLBACK_SCSV" \
1525 -S "inapropriate fallback"
1526
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001527# Test sending and receiving empty application data records
1528
1529run_test "Encrypt then MAC: empty application data record" \
1530 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1531 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1532 0 \
1533 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1534 -s "dumping 'input payload after decrypt' (0 bytes)" \
1535 -c "0 bytes written in 1 fragments"
1536
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001537run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001538 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1539 "$P_CLI auth_mode=none etm=0 request_size=0" \
1540 0 \
1541 -s "dumping 'input payload after decrypt' (0 bytes)" \
1542 -c "0 bytes written in 1 fragments"
1543
1544run_test "Encrypt then MAC, DTLS: empty application data record" \
1545 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1546 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1547 0 \
1548 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1549 -s "dumping 'input payload after decrypt' (0 bytes)" \
1550 -c "0 bytes written in 1 fragments"
1551
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001552run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001553 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1554 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1555 0 \
1556 -s "dumping 'input payload after decrypt' (0 bytes)" \
1557 -c "0 bytes written in 1 fragments"
1558
Gilles Peskined50177f2017-05-16 17:53:03 +02001559## ClientHello generated with
1560## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1561## then manually twiddling the ciphersuite list.
1562## The ClientHello content is spelled out below as a hex string as
1563## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1564## The expected response is an inappropriate_fallback alert.
1565requires_openssl_with_fallback_scsv
1566run_test "Fallback SCSV: beginning of list" \
1567 "$P_SRV debug_level=2" \
1568 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1569 0 \
1570 -s "received FALLBACK_SCSV" \
1571 -s "inapropriate fallback"
1572
1573requires_openssl_with_fallback_scsv
1574run_test "Fallback SCSV: end of list" \
1575 "$P_SRV debug_level=2" \
1576 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1577 0 \
1578 -s "received FALLBACK_SCSV" \
1579 -s "inapropriate fallback"
1580
1581## Here the expected response is a valid ServerHello prefix, up to the random.
1582requires_openssl_with_fallback_scsv
1583run_test "Fallback SCSV: not in list" \
1584 "$P_SRV debug_level=2" \
1585 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1586 0 \
1587 -S "received FALLBACK_SCSV" \
1588 -S "inapropriate fallback"
1589
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001590# Tests for CBC 1/n-1 record splitting
1591
1592run_test "CBC Record splitting: TLS 1.2, no splitting" \
1593 "$P_SRV" \
1594 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1595 request_size=123 force_version=tls1_2" \
1596 0 \
1597 -s "Read from client: 123 bytes read" \
1598 -S "Read from client: 1 bytes read" \
1599 -S "122 bytes read"
1600
1601run_test "CBC Record splitting: TLS 1.1, no splitting" \
1602 "$P_SRV" \
1603 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1604 request_size=123 force_version=tls1_1" \
1605 0 \
1606 -s "Read from client: 123 bytes read" \
1607 -S "Read from client: 1 bytes read" \
1608 -S "122 bytes read"
1609
1610run_test "CBC Record splitting: TLS 1.0, splitting" \
1611 "$P_SRV" \
1612 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1613 request_size=123 force_version=tls1" \
1614 0 \
1615 -S "Read from client: 123 bytes read" \
1616 -s "Read from client: 1 bytes read" \
1617 -s "122 bytes read"
1618
Janos Follathe2681a42016-03-07 15:57:05 +00001619requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001620run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001621 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001622 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1623 request_size=123 force_version=ssl3" \
1624 0 \
1625 -S "Read from client: 123 bytes read" \
1626 -s "Read from client: 1 bytes read" \
1627 -s "122 bytes read"
1628
1629run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001630 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001631 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1632 request_size=123 force_version=tls1" \
1633 0 \
1634 -s "Read from client: 123 bytes read" \
1635 -S "Read from client: 1 bytes read" \
1636 -S "122 bytes read"
1637
1638run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1639 "$P_SRV" \
1640 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1641 request_size=123 force_version=tls1 recsplit=0" \
1642 0 \
1643 -s "Read from client: 123 bytes read" \
1644 -S "Read from client: 1 bytes read" \
1645 -S "122 bytes read"
1646
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001647run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1648 "$P_SRV nbio=2" \
1649 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1650 request_size=123 force_version=tls1" \
1651 0 \
1652 -S "Read from client: 123 bytes read" \
1653 -s "Read from client: 1 bytes read" \
1654 -s "122 bytes read"
1655
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001656# Tests for Session Tickets
1657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001658run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001659 "$P_SRV debug_level=3 tickets=1" \
1660 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001661 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001662 -c "client hello, adding session ticket extension" \
1663 -s "found session ticket extension" \
1664 -s "server hello, adding session ticket extension" \
1665 -c "found session_ticket extension" \
1666 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001667 -S "session successfully restored from cache" \
1668 -s "session successfully restored from ticket" \
1669 -s "a session has been resumed" \
1670 -c "a session has been resumed"
1671
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001672run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001673 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1674 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001675 0 \
1676 -c "client hello, adding session ticket extension" \
1677 -s "found session ticket extension" \
1678 -s "server hello, adding session ticket extension" \
1679 -c "found session_ticket extension" \
1680 -c "parse new session ticket" \
1681 -S "session successfully restored from cache" \
1682 -s "session successfully restored from ticket" \
1683 -s "a session has been resumed" \
1684 -c "a session has been resumed"
1685
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001686run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001687 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1688 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001689 0 \
1690 -c "client hello, adding session ticket extension" \
1691 -s "found session ticket extension" \
1692 -s "server hello, adding session ticket extension" \
1693 -c "found session_ticket extension" \
1694 -c "parse new session ticket" \
1695 -S "session successfully restored from cache" \
1696 -S "session successfully restored from ticket" \
1697 -S "a session has been resumed" \
1698 -C "a session has been resumed"
1699
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001700run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001701 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001702 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001703 0 \
1704 -c "client hello, adding session ticket extension" \
1705 -c "found session_ticket extension" \
1706 -c "parse new session ticket" \
1707 -c "a session has been resumed"
1708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001711 "( $O_CLI -sess_out $SESSION; \
1712 $O_CLI -sess_in $SESSION; \
1713 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001714 0 \
1715 -s "found session ticket extension" \
1716 -s "server hello, adding session ticket extension" \
1717 -S "session successfully restored from cache" \
1718 -s "session successfully restored from ticket" \
1719 -s "a session has been resumed"
1720
Hanno Becker1d739932018-08-21 13:55:22 +01001721# Tests for Session Tickets with DTLS
1722
1723run_test "Session resume using tickets, DTLS: basic" \
1724 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001725 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001726 0 \
1727 -c "client hello, adding session ticket extension" \
1728 -s "found session ticket extension" \
1729 -s "server hello, adding session ticket extension" \
1730 -c "found session_ticket extension" \
1731 -c "parse new session ticket" \
1732 -S "session successfully restored from cache" \
1733 -s "session successfully restored from ticket" \
1734 -s "a session has been resumed" \
1735 -c "a session has been resumed"
1736
1737run_test "Session resume using tickets, DTLS: cache disabled" \
1738 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001739 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001740 0 \
1741 -c "client hello, adding session ticket extension" \
1742 -s "found session ticket extension" \
1743 -s "server hello, adding session ticket extension" \
1744 -c "found session_ticket extension" \
1745 -c "parse new session ticket" \
1746 -S "session successfully restored from cache" \
1747 -s "session successfully restored from ticket" \
1748 -s "a session has been resumed" \
1749 -c "a session has been resumed"
1750
1751run_test "Session resume using tickets, DTLS: timeout" \
1752 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001753 "$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 +01001754 0 \
1755 -c "client hello, adding session ticket extension" \
1756 -s "found session ticket extension" \
1757 -s "server hello, adding session ticket extension" \
1758 -c "found session_ticket extension" \
1759 -c "parse new session ticket" \
1760 -S "session successfully restored from cache" \
1761 -S "session successfully restored from ticket" \
1762 -S "a session has been resumed" \
1763 -C "a session has been resumed"
1764
1765run_test "Session resume using tickets, DTLS: openssl server" \
1766 "$O_SRV -dtls1" \
1767 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1768 0 \
1769 -c "client hello, adding session ticket extension" \
1770 -c "found session_ticket extension" \
1771 -c "parse new session ticket" \
1772 -c "a session has been resumed"
1773
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001774# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001775# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001776requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001777run_test "Session resume using tickets, DTLS: openssl client" \
1778 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001779 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1780 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001781 rm -f $SESSION )" \
1782 0 \
1783 -s "found session ticket extension" \
1784 -s "server hello, adding session ticket extension" \
1785 -S "session successfully restored from cache" \
1786 -s "session successfully restored from ticket" \
1787 -s "a session has been resumed"
1788
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001789# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001791run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001792 "$P_SRV debug_level=3 tickets=0" \
1793 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001794 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001795 -c "client hello, adding session ticket extension" \
1796 -s "found session ticket extension" \
1797 -S "server hello, adding session ticket extension" \
1798 -C "found session_ticket extension" \
1799 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001800 -s "session successfully restored from cache" \
1801 -S "session successfully restored from ticket" \
1802 -s "a session has been resumed" \
1803 -c "a session has been resumed"
1804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001805run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001806 "$P_SRV debug_level=3 tickets=1" \
1807 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001808 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001809 -C "client hello, adding session ticket extension" \
1810 -S "found session ticket extension" \
1811 -S "server hello, adding session ticket extension" \
1812 -C "found session_ticket extension" \
1813 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001814 -s "session successfully restored from cache" \
1815 -S "session successfully restored from ticket" \
1816 -s "a session has been resumed" \
1817 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001819run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001820 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1821 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001822 0 \
1823 -S "session successfully restored from cache" \
1824 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001825 -S "a session has been resumed" \
1826 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001828run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001829 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1830 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001831 0 \
1832 -s "session successfully restored from cache" \
1833 -S "session successfully restored from ticket" \
1834 -s "a session has been resumed" \
1835 -c "a session has been resumed"
1836
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001837run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001838 "$P_SRV debug_level=3 tickets=0" \
1839 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001840 0 \
1841 -s "session successfully restored from cache" \
1842 -S "session successfully restored from ticket" \
1843 -s "a session has been resumed" \
1844 -c "a session has been resumed"
1845
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001846run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001847 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1848 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001849 0 \
1850 -S "session successfully restored from cache" \
1851 -S "session successfully restored from ticket" \
1852 -S "a session has been resumed" \
1853 -C "a session has been resumed"
1854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001855run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001856 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1857 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001858 0 \
1859 -s "session successfully restored from cache" \
1860 -S "session successfully restored from ticket" \
1861 -s "a session has been resumed" \
1862 -c "a session has been resumed"
1863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001864run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001865 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001866 "( $O_CLI -sess_out $SESSION; \
1867 $O_CLI -sess_in $SESSION; \
1868 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001869 0 \
1870 -s "found session ticket extension" \
1871 -S "server hello, adding session ticket extension" \
1872 -s "session successfully restored from cache" \
1873 -S "session successfully restored from ticket" \
1874 -s "a session has been resumed"
1875
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001876run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001877 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001878 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001879 0 \
1880 -C "found session_ticket extension" \
1881 -C "parse new session ticket" \
1882 -c "a session has been resumed"
1883
Hanno Becker1d739932018-08-21 13:55:22 +01001884# Tests for Session Resume based on session-ID and cache, DTLS
1885
1886run_test "Session resume using cache, DTLS: tickets enabled on client" \
1887 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001888 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001889 0 \
1890 -c "client hello, adding session ticket extension" \
1891 -s "found session ticket extension" \
1892 -S "server hello, adding session ticket extension" \
1893 -C "found session_ticket extension" \
1894 -C "parse new session ticket" \
1895 -s "session successfully restored from cache" \
1896 -S "session successfully restored from ticket" \
1897 -s "a session has been resumed" \
1898 -c "a session has been resumed"
1899
1900run_test "Session resume using cache, DTLS: tickets enabled on server" \
1901 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001902 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001903 0 \
1904 -C "client hello, adding session ticket extension" \
1905 -S "found session ticket extension" \
1906 -S "server hello, adding session ticket extension" \
1907 -C "found session_ticket extension" \
1908 -C "parse new session ticket" \
1909 -s "session successfully restored from cache" \
1910 -S "session successfully restored from ticket" \
1911 -s "a session has been resumed" \
1912 -c "a session has been resumed"
1913
1914run_test "Session resume using cache, DTLS: cache_max=0" \
1915 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001916 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001917 0 \
1918 -S "session successfully restored from cache" \
1919 -S "session successfully restored from ticket" \
1920 -S "a session has been resumed" \
1921 -C "a session has been resumed"
1922
1923run_test "Session resume using cache, DTLS: cache_max=1" \
1924 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001925 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001926 0 \
1927 -s "session successfully restored from cache" \
1928 -S "session successfully restored from ticket" \
1929 -s "a session has been resumed" \
1930 -c "a session has been resumed"
1931
1932run_test "Session resume using cache, DTLS: timeout > delay" \
1933 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001934 "$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 +01001935 0 \
1936 -s "session successfully restored from cache" \
1937 -S "session successfully restored from ticket" \
1938 -s "a session has been resumed" \
1939 -c "a session has been resumed"
1940
1941run_test "Session resume using cache, DTLS: timeout < delay" \
1942 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001943 "$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 +01001944 0 \
1945 -S "session successfully restored from cache" \
1946 -S "session successfully restored from ticket" \
1947 -S "a session has been resumed" \
1948 -C "a session has been resumed"
1949
1950run_test "Session resume using cache, DTLS: no timeout" \
1951 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001952 "$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 +01001953 0 \
1954 -s "session successfully restored from cache" \
1955 -S "session successfully restored from ticket" \
1956 -s "a session has been resumed" \
1957 -c "a session has been resumed"
1958
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001959# For reasons that aren't fully understood, this test randomly fails with high
Paul Elliott6c649832021-10-13 16:13:44 +01001960# probability with OpenSSL 1.0.2g on the CI, see #5012.
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001961requires_openssl_next
Hanno Becker1d739932018-08-21 13:55:22 +01001962run_test "Session resume using cache, DTLS: openssl client" \
1963 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnarda4700752021-10-13 13:12:47 +02001964 "( $O_NEXT_CLI -dtls1 -sess_out $SESSION; \
1965 $O_NEXT_CLI -dtls1 -sess_in $SESSION; \
Hanno Becker1d739932018-08-21 13:55:22 +01001966 rm -f $SESSION )" \
1967 0 \
1968 -s "found session ticket extension" \
1969 -S "server hello, adding session ticket extension" \
1970 -s "session successfully restored from cache" \
1971 -S "session successfully restored from ticket" \
1972 -s "a session has been resumed"
1973
1974run_test "Session resume using cache, DTLS: openssl server" \
1975 "$O_SRV -dtls1" \
1976 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1977 0 \
1978 -C "found session_ticket extension" \
1979 -C "parse new session ticket" \
1980 -c "a session has been resumed"
1981
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001982# Tests for Max Fragment Length extension
1983
Hanno Becker4aed27e2017-09-18 15:00:34 +01001984requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001985run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001986 "$P_SRV debug_level=3" \
1987 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001988 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001989 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1990 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001991 -C "client hello, adding max_fragment_length extension" \
1992 -S "found max fragment length extension" \
1993 -S "server hello, max_fragment_length extension" \
1994 -C "found max_fragment_length extension"
1995
Hanno Becker4aed27e2017-09-18 15:00:34 +01001996requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001997run_test "Max fragment length: enabled, default, larger message" \
1998 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001999 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002000 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002001 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2002 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002003 -C "client hello, adding max_fragment_length extension" \
2004 -S "found max fragment length extension" \
2005 -S "server hello, max_fragment_length extension" \
2006 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002007 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2008 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002009 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002010
2011requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2012run_test "Max fragment length, DTLS: enabled, default, larger message" \
2013 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002014 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002015 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002016 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
2017 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002018 -C "client hello, adding max_fragment_length extension" \
2019 -S "found max fragment length extension" \
2020 -S "server hello, max_fragment_length extension" \
2021 -C "found max_fragment_length extension" \
2022 -c "fragment larger than.*maximum "
2023
Angus Grattonc4dd0732018-04-11 16:28:39 +10002024# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2025# (session fragment length will be 16384 regardless of mbedtls
2026# content length configuration.)
2027
Hanno Beckerc5266962017-09-18 15:01:50 +01002028requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2029run_test "Max fragment length: disabled, larger message" \
2030 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002031 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002032 0 \
2033 -C "Maximum fragment length is 16384" \
2034 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002035 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2036 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002037 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002038
2039requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takano2e580ce2021-06-21 19:43:33 +01002040run_test "Max fragment length, DTLS: disabled, larger message" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002041 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002042 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002043 1 \
2044 -C "Maximum fragment length is 16384" \
2045 -S "Maximum fragment length is 16384" \
2046 -c "fragment larger than.*maximum "
2047
Yuto Takano0807e1d2021-07-02 10:10:49 +01002048requires_max_content_len 4096
Hanno Beckerc5266962017-09-18 15:01:50 +01002049requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002050run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002051 "$P_SRV debug_level=3" \
2052 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002053 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002054 -c "Maximum fragment length is 4096" \
2055 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002056 -c "client hello, adding max_fragment_length extension" \
2057 -s "found max fragment length extension" \
2058 -s "server hello, max_fragment_length extension" \
2059 -c "found max_fragment_length extension"
2060
Yuto Takano0807e1d2021-07-02 10:10:49 +01002061requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002062requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002063run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002064 "$P_SRV debug_level=3 max_frag_len=4096" \
2065 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002066 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002067 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002068 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002069 -C "client hello, adding max_fragment_length extension" \
2070 -S "found max fragment length extension" \
2071 -S "server hello, max_fragment_length extension" \
2072 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002073
Yuto Takano0807e1d2021-07-02 10:10:49 +01002074requires_max_content_len 4096
Hanno Becker4aed27e2017-09-18 15:00:34 +01002075requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002076requires_gnutls
2077run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002078 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002079 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002080 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002081 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02002082 -c "client hello, adding max_fragment_length extension" \
2083 -c "found max_fragment_length extension"
2084
Yuto Takano0807e1d2021-07-02 10:10:49 +01002085requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002086requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002087run_test "Max fragment length: client, message just fits" \
2088 "$P_SRV debug_level=3" \
2089 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
2090 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002091 -c "Maximum fragment length is 2048" \
2092 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002093 -c "client hello, adding max_fragment_length extension" \
2094 -s "found max fragment length extension" \
2095 -s "server hello, max_fragment_length extension" \
2096 -c "found max_fragment_length extension" \
2097 -c "2048 bytes written in 1 fragments" \
2098 -s "2048 bytes read"
2099
Yuto Takano0807e1d2021-07-02 10:10:49 +01002100requires_max_content_len 2048
Hanno Becker4aed27e2017-09-18 15:00:34 +01002101requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002102run_test "Max fragment length: client, larger message" \
2103 "$P_SRV debug_level=3" \
2104 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2105 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002106 -c "Maximum fragment length is 2048" \
2107 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002108 -c "client hello, adding max_fragment_length extension" \
2109 -s "found max fragment length extension" \
2110 -s "server hello, max_fragment_length extension" \
2111 -c "found max_fragment_length extension" \
2112 -c "2345 bytes written in 2 fragments" \
2113 -s "2048 bytes read" \
2114 -s "297 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é-Gonnard23eb74d2015-01-21 14:37:13 +00002118run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002119 "$P_SRV debug_level=3 dtls=1" \
2120 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2121 1 \
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 "fragment larger than.*maximum"
2129
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002130# Tests for renegotiation
2131
Hanno Becker6a243642017-10-12 15:18:45 +01002132# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002133run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002134 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002135 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002136 0 \
2137 -C "client hello, adding renegotiation extension" \
2138 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2139 -S "found renegotiation extension" \
2140 -s "server hello, secure renegotiation extension" \
2141 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002142 -C "=> renegotiate" \
2143 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002144 -S "write hello request"
2145
Hanno Becker6a243642017-10-12 15:18:45 +01002146requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002147run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002148 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002149 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002150 0 \
2151 -c "client hello, adding renegotiation extension" \
2152 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2153 -s "found renegotiation extension" \
2154 -s "server hello, secure renegotiation extension" \
2155 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002156 -c "=> renegotiate" \
2157 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002158 -S "write hello request"
2159
Hanno Becker6a243642017-10-12 15:18:45 +01002160requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002161run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002162 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002163 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002164 0 \
2165 -c "client hello, adding renegotiation extension" \
2166 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2167 -s "found renegotiation extension" \
2168 -s "server hello, secure renegotiation extension" \
2169 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002170 -c "=> renegotiate" \
2171 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002172 -s "write hello request"
2173
Janos Follathb0f148c2017-10-05 12:29:42 +01002174# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2175# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2176# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002177requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002178run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2179 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2180 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2181 0 \
2182 -c "client hello, adding renegotiation extension" \
2183 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2184 -s "found renegotiation extension" \
2185 -s "server hello, secure renegotiation extension" \
2186 -c "found renegotiation extension" \
2187 -c "=> renegotiate" \
2188 -s "=> renegotiate" \
2189 -S "write hello request" \
2190 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2191
2192# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2193# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2194# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002195requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002196run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2197 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2198 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2199 0 \
2200 -c "client hello, adding renegotiation extension" \
2201 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2202 -s "found renegotiation extension" \
2203 -s "server hello, secure renegotiation extension" \
2204 -c "found renegotiation extension" \
2205 -c "=> renegotiate" \
2206 -s "=> renegotiate" \
2207 -s "write hello request" \
2208 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2209
Hanno Becker6a243642017-10-12 15:18:45 +01002210requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002211run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002212 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002213 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002214 0 \
2215 -c "client hello, adding renegotiation extension" \
2216 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2217 -s "found renegotiation extension" \
2218 -s "server hello, secure renegotiation extension" \
2219 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002220 -c "=> renegotiate" \
2221 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002222 -s "write hello request"
2223
Hanno Becker6a243642017-10-12 15:18:45 +01002224requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002225run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002226 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002227 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002228 1 \
2229 -c "client hello, adding renegotiation extension" \
2230 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2231 -S "found renegotiation extension" \
2232 -s "server hello, secure renegotiation extension" \
2233 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002234 -c "=> renegotiate" \
2235 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002236 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002237 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002238 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002239
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: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002242 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002243 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002244 0 \
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é-Gonnard780d6712014-02-20 17:19:59 +01002252 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002253 -S "SSL - An unexpected message was received from our peer" \
2254 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +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, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002258 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002259 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002260 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002261 0 \
2262 -C "client hello, adding renegotiation extension" \
2263 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2264 -S "found renegotiation extension" \
2265 -s "server hello, secure renegotiation extension" \
2266 -c "found renegotiation extension" \
2267 -C "=> renegotiate" \
2268 -S "=> renegotiate" \
2269 -s "write hello request" \
2270 -S "SSL - An unexpected message was received from our peer" \
2271 -S "failed"
2272
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002273# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002274requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002275run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002276 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002277 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002278 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002279 0 \
2280 -C "client hello, adding renegotiation extension" \
2281 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2282 -S "found renegotiation extension" \
2283 -s "server hello, secure renegotiation extension" \
2284 -c "found renegotiation extension" \
2285 -C "=> renegotiate" \
2286 -S "=> renegotiate" \
2287 -s "write hello request" \
2288 -S "SSL - An unexpected message was received from our peer" \
2289 -S "failed"
2290
Hanno Becker6a243642017-10-12 15:18:45 +01002291requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002292run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002293 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002294 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002295 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002296 0 \
2297 -C "client hello, adding renegotiation extension" \
2298 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2299 -S "found renegotiation extension" \
2300 -s "server hello, secure renegotiation extension" \
2301 -c "found renegotiation extension" \
2302 -C "=> renegotiate" \
2303 -S "=> renegotiate" \
2304 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002305 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002306
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-accepted, 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=1" \
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" \
2321 -S "SSL - An unexpected message was received from our peer" \
2322 -S "failed"
2323
Hanno Becker6a243642017-10-12 15:18:45 +01002324requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002325run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002326 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002327 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2328 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 -S "record counter limit reached: renegotiate" \
2335 -C "=> renegotiate" \
2336 -S "=> renegotiate" \
2337 -S "write hello request" \
2338 -S "SSL - An unexpected message was received from our peer" \
2339 -S "failed"
2340
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002341# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002342requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002343run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002344 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002345 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002346 0 \
2347 -c "client hello, adding renegotiation extension" \
2348 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2349 -s "found renegotiation extension" \
2350 -s "server hello, secure renegotiation extension" \
2351 -c "found renegotiation extension" \
2352 -s "record counter limit reached: renegotiate" \
2353 -c "=> renegotiate" \
2354 -s "=> renegotiate" \
2355 -s "write hello request" \
2356 -S "SSL - An unexpected message was received from our peer" \
2357 -S "failed"
2358
Hanno Becker6a243642017-10-12 15:18:45 +01002359requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002360run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002361 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002362 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002363 0 \
2364 -c "client hello, adding renegotiation extension" \
2365 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2366 -s "found renegotiation extension" \
2367 -s "server hello, secure renegotiation extension" \
2368 -c "found renegotiation extension" \
2369 -s "record counter limit reached: renegotiate" \
2370 -c "=> renegotiate" \
2371 -s "=> renegotiate" \
2372 -s "write hello request" \
2373 -S "SSL - An unexpected message was received from our peer" \
2374 -S "failed"
2375
Hanno Becker6a243642017-10-12 15:18:45 +01002376requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002377run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002378 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002379 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2380 0 \
2381 -C "client hello, adding renegotiation extension" \
2382 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2383 -S "found renegotiation extension" \
2384 -s "server hello, secure renegotiation extension" \
2385 -c "found renegotiation extension" \
2386 -S "record counter limit reached: renegotiate" \
2387 -C "=> renegotiate" \
2388 -S "=> renegotiate" \
2389 -S "write hello request" \
2390 -S "SSL - An unexpected message was received from our peer" \
2391 -S "failed"
2392
Hanno Becker6a243642017-10-12 15:18:45 +01002393requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002394run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002395 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002396 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002397 0 \
2398 -c "client hello, adding renegotiation extension" \
2399 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2400 -s "found renegotiation extension" \
2401 -s "server hello, secure renegotiation extension" \
2402 -c "found renegotiation extension" \
2403 -c "=> renegotiate" \
2404 -s "=> renegotiate" \
2405 -S "write hello request"
2406
Hanno Becker6a243642017-10-12 15:18:45 +01002407requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002408run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002409 "$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 +02002410 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002411 0 \
2412 -c "client hello, adding renegotiation extension" \
2413 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2414 -s "found renegotiation extension" \
2415 -s "server hello, secure renegotiation extension" \
2416 -c "found renegotiation extension" \
2417 -c "=> renegotiate" \
2418 -s "=> renegotiate" \
2419 -s "write hello request"
2420
Hanno Becker6a243642017-10-12 15:18:45 +01002421requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002422run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002423 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002424 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002425 0 \
2426 -c "client hello, adding renegotiation extension" \
2427 -c "found renegotiation extension" \
2428 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002429 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002430 -C "error" \
2431 -c "HTTP/1.0 200 [Oo][Kk]"
2432
Paul Bakker539d9722015-02-08 16:18:35 +01002433requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002434requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002435run_test "Renegotiation: gnutls server strict, client-initiated" \
2436 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002437 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002438 0 \
2439 -c "client hello, adding renegotiation extension" \
2440 -c "found renegotiation extension" \
2441 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002442 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002443 -C "error" \
2444 -c "HTTP/1.0 200 [Oo][Kk]"
2445
Paul Bakker539d9722015-02-08 16:18:35 +01002446requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002447requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002448run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2449 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2450 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2451 1 \
2452 -c "client hello, adding renegotiation extension" \
2453 -C "found renegotiation extension" \
2454 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002455 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002456 -c "error" \
2457 -C "HTTP/1.0 200 [Oo][Kk]"
2458
Paul Bakker539d9722015-02-08 16:18:35 +01002459requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002460requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002461run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2462 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2463 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2464 allow_legacy=0" \
2465 1 \
2466 -c "client hello, adding renegotiation extension" \
2467 -C "found renegotiation extension" \
2468 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002469 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002470 -c "error" \
2471 -C "HTTP/1.0 200 [Oo][Kk]"
2472
Paul Bakker539d9722015-02-08 16:18:35 +01002473requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002474requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002475run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2476 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2477 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2478 allow_legacy=1" \
2479 0 \
2480 -c "client hello, adding renegotiation extension" \
2481 -C "found renegotiation extension" \
2482 -c "=> renegotiate" \
2483 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002484 -C "error" \
2485 -c "HTTP/1.0 200 [Oo][Kk]"
2486
Hanno Becker6a243642017-10-12 15:18:45 +01002487requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002488run_test "Renegotiation: DTLS, client-initiated" \
2489 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2490 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2491 0 \
2492 -c "client hello, adding renegotiation extension" \
2493 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2494 -s "found renegotiation extension" \
2495 -s "server hello, secure renegotiation extension" \
2496 -c "found renegotiation extension" \
2497 -c "=> renegotiate" \
2498 -s "=> renegotiate" \
2499 -S "write hello request"
2500
Hanno Becker6a243642017-10-12 15:18:45 +01002501requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002502run_test "Renegotiation: DTLS, server-initiated" \
2503 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002504 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2505 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002506 0 \
2507 -c "client hello, adding renegotiation extension" \
2508 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2509 -s "found renegotiation extension" \
2510 -s "server hello, secure renegotiation extension" \
2511 -c "found renegotiation extension" \
2512 -c "=> renegotiate" \
2513 -s "=> renegotiate" \
2514 -s "write hello request"
2515
Hanno Becker6a243642017-10-12 15:18:45 +01002516requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002517run_test "Renegotiation: DTLS, renego_period overflow" \
2518 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2519 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2520 0 \
2521 -c "client hello, adding renegotiation extension" \
2522 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2523 -s "found renegotiation extension" \
2524 -s "server hello, secure renegotiation extension" \
2525 -s "record counter limit reached: renegotiate" \
2526 -c "=> renegotiate" \
2527 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002528 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002529
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002530requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002531requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002532run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2533 "$G_SRV -u --mtu 4096" \
2534 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2535 0 \
2536 -c "client hello, adding renegotiation extension" \
2537 -c "found renegotiation extension" \
2538 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002539 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002540 -C "error" \
2541 -s "Extra-header:"
2542
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002543# Test for the "secure renegotation" extension only (no actual renegotiation)
2544
Paul Bakker539d9722015-02-08 16:18:35 +01002545requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002546run_test "Renego ext: gnutls server strict, client default" \
2547 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2548 "$P_CLI debug_level=3" \
2549 0 \
2550 -c "found renegotiation extension" \
2551 -C "error" \
2552 -c "HTTP/1.0 200 [Oo][Kk]"
2553
Paul Bakker539d9722015-02-08 16:18:35 +01002554requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002555run_test "Renego ext: gnutls server unsafe, client default" \
2556 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2557 "$P_CLI debug_level=3" \
2558 0 \
2559 -C "found renegotiation extension" \
2560 -C "error" \
2561 -c "HTTP/1.0 200 [Oo][Kk]"
2562
Paul Bakker539d9722015-02-08 16:18:35 +01002563requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002564run_test "Renego ext: gnutls server unsafe, client break legacy" \
2565 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2566 "$P_CLI debug_level=3 allow_legacy=-1" \
2567 1 \
2568 -C "found renegotiation extension" \
2569 -c "error" \
2570 -C "HTTP/1.0 200 [Oo][Kk]"
2571
Paul Bakker539d9722015-02-08 16:18:35 +01002572requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002573run_test "Renego ext: gnutls client strict, server default" \
2574 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002575 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002576 0 \
2577 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2578 -s "server hello, secure renegotiation extension"
2579
Paul Bakker539d9722015-02-08 16:18:35 +01002580requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002581run_test "Renego ext: gnutls client unsafe, server default" \
2582 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002583 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002584 0 \
2585 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2586 -S "server hello, secure renegotiation extension"
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 unsafe, server break legacy" \
2590 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002591 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002592 1 \
2593 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2594 -S "server hello, secure renegotiation extension"
2595
Janos Follath0b242342016-02-17 10:11:21 +00002596# Tests for silently dropping trailing extra bytes in .der certificates
2597
2598requires_gnutls
2599run_test "DER format: no trailing bytes" \
2600 "$P_SRV crt_file=data_files/server5-der0.crt \
2601 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002602 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002603 0 \
2604 -c "Handshake was completed" \
2605
2606requires_gnutls
2607run_test "DER format: with a trailing zero byte" \
2608 "$P_SRV crt_file=data_files/server5-der1a.crt \
2609 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002610 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002611 0 \
2612 -c "Handshake was completed" \
2613
2614requires_gnutls
2615run_test "DER format: with a trailing random byte" \
2616 "$P_SRV crt_file=data_files/server5-der1b.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 2 trailing random bytes" \
2624 "$P_SRV crt_file=data_files/server5-der2.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 4 trailing random bytes" \
2632 "$P_SRV crt_file=data_files/server5-der4.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 8 trailing random bytes" \
2640 "$P_SRV crt_file=data_files/server5-der8.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 9 trailing random bytes" \
2648 "$P_SRV crt_file=data_files/server5-der9.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
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002654# Tests for auth_mode
2655
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002656run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002657 "$P_SRV crt_file=data_files/server5-badsign.crt \
2658 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002659 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002660 1 \
2661 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002662 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002663 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002664 -c "X509 - Certificate verification failed"
2665
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002666run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002667 "$P_SRV crt_file=data_files/server5-badsign.crt \
2668 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002669 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002670 0 \
2671 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002672 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002673 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002674 -C "X509 - Certificate verification failed"
2675
Hanno Beckere6706e62017-05-15 16:05:15 +01002676run_test "Authentication: server goodcert, client optional, no trusted CA" \
2677 "$P_SRV" \
2678 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2679 0 \
2680 -c "x509_verify_cert() returned" \
2681 -c "! The certificate is not correctly signed by the trusted CA" \
2682 -c "! Certificate verification flags"\
2683 -C "! mbedtls_ssl_handshake returned" \
2684 -C "X509 - Certificate verification failed" \
2685 -C "SSL - No CA Chain is set, but required to operate"
2686
2687run_test "Authentication: server goodcert, client required, no trusted CA" \
2688 "$P_SRV" \
2689 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2690 1 \
2691 -c "x509_verify_cert() returned" \
2692 -c "! The certificate is not correctly signed by the trusted CA" \
2693 -c "! Certificate verification flags"\
2694 -c "! mbedtls_ssl_handshake returned" \
2695 -c "SSL - No CA Chain is set, but required to operate"
2696
2697# The purpose of the next two tests is to test the client's behaviour when receiving a server
2698# certificate with an unsupported elliptic curve. This should usually not happen because
2699# the client informs the server about the supported curves - it does, though, in the
2700# corner case of a static ECDH suite, because the server doesn't check the curve on that
2701# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2702# different means to have the server ignoring the client's supported curve list.
2703
2704requires_config_enabled MBEDTLS_ECP_C
2705run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2706 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2707 crt_file=data_files/server5.ku-ka.crt" \
2708 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2709 1 \
2710 -c "bad certificate (EC key curve)"\
2711 -c "! Certificate verification flags"\
2712 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2713
2714requires_config_enabled MBEDTLS_ECP_C
2715run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2716 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2717 crt_file=data_files/server5.ku-ka.crt" \
2718 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2719 1 \
2720 -c "bad certificate (EC key curve)"\
2721 -c "! Certificate verification flags"\
2722 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002724run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002725 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002726 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002727 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002728 0 \
2729 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002730 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002731 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002732 -C "X509 - Certificate verification failed"
2733
Simon Butcher99000142016-10-13 17:21:01 +01002734run_test "Authentication: client SHA256, server required" \
2735 "$P_SRV auth_mode=required" \
2736 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2737 key_file=data_files/server6.key \
2738 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2739 0 \
2740 -c "Supported Signature Algorithm found: 4," \
2741 -c "Supported Signature Algorithm found: 5,"
2742
2743run_test "Authentication: client SHA384, server required" \
2744 "$P_SRV auth_mode=required" \
2745 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2746 key_file=data_files/server6.key \
2747 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2748 0 \
2749 -c "Supported Signature Algorithm found: 4," \
2750 -c "Supported Signature Algorithm found: 5,"
2751
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002752requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2753run_test "Authentication: client has no cert, server required (SSLv3)" \
2754 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2755 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2756 key_file=data_files/server5.key" \
2757 1 \
2758 -S "skip write certificate request" \
2759 -C "skip parse certificate request" \
2760 -c "got a certificate request" \
2761 -c "got no certificate to send" \
2762 -S "x509_verify_cert() returned" \
2763 -s "client has no certificate" \
2764 -s "! mbedtls_ssl_handshake returned" \
2765 -c "! mbedtls_ssl_handshake returned" \
2766 -s "No client certification received from the client, but required by the authentication mode"
2767
2768run_test "Authentication: client has no cert, server required (TLS)" \
2769 "$P_SRV debug_level=3 auth_mode=required" \
2770 "$P_CLI debug_level=3 crt_file=none \
2771 key_file=data_files/server5.key" \
2772 1 \
2773 -S "skip write certificate request" \
2774 -C "skip parse certificate request" \
2775 -c "got a certificate request" \
2776 -c "= write certificate$" \
2777 -C "skip write certificate$" \
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002784run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_SRV debug_level=3 auth_mode=required" \
2786 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002787 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 "skip write certificate" \
2793 -C "skip write certificate verify" \
2794 -S "skip parse certificate verify" \
2795 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002796 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002797 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002798 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002799 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002800 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002801# We don't check that the client receives the alert because it might
2802# detect that its write end of the connection is closed and abort
2803# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002804
Janos Follath89baba22017-04-10 14:34:35 +01002805run_test "Authentication: client cert not trusted, server required" \
2806 "$P_SRV debug_level=3 auth_mode=required" \
2807 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2808 key_file=data_files/server5.key" \
2809 1 \
2810 -S "skip write certificate request" \
2811 -C "skip parse certificate request" \
2812 -c "got a certificate request" \
2813 -C "skip write certificate" \
2814 -C "skip write certificate verify" \
2815 -S "skip parse certificate verify" \
2816 -s "x509_verify_cert() returned" \
2817 -s "! The certificate is not correctly signed by the trusted CA" \
2818 -s "! mbedtls_ssl_handshake returned" \
2819 -c "! mbedtls_ssl_handshake returned" \
2820 -s "X509 - Certificate verification failed"
2821
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002822run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002823 "$P_SRV debug_level=3 auth_mode=optional" \
2824 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002825 key_file=data_files/server5.key" \
2826 0 \
2827 -S "skip write certificate request" \
2828 -C "skip parse certificate request" \
2829 -c "got a certificate request" \
2830 -C "skip write certificate" \
2831 -C "skip write certificate verify" \
2832 -S "skip parse certificate verify" \
2833 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002834 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002835 -S "! mbedtls_ssl_handshake returned" \
2836 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002837 -S "X509 - Certificate verification failed"
2838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002839run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002840 "$P_SRV debug_level=3 auth_mode=none" \
2841 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002842 key_file=data_files/server5.key" \
2843 0 \
2844 -s "skip write certificate request" \
2845 -C "skip parse certificate request" \
2846 -c "got no certificate request" \
2847 -c "skip write certificate" \
2848 -c "skip write certificate verify" \
2849 -s "skip parse certificate verify" \
2850 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002851 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002852 -S "! mbedtls_ssl_handshake returned" \
2853 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002854 -S "X509 - Certificate verification failed"
2855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002856run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002857 "$P_SRV debug_level=3 auth_mode=optional" \
2858 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002859 0 \
2860 -S "skip write certificate request" \
2861 -C "skip parse certificate request" \
2862 -c "got a certificate request" \
2863 -C "skip write certificate$" \
2864 -C "got no certificate to send" \
2865 -S "SSLv3 client has no certificate" \
2866 -c "skip write certificate verify" \
2867 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002868 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002869 -S "! mbedtls_ssl_handshake returned" \
2870 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002871 -S "X509 - Certificate verification failed"
2872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002873run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002874 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002875 "$O_CLI" \
2876 0 \
2877 -S "skip write certificate request" \
2878 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002879 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002880 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002881 -S "X509 - Certificate verification failed"
2882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002883run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002884 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002885 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002886 0 \
2887 -C "skip parse certificate request" \
2888 -c "got a certificate request" \
2889 -C "skip write certificate$" \
2890 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002891 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002892
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002893run_test "Authentication: client no cert, openssl server required" \
2894 "$O_SRV -Verify 10" \
2895 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2896 1 \
2897 -C "skip parse certificate request" \
2898 -c "got a certificate request" \
2899 -C "skip write certificate$" \
2900 -c "skip write certificate verify" \
2901 -c "! mbedtls_ssl_handshake returned"
2902
Janos Follathe2681a42016-03-07 15:57:05 +00002903requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002904run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002905 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002906 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002907 0 \
2908 -S "skip write certificate request" \
2909 -C "skip parse certificate request" \
2910 -c "got a certificate request" \
2911 -C "skip write certificate$" \
2912 -c "skip write certificate verify" \
2913 -c "got no certificate to send" \
2914 -s "SSLv3 client has no certificate" \
2915 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002916 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002917 -S "! mbedtls_ssl_handshake returned" \
2918 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002919 -S "X509 - Certificate verification failed"
2920
Yuto Takano8df2d252021-07-02 13:05:15 +01002921# This script assumes that MBEDTLS_X509_MAX_INTERMEDIATE_CA has its default
2922# value, defined here as MAX_IM_CA. Some test cases will be skipped if the
2923# library is configured with a different value.
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002924
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002925MAX_IM_CA='8'
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002926
Yuto Takano8df2d252021-07-02 13:05:15 +01002927# The tests for the max_int tests can pass with any number higher than MAX_IM_CA
2928# because only a chain of MAX_IM_CA length is tested. Equally, the max_int+1
2929# tests can pass with any number less than MAX_IM_CA. However, stricter preconditions
2930# are in place so that the semantics are consistent with the test description.
Yuto Takanobc632c22021-07-02 13:10:41 +01002931requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002932requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002933run_test "Authentication: server max_int chain, client default" \
2934 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2935 key_file=data_files/dir-maxpath/09.key" \
2936 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2937 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002938 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002939
Yuto Takanobc632c22021-07-02 13:10:41 +01002940requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002941requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002942run_test "Authentication: server max_int+1 chain, client default" \
2943 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2944 key_file=data_files/dir-maxpath/10.key" \
2945 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2946 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002947 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002948
Yuto Takanobc632c22021-07-02 13:10:41 +01002949requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002950requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002951run_test "Authentication: server max_int+1 chain, client optional" \
2952 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2953 key_file=data_files/dir-maxpath/10.key" \
2954 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2955 auth_mode=optional" \
2956 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002957 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002958
Yuto Takanobc632c22021-07-02 13:10:41 +01002959requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002960requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002961run_test "Authentication: server max_int+1 chain, client none" \
2962 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2963 key_file=data_files/dir-maxpath/10.key" \
2964 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2965 auth_mode=none" \
2966 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002967 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002968
Yuto Takanobc632c22021-07-02 13:10:41 +01002969requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002970requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002971run_test "Authentication: client max_int+1 chain, server default" \
2972 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2973 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2974 key_file=data_files/dir-maxpath/10.key" \
2975 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002976 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002977
Yuto Takanobc632c22021-07-02 13:10:41 +01002978requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002979requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002980run_test "Authentication: client max_int+1 chain, server optional" \
2981 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2982 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2983 key_file=data_files/dir-maxpath/10.key" \
2984 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002985 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002986
Yuto Takanobc632c22021-07-02 13:10:41 +01002987requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002988requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002989run_test "Authentication: client max_int+1 chain, server required" \
2990 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2991 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2992 key_file=data_files/dir-maxpath/10.key" \
2993 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002994 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002995
Yuto Takanobc632c22021-07-02 13:10:41 +01002996requires_config_value_equals "MBEDTLS_X509_MAX_INTERMEDIATE_CA" $MAX_IM_CA
Angus Grattonc4dd0732018-04-11 16:28:39 +10002997requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002998run_test "Authentication: client max_int chain, server required" \
2999 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
3000 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
3001 key_file=data_files/dir-maxpath/09.key" \
3002 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01003003 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003004
Janos Follath89baba22017-04-10 14:34:35 +01003005# Tests for CA list in CertificateRequest messages
3006
3007run_test "Authentication: send CA list in CertificateRequest (default)" \
3008 "$P_SRV debug_level=3 auth_mode=required" \
3009 "$P_CLI crt_file=data_files/server6.crt \
3010 key_file=data_files/server6.key" \
3011 0 \
3012 -s "requested DN"
3013
3014run_test "Authentication: do not send CA list in CertificateRequest" \
3015 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3016 "$P_CLI crt_file=data_files/server6.crt \
3017 key_file=data_files/server6.key" \
3018 0 \
3019 -S "requested DN"
3020
3021run_test "Authentication: send CA list in CertificateRequest, client self signed" \
3022 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
3023 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3024 key_file=data_files/server5.key" \
3025 1 \
3026 -S "requested DN" \
3027 -s "x509_verify_cert() returned" \
3028 -s "! The certificate is not correctly signed by the trusted CA" \
3029 -s "! mbedtls_ssl_handshake returned" \
3030 -c "! mbedtls_ssl_handshake returned" \
3031 -s "X509 - Certificate verification failed"
3032
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01003033# Tests for certificate selection based on SHA verson
3034
3035run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
3036 "$P_SRV crt_file=data_files/server5.crt \
3037 key_file=data_files/server5.key \
3038 crt_file2=data_files/server5-sha1.crt \
3039 key_file2=data_files/server5.key" \
3040 "$P_CLI force_version=tls1_2" \
3041 0 \
3042 -c "signed using.*ECDSA with SHA256" \
3043 -C "signed using.*ECDSA with SHA1"
3044
3045run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
3046 "$P_SRV crt_file=data_files/server5.crt \
3047 key_file=data_files/server5.key \
3048 crt_file2=data_files/server5-sha1.crt \
3049 key_file2=data_files/server5.key" \
3050 "$P_CLI force_version=tls1_1" \
3051 0 \
3052 -C "signed using.*ECDSA with SHA256" \
3053 -c "signed using.*ECDSA with SHA1"
3054
3055run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
3056 "$P_SRV crt_file=data_files/server5.crt \
3057 key_file=data_files/server5.key \
3058 crt_file2=data_files/server5-sha1.crt \
3059 key_file2=data_files/server5.key" \
3060 "$P_CLI force_version=tls1" \
3061 0 \
3062 -C "signed using.*ECDSA with SHA256" \
3063 -c "signed using.*ECDSA with SHA1"
3064
3065run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
3066 "$P_SRV crt_file=data_files/server5.crt \
3067 key_file=data_files/server5.key \
3068 crt_file2=data_files/server6.crt \
3069 key_file2=data_files/server6.key" \
3070 "$P_CLI force_version=tls1_1" \
3071 0 \
3072 -c "serial number.*09" \
3073 -c "signed using.*ECDSA with SHA256" \
3074 -C "signed using.*ECDSA with SHA1"
3075
3076run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
3077 "$P_SRV crt_file=data_files/server6.crt \
3078 key_file=data_files/server6.key \
3079 crt_file2=data_files/server5.crt \
3080 key_file2=data_files/server5.key" \
3081 "$P_CLI force_version=tls1_1" \
3082 0 \
3083 -c "serial number.*0A" \
3084 -c "signed using.*ECDSA with SHA256" \
3085 -C "signed using.*ECDSA with SHA1"
3086
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003087# tests for SNI
3088
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003089run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003090 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003091 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003092 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003093 0 \
3094 -S "parse ServerName extension" \
3095 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3096 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003098run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003099 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003100 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003101 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 +02003102 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003103 0 \
3104 -s "parse ServerName extension" \
3105 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3106 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003107
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003108run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003109 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003110 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003111 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 +02003112 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003113 0 \
3114 -s "parse ServerName extension" \
3115 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3116 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003118run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003119 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003120 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003121 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 +02003122 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003123 1 \
3124 -s "parse ServerName extension" \
3125 -s "ssl_sni_wrapper() returned" \
3126 -s "mbedtls_ssl_handshake returned" \
3127 -c "mbedtls_ssl_handshake returned" \
3128 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003129
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003130run_test "SNI: client auth no override: optional" \
3131 "$P_SRV debug_level=3 auth_mode=optional \
3132 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3133 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3134 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003135 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003136 -S "skip write certificate request" \
3137 -C "skip parse certificate request" \
3138 -c "got a certificate request" \
3139 -C "skip write certificate" \
3140 -C "skip write certificate verify" \
3141 -S "skip parse certificate verify"
3142
3143run_test "SNI: client auth override: none -> optional" \
3144 "$P_SRV debug_level=3 auth_mode=none \
3145 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3146 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3147 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003148 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003149 -S "skip write certificate request" \
3150 -C "skip parse certificate request" \
3151 -c "got a certificate request" \
3152 -C "skip write certificate" \
3153 -C "skip write certificate verify" \
3154 -S "skip parse certificate verify"
3155
3156run_test "SNI: client auth override: optional -> none" \
3157 "$P_SRV debug_level=3 auth_mode=optional \
3158 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3159 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3160 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003161 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003162 -s "skip write certificate request" \
3163 -C "skip parse certificate request" \
3164 -c "got no certificate request" \
3165 -c "skip write certificate" \
3166 -c "skip write certificate verify" \
3167 -s "skip parse certificate verify"
3168
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003169run_test "SNI: CA no override" \
3170 "$P_SRV debug_level=3 auth_mode=optional \
3171 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3172 ca_file=data_files/test-ca.crt \
3173 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3174 "$P_CLI debug_level=3 server_name=localhost \
3175 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3176 1 \
3177 -S "skip write certificate request" \
3178 -C "skip parse certificate request" \
3179 -c "got a certificate request" \
3180 -C "skip write certificate" \
3181 -C "skip write certificate verify" \
3182 -S "skip parse certificate verify" \
3183 -s "x509_verify_cert() returned" \
3184 -s "! The certificate is not correctly signed by the trusted CA" \
3185 -S "The certificate has been revoked (is on a CRL)"
3186
3187run_test "SNI: CA override" \
3188 "$P_SRV debug_level=3 auth_mode=optional \
3189 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3190 ca_file=data_files/test-ca.crt \
3191 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3192 "$P_CLI debug_level=3 server_name=localhost \
3193 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3194 0 \
3195 -S "skip write certificate request" \
3196 -C "skip parse certificate request" \
3197 -c "got a certificate request" \
3198 -C "skip write certificate" \
3199 -C "skip write certificate verify" \
3200 -S "skip parse certificate verify" \
3201 -S "x509_verify_cert() returned" \
3202 -S "! The certificate is not correctly signed by the trusted CA" \
3203 -S "The certificate has been revoked (is on a CRL)"
3204
3205run_test "SNI: CA override with CRL" \
3206 "$P_SRV debug_level=3 auth_mode=optional \
3207 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3208 ca_file=data_files/test-ca.crt \
3209 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3210 "$P_CLI debug_level=3 server_name=localhost \
3211 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3212 1 \
3213 -S "skip write certificate request" \
3214 -C "skip parse certificate request" \
3215 -c "got a certificate request" \
3216 -C "skip write certificate" \
3217 -C "skip write certificate verify" \
3218 -S "skip parse certificate verify" \
3219 -s "x509_verify_cert() returned" \
3220 -S "! The certificate is not correctly signed by the trusted CA" \
3221 -s "The certificate has been revoked (is on a CRL)"
3222
Andres AG1a834452016-12-07 10:01:30 +00003223# Tests for SNI and DTLS
3224
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003225run_test "SNI: DTLS, no SNI callback" \
3226 "$P_SRV debug_level=3 dtls=1 \
3227 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3228 "$P_CLI server_name=localhost dtls=1" \
3229 0 \
3230 -S "parse ServerName extension" \
3231 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3232 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3233
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003234run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003235 "$P_SRV debug_level=3 dtls=1 \
3236 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3237 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3238 "$P_CLI server_name=localhost dtls=1" \
3239 0 \
3240 -s "parse ServerName extension" \
3241 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3242 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3243
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003244run_test "SNI: DTLS, matching cert 2" \
3245 "$P_SRV debug_level=3 dtls=1 \
3246 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3247 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3248 "$P_CLI server_name=polarssl.example dtls=1" \
3249 0 \
3250 -s "parse ServerName extension" \
3251 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3252 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3253
3254run_test "SNI: DTLS, no matching cert" \
3255 "$P_SRV debug_level=3 dtls=1 \
3256 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3257 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3258 "$P_CLI server_name=nonesuch.example dtls=1" \
3259 1 \
3260 -s "parse ServerName extension" \
3261 -s "ssl_sni_wrapper() returned" \
3262 -s "mbedtls_ssl_handshake returned" \
3263 -c "mbedtls_ssl_handshake returned" \
3264 -c "SSL - A fatal alert message was received from our peer"
3265
3266run_test "SNI: DTLS, client auth no override: optional" \
3267 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3268 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3269 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3270 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3271 0 \
3272 -S "skip write certificate request" \
3273 -C "skip parse certificate request" \
3274 -c "got a certificate request" \
3275 -C "skip write certificate" \
3276 -C "skip write certificate verify" \
3277 -S "skip parse certificate verify"
3278
3279run_test "SNI: DTLS, client auth override: none -> optional" \
3280 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3281 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3282 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3283 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3284 0 \
3285 -S "skip write certificate request" \
3286 -C "skip parse certificate request" \
3287 -c "got a certificate request" \
3288 -C "skip write certificate" \
3289 -C "skip write certificate verify" \
3290 -S "skip parse certificate verify"
3291
3292run_test "SNI: DTLS, client auth override: optional -> none" \
3293 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3294 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3295 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3296 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3297 0 \
3298 -s "skip write certificate request" \
3299 -C "skip parse certificate request" \
3300 -c "got no certificate request" \
3301 -c "skip write certificate" \
3302 -c "skip write certificate verify" \
3303 -s "skip parse certificate verify"
3304
3305run_test "SNI: DTLS, CA no override" \
3306 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3307 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3308 ca_file=data_files/test-ca.crt \
3309 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3310 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3311 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3312 1 \
3313 -S "skip write certificate request" \
3314 -C "skip parse certificate request" \
3315 -c "got a certificate request" \
3316 -C "skip write certificate" \
3317 -C "skip write certificate verify" \
3318 -S "skip parse certificate verify" \
3319 -s "x509_verify_cert() returned" \
3320 -s "! The certificate is not correctly signed by the trusted CA" \
3321 -S "The certificate has been revoked (is on a CRL)"
3322
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003323run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003324 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3325 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3326 ca_file=data_files/test-ca.crt \
3327 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3328 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3329 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3330 0 \
3331 -S "skip write certificate request" \
3332 -C "skip parse certificate request" \
3333 -c "got a certificate request" \
3334 -C "skip write certificate" \
3335 -C "skip write certificate verify" \
3336 -S "skip parse certificate verify" \
3337 -S "x509_verify_cert() returned" \
3338 -S "! The certificate is not correctly signed by the trusted CA" \
3339 -S "The certificate has been revoked (is on a CRL)"
3340
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003341run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003342 "$P_SRV debug_level=3 auth_mode=optional \
3343 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3344 ca_file=data_files/test-ca.crt \
3345 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3346 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3347 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3348 1 \
3349 -S "skip write certificate request" \
3350 -C "skip parse certificate request" \
3351 -c "got a certificate request" \
3352 -C "skip write certificate" \
3353 -C "skip write certificate verify" \
3354 -S "skip parse certificate verify" \
3355 -s "x509_verify_cert() returned" \
3356 -S "! The certificate is not correctly signed by the trusted CA" \
3357 -s "The certificate has been revoked (is on a CRL)"
3358
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003359# Tests for non-blocking I/O: exercise a variety of handshake flows
3360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003361run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003362 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3363 "$P_CLI nbio=2 tickets=0" \
3364 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003365 -S "mbedtls_ssl_handshake returned" \
3366 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003367 -c "Read from server: .* bytes read"
3368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003369run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003370 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3371 "$P_CLI nbio=2 tickets=0" \
3372 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003373 -S "mbedtls_ssl_handshake returned" \
3374 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003375 -c "Read from server: .* bytes read"
3376
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003377run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003378 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3379 "$P_CLI nbio=2 tickets=1" \
3380 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003381 -S "mbedtls_ssl_handshake returned" \
3382 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003383 -c "Read from server: .* bytes read"
3384
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003385run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003386 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3387 "$P_CLI nbio=2 tickets=1" \
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 + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003394 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3395 "$P_CLI nbio=2 tickets=1 reconnect=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 + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003402 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3403 "$P_CLI nbio=2 tickets=1 reconnect=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: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003410 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3411 "$P_CLI nbio=2 tickets=0 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
Hanno Becker00076712017-11-15 16:39:08 +00003417# Tests for event-driven I/O: exercise a variety of handshake flows
3418
3419run_test "Event-driven I/O: basic handshake" \
3420 "$P_SRV event=1 tickets=0 auth_mode=none" \
3421 "$P_CLI event=1 tickets=0" \
3422 0 \
3423 -S "mbedtls_ssl_handshake returned" \
3424 -C "mbedtls_ssl_handshake returned" \
3425 -c "Read from server: .* bytes read"
3426
3427run_test "Event-driven I/O: client auth" \
3428 "$P_SRV event=1 tickets=0 auth_mode=required" \
3429 "$P_CLI event=1 tickets=0" \
3430 0 \
3431 -S "mbedtls_ssl_handshake returned" \
3432 -C "mbedtls_ssl_handshake returned" \
3433 -c "Read from server: .* bytes read"
3434
3435run_test "Event-driven I/O: ticket" \
3436 "$P_SRV event=1 tickets=1 auth_mode=none" \
3437 "$P_CLI event=1 tickets=1" \
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: ticket + client auth" \
3444 "$P_SRV event=1 tickets=1 auth_mode=required" \
3445 "$P_CLI event=1 tickets=1" \
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 + client auth + resume" \
3452 "$P_SRV event=1 tickets=1 auth_mode=required" \
3453 "$P_CLI event=1 tickets=1 reconnect=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 + resume" \
3460 "$P_SRV event=1 tickets=1 auth_mode=none" \
3461 "$P_CLI event=1 tickets=1 reconnect=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: session-id resume" \
3468 "$P_SRV event=1 tickets=0 auth_mode=none" \
3469 "$P_CLI event=1 tickets=0 reconnect=1" \
3470 0 \
3471 -S "mbedtls_ssl_handshake returned" \
3472 -C "mbedtls_ssl_handshake returned" \
3473 -c "Read from server: .* bytes read"
3474
Hanno Becker6a33f592018-03-13 11:38:46 +00003475run_test "Event-driven I/O, DTLS: basic handshake" \
3476 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3477 "$P_CLI dtls=1 event=1 tickets=0" \
3478 0 \
3479 -c "Read from server: .* bytes read"
3480
3481run_test "Event-driven I/O, DTLS: client auth" \
3482 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3483 "$P_CLI dtls=1 event=1 tickets=0" \
3484 0 \
3485 -c "Read from server: .* bytes read"
3486
3487run_test "Event-driven I/O, DTLS: ticket" \
3488 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3489 "$P_CLI dtls=1 event=1 tickets=1" \
3490 0 \
3491 -c "Read from server: .* bytes read"
3492
3493run_test "Event-driven I/O, DTLS: ticket + client auth" \
3494 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3495 "$P_CLI dtls=1 event=1 tickets=1" \
3496 0 \
3497 -c "Read from server: .* bytes read"
3498
3499run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3500 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003501 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003502 0 \
3503 -c "Read from server: .* bytes read"
3504
3505run_test "Event-driven I/O, DTLS: ticket + resume" \
3506 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003507 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003508 0 \
3509 -c "Read from server: .* bytes read"
3510
3511run_test "Event-driven I/O, DTLS: session-id resume" \
3512 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003513 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003514 0 \
3515 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003516
3517# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3518# During session resumption, the client will send its ApplicationData record
3519# within the same datagram as the Finished messages. In this situation, the
3520# server MUST NOT idle on the underlying transport after handshake completion,
3521# because the ApplicationData request has already been queued internally.
3522run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003523 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003524 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003525 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003526 0 \
3527 -c "Read from server: .* bytes read"
3528
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003529# Tests for version negotiation
3530
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003531run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003532 "$P_SRV" \
3533 "$P_CLI" \
3534 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003535 -S "mbedtls_ssl_handshake returned" \
3536 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003537 -s "Protocol is TLSv1.2" \
3538 -c "Protocol is TLSv1.2"
3539
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003540run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003541 "$P_SRV" \
3542 "$P_CLI max_version=tls1_1" \
3543 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003544 -S "mbedtls_ssl_handshake returned" \
3545 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003546 -s "Protocol is TLSv1.1" \
3547 -c "Protocol is TLSv1.1"
3548
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003549run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003550 "$P_SRV max_version=tls1_1" \
3551 "$P_CLI" \
3552 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003553 -S "mbedtls_ssl_handshake returned" \
3554 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003555 -s "Protocol is TLSv1.1" \
3556 -c "Protocol is TLSv1.1"
3557
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003558run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003559 "$P_SRV max_version=tls1_1" \
3560 "$P_CLI max_version=tls1_1" \
3561 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003562 -S "mbedtls_ssl_handshake returned" \
3563 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003564 -s "Protocol is TLSv1.1" \
3565 -c "Protocol is TLSv1.1"
3566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003567run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003568 "$P_SRV min_version=tls1_1" \
3569 "$P_CLI max_version=tls1_1" \
3570 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003571 -S "mbedtls_ssl_handshake returned" \
3572 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003573 -s "Protocol is TLSv1.1" \
3574 -c "Protocol is TLSv1.1"
3575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003576run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003577 "$P_SRV max_version=tls1_1" \
3578 "$P_CLI min_version=tls1_1" \
3579 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003580 -S "mbedtls_ssl_handshake returned" \
3581 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003582 -s "Protocol is TLSv1.1" \
3583 -c "Protocol is TLSv1.1"
3584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003585run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003586 "$P_SRV max_version=tls1_1" \
3587 "$P_CLI min_version=tls1_2" \
3588 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003589 -s "mbedtls_ssl_handshake returned" \
3590 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003591 -c "SSL - Handshake protocol not within min/max boundaries"
3592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003593run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003594 "$P_SRV min_version=tls1_2" \
3595 "$P_CLI max_version=tls1_1" \
3596 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003597 -s "mbedtls_ssl_handshake returned" \
3598 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003599 -s "SSL - Handshake protocol not within min/max boundaries"
3600
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003601# Tests for ALPN extension
3602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003603run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003604 "$P_SRV debug_level=3" \
3605 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003606 0 \
3607 -C "client hello, adding alpn extension" \
3608 -S "found alpn extension" \
3609 -C "got an alert message, type: \\[2:120]" \
3610 -S "server hello, adding alpn extension" \
3611 -C "found alpn extension " \
3612 -C "Application Layer Protocol is" \
3613 -S "Application Layer Protocol is"
3614
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003615run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003616 "$P_SRV debug_level=3" \
3617 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003618 0 \
3619 -c "client hello, adding alpn extension" \
3620 -s "found alpn extension" \
3621 -C "got an alert message, type: \\[2:120]" \
3622 -S "server hello, adding alpn extension" \
3623 -C "found alpn extension " \
3624 -c "Application Layer Protocol is (none)" \
3625 -S "Application Layer Protocol is"
3626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003627run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003628 "$P_SRV debug_level=3 alpn=abc,1234" \
3629 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003630 0 \
3631 -C "client hello, adding alpn extension" \
3632 -S "found alpn extension" \
3633 -C "got an alert message, type: \\[2:120]" \
3634 -S "server hello, adding alpn extension" \
3635 -C "found alpn extension " \
3636 -C "Application Layer Protocol is" \
3637 -s "Application Layer Protocol is (none)"
3638
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003639run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003640 "$P_SRV debug_level=3 alpn=abc,1234" \
3641 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003642 0 \
3643 -c "client hello, adding alpn extension" \
3644 -s "found alpn extension" \
3645 -C "got an alert message, type: \\[2:120]" \
3646 -s "server hello, adding alpn extension" \
3647 -c "found alpn extension" \
3648 -c "Application Layer Protocol is abc" \
3649 -s "Application Layer Protocol is abc"
3650
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003651run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003652 "$P_SRV debug_level=3 alpn=abc,1234" \
3653 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003654 0 \
3655 -c "client hello, adding alpn extension" \
3656 -s "found alpn extension" \
3657 -C "got an alert message, type: \\[2:120]" \
3658 -s "server hello, adding alpn extension" \
3659 -c "found alpn extension" \
3660 -c "Application Layer Protocol is abc" \
3661 -s "Application Layer Protocol is abc"
3662
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003663run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003664 "$P_SRV debug_level=3 alpn=abc,1234" \
3665 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003666 0 \
3667 -c "client hello, adding alpn extension" \
3668 -s "found alpn extension" \
3669 -C "got an alert message, type: \\[2:120]" \
3670 -s "server hello, adding alpn extension" \
3671 -c "found alpn extension" \
3672 -c "Application Layer Protocol is 1234" \
3673 -s "Application Layer Protocol is 1234"
3674
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003675run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003676 "$P_SRV debug_level=3 alpn=abc,123" \
3677 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003678 1 \
3679 -c "client hello, adding alpn extension" \
3680 -s "found alpn extension" \
3681 -c "got an alert message, type: \\[2:120]" \
3682 -S "server hello, adding alpn extension" \
3683 -C "found alpn extension" \
3684 -C "Application Layer Protocol is 1234" \
3685 -S "Application Layer Protocol is 1234"
3686
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003687
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003688# Tests for keyUsage in leaf certificates, part 1:
3689# server-side certificate/suite selection
3690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003691run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003692 "$P_SRV key_file=data_files/server2.key \
3693 crt_file=data_files/server2.ku-ds.crt" \
3694 "$P_CLI" \
3695 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003696 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003697
3698
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003699run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003700 "$P_SRV key_file=data_files/server2.key \
3701 crt_file=data_files/server2.ku-ke.crt" \
3702 "$P_CLI" \
3703 0 \
3704 -c "Ciphersuite is TLS-RSA-WITH-"
3705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003706run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003707 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003708 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003709 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003710 1 \
3711 -C "Ciphersuite is "
3712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003713run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003714 "$P_SRV key_file=data_files/server5.key \
3715 crt_file=data_files/server5.ku-ds.crt" \
3716 "$P_CLI" \
3717 0 \
3718 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3719
3720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003721run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003722 "$P_SRV key_file=data_files/server5.key \
3723 crt_file=data_files/server5.ku-ka.crt" \
3724 "$P_CLI" \
3725 0 \
3726 -c "Ciphersuite is TLS-ECDH-"
3727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003728run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003729 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003730 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003731 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003732 1 \
3733 -C "Ciphersuite is "
3734
3735# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003736# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003737
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003738run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003739 "$O_SRV -key data_files/server2.key \
3740 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003741 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003742 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3743 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003744 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003745 -C "Processing of the Certificate handshake message failed" \
3746 -c "Ciphersuite is TLS-"
3747
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003748run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003749 "$O_SRV -key data_files/server2.key \
3750 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003751 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003752 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3753 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003754 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003755 -C "Processing of the Certificate handshake message failed" \
3756 -c "Ciphersuite is TLS-"
3757
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003758run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003759 "$O_SRV -key data_files/server2.key \
3760 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003761 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003762 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3763 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003764 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003765 -C "Processing of the Certificate handshake message failed" \
3766 -c "Ciphersuite is TLS-"
3767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003768run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003769 "$O_SRV -key data_files/server2.key \
3770 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003771 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003772 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3773 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003774 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003775 -c "Processing of the Certificate handshake message failed" \
3776 -C "Ciphersuite is TLS-"
3777
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003778run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3779 "$O_SRV -key data_files/server2.key \
3780 -cert data_files/server2.ku-ke.crt" \
3781 "$P_CLI debug_level=1 auth_mode=optional \
3782 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3783 0 \
3784 -c "bad certificate (usage extensions)" \
3785 -C "Processing of the Certificate handshake message failed" \
3786 -c "Ciphersuite is TLS-" \
3787 -c "! Usage does not match the keyUsage extension"
3788
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003789run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003790 "$O_SRV -key data_files/server2.key \
3791 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003792 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003793 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3794 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003795 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003796 -C "Processing of the Certificate handshake message failed" \
3797 -c "Ciphersuite is TLS-"
3798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003799run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003800 "$O_SRV -key data_files/server2.key \
3801 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003802 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003803 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3804 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003805 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003806 -c "Processing of the Certificate handshake message failed" \
3807 -C "Ciphersuite is TLS-"
3808
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003809run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3810 "$O_SRV -key data_files/server2.key \
3811 -cert data_files/server2.ku-ds.crt" \
3812 "$P_CLI debug_level=1 auth_mode=optional \
3813 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3814 0 \
3815 -c "bad certificate (usage extensions)" \
3816 -C "Processing of the Certificate handshake message failed" \
3817 -c "Ciphersuite is TLS-" \
3818 -c "! Usage does not match the keyUsage extension"
3819
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003820# Tests for keyUsage in leaf certificates, part 3:
3821# server-side checking of client cert
3822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003823run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003824 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003825 "$O_CLI -key data_files/server2.key \
3826 -cert data_files/server2.ku-ds.crt" \
3827 0 \
3828 -S "bad certificate (usage extensions)" \
3829 -S "Processing of the Certificate handshake message failed"
3830
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003831run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003832 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003833 "$O_CLI -key data_files/server2.key \
3834 -cert data_files/server2.ku-ke.crt" \
3835 0 \
3836 -s "bad certificate (usage extensions)" \
3837 -S "Processing of the Certificate handshake message failed"
3838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003839run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003840 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003841 "$O_CLI -key data_files/server2.key \
3842 -cert data_files/server2.ku-ke.crt" \
3843 1 \
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: ECDSA, DigitalSignature: OK" \
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/server5.key \
3850 -cert data_files/server5.ku-ds.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: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003856 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003857 "$O_CLI -key data_files/server5.key \
3858 -cert data_files/server5.ku-ka.crt" \
3859 0 \
3860 -s "bad certificate (usage extensions)" \
3861 -S "Processing of the Certificate handshake message failed"
3862
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003863# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3864
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003865run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003866 "$P_SRV key_file=data_files/server5.key \
3867 crt_file=data_files/server5.eku-srv.crt" \
3868 "$P_CLI" \
3869 0
3870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003872 "$P_SRV key_file=data_files/server5.key \
3873 crt_file=data_files/server5.eku-srv.crt" \
3874 "$P_CLI" \
3875 0
3876
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003877run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003878 "$P_SRV key_file=data_files/server5.key \
3879 crt_file=data_files/server5.eku-cs_any.crt" \
3880 "$P_CLI" \
3881 0
3882
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003883run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003884 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003885 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003886 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003887 1
3888
3889# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003891run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003892 "$O_SRV -key data_files/server5.key \
3893 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003894 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003895 0 \
3896 -C "bad certificate (usage extensions)" \
3897 -C "Processing of the Certificate handshake message failed" \
3898 -c "Ciphersuite is TLS-"
3899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003900run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003901 "$O_SRV -key data_files/server5.key \
3902 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003903 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003904 0 \
3905 -C "bad certificate (usage extensions)" \
3906 -C "Processing of the Certificate handshake message failed" \
3907 -c "Ciphersuite is TLS-"
3908
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003909run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003910 "$O_SRV -key data_files/server5.key \
3911 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003912 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003913 0 \
3914 -C "bad certificate (usage extensions)" \
3915 -C "Processing of the Certificate handshake message failed" \
3916 -c "Ciphersuite is TLS-"
3917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003918run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003919 "$O_SRV -key data_files/server5.key \
3920 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003921 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003922 1 \
3923 -c "bad certificate (usage extensions)" \
3924 -c "Processing of the Certificate handshake message failed" \
3925 -C "Ciphersuite is TLS-"
3926
3927# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3928
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003929run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003930 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003931 "$O_CLI -key data_files/server5.key \
3932 -cert data_files/server5.eku-cli.crt" \
3933 0 \
3934 -S "bad certificate (usage extensions)" \
3935 -S "Processing of the Certificate handshake message failed"
3936
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003937run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003938 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003939 "$O_CLI -key data_files/server5.key \
3940 -cert data_files/server5.eku-srv_cli.crt" \
3941 0 \
3942 -S "bad certificate (usage extensions)" \
3943 -S "Processing of the Certificate handshake message failed"
3944
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003945run_test "extKeyUsage cli-auth: codeSign,anyEKU -> 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-cs_any.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: codeSign -> fail (soft)" \
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-cs.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 -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003962 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003963 "$O_CLI -key data_files/server5.key \
3964 -cert data_files/server5.eku-cs.crt" \
3965 1 \
3966 -s "bad certificate (usage extensions)" \
3967 -s "Processing of the Certificate handshake message failed"
3968
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003969# Tests for DHM parameters loading
3970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003971run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003972 "$P_SRV" \
3973 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3974 debug_level=3" \
3975 0 \
3976 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003977 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003979run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003980 "$P_SRV dhm_file=data_files/dhparams.pem" \
3981 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3982 debug_level=3" \
3983 0 \
3984 -c "value of 'DHM: P ' (1024 bits)" \
3985 -c "value of 'DHM: G ' (2 bits)"
3986
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003987# Tests for DHM client-side size checking
3988
3989run_test "DHM size: server default, client default, OK" \
3990 "$P_SRV" \
3991 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3992 debug_level=1" \
3993 0 \
3994 -C "DHM prime too short:"
3995
3996run_test "DHM size: server default, client 2048, OK" \
3997 "$P_SRV" \
3998 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3999 debug_level=1 dhmlen=2048" \
4000 0 \
4001 -C "DHM prime too short:"
4002
4003run_test "DHM size: server 1024, client default, OK" \
4004 "$P_SRV dhm_file=data_files/dhparams.pem" \
4005 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4006 debug_level=1" \
4007 0 \
4008 -C "DHM prime too short:"
4009
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004010run_test "DHM size: server 999, client 999, OK" \
4011 "$P_SRV dhm_file=data_files/dh.999.pem" \
4012 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4013 debug_level=1 dhmlen=999" \
4014 0 \
4015 -C "DHM prime too short:"
4016
4017run_test "DHM size: server 1000, client 1000, OK" \
4018 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4019 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4020 debug_level=1 dhmlen=1000" \
4021 0 \
4022 -C "DHM prime too short:"
4023
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004024run_test "DHM size: server 1000, client default, rejected" \
4025 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4026 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4027 debug_level=1" \
4028 1 \
4029 -c "DHM prime too short:"
4030
Gilles Peskine3e7b61c2020-12-08 22:31:52 +01004031run_test "DHM size: server 1000, client 1001, rejected" \
4032 "$P_SRV dhm_file=data_files/dh.1000.pem" \
4033 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4034 debug_level=1 dhmlen=1001" \
4035 1 \
4036 -c "DHM prime too short:"
4037
4038run_test "DHM size: server 999, client 1000, rejected" \
4039 "$P_SRV dhm_file=data_files/dh.999.pem" \
4040 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4041 debug_level=1 dhmlen=1000" \
4042 1 \
4043 -c "DHM prime too short:"
4044
4045run_test "DHM size: server 998, client 999, rejected" \
4046 "$P_SRV dhm_file=data_files/dh.998.pem" \
4047 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4048 debug_level=1 dhmlen=999" \
4049 1 \
4050 -c "DHM prime too short:"
4051
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02004052run_test "DHM size: server default, client 2049, rejected" \
4053 "$P_SRV" \
4054 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
4055 debug_level=1 dhmlen=2049" \
4056 1 \
4057 -c "DHM prime too short:"
4058
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004059# Tests for PSK callback
4060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004061run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004062 "$P_SRV psk=abc123 psk_identity=foo" \
4063 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4064 psk_identity=foo psk=abc123" \
4065 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004066 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004067 -S "SSL - Unknown identity received" \
4068 -S "SSL - Verification of the message MAC failed"
4069
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004070run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02004071 "$P_SRV" \
4072 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4073 psk_identity=foo psk=abc123" \
4074 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004075 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004076 -S "SSL - Unknown identity received" \
4077 -S "SSL - Verification of the message MAC failed"
4078
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004079run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004080 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
4081 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4082 psk_identity=foo psk=abc123" \
4083 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004084 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004085 -s "SSL - Unknown identity received" \
4086 -S "SSL - Verification of the message MAC failed"
4087
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004088run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004089 "$P_SRV psk_list=abc,dead,def,beef" \
4090 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4091 psk_identity=abc psk=dead" \
4092 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004093 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004094 -S "SSL - Unknown identity received" \
4095 -S "SSL - Verification of the message MAC failed"
4096
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004097run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004098 "$P_SRV psk_list=abc,dead,def,beef" \
4099 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4100 psk_identity=def psk=beef" \
4101 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004102 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004103 -S "SSL - Unknown identity received" \
4104 -S "SSL - Verification of the message MAC failed"
4105
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004106run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004107 "$P_SRV psk_list=abc,dead,def,beef" \
4108 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4109 psk_identity=ghi psk=beef" \
4110 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004111 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004112 -s "SSL - Unknown identity received" \
4113 -S "SSL - Verification of the message MAC failed"
4114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004115run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004116 "$P_SRV psk_list=abc,dead,def,beef" \
4117 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
4118 psk_identity=abc psk=beef" \
4119 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01004120 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02004121 -S "SSL - Unknown identity received" \
4122 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02004123
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004124# Tests for EC J-PAKE
4125
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004126requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004127run_test "ECJPAKE: client not configured" \
4128 "$P_SRV debug_level=3" \
4129 "$P_CLI debug_level=3" \
4130 0 \
4131 -C "add ciphersuite: c0ff" \
4132 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004133 -S "found ecjpake kkpp extension" \
4134 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004135 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004136 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004137 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004138 -S "None of the common ciphersuites is usable"
4139
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004140requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004141run_test "ECJPAKE: server not configured" \
4142 "$P_SRV debug_level=3" \
4143 "$P_CLI debug_level=3 ecjpake_pw=bla \
4144 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4145 1 \
4146 -c "add ciphersuite: c0ff" \
4147 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004148 -s "found ecjpake kkpp extension" \
4149 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004150 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004151 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004152 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004153 -s "None of the common ciphersuites is usable"
4154
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004155requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004156run_test "ECJPAKE: working, TLS" \
4157 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4158 "$P_CLI debug_level=3 ecjpake_pw=bla \
4159 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004160 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004161 -c "add ciphersuite: c0ff" \
4162 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004163 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004164 -s "found ecjpake kkpp extension" \
4165 -S "skip ecjpake kkpp extension" \
4166 -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é-Gonnard921f2d02015-09-16 22:52:18 +02004169 -S "None of the common ciphersuites is usable" \
4170 -S "SSL - Verification of the message MAC failed"
4171
Janos Follath74537a62016-09-02 13:45:28 +01004172server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004173requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004174run_test "ECJPAKE: password mismatch, TLS" \
4175 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4176 "$P_CLI debug_level=3 ecjpake_pw=bad \
4177 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4178 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004179 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004180 -s "SSL - Verification of the message MAC failed"
4181
Dave Rodgmancee9e922021-06-29 19:05:34 +01004182requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004183run_test "ECJPAKE: working, DTLS" \
4184 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4185 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4186 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4187 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004188 -c "re-using cached ecjpake parameters" \
4189 -S "SSL - Verification of the message MAC failed"
4190
Dave Rodgmancee9e922021-06-29 19:05:34 +01004191requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004192run_test "ECJPAKE: working, DTLS, no cookie" \
4193 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4194 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4195 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4196 0 \
4197 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004198 -S "SSL - Verification of the message MAC failed"
4199
Janos Follath74537a62016-09-02 13:45:28 +01004200server_needs_more_time 1
Dave Rodgmancee9e922021-06-29 19:05:34 +01004201requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004202run_test "ECJPAKE: password mismatch, DTLS" \
4203 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4204 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4205 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4206 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004207 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004208 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004209
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004210# for tests with configs/config-thread.h
Dave Rodgmancee9e922021-06-29 19:05:34 +01004211requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004212run_test "ECJPAKE: working, DTLS, nolog" \
4213 "$P_SRV dtls=1 ecjpake_pw=bla" \
4214 "$P_CLI dtls=1 ecjpake_pw=bla \
4215 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4216 0
4217
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004218# Tests for ciphersuites per version
4219
Janos Follathe2681a42016-03-07 15:57:05 +00004220requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004221requires_config_enabled MBEDTLS_CAMELLIA_C
4222requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004223run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004224 "$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 +02004225 "$P_CLI force_version=ssl3" \
4226 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004227 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004228
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004229requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4230requires_config_enabled MBEDTLS_CAMELLIA_C
4231requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004232run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004233 "$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 +01004234 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004235 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004236 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004237
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004238requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4239requires_config_enabled MBEDTLS_CAMELLIA_C
4240requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004241run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004242 "$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 +02004243 "$P_CLI force_version=tls1_1" \
4244 0 \
4245 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4246
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004247requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4248requires_config_enabled MBEDTLS_CAMELLIA_C
4249requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004250run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004251 "$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 +02004252 "$P_CLI force_version=tls1_2" \
4253 0 \
4254 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4255
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004256# Test for ClientHello without extensions
4257
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004258requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004259run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004260 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004261 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004262 0 \
4263 -s "dumping 'client hello extensions' (0 bytes)"
4264
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004265# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004266
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004267run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004268 "$P_SRV" \
4269 "$P_CLI request_size=100" \
4270 0 \
4271 -s "Read from client: 100 bytes read$"
4272
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004273run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004274 "$P_SRV" \
4275 "$P_CLI request_size=500" \
4276 0 \
4277 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004278
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004279# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004280
Janos Follathe2681a42016-03-07 15:57:05 +00004281requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004282run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004283 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004284 "$P_CLI request_size=1 force_version=ssl3 \
4285 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4286 0 \
4287 -s "Read from client: 1 bytes read"
4288
Janos Follathe2681a42016-03-07 15:57:05 +00004289requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004290run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004291 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004292 "$P_CLI request_size=1 force_version=ssl3 \
4293 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4294 0 \
4295 -s "Read from client: 1 bytes read"
4296
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004297run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004298 "$P_SRV" \
4299 "$P_CLI request_size=1 force_version=tls1 \
4300 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4301 0 \
4302 -s "Read from client: 1 bytes read"
4303
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004304run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004305 "$P_SRV" \
4306 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4308 0 \
4309 -s "Read from client: 1 bytes read"
4310
Hanno Becker32c55012017-11-10 08:42:54 +00004311requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004312run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004313 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004314 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004315 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004316 0 \
4317 -s "Read from client: 1 bytes read"
4318
Hanno Becker32c55012017-11-10 08:42:54 +00004319requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004320run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004321 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004322 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004323 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004324 0 \
4325 -s "Read from client: 1 bytes read"
4326
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004327run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004328 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004329 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004330 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4331 0 \
4332 -s "Read from client: 1 bytes read"
4333
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004334run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004335 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4336 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004337 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004338 0 \
4339 -s "Read from client: 1 bytes read"
4340
4341requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004342run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004343 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004344 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004345 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004346 0 \
4347 -s "Read from client: 1 bytes read"
4348
Hanno Becker8501f982017-11-10 08:59:04 +00004349requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004350run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004351 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4352 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4353 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004354 0 \
4355 -s "Read from client: 1 bytes read"
4356
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004357run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004358 "$P_SRV" \
4359 "$P_CLI request_size=1 force_version=tls1_1 \
4360 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4361 0 \
4362 -s "Read from client: 1 bytes read"
4363
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004364run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004365 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004366 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004368 0 \
4369 -s "Read from client: 1 bytes read"
4370
4371requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004372run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004373 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004374 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004375 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004376 0 \
4377 -s "Read from client: 1 bytes read"
4378
4379requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004380run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004381 "$P_SRV trunc_hmac=1" \
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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004384 0 \
4385 -s "Read from client: 1 bytes read"
4386
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004387run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004388 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004389 "$P_CLI request_size=1 force_version=tls1_1 \
4390 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4391 0 \
4392 -s "Read from client: 1 bytes read"
4393
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004394run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004395 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004396 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004397 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004398 0 \
4399 -s "Read from client: 1 bytes read"
4400
Hanno Becker8501f982017-11-10 08:59:04 +00004401requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004402run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004403 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004404 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004405 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004406 0 \
4407 -s "Read from client: 1 bytes read"
4408
Hanno Becker32c55012017-11-10 08:42:54 +00004409requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004410run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004411 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004414 0 \
4415 -s "Read from client: 1 bytes read"
4416
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004417run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004418 "$P_SRV" \
4419 "$P_CLI request_size=1 force_version=tls1_2 \
4420 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4421 0 \
4422 -s "Read from client: 1 bytes read"
4423
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004424run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004425 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004426 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004427 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004428 0 \
4429 -s "Read from client: 1 bytes read"
4430
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004431run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004432 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004433 "$P_CLI request_size=1 force_version=tls1_2 \
4434 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004435 0 \
4436 -s "Read from client: 1 bytes read"
4437
Hanno Becker32c55012017-11-10 08:42:54 +00004438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004439run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004440 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004441 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004442 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004443 0 \
4444 -s "Read from client: 1 bytes read"
4445
Hanno Becker8501f982017-11-10 08:59:04 +00004446requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004447run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004448 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004449 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004450 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004451 0 \
4452 -s "Read from client: 1 bytes read"
4453
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004454run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004455 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004456 "$P_CLI request_size=1 force_version=tls1_2 \
4457 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4458 0 \
4459 -s "Read from client: 1 bytes read"
4460
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004461run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004462 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004463 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004464 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004465 0 \
4466 -s "Read from client: 1 bytes read"
4467
Hanno Becker32c55012017-11-10 08:42:54 +00004468requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004469run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004470 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004471 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004472 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004473 0 \
4474 -s "Read from client: 1 bytes read"
4475
Hanno Becker8501f982017-11-10 08:59:04 +00004476requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004477run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004478 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004479 "$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 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004481 0 \
4482 -s "Read from client: 1 bytes read"
4483
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004484run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004485 "$P_SRV" \
4486 "$P_CLI request_size=1 force_version=tls1_2 \
4487 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4488 0 \
4489 -s "Read from client: 1 bytes read"
4490
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004491run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004492 "$P_SRV" \
4493 "$P_CLI request_size=1 force_version=tls1_2 \
4494 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4495 0 \
4496 -s "Read from client: 1 bytes read"
4497
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004498# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004499
4500requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004501run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004502 "$P_SRV dtls=1 force_version=dtls1" \
4503 "$P_CLI dtls=1 request_size=1 \
4504 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4505 0 \
4506 -s "Read from client: 1 bytes read"
4507
4508requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004509run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004510 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4511 "$P_CLI dtls=1 request_size=1 \
4512 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4513 0 \
4514 -s "Read from client: 1 bytes read"
4515
4516requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4517requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004518run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004519 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4520 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004521 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4522 0 \
4523 -s "Read from client: 1 bytes read"
4524
4525requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4526requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004527run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004528 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004529 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004531 0 \
4532 -s "Read from client: 1 bytes read"
4533
4534requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004535run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004536 "$P_SRV dtls=1 force_version=dtls1_2" \
4537 "$P_CLI dtls=1 request_size=1 \
4538 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4539 0 \
4540 -s "Read from client: 1 bytes read"
4541
4542requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004543run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004544 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004545 "$P_CLI dtls=1 request_size=1 \
4546 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4547 0 \
4548 -s "Read from client: 1 bytes read"
4549
4550requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4551requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004552run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004553 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004554 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004555 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004556 0 \
4557 -s "Read from client: 1 bytes read"
4558
4559requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4560requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004561run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004562 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004563 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004564 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004565 0 \
4566 -s "Read from client: 1 bytes read"
4567
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004568# Tests for small server packets
4569
4570requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4571run_test "Small server packet SSLv3 BlockCipher" \
4572 "$P_SRV response_size=1 min_version=ssl3" \
4573 "$P_CLI force_version=ssl3 \
4574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4575 0 \
4576 -c "Read from server: 1 bytes read"
4577
4578requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4579run_test "Small server packet SSLv3 StreamCipher" \
4580 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4581 "$P_CLI force_version=ssl3 \
4582 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4583 0 \
4584 -c "Read from server: 1 bytes read"
4585
4586run_test "Small server packet TLS 1.0 BlockCipher" \
4587 "$P_SRV response_size=1" \
4588 "$P_CLI force_version=tls1 \
4589 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4590 0 \
4591 -c "Read from server: 1 bytes read"
4592
4593run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4594 "$P_SRV response_size=1" \
4595 "$P_CLI force_version=tls1 etm=0 \
4596 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4597 0 \
4598 -c "Read from server: 1 bytes read"
4599
4600requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4601run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4602 "$P_SRV response_size=1 trunc_hmac=1" \
4603 "$P_CLI force_version=tls1 \
4604 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4605 0 \
4606 -c "Read from server: 1 bytes read"
4607
4608requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4609run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4610 "$P_SRV response_size=1 trunc_hmac=1" \
4611 "$P_CLI force_version=tls1 \
4612 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4613 0 \
4614 -c "Read from server: 1 bytes read"
4615
4616run_test "Small server packet TLS 1.0 StreamCipher" \
4617 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4618 "$P_CLI force_version=tls1 \
4619 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4620 0 \
4621 -c "Read from server: 1 bytes read"
4622
4623run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4624 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4625 "$P_CLI force_version=tls1 \
4626 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4627 0 \
4628 -c "Read from server: 1 bytes read"
4629
4630requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4631run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4632 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4633 "$P_CLI force_version=tls1 \
4634 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4635 0 \
4636 -c "Read from server: 1 bytes read"
4637
4638requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4639run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4640 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4641 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4642 trunc_hmac=1 etm=0" \
4643 0 \
4644 -c "Read from server: 1 bytes read"
4645
4646run_test "Small server packet TLS 1.1 BlockCipher" \
4647 "$P_SRV response_size=1" \
4648 "$P_CLI force_version=tls1_1 \
4649 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4650 0 \
4651 -c "Read from server: 1 bytes read"
4652
4653run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4654 "$P_SRV response_size=1" \
4655 "$P_CLI force_version=tls1_1 \
4656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4657 0 \
4658 -c "Read from server: 1 bytes read"
4659
4660requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4661run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4662 "$P_SRV response_size=1 trunc_hmac=1" \
4663 "$P_CLI force_version=tls1_1 \
4664 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4665 0 \
4666 -c "Read from server: 1 bytes read"
4667
4668requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4669run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4670 "$P_SRV response_size=1 trunc_hmac=1" \
4671 "$P_CLI force_version=tls1_1 \
4672 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4673 0 \
4674 -c "Read from server: 1 bytes read"
4675
4676run_test "Small server packet TLS 1.1 StreamCipher" \
4677 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4678 "$P_CLI force_version=tls1_1 \
4679 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4680 0 \
4681 -c "Read from server: 1 bytes read"
4682
4683run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4684 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4685 "$P_CLI force_version=tls1_1 \
4686 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4687 0 \
4688 -c "Read from server: 1 bytes read"
4689
4690requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4691run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4692 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4693 "$P_CLI force_version=tls1_1 \
4694 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4695 0 \
4696 -c "Read from server: 1 bytes read"
4697
4698requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4699run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4700 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4701 "$P_CLI force_version=tls1_1 \
4702 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4703 0 \
4704 -c "Read from server: 1 bytes read"
4705
4706run_test "Small server packet TLS 1.2 BlockCipher" \
4707 "$P_SRV response_size=1" \
4708 "$P_CLI force_version=tls1_2 \
4709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4710 0 \
4711 -c "Read from server: 1 bytes read"
4712
4713run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4714 "$P_SRV response_size=1" \
4715 "$P_CLI force_version=tls1_2 \
4716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4717 0 \
4718 -c "Read from server: 1 bytes read"
4719
4720run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4721 "$P_SRV response_size=1" \
4722 "$P_CLI force_version=tls1_2 \
4723 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4724 0 \
4725 -c "Read from server: 1 bytes read"
4726
4727requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4728run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4729 "$P_SRV response_size=1 trunc_hmac=1" \
4730 "$P_CLI force_version=tls1_2 \
4731 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4732 0 \
4733 -c "Read from server: 1 bytes read"
4734
4735requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4736run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4737 "$P_SRV response_size=1 trunc_hmac=1" \
4738 "$P_CLI force_version=tls1_2 \
4739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4740 0 \
4741 -c "Read from server: 1 bytes read"
4742
4743run_test "Small server packet TLS 1.2 StreamCipher" \
4744 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4745 "$P_CLI force_version=tls1_2 \
4746 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4747 0 \
4748 -c "Read from server: 1 bytes read"
4749
4750run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4751 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4752 "$P_CLI force_version=tls1_2 \
4753 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4754 0 \
4755 -c "Read from server: 1 bytes read"
4756
4757requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4758run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4759 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4760 "$P_CLI force_version=tls1_2 \
4761 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4762 0 \
4763 -c "Read from server: 1 bytes read"
4764
4765requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4766run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4767 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4768 "$P_CLI force_version=tls1_2 \
4769 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4770 0 \
4771 -c "Read from server: 1 bytes read"
4772
4773run_test "Small server packet TLS 1.2 AEAD" \
4774 "$P_SRV response_size=1" \
4775 "$P_CLI force_version=tls1_2 \
4776 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4777 0 \
4778 -c "Read from server: 1 bytes read"
4779
4780run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4781 "$P_SRV response_size=1" \
4782 "$P_CLI force_version=tls1_2 \
4783 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4784 0 \
4785 -c "Read from server: 1 bytes read"
4786
4787# Tests for small server packets in DTLS
4788
4789requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4790run_test "Small server packet DTLS 1.0" \
4791 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4792 "$P_CLI dtls=1 \
4793 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4794 0 \
4795 -c "Read from server: 1 bytes read"
4796
4797requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4798run_test "Small server packet DTLS 1.0, without EtM" \
4799 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4800 "$P_CLI dtls=1 \
4801 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4802 0 \
4803 -c "Read from server: 1 bytes read"
4804
4805requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4806requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4807run_test "Small server packet DTLS 1.0, truncated hmac" \
4808 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4809 "$P_CLI dtls=1 trunc_hmac=1 \
4810 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4811 0 \
4812 -c "Read from server: 1 bytes read"
4813
4814requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4815requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4816run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4817 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4818 "$P_CLI dtls=1 \
4819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4820 0 \
4821 -c "Read from server: 1 bytes read"
4822
4823requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4824run_test "Small server packet DTLS 1.2" \
4825 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4826 "$P_CLI dtls=1 \
4827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4828 0 \
4829 -c "Read from server: 1 bytes read"
4830
4831requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4832run_test "Small server packet DTLS 1.2, without EtM" \
4833 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4834 "$P_CLI dtls=1 \
4835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4836 0 \
4837 -c "Read from server: 1 bytes read"
4838
4839requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4840requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4841run_test "Small server packet DTLS 1.2, truncated hmac" \
4842 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4843 "$P_CLI dtls=1 \
4844 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4845 0 \
4846 -c "Read from server: 1 bytes read"
4847
4848requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4849requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4850run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4851 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4852 "$P_CLI dtls=1 \
4853 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4854 0 \
4855 -c "Read from server: 1 bytes read"
4856
Janos Follath00efff72016-05-06 13:48:23 +01004857# A test for extensions in SSLv3
Yuto Takanoc75df632021-07-08 15:56:33 +01004858requires_max_content_len 4096
Janos Follath00efff72016-05-06 13:48:23 +01004859requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4860run_test "SSLv3 with extensions, server side" \
4861 "$P_SRV min_version=ssl3 debug_level=3" \
4862 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4863 0 \
4864 -S "dumping 'client hello extensions'" \
4865 -S "server hello, total extension length:"
4866
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004867# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004868
Angus Grattonc4dd0732018-04-11 16:28:39 +10004869# How many fragments do we expect to write $1 bytes?
4870fragments_for_write() {
4871 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4872}
4873
Janos Follathe2681a42016-03-07 15:57:05 +00004874requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004875run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004876 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004877 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004878 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4879 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004880 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4881 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004882
Janos Follathe2681a42016-03-07 15:57:05 +00004883requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004884run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004885 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004886 "$P_CLI request_size=16384 force_version=ssl3 \
4887 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4888 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004889 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4890 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004891
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004892run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004893 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004894 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004895 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4896 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004897 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4898 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004899
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004900run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004901 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004902 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4903 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4904 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004905 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004906
Hanno Becker32c55012017-11-10 08:42:54 +00004907requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004908run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004909 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004910 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004912 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
Hanno Becker32c55012017-11-10 08:42:54 +00004916requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004917run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004918 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004919 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004920 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004921 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004922 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004923
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004924run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004925 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004926 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004927 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4928 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004929 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004930
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004931run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004932 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4933 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004934 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004935 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004936 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004937
4938requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004939run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004940 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004941 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004942 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004943 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004944 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004945
Hanno Becker278fc7a2017-11-10 09:16:28 +00004946requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004947run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004948 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004949 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004950 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004951 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004952 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4953 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004954
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004955run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004956 "$P_SRV" \
4957 "$P_CLI request_size=16384 force_version=tls1_1 \
4958 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4959 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004960 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4961 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004962
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004963run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004964 "$P_SRV" \
4965 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4966 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004967 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004968 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004969
Hanno Becker32c55012017-11-10 08:42:54 +00004970requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004971run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004972 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004973 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004974 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004975 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004976 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004977
Hanno Becker32c55012017-11-10 08:42:54 +00004978requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004979run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004980 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004981 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004983 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004984 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004985
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004986run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004987 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4988 "$P_CLI request_size=16384 force_version=tls1_1 \
4989 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4990 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004991 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4992 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004993
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004994run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004995 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004996 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004997 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004998 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004999 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5000 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005001
Hanno Becker278fc7a2017-11-10 09:16:28 +00005002requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005003run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005004 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005005 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005006 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005007 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005008 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005009
Hanno Becker278fc7a2017-11-10 09:16:28 +00005010requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005011run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005013 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005015 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005016 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5017 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005018
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005019run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005020 "$P_SRV" \
5021 "$P_CLI request_size=16384 force_version=tls1_2 \
5022 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5023 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005024 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5025 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005026
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005027run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005028 "$P_SRV" \
5029 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
5030 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5031 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005032 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005033
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005034run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005035 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005036 "$P_CLI request_size=16384 force_version=tls1_2 \
5037 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005038 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005039 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5040 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005041
Hanno Becker32c55012017-11-10 08:42:54 +00005042requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005043run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005044 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005045 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005046 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005047 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005048 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005049
Hanno Becker278fc7a2017-11-10 09:16:28 +00005050requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005051run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005052 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005053 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005054 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005055 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005056 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5057 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005058
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005059run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005060 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005061 "$P_CLI request_size=16384 force_version=tls1_2 \
5062 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5063 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005064 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5065 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005066
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005067run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005068 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005069 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005070 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5071 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005072 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005073
Hanno Becker32c55012017-11-10 08:42:54 +00005074requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005075run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005076 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005077 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005078 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005079 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005080 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005081
Hanno Becker278fc7a2017-11-10 09:16:28 +00005082requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005083run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005084 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005085 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005086 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005087 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005088 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5089 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005090
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005091run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005092 "$P_SRV" \
5093 "$P_CLI request_size=16384 force_version=tls1_2 \
5094 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5095 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005096 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5097 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005098
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005099run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005100 "$P_SRV" \
5101 "$P_CLI request_size=16384 force_version=tls1_2 \
5102 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5103 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 +02005107# Test for large server packets
Yuto Takanoc75df632021-07-08 15:56:33 +01005108# The tests below fail when the server's OUT_CONTENT_LEN is less than 16384.
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005109requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5110run_test "Large server packet SSLv3 StreamCipher" \
5111 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5112 "$P_CLI force_version=ssl3 \
5113 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5114 0 \
5115 -c "Read from server: 16384 bytes read"
5116
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04005117# Checking next 4 tests logs for 1n-1 split against BEAST too
5118requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
5119run_test "Large server packet SSLv3 BlockCipher" \
5120 "$P_SRV response_size=16384 min_version=ssl3" \
5121 "$P_CLI force_version=ssl3 recsplit=0 \
5122 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5123 0 \
5124 -c "Read from server: 1 bytes read"\
5125 -c "16383 bytes read"\
5126 -C "Read from server: 16384 bytes read"
5127
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005128run_test "Large server packet TLS 1.0 BlockCipher" \
5129 "$P_SRV response_size=16384" \
5130 "$P_CLI force_version=tls1 recsplit=0 \
5131 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5132 0 \
5133 -c "Read from server: 1 bytes read"\
5134 -c "16383 bytes read"\
5135 -C "Read from server: 16384 bytes read"
5136
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005137run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5138 "$P_SRV response_size=16384" \
5139 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5140 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5141 0 \
5142 -c "Read from server: 1 bytes read"\
5143 -c "16383 bytes read"\
5144 -C "Read from server: 16384 bytes read"
5145
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005146requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5147run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5148 "$P_SRV response_size=16384" \
5149 "$P_CLI force_version=tls1 recsplit=0 \
5150 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5151 trunc_hmac=1" \
5152 0 \
5153 -c "Read from server: 1 bytes read"\
5154 -c "16383 bytes read"\
5155 -C "Read from server: 16384 bytes read"
5156
5157requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5158run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5159 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5160 "$P_CLI force_version=tls1 \
5161 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5162 trunc_hmac=1" \
5163 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005164 -s "16384 bytes written in 1 fragments" \
5165 -c "Read from server: 16384 bytes read"
5166
5167run_test "Large server packet TLS 1.0 StreamCipher" \
5168 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5169 "$P_CLI force_version=tls1 \
5170 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5171 0 \
5172 -s "16384 bytes written in 1 fragments" \
5173 -c "Read from server: 16384 bytes read"
5174
5175run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5176 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5177 "$P_CLI force_version=tls1 \
5178 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5179 0 \
5180 -s "16384 bytes written in 1 fragments" \
5181 -c "Read from server: 16384 bytes read"
5182
5183requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5184run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5185 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5186 "$P_CLI force_version=tls1 \
5187 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5188 0 \
5189 -s "16384 bytes written in 1 fragments" \
5190 -c "Read from server: 16384 bytes read"
5191
5192requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5193run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5194 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5195 "$P_CLI force_version=tls1 \
5196 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5197 0 \
5198 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005199 -c "Read from server: 16384 bytes read"
5200
5201run_test "Large server packet TLS 1.1 BlockCipher" \
5202 "$P_SRV response_size=16384" \
5203 "$P_CLI force_version=tls1_1 \
5204 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5205 0 \
5206 -c "Read from server: 16384 bytes read"
5207
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005208run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5209 "$P_SRV response_size=16384" \
5210 "$P_CLI force_version=tls1_1 etm=0 \
5211 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005212 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005213 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005214 -c "Read from server: 16384 bytes read"
5215
5216requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5217run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5218 "$P_SRV response_size=16384" \
5219 "$P_CLI force_version=tls1_1 \
5220 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5221 trunc_hmac=1" \
5222 0 \
5223 -c "Read from server: 16384 bytes read"
5224
5225requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005226run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5227 "$P_SRV response_size=16384 trunc_hmac=1" \
5228 "$P_CLI force_version=tls1_1 \
5229 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5230 0 \
5231 -s "16384 bytes written in 1 fragments" \
5232 -c "Read from server: 16384 bytes read"
5233
5234run_test "Large server packet TLS 1.1 StreamCipher" \
5235 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5236 "$P_CLI force_version=tls1_1 \
5237 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5238 0 \
5239 -c "Read from server: 16384 bytes read"
5240
5241run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5242 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5243 "$P_CLI force_version=tls1_1 \
5244 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5245 0 \
5246 -s "16384 bytes written in 1 fragments" \
5247 -c "Read from server: 16384 bytes read"
5248
5249requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005250run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
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 trunc_hmac=1" \
5255 0 \
5256 -c "Read from server: 16384 bytes read"
5257
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005258run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5259 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5260 "$P_CLI force_version=tls1_1 \
5261 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5262 0 \
5263 -s "16384 bytes written in 1 fragments" \
5264 -c "Read from server: 16384 bytes read"
5265
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005266run_test "Large server packet TLS 1.2 BlockCipher" \
5267 "$P_SRV response_size=16384" \
5268 "$P_CLI force_version=tls1_2 \
5269 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5270 0 \
5271 -c "Read from server: 16384 bytes read"
5272
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005273run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5274 "$P_SRV response_size=16384" \
5275 "$P_CLI force_version=tls1_2 etm=0 \
5276 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5277 0 \
5278 -s "16384 bytes written in 1 fragments" \
5279 -c "Read from server: 16384 bytes read"
5280
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005281run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5282 "$P_SRV response_size=16384" \
5283 "$P_CLI force_version=tls1_2 \
5284 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5285 0 \
5286 -c "Read from server: 16384 bytes read"
5287
5288requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5289run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5290 "$P_SRV response_size=16384" \
5291 "$P_CLI force_version=tls1_2 \
5292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5293 trunc_hmac=1" \
5294 0 \
5295 -c "Read from server: 16384 bytes read"
5296
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005297run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5298 "$P_SRV response_size=16384 trunc_hmac=1" \
5299 "$P_CLI force_version=tls1_2 \
5300 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5301 0 \
5302 -s "16384 bytes written in 1 fragments" \
5303 -c "Read from server: 16384 bytes read"
5304
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005305run_test "Large server packet TLS 1.2 StreamCipher" \
5306 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5307 "$P_CLI force_version=tls1_2 \
5308 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5309 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005310 -s "16384 bytes written in 1 fragments" \
5311 -c "Read from server: 16384 bytes read"
5312
5313run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5314 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5315 "$P_CLI force_version=tls1_2 \
5316 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5317 0 \
5318 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005319 -c "Read from server: 16384 bytes read"
5320
5321requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5322run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5323 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5324 "$P_CLI force_version=tls1_2 \
5325 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5326 trunc_hmac=1" \
5327 0 \
5328 -c "Read from server: 16384 bytes read"
5329
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005330requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5331run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5332 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5333 "$P_CLI force_version=tls1_2 \
5334 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5335 0 \
5336 -s "16384 bytes written in 1 fragments" \
5337 -c "Read from server: 16384 bytes read"
5338
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005339run_test "Large server packet TLS 1.2 AEAD" \
5340 "$P_SRV response_size=16384" \
5341 "$P_CLI force_version=tls1_2 \
5342 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5343 0 \
5344 -c "Read from server: 16384 bytes read"
5345
5346run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5347 "$P_SRV response_size=16384" \
5348 "$P_CLI force_version=tls1_2 \
5349 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5350 0 \
5351 -c "Read from server: 16384 bytes read"
5352
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005353# Tests for restartable ECC
5354
5355requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5356run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005357 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005358 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005359 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005360 debug_level=1" \
5361 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005362 -C "x509_verify_cert.*4b00" \
5363 -C "mbedtls_pk_verify.*4b00" \
5364 -C "mbedtls_ecdh_make_public.*4b00" \
5365 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005366
5367requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5368run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005369 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005370 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005371 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005372 debug_level=1 ec_max_ops=0" \
5373 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005374 -C "x509_verify_cert.*4b00" \
5375 -C "mbedtls_pk_verify.*4b00" \
5376 -C "mbedtls_ecdh_make_public.*4b00" \
5377 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005378
5379requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5380run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005381 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005382 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005383 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005384 debug_level=1 ec_max_ops=65535" \
5385 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005386 -C "x509_verify_cert.*4b00" \
5387 -C "mbedtls_pk_verify.*4b00" \
5388 -C "mbedtls_ecdh_make_public.*4b00" \
5389 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005390
5391requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5392run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005393 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005394 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005395 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005396 debug_level=1 ec_max_ops=1000" \
5397 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005398 -c "x509_verify_cert.*4b00" \
5399 -c "mbedtls_pk_verify.*4b00" \
5400 -c "mbedtls_ecdh_make_public.*4b00" \
5401 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005402
5403requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005404run_test "EC restart: TLS, max_ops=1000, badsign" \
5405 "$P_SRV auth_mode=required \
5406 crt_file=data_files/server5-badsign.crt \
5407 key_file=data_files/server5.key" \
5408 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5409 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5410 debug_level=1 ec_max_ops=1000" \
5411 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005412 -c "x509_verify_cert.*4b00" \
5413 -C "mbedtls_pk_verify.*4b00" \
5414 -C "mbedtls_ecdh_make_public.*4b00" \
5415 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005416 -c "! The certificate is not correctly signed by the trusted CA" \
5417 -c "! mbedtls_ssl_handshake returned" \
5418 -c "X509 - Certificate verification failed"
5419
5420requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5421run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5422 "$P_SRV auth_mode=required \
5423 crt_file=data_files/server5-badsign.crt \
5424 key_file=data_files/server5.key" \
5425 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5426 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5427 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5428 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005429 -c "x509_verify_cert.*4b00" \
5430 -c "mbedtls_pk_verify.*4b00" \
5431 -c "mbedtls_ecdh_make_public.*4b00" \
5432 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005433 -c "! The certificate is not correctly signed by the trusted CA" \
5434 -C "! mbedtls_ssl_handshake returned" \
5435 -C "X509 - Certificate verification failed"
5436
5437requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5438run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5439 "$P_SRV auth_mode=required \
5440 crt_file=data_files/server5-badsign.crt \
5441 key_file=data_files/server5.key" \
5442 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5443 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5444 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5445 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005446 -C "x509_verify_cert.*4b00" \
5447 -c "mbedtls_pk_verify.*4b00" \
5448 -c "mbedtls_ecdh_make_public.*4b00" \
5449 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005450 -C "! The certificate is not correctly signed by the trusted CA" \
5451 -C "! mbedtls_ssl_handshake returned" \
5452 -C "X509 - Certificate verification failed"
5453
5454requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005455run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005456 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005457 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005458 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005459 dtls=1 debug_level=1 ec_max_ops=1000" \
5460 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005461 -c "x509_verify_cert.*4b00" \
5462 -c "mbedtls_pk_verify.*4b00" \
5463 -c "mbedtls_ecdh_make_public.*4b00" \
5464 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005465
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005466requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5467run_test "EC restart: TLS, max_ops=1000 no client auth" \
5468 "$P_SRV" \
5469 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5470 debug_level=1 ec_max_ops=1000" \
5471 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005472 -c "x509_verify_cert.*4b00" \
5473 -c "mbedtls_pk_verify.*4b00" \
5474 -c "mbedtls_ecdh_make_public.*4b00" \
5475 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005476
5477requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5478run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5479 "$P_SRV psk=abc123" \
5480 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5481 psk=abc123 debug_level=1 ec_max_ops=1000" \
5482 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005483 -C "x509_verify_cert.*4b00" \
5484 -C "mbedtls_pk_verify.*4b00" \
5485 -C "mbedtls_ecdh_make_public.*4b00" \
5486 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005487
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005488# Tests of asynchronous private key support in SSL
5489
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005490requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005491run_test "SSL async private: sign, delay=0" \
5492 "$P_SRV \
5493 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005494 "$P_CLI" \
5495 0 \
5496 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005497 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005498
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005499requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005500run_test "SSL async private: sign, delay=1" \
5501 "$P_SRV \
5502 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005503 "$P_CLI" \
5504 0 \
5505 -s "Async sign callback: using key slot " \
5506 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005507 -s "Async resume (slot [0-9]): sign done, status=0"
5508
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005509requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5510run_test "SSL async private: sign, delay=2" \
5511 "$P_SRV \
5512 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5513 "$P_CLI" \
5514 0 \
5515 -s "Async sign callback: using key slot " \
5516 -U "Async sign callback: using key slot " \
5517 -s "Async resume (slot [0-9]): call 1 more times." \
5518 -s "Async resume (slot [0-9]): call 0 more times." \
5519 -s "Async resume (slot [0-9]): sign done, status=0"
5520
Gilles Peskined3268832018-04-26 06:23:59 +02005521# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5522# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5523requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5524requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5525run_test "SSL async private: sign, RSA, TLS 1.1" \
5526 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5527 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5528 "$P_CLI force_version=tls1_1" \
5529 0 \
5530 -s "Async sign callback: using key slot " \
5531 -s "Async resume (slot [0-9]): sign done, status=0"
5532
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005533requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005534run_test "SSL async private: sign, SNI" \
5535 "$P_SRV debug_level=3 \
5536 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5537 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5538 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5539 "$P_CLI server_name=polarssl.example" \
5540 0 \
5541 -s "Async sign callback: using key slot " \
5542 -s "Async resume (slot [0-9]): sign done, status=0" \
5543 -s "parse ServerName extension" \
5544 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5545 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5546
5547requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005548run_test "SSL async private: decrypt, delay=0" \
5549 "$P_SRV \
5550 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5551 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5552 0 \
5553 -s "Async decrypt callback: using key slot " \
5554 -s "Async resume (slot [0-9]): decrypt done, status=0"
5555
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005556requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005557run_test "SSL async private: decrypt, delay=1" \
5558 "$P_SRV \
5559 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5560 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5561 0 \
5562 -s "Async decrypt callback: using key slot " \
5563 -s "Async resume (slot [0-9]): call 0 more times." \
5564 -s "Async resume (slot [0-9]): decrypt done, status=0"
5565
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005566requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005567run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5568 "$P_SRV psk=abc123 \
5569 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5570 "$P_CLI psk=abc123 \
5571 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5572 0 \
5573 -s "Async decrypt callback: using key slot " \
5574 -s "Async resume (slot [0-9]): decrypt done, status=0"
5575
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005576requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005577run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5578 "$P_SRV psk=abc123 \
5579 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5580 "$P_CLI psk=abc123 \
5581 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5582 0 \
5583 -s "Async decrypt callback: using key slot " \
5584 -s "Async resume (slot [0-9]): call 0 more times." \
5585 -s "Async resume (slot [0-9]): decrypt done, status=0"
5586
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005587requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005588run_test "SSL async private: sign callback not present" \
5589 "$P_SRV \
5590 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5591 "$P_CLI; [ \$? -eq 1 ] &&
5592 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5593 0 \
5594 -S "Async sign callback" \
5595 -s "! mbedtls_ssl_handshake returned" \
5596 -s "The own private key or pre-shared key is not set, but needed" \
5597 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5598 -s "Successful connection"
5599
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005600requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005601run_test "SSL async private: decrypt callback not present" \
5602 "$P_SRV debug_level=1 \
5603 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5604 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5605 [ \$? -eq 1 ] && $P_CLI" \
5606 0 \
5607 -S "Async decrypt callback" \
5608 -s "! mbedtls_ssl_handshake returned" \
5609 -s "got no RSA private key" \
5610 -s "Async resume (slot [0-9]): sign done, status=0" \
5611 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005612
5613# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005614requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005615run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005616 "$P_SRV \
5617 async_operations=s async_private_delay1=1 \
5618 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5619 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005620 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5621 0 \
5622 -s "Async sign callback: using key slot 0," \
5623 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005624 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005625
5626# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005627requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005628run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005629 "$P_SRV \
5630 async_operations=s async_private_delay2=1 \
5631 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5632 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005633 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5634 0 \
5635 -s "Async sign callback: using key slot 0," \
5636 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005637 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005638
5639# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005640requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005641run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005642 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005643 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005644 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5645 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005646 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5647 0 \
5648 -s "Async sign callback: using key slot 1," \
5649 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005650 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005651
5652# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005653requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005654run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005655 "$P_SRV \
5656 async_operations=s async_private_delay1=1 \
5657 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5658 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005659 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5660 0 \
5661 -s "Async sign callback: no key matches this certificate."
5662
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005663requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005664run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005665 "$P_SRV \
5666 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5667 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005668 "$P_CLI" \
5669 1 \
5670 -s "Async sign callback: injected error" \
5671 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005672 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005673 -s "! mbedtls_ssl_handshake returned"
5674
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005675requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005676run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005677 "$P_SRV \
5678 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5679 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005680 "$P_CLI" \
5681 1 \
5682 -s "Async sign callback: using key slot " \
5683 -S "Async resume" \
5684 -s "Async cancel"
5685
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005686requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005687run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005688 "$P_SRV \
5689 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5690 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005691 "$P_CLI" \
5692 1 \
5693 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005694 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005695 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005696 -s "! mbedtls_ssl_handshake returned"
5697
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005698requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005699run_test "SSL async private: decrypt, error in start" \
5700 "$P_SRV \
5701 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5702 async_private_error=1" \
5703 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5704 1 \
5705 -s "Async decrypt callback: injected error" \
5706 -S "Async resume" \
5707 -S "Async cancel" \
5708 -s "! mbedtls_ssl_handshake returned"
5709
5710requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5711run_test "SSL async private: decrypt, cancel after start" \
5712 "$P_SRV \
5713 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5714 async_private_error=2" \
5715 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5716 1 \
5717 -s "Async decrypt callback: using key slot " \
5718 -S "Async resume" \
5719 -s "Async cancel"
5720
5721requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5722run_test "SSL async private: decrypt, error in resume" \
5723 "$P_SRV \
5724 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5725 async_private_error=3" \
5726 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5727 1 \
5728 -s "Async decrypt callback: using key slot " \
5729 -s "Async resume callback: decrypt done but injected error" \
5730 -S "Async cancel" \
5731 -s "! mbedtls_ssl_handshake returned"
5732
5733requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005734run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005735 "$P_SRV \
5736 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5737 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005738 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5739 0 \
5740 -s "Async cancel" \
5741 -s "! mbedtls_ssl_handshake returned" \
5742 -s "Async resume" \
5743 -s "Successful connection"
5744
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005745requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005746run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005747 "$P_SRV \
5748 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5749 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005750 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5751 0 \
5752 -s "! mbedtls_ssl_handshake returned" \
5753 -s "Async resume" \
5754 -s "Successful connection"
5755
5756# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005757requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005758run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005759 "$P_SRV \
5760 async_operations=s async_private_delay1=1 async_private_error=-2 \
5761 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5762 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005763 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5764 [ \$? -eq 1 ] &&
5765 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5766 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005767 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005768 -S "Async resume" \
5769 -s "Async cancel" \
5770 -s "! mbedtls_ssl_handshake returned" \
5771 -s "Async sign callback: no key matches this certificate." \
5772 -s "Successful connection"
5773
5774# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005775requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005776run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005777 "$P_SRV \
5778 async_operations=s async_private_delay1=1 async_private_error=-3 \
5779 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5780 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005781 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5782 [ \$? -eq 1 ] &&
5783 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5784 0 \
5785 -s "Async resume" \
5786 -s "! mbedtls_ssl_handshake returned" \
5787 -s "Async sign callback: no key matches this certificate." \
5788 -s "Successful connection"
5789
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005790requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005791requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005792run_test "SSL async private: renegotiation: client-initiated; sign" \
5793 "$P_SRV \
5794 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005795 exchanges=2 renegotiation=1" \
5796 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5797 0 \
5798 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005799 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005800
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005801requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005802requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005803run_test "SSL async private: renegotiation: server-initiated; sign" \
5804 "$P_SRV \
5805 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005806 exchanges=2 renegotiation=1 renegotiate=1" \
5807 "$P_CLI exchanges=2 renegotiation=1" \
5808 0 \
5809 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005810 -s "Async resume (slot [0-9]): sign done, status=0"
5811
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005812requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005813requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5814run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5815 "$P_SRV \
5816 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5817 exchanges=2 renegotiation=1" \
5818 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5819 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5820 0 \
5821 -s "Async decrypt callback: using key slot " \
5822 -s "Async resume (slot [0-9]): decrypt done, status=0"
5823
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005824requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005825requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5826run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5827 "$P_SRV \
5828 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5829 exchanges=2 renegotiation=1 renegotiate=1" \
5830 "$P_CLI exchanges=2 renegotiation=1 \
5831 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5832 0 \
5833 -s "Async decrypt callback: using key slot " \
5834 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005835
Ron Eldor58093c82018-06-28 13:22:05 +03005836# Tests for ECC extensions (rfc 4492)
5837
Ron Eldor643df7c2018-06-28 16:17:00 +03005838requires_config_enabled MBEDTLS_AES_C
5839requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5840requires_config_enabled MBEDTLS_SHA256_C
5841requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005842run_test "Force a non ECC ciphersuite in the client side" \
5843 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005844 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005845 0 \
5846 -C "client hello, adding supported_elliptic_curves extension" \
5847 -C "client hello, adding supported_point_formats extension" \
5848 -S "found supported elliptic curves extension" \
5849 -S "found supported point formats extension"
5850
Ron Eldor643df7c2018-06-28 16:17:00 +03005851requires_config_enabled MBEDTLS_AES_C
5852requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5853requires_config_enabled MBEDTLS_SHA256_C
5854requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005855run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005856 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005857 "$P_CLI debug_level=3" \
5858 0 \
5859 -C "found supported_point_formats extension" \
5860 -S "server hello, supported_point_formats extension"
5861
Ron Eldor643df7c2018-06-28 16:17:00 +03005862requires_config_enabled MBEDTLS_AES_C
5863requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5864requires_config_enabled MBEDTLS_SHA256_C
5865requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005866run_test "Force an ECC ciphersuite in the client side" \
5867 "$P_SRV debug_level=3" \
5868 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5869 0 \
5870 -c "client hello, adding supported_elliptic_curves extension" \
5871 -c "client hello, adding supported_point_formats extension" \
5872 -s "found supported elliptic curves extension" \
5873 -s "found supported point formats extension"
5874
Ron Eldor643df7c2018-06-28 16:17:00 +03005875requires_config_enabled MBEDTLS_AES_C
5876requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5877requires_config_enabled MBEDTLS_SHA256_C
5878requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005879run_test "Force an ECC ciphersuite in the server side" \
5880 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5881 "$P_CLI debug_level=3" \
5882 0 \
5883 -c "found supported_point_formats extension" \
5884 -s "server hello, supported_point_formats extension"
5885
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005886# Tests for DTLS HelloVerifyRequest
5887
5888run_test "DTLS cookie: enabled" \
5889 "$P_SRV dtls=1 debug_level=2" \
5890 "$P_CLI dtls=1 debug_level=2" \
5891 0 \
5892 -s "cookie verification failed" \
5893 -s "cookie verification passed" \
5894 -S "cookie verification skipped" \
5895 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005896 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005897 -S "SSL - The requested feature is not available"
5898
5899run_test "DTLS cookie: disabled" \
5900 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5901 "$P_CLI dtls=1 debug_level=2" \
5902 0 \
5903 -S "cookie verification failed" \
5904 -S "cookie verification passed" \
5905 -s "cookie verification skipped" \
5906 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005907 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005908 -S "SSL - The requested feature is not available"
5909
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005910run_test "DTLS cookie: default (failing)" \
5911 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5912 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5913 1 \
5914 -s "cookie verification failed" \
5915 -S "cookie verification passed" \
5916 -S "cookie verification skipped" \
5917 -C "received hello verify request" \
5918 -S "hello verification requested" \
5919 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005920
5921requires_ipv6
5922run_test "DTLS cookie: enabled, IPv6" \
5923 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5924 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5925 0 \
5926 -s "cookie verification failed" \
5927 -s "cookie verification passed" \
5928 -S "cookie verification skipped" \
5929 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005930 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005931 -S "SSL - The requested feature is not available"
5932
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005933run_test "DTLS cookie: enabled, nbio" \
5934 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5935 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5936 0 \
5937 -s "cookie verification failed" \
5938 -s "cookie verification passed" \
5939 -S "cookie verification skipped" \
5940 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005941 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005942 -S "SSL - The requested feature is not available"
5943
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005944# Tests for client reconnecting from the same port with DTLS
5945
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005946not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005947run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005948 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5949 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005950 0 \
5951 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005952 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005953 -S "Client initiated reconnection from same port"
5954
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005955not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005956run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005957 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5958 "$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 +02005959 0 \
5960 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005961 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005962 -s "Client initiated reconnection from same port"
5963
Paul Bakker362689d2016-05-13 10:33:25 +01005964not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5965run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005966 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5967 "$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 +02005968 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005969 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005970 -s "Client initiated reconnection from same port"
5971
Paul Bakker362689d2016-05-13 10:33:25 +01005972only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5973run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5974 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5975 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5976 0 \
5977 -S "The operation timed out" \
5978 -s "Client initiated reconnection from same port"
5979
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005980run_test "DTLS client reconnect from same port: no cookies" \
5981 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005982 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5983 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005984 -s "The operation timed out" \
5985 -S "Client initiated reconnection from same port"
5986
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005987run_test "DTLS client reconnect from same port: attacker-injected" \
5988 -p "$P_PXY inject_clihlo=1" \
5989 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5990 "$P_CLI dtls=1 exchanges=2" \
5991 0 \
5992 -s "possible client reconnect from the same port" \
5993 -S "Client initiated reconnection from same port"
5994
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005995# Tests for various cases of client authentication with DTLS
5996# (focused on handshake flows and message parsing)
5997
5998run_test "DTLS client auth: required" \
5999 "$P_SRV dtls=1 auth_mode=required" \
6000 "$P_CLI dtls=1" \
6001 0 \
6002 -s "Verifying peer X.509 certificate... ok"
6003
6004run_test "DTLS client auth: optional, client has no cert" \
6005 "$P_SRV dtls=1 auth_mode=optional" \
6006 "$P_CLI dtls=1 crt_file=none key_file=none" \
6007 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006008 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006009
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006010run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006011 "$P_SRV dtls=1 auth_mode=none" \
6012 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
6013 0 \
6014 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006015 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006016
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02006017run_test "DTLS wrong PSK: badmac alert" \
6018 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
6019 "$P_CLI dtls=1 psk=abc124" \
6020 1 \
6021 -s "SSL - Verification of the message MAC failed" \
6022 -c "SSL - A fatal alert message was received from our peer"
6023
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02006024# Tests for receiving fragmented handshake messages with DTLS
6025
6026requires_gnutls
6027run_test "DTLS reassembly: no fragmentation (gnutls server)" \
6028 "$G_SRV -u --mtu 2048 -a" \
6029 "$P_CLI dtls=1 debug_level=2" \
6030 0 \
6031 -C "found fragmented DTLS handshake message" \
6032 -C "error"
6033
6034requires_gnutls
6035run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6036 "$G_SRV -u --mtu 512" \
6037 "$P_CLI dtls=1 debug_level=2" \
6038 0 \
6039 -c "found fragmented DTLS handshake message" \
6040 -C "error"
6041
6042requires_gnutls
6043run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6044 "$G_SRV -u --mtu 128" \
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: more fragmentation, nbio (gnutls server)" \
6052 "$G_SRV -u --mtu 128" \
6053 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6054 0 \
6055 -c "found fragmented DTLS handshake message" \
6056 -C "error"
6057
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006058requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006059requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006060run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6061 "$G_SRV -u --mtu 256" \
6062 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6063 0 \
6064 -c "found fragmented DTLS handshake message" \
6065 -c "client hello, adding renegotiation extension" \
6066 -c "found renegotiation extension" \
6067 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006068 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006069 -C "error" \
6070 -s "Extra-header:"
6071
6072requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006073requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006074run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6075 "$G_SRV -u --mtu 256" \
6076 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6077 0 \
6078 -c "found fragmented DTLS handshake message" \
6079 -c "client hello, adding renegotiation extension" \
6080 -c "found renegotiation extension" \
6081 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006082 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006083 -C "error" \
6084 -s "Extra-header:"
6085
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006086run_test "DTLS reassembly: no fragmentation (openssl server)" \
6087 "$O_SRV -dtls1 -mtu 2048" \
6088 "$P_CLI dtls=1 debug_level=2" \
6089 0 \
6090 -C "found fragmented DTLS handshake message" \
6091 -C "error"
6092
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006093run_test "DTLS reassembly: some fragmentation (openssl server)" \
6094 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006095 "$P_CLI dtls=1 debug_level=2" \
6096 0 \
6097 -c "found fragmented DTLS handshake message" \
6098 -C "error"
6099
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006100run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02006101 "$O_SRV -dtls1 -mtu 256" \
6102 "$P_CLI dtls=1 debug_level=2" \
6103 0 \
6104 -c "found fragmented DTLS handshake message" \
6105 -C "error"
6106
6107run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6108 "$O_SRV -dtls1 -mtu 256" \
6109 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6110 0 \
6111 -c "found fragmented DTLS handshake message" \
6112 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006113
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006114# Tests for sending fragmented handshake messages with DTLS
6115#
6116# Use client auth when we need the client to send large messages,
6117# and use large cert chains on both sides too (the long chains we have all use
6118# both RSA and ECDSA, but ideally we should have long chains with either).
6119# Sizes reached (UDP payload):
6120# - 2037B for server certificate
6121# - 1542B for client certificate
6122# - 1013B for newsessionticket
6123# - all others below 512B
6124# All those tests assume MAX_CONTENT_LEN is at least 2048
6125
6126requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6127requires_config_enabled MBEDTLS_RSA_C
6128requires_config_enabled MBEDTLS_ECDSA_C
6129requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006130requires_max_content_len 4096
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006131run_test "DTLS fragmenting: none (for reference)" \
6132 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6133 crt_file=data_files/server7_int-ca.crt \
6134 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006135 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006136 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006137 "$P_CLI dtls=1 debug_level=2 \
6138 crt_file=data_files/server8_int-ca2.crt \
6139 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006140 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006141 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006142 0 \
6143 -S "found fragmented DTLS handshake message" \
6144 -C "found fragmented DTLS handshake message" \
6145 -C "error"
6146
6147requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6148requires_config_enabled MBEDTLS_RSA_C
6149requires_config_enabled MBEDTLS_ECDSA_C
6150requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006151requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006152run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006153 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6154 crt_file=data_files/server7_int-ca.crt \
6155 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006156 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006157 max_frag_len=1024" \
6158 "$P_CLI dtls=1 debug_level=2 \
6159 crt_file=data_files/server8_int-ca2.crt \
6160 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006161 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006162 max_frag_len=2048" \
6163 0 \
6164 -S "found fragmented DTLS handshake message" \
6165 -c "found fragmented DTLS handshake message" \
6166 -C "error"
6167
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006168# With the MFL extension, the server has no way of forcing
6169# the client to not exceed a certain MTU; hence, the following
6170# test can't be replicated with an MTU proxy such as the one
6171# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006172requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6173requires_config_enabled MBEDTLS_RSA_C
6174requires_config_enabled MBEDTLS_ECDSA_C
6175requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006176requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006177run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006178 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6179 crt_file=data_files/server7_int-ca.crt \
6180 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006181 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006182 max_frag_len=512" \
6183 "$P_CLI dtls=1 debug_level=2 \
6184 crt_file=data_files/server8_int-ca2.crt \
6185 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006186 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006187 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006188 0 \
6189 -S "found fragmented DTLS handshake message" \
6190 -c "found fragmented DTLS handshake message" \
6191 -C "error"
6192
6193requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6194requires_config_enabled MBEDTLS_RSA_C
6195requires_config_enabled MBEDTLS_ECDSA_C
6196requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006197requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006198run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006199 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6200 crt_file=data_files/server7_int-ca.crt \
6201 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006202 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006203 max_frag_len=2048" \
6204 "$P_CLI dtls=1 debug_level=2 \
6205 crt_file=data_files/server8_int-ca2.crt \
6206 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006207 hs_timeout=2500-60000 \
6208 max_frag_len=1024" \
6209 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006210 -S "found fragmented DTLS handshake message" \
6211 -c "found fragmented DTLS handshake message" \
6212 -C "error"
6213
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006214# While not required by the standard defining the MFL extension
6215# (according to which it only applies to records, not to datagrams),
6216# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6217# as otherwise there wouldn't be any means to communicate MTU restrictions
6218# to the peer.
6219# The next test checks that no datagrams significantly larger than the
6220# negotiated MFL are sent.
6221requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6222requires_config_enabled MBEDTLS_RSA_C
6223requires_config_enabled MBEDTLS_ECDSA_C
6224requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006225requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006226run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006227 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006228 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6229 crt_file=data_files/server7_int-ca.crt \
6230 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006231 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006232 max_frag_len=2048" \
6233 "$P_CLI dtls=1 debug_level=2 \
6234 crt_file=data_files/server8_int-ca2.crt \
6235 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006236 hs_timeout=2500-60000 \
6237 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006238 0 \
6239 -S "found fragmented DTLS handshake message" \
6240 -c "found fragmented DTLS handshake message" \
6241 -C "error"
6242
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006243requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6244requires_config_enabled MBEDTLS_RSA_C
6245requires_config_enabled MBEDTLS_ECDSA_C
6246requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006247requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006248run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006249 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6250 crt_file=data_files/server7_int-ca.crt \
6251 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006252 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006253 max_frag_len=2048" \
6254 "$P_CLI dtls=1 debug_level=2 \
6255 crt_file=data_files/server8_int-ca2.crt \
6256 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006257 hs_timeout=2500-60000 \
6258 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006259 0 \
6260 -s "found fragmented DTLS handshake message" \
6261 -c "found fragmented DTLS handshake message" \
6262 -C "error"
6263
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006264# While not required by the standard defining the MFL extension
6265# (according to which it only applies to records, not to datagrams),
6266# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6267# as otherwise there wouldn't be any means to communicate MTU restrictions
6268# to the peer.
6269# The next test checks that no datagrams significantly larger than the
6270# negotiated MFL are sent.
6271requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6272requires_config_enabled MBEDTLS_RSA_C
6273requires_config_enabled MBEDTLS_ECDSA_C
6274requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Yuto Takanoc75df632021-07-08 15:56:33 +01006275requires_max_content_len 2048
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006276run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006277 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006278 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6279 crt_file=data_files/server7_int-ca.crt \
6280 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006281 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006282 max_frag_len=2048" \
6283 "$P_CLI dtls=1 debug_level=2 \
6284 crt_file=data_files/server8_int-ca2.crt \
6285 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006286 hs_timeout=2500-60000 \
6287 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006288 0 \
6289 -s "found fragmented DTLS handshake message" \
6290 -c "found fragmented DTLS handshake message" \
6291 -C "error"
6292
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006293requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6294requires_config_enabled MBEDTLS_RSA_C
6295requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006296requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006297run_test "DTLS fragmenting: none (for reference) (MTU)" \
6298 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6299 crt_file=data_files/server7_int-ca.crt \
6300 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006301 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006302 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006303 "$P_CLI dtls=1 debug_level=2 \
6304 crt_file=data_files/server8_int-ca2.crt \
6305 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006306 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006307 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006308 0 \
6309 -S "found fragmented DTLS handshake message" \
6310 -C "found fragmented DTLS handshake message" \
6311 -C "error"
6312
6313requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6314requires_config_enabled MBEDTLS_RSA_C
6315requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006316requires_max_content_len 4096
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006317run_test "DTLS fragmenting: client (MTU)" \
6318 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6319 crt_file=data_files/server7_int-ca.crt \
6320 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006321 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006322 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006323 "$P_CLI dtls=1 debug_level=2 \
6324 crt_file=data_files/server8_int-ca2.crt \
6325 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006326 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006327 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006328 0 \
6329 -s "found fragmented DTLS handshake message" \
6330 -C "found fragmented DTLS handshake message" \
6331 -C "error"
6332
6333requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6334requires_config_enabled MBEDTLS_RSA_C
6335requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006336requires_max_content_len 2048
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006337run_test "DTLS fragmenting: server (MTU)" \
6338 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6339 crt_file=data_files/server7_int-ca.crt \
6340 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006341 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006342 mtu=512" \
6343 "$P_CLI dtls=1 debug_level=2 \
6344 crt_file=data_files/server8_int-ca2.crt \
6345 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006346 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006347 mtu=2048" \
6348 0 \
6349 -S "found fragmented DTLS handshake message" \
6350 -c "found fragmented DTLS handshake message" \
6351 -C "error"
6352
6353requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6354requires_config_enabled MBEDTLS_RSA_C
6355requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006356requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006357run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006358 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006359 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6360 crt_file=data_files/server7_int-ca.crt \
6361 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006362 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006363 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006364 "$P_CLI dtls=1 debug_level=2 \
6365 crt_file=data_files/server8_int-ca2.crt \
6366 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006367 hs_timeout=2500-60000 \
6368 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006369 0 \
6370 -s "found fragmented DTLS handshake message" \
6371 -c "found fragmented DTLS handshake message" \
6372 -C "error"
6373
Andrzej Kurek77826052018-10-11 07:34:08 -04006374# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006375requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6376requires_config_enabled MBEDTLS_RSA_C
6377requires_config_enabled MBEDTLS_ECDSA_C
6378requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006379requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006380requires_config_enabled MBEDTLS_AES_C
6381requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006382requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006383run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006384 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006385 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6386 crt_file=data_files/server7_int-ca.crt \
6387 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006388 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006389 mtu=512" \
6390 "$P_CLI dtls=1 debug_level=2 \
6391 crt_file=data_files/server8_int-ca2.crt \
6392 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006393 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6394 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006395 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006396 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006397 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006398 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006399 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006400
Andrzej Kurek7311c782018-10-11 06:49:41 -04006401# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006402# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006403# The ratio of max/min timeout should ideally equal 4 to accept two
6404# retransmissions, but in some cases (like both the server and client using
6405# fragmentation and auto-reduction) an extra retransmission might occur,
6406# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006407not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006408requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6409requires_config_enabled MBEDTLS_RSA_C
6410requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006411requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006412requires_config_enabled MBEDTLS_AES_C
6413requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006414requires_max_content_len 2048
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006415run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6416 -p "$P_PXY mtu=508" \
6417 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6418 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006419 key_file=data_files/server7.key \
6420 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006421 "$P_CLI dtls=1 debug_level=2 \
6422 crt_file=data_files/server8_int-ca2.crt \
6423 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006424 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6425 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006426 0 \
6427 -s "found fragmented DTLS handshake message" \
6428 -c "found fragmented DTLS handshake message" \
6429 -C "error"
6430
Andrzej Kurek77826052018-10-11 07:34:08 -04006431# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006432only_with_valgrind
6433requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6434requires_config_enabled MBEDTLS_RSA_C
6435requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006436requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006437requires_config_enabled MBEDTLS_AES_C
6438requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006439requires_max_content_len 2048
Hanno Becker108992e2018-08-29 17:04:18 +01006440run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6441 -p "$P_PXY mtu=508" \
6442 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6443 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006444 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006445 hs_timeout=250-10000" \
6446 "$P_CLI dtls=1 debug_level=2 \
6447 crt_file=data_files/server8_int-ca2.crt \
6448 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006449 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006450 hs_timeout=250-10000" \
6451 0 \
6452 -s "found fragmented DTLS handshake message" \
6453 -c "found fragmented DTLS handshake message" \
6454 -C "error"
6455
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006456# 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 +02006457# OTOH the client might resend if the server is to slow to reset after sending
6458# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006459not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006460requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6461requires_config_enabled MBEDTLS_RSA_C
6462requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006463requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006464run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006465 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006466 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6467 crt_file=data_files/server7_int-ca.crt \
6468 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006469 hs_timeout=10000-60000 \
6470 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006471 "$P_CLI dtls=1 debug_level=2 \
6472 crt_file=data_files/server8_int-ca2.crt \
6473 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006474 hs_timeout=10000-60000 \
6475 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006476 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006477 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006478 -s "found fragmented DTLS handshake message" \
6479 -c "found fragmented DTLS handshake message" \
6480 -C "error"
6481
Andrzej Kurek77826052018-10-11 07:34:08 -04006482# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006483# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6484# OTOH the client might resend if the server is to slow to reset after sending
6485# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006486not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006487requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6488requires_config_enabled MBEDTLS_RSA_C
6489requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006490requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006491requires_config_enabled MBEDTLS_AES_C
6492requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006493requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006494run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006495 -p "$P_PXY mtu=512" \
6496 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6497 crt_file=data_files/server7_int-ca.crt \
6498 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006499 hs_timeout=10000-60000 \
6500 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006501 "$P_CLI dtls=1 debug_level=2 \
6502 crt_file=data_files/server8_int-ca2.crt \
6503 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006504 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6505 hs_timeout=10000-60000 \
6506 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006507 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006508 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006509 -s "found fragmented DTLS handshake message" \
6510 -c "found fragmented DTLS handshake message" \
6511 -C "error"
6512
Andrzej Kurek7311c782018-10-11 06:49:41 -04006513not_with_valgrind # spurious autoreduction due to timeout
6514requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6515requires_config_enabled MBEDTLS_RSA_C
6516requires_config_enabled MBEDTLS_ECDSA_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006517requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006518run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006519 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006520 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6521 crt_file=data_files/server7_int-ca.crt \
6522 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006523 hs_timeout=10000-60000 \
6524 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006525 "$P_CLI dtls=1 debug_level=2 \
6526 crt_file=data_files/server8_int-ca2.crt \
6527 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006528 hs_timeout=10000-60000 \
6529 mtu=1024 nbio=2" \
6530 0 \
6531 -S "autoreduction" \
6532 -s "found fragmented DTLS handshake message" \
6533 -c "found fragmented DTLS handshake message" \
6534 -C "error"
6535
Andrzej Kurek77826052018-10-11 07:34:08 -04006536# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006537not_with_valgrind # spurious autoreduction due to timeout
6538requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6539requires_config_enabled MBEDTLS_RSA_C
6540requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006541requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006542requires_config_enabled MBEDTLS_AES_C
6543requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006544requires_max_content_len 2048
Andrzej Kurek7311c782018-10-11 06:49:41 -04006545run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6546 -p "$P_PXY mtu=512" \
6547 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6548 crt_file=data_files/server7_int-ca.crt \
6549 key_file=data_files/server7.key \
6550 hs_timeout=10000-60000 \
6551 mtu=512 nbio=2" \
6552 "$P_CLI dtls=1 debug_level=2 \
6553 crt_file=data_files/server8_int-ca2.crt \
6554 key_file=data_files/server8.key \
6555 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6556 hs_timeout=10000-60000 \
6557 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006558 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006559 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006560 -s "found fragmented DTLS handshake message" \
6561 -c "found fragmented DTLS handshake message" \
6562 -C "error"
6563
Andrzej Kurek77826052018-10-11 07:34:08 -04006564# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006565# This ensures things still work after session_reset().
6566# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006567# Since we don't support reading fragmented ClientHello yet,
6568# up the MTU to 1450 (larger than ClientHello with session ticket,
6569# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006570# An autoreduction on the client-side might happen if the server is
6571# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006572# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006573# resumed listening, which would result in a spurious autoreduction.
6574not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006575requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6576requires_config_enabled MBEDTLS_RSA_C
6577requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006578requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006579requires_config_enabled MBEDTLS_AES_C
6580requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006581requires_max_content_len 2048
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006582run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6583 -p "$P_PXY mtu=1450" \
6584 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6585 crt_file=data_files/server7_int-ca.crt \
6586 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006587 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006588 mtu=1450" \
6589 "$P_CLI dtls=1 debug_level=2 \
6590 crt_file=data_files/server8_int-ca2.crt \
6591 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006592 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006593 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006594 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006595 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006596 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006597 -s "found fragmented DTLS handshake message" \
6598 -c "found fragmented DTLS handshake message" \
6599 -C "error"
6600
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006601# An autoreduction on the client-side might happen if the server is
6602# slow to reset, therefore omitting '-C "autoreduction"' below.
6603not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006604requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6605requires_config_enabled MBEDTLS_RSA_C
6606requires_config_enabled MBEDTLS_ECDSA_C
6607requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006608requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006609requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6610requires_config_enabled MBEDTLS_CHACHAPOLY_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006611requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006612run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6613 -p "$P_PXY mtu=512" \
6614 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6615 crt_file=data_files/server7_int-ca.crt \
6616 key_file=data_files/server7.key \
6617 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006618 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006619 mtu=512" \
6620 "$P_CLI dtls=1 debug_level=2 \
6621 crt_file=data_files/server8_int-ca2.crt \
6622 key_file=data_files/server8.key \
6623 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006624 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006625 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006626 mtu=512" \
6627 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006628 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006629 -s "found fragmented DTLS handshake message" \
6630 -c "found fragmented DTLS handshake message" \
6631 -C "error"
6632
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006633# An autoreduction on the client-side might happen if the server is
6634# slow to reset, therefore omitting '-C "autoreduction"' below.
6635not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006636requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6637requires_config_enabled MBEDTLS_RSA_C
6638requires_config_enabled MBEDTLS_ECDSA_C
6639requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006640requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006641requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6642requires_config_enabled MBEDTLS_AES_C
6643requires_config_enabled MBEDTLS_GCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006644requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006645run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6646 -p "$P_PXY mtu=512" \
6647 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6648 crt_file=data_files/server7_int-ca.crt \
6649 key_file=data_files/server7.key \
6650 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006651 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006652 mtu=512" \
6653 "$P_CLI dtls=1 debug_level=2 \
6654 crt_file=data_files/server8_int-ca2.crt \
6655 key_file=data_files/server8.key \
6656 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006657 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006658 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006659 mtu=512" \
6660 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006661 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006662 -s "found fragmented DTLS handshake message" \
6663 -c "found fragmented DTLS handshake message" \
6664 -C "error"
6665
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006666# An autoreduction on the client-side might happen if the server is
6667# slow to reset, therefore omitting '-C "autoreduction"' below.
6668not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006669requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6670requires_config_enabled MBEDTLS_RSA_C
6671requires_config_enabled MBEDTLS_ECDSA_C
6672requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006673requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006674requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6675requires_config_enabled MBEDTLS_AES_C
6676requires_config_enabled MBEDTLS_CCM_C
Yuto Takanoc75df632021-07-08 15:56:33 +01006677requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006678run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006679 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006680 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6681 crt_file=data_files/server7_int-ca.crt \
6682 key_file=data_files/server7.key \
6683 exchanges=2 renegotiation=1 \
6684 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006685 hs_timeout=10000-60000 \
6686 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006687 "$P_CLI dtls=1 debug_level=2 \
6688 crt_file=data_files/server8_int-ca2.crt \
6689 key_file=data_files/server8.key \
6690 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006691 hs_timeout=10000-60000 \
6692 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006693 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006694 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006695 -s "found fragmented DTLS handshake message" \
6696 -c "found fragmented DTLS handshake message" \
6697 -C "error"
6698
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006699# An autoreduction on the client-side might happen if the server is
6700# slow to reset, therefore omitting '-C "autoreduction"' below.
6701not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006702requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6703requires_config_enabled MBEDTLS_RSA_C
6704requires_config_enabled MBEDTLS_ECDSA_C
6705requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006706requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006707requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6708requires_config_enabled MBEDTLS_AES_C
6709requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6710requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
Yuto Takanoc75df632021-07-08 15:56:33 +01006711requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006712run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006713 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006714 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6715 crt_file=data_files/server7_int-ca.crt \
6716 key_file=data_files/server7.key \
6717 exchanges=2 renegotiation=1 \
6718 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006719 hs_timeout=10000-60000 \
6720 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006721 "$P_CLI dtls=1 debug_level=2 \
6722 crt_file=data_files/server8_int-ca2.crt \
6723 key_file=data_files/server8.key \
6724 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006725 hs_timeout=10000-60000 \
6726 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006727 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006728 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006729 -s "found fragmented DTLS handshake message" \
6730 -c "found fragmented DTLS handshake message" \
6731 -C "error"
6732
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006733# An autoreduction on the client-side might happen if the server is
6734# slow to reset, therefore omitting '-C "autoreduction"' below.
6735not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006736requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6737requires_config_enabled MBEDTLS_RSA_C
6738requires_config_enabled MBEDTLS_ECDSA_C
6739requires_config_enabled MBEDTLS_SHA256_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006740requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006741requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6742requires_config_enabled MBEDTLS_AES_C
6743requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
Yuto Takanoc75df632021-07-08 15:56:33 +01006744requires_max_content_len 2048
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006745run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006746 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006747 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6748 crt_file=data_files/server7_int-ca.crt \
6749 key_file=data_files/server7.key \
6750 exchanges=2 renegotiation=1 \
6751 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006752 hs_timeout=10000-60000 \
6753 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006754 "$P_CLI dtls=1 debug_level=2 \
6755 crt_file=data_files/server8_int-ca2.crt \
6756 key_file=data_files/server8.key \
6757 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006758 hs_timeout=10000-60000 \
6759 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006760 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006761 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006762 -s "found fragmented DTLS handshake message" \
6763 -c "found fragmented DTLS handshake message" \
6764 -C "error"
6765
Andrzej Kurek77826052018-10-11 07:34:08 -04006766# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006767requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6768requires_config_enabled MBEDTLS_RSA_C
6769requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006770requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006771requires_config_enabled MBEDTLS_AES_C
6772requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006773client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006774requires_max_content_len 2048
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006775run_test "DTLS fragmenting: proxy MTU + 3d" \
6776 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006777 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006778 crt_file=data_files/server7_int-ca.crt \
6779 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006780 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006781 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006782 crt_file=data_files/server8_int-ca2.crt \
6783 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006784 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006785 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006786 0 \
6787 -s "found fragmented DTLS handshake message" \
6788 -c "found fragmented DTLS handshake message" \
6789 -C "error"
6790
Andrzej Kurek77826052018-10-11 07:34:08 -04006791# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006792requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6793requires_config_enabled MBEDTLS_RSA_C
6794requires_config_enabled MBEDTLS_ECDSA_C
Gilles Peskinec221e532021-07-13 20:34:55 +02006795requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Andrzej Kurek7311c782018-10-11 06:49:41 -04006796requires_config_enabled MBEDTLS_AES_C
6797requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006798client_needs_more_time 2
Yuto Takanoc75df632021-07-08 15:56:33 +01006799requires_max_content_len 2048
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006800run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6801 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6802 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6803 crt_file=data_files/server7_int-ca.crt \
6804 key_file=data_files/server7.key \
6805 hs_timeout=250-10000 mtu=512 nbio=2" \
6806 "$P_CLI dtls=1 debug_level=2 \
6807 crt_file=data_files/server8_int-ca2.crt \
6808 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006809 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006810 hs_timeout=250-10000 mtu=512 nbio=2" \
6811 0 \
6812 -s "found fragmented DTLS handshake message" \
6813 -c "found fragmented DTLS handshake message" \
6814 -C "error"
6815
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006816# interop tests for DTLS fragmentating with reliable connection
6817#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006818# here and below we just want to test that the we fragment in a way that
6819# pleases other implementations, so we don't need the peer to fragment
6820requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6821requires_config_enabled MBEDTLS_RSA_C
6822requires_config_enabled MBEDTLS_ECDSA_C
6823requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006824requires_gnutls
Yuto Takanoc75df632021-07-08 15:56:33 +01006825requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006826run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6827 "$G_SRV -u" \
6828 "$P_CLI dtls=1 debug_level=2 \
6829 crt_file=data_files/server8_int-ca2.crt \
6830 key_file=data_files/server8.key \
6831 mtu=512 force_version=dtls1_2" \
6832 0 \
6833 -c "fragmenting handshake message" \
6834 -C "error"
6835
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_1
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.0" \
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 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006847 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006848 0 \
6849 -c "fragmenting handshake message" \
6850 -C "error"
6851
Hanno Beckerb9a00862018-08-28 10:20:22 +01006852# We use --insecure for the GnuTLS client because it expects
6853# the hostname / IP it connects to to be the name used in the
6854# certificate obtained from the server. Here, however, it
6855# connects to 127.0.0.1 while our test certificates use 'localhost'
6856# as the server name in the certificate. This will make the
6857# certifiate validation fail, but passing --insecure makes
6858# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006859requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6860requires_config_enabled MBEDTLS_RSA_C
6861requires_config_enabled MBEDTLS_ECDSA_C
6862requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006863requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006864requires_not_i686
Yuto Takanoc75df632021-07-08 15:56:33 +01006865requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006866run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006867 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006868 crt_file=data_files/server7_int-ca.crt \
6869 key_file=data_files/server7.key \
6870 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006871 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006872 0 \
6873 -s "fragmenting handshake message"
6874
Hanno Beckerb9a00862018-08-28 10:20:22 +01006875# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006876requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6877requires_config_enabled MBEDTLS_RSA_C
6878requires_config_enabled MBEDTLS_ECDSA_C
6879requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006880requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006881requires_not_i686
Yuto Takanoc75df632021-07-08 15:56:33 +01006882requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006883run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006884 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006885 crt_file=data_files/server7_int-ca.crt \
6886 key_file=data_files/server7.key \
6887 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006888 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006889 0 \
6890 -s "fragmenting handshake message"
6891
6892requires_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_2
Yuto Takanoc75df632021-07-08 15:56:33 +01006896requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006897run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6898 "$O_SRV -dtls1_2 -verify 10" \
6899 "$P_CLI dtls=1 debug_level=2 \
6900 crt_file=data_files/server8_int-ca2.crt \
6901 key_file=data_files/server8.key \
6902 mtu=512 force_version=dtls1_2" \
6903 0 \
6904 -c "fragmenting handshake message" \
6905 -C "error"
6906
6907requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6908requires_config_enabled MBEDTLS_RSA_C
6909requires_config_enabled MBEDTLS_ECDSA_C
6910requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006911requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006912run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6913 "$O_SRV -dtls1 -verify 10" \
6914 "$P_CLI dtls=1 debug_level=2 \
6915 crt_file=data_files/server8_int-ca2.crt \
6916 key_file=data_files/server8.key \
6917 mtu=512 force_version=dtls1" \
6918 0 \
6919 -c "fragmenting handshake message" \
6920 -C "error"
6921
6922requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6923requires_config_enabled MBEDTLS_RSA_C
6924requires_config_enabled MBEDTLS_ECDSA_C
6925requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Yuto Takanoc75df632021-07-08 15:56:33 +01006926requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006927run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6928 "$P_SRV dtls=1 debug_level=2 \
6929 crt_file=data_files/server7_int-ca.crt \
6930 key_file=data_files/server7.key \
6931 mtu=512 force_version=dtls1_2" \
6932 "$O_CLI -dtls1_2" \
6933 0 \
6934 -s "fragmenting handshake message"
6935
6936requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6937requires_config_enabled MBEDTLS_RSA_C
6938requires_config_enabled MBEDTLS_ECDSA_C
6939requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Yuto Takanoc75df632021-07-08 15:56:33 +01006940requires_max_content_len 2048
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006941run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6942 "$P_SRV dtls=1 debug_level=2 \
6943 crt_file=data_files/server7_int-ca.crt \
6944 key_file=data_files/server7.key \
6945 mtu=512 force_version=dtls1" \
6946 "$O_CLI -dtls1" \
6947 0 \
6948 -s "fragmenting handshake message"
6949
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006950# interop tests for DTLS fragmentating with unreliable connection
6951#
6952# again we just want to test that the we fragment in a way that
6953# pleases other implementations, so we don't need the peer to fragment
6954requires_gnutls_next
6955requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6956requires_config_enabled MBEDTLS_RSA_C
6957requires_config_enabled MBEDTLS_ECDSA_C
6958requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006959client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006960requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006961run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6962 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6963 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006964 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006965 crt_file=data_files/server8_int-ca2.crt \
6966 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006967 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006968 0 \
6969 -c "fragmenting handshake message" \
6970 -C "error"
6971
6972requires_gnutls_next
6973requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6974requires_config_enabled MBEDTLS_RSA_C
6975requires_config_enabled MBEDTLS_ECDSA_C
6976requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006977client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006978requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006979run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6980 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6981 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006982 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006983 crt_file=data_files/server8_int-ca2.crt \
6984 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006985 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006986 0 \
6987 -c "fragmenting handshake message" \
6988 -C "error"
6989
k-stachowiakabb843e2019-02-18 16:14:03 +01006990requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006991requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6992requires_config_enabled MBEDTLS_RSA_C
6993requires_config_enabled MBEDTLS_ECDSA_C
6994requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6995client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01006996requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006997run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6998 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6999 "$P_SRV dtls=1 debug_level=2 \
7000 crt_file=data_files/server7_int-ca.crt \
7001 key_file=data_files/server7.key \
7002 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007003 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007004 0 \
7005 -s "fragmenting handshake message"
7006
k-stachowiakabb843e2019-02-18 16:14:03 +01007007requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007008requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7009requires_config_enabled MBEDTLS_RSA_C
7010requires_config_enabled MBEDTLS_ECDSA_C
7011requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7012client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007013requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007014run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
7015 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7016 "$P_SRV dtls=1 debug_level=2 \
7017 crt_file=data_files/server7_int-ca.crt \
7018 key_file=data_files/server7.key \
7019 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007020 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007021 0 \
7022 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007023
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007024## Interop test with OpenSSL might trigger a bug in recent versions (including
7025## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007026## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007027## They should be re-enabled once a fixed version of OpenSSL is available
7028## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007029skip_next_test
7030requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7031requires_config_enabled MBEDTLS_RSA_C
7032requires_config_enabled MBEDTLS_ECDSA_C
7033requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7034client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007035requires_max_content_len 2048
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007036run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
7037 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7038 "$O_SRV -dtls1_2 -verify 10" \
7039 "$P_CLI dtls=1 debug_level=2 \
7040 crt_file=data_files/server8_int-ca2.crt \
7041 key_file=data_files/server8.key \
7042 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7043 0 \
7044 -c "fragmenting handshake message" \
7045 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007046
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007047skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007048requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7049requires_config_enabled MBEDTLS_RSA_C
7050requires_config_enabled MBEDTLS_ECDSA_C
7051requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007052client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007053requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007054run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
7055 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007056 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007057 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007058 crt_file=data_files/server8_int-ca2.crt \
7059 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007060 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007061 0 \
7062 -c "fragmenting handshake message" \
7063 -C "error"
7064
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007065skip_next_test
7066requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7067requires_config_enabled MBEDTLS_RSA_C
7068requires_config_enabled MBEDTLS_ECDSA_C
7069requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7070client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007071requires_max_content_len 2048
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007072run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
7073 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7074 "$P_SRV dtls=1 debug_level=2 \
7075 crt_file=data_files/server7_int-ca.crt \
7076 key_file=data_files/server7.key \
7077 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7078 "$O_CLI -dtls1_2" \
7079 0 \
7080 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007081
7082# -nbio is added to prevent s_client from blocking in case of duplicated
7083# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007084skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007085requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7086requires_config_enabled MBEDTLS_RSA_C
7087requires_config_enabled MBEDTLS_ECDSA_C
7088requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007089client_needs_more_time 4
Yuto Takanoc75df632021-07-08 15:56:33 +01007090requires_max_content_len 2048
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007091run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
7092 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007093 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007094 crt_file=data_files/server7_int-ca.crt \
7095 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007096 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007097 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007098 0 \
7099 -s "fragmenting handshake message"
7100
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007101# Tests for specific things with "unreliable" UDP connection
7102
7103not_with_valgrind # spurious resend due to timeout
7104run_test "DTLS proxy: reference" \
7105 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007106 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7107 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007108 0 \
7109 -C "replayed record" \
7110 -S "replayed record" \
7111 -C "record from another epoch" \
7112 -S "record from another epoch" \
7113 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007114 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007115 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007116 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007117 -c "HTTP/1.0 200 OK"
7118
7119not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007120run_test "DTLS proxy: duplicate every packet" \
7121 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02007122 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7123 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007124 0 \
7125 -c "replayed record" \
7126 -s "replayed record" \
7127 -c "record from another epoch" \
7128 -s "record from another epoch" \
7129 -S "resend" \
7130 -s "Extra-header:" \
7131 -c "HTTP/1.0 200 OK"
7132
7133run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7134 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007135 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7136 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007137 0 \
7138 -c "replayed record" \
7139 -S "replayed record" \
7140 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007141 -s "record from another epoch" \
7142 -c "resend" \
7143 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007144 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007145 -c "HTTP/1.0 200 OK"
7146
7147run_test "DTLS proxy: multiple records in same datagram" \
7148 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007149 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7150 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007151 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007152 -c "next record in same datagram" \
7153 -s "next record in same datagram"
7154
7155run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7156 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007157 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7158 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007159 0 \
7160 -c "next record in same datagram" \
7161 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007162
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007163run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7164 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007165 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7166 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007167 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007168 -c "discarding invalid record (mac)" \
7169 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007170 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007171 -c "HTTP/1.0 200 OK" \
7172 -S "too many records with bad MAC" \
7173 -S "Verification of the message MAC failed"
7174
7175run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7176 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007177 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7178 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007179 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007180 -C "discarding invalid record (mac)" \
7181 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007182 -S "Extra-header:" \
7183 -C "HTTP/1.0 200 OK" \
7184 -s "too many records with bad MAC" \
7185 -s "Verification of the message MAC failed"
7186
7187run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7188 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007189 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7190 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007191 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007192 -c "discarding invalid record (mac)" \
7193 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007194 -s "Extra-header:" \
7195 -c "HTTP/1.0 200 OK" \
7196 -S "too many records with bad MAC" \
7197 -S "Verification of the message MAC failed"
7198
7199run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7200 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007201 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7202 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007203 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007204 -c "discarding invalid record (mac)" \
7205 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007206 -s "Extra-header:" \
7207 -c "HTTP/1.0 200 OK" \
7208 -s "too many records with bad MAC" \
7209 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007210
7211run_test "DTLS proxy: delay ChangeCipherSpec" \
7212 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007213 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7214 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007215 0 \
7216 -c "record from another epoch" \
7217 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007218 -s "Extra-header:" \
7219 -c "HTTP/1.0 200 OK"
7220
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007221# Tests for reordering support with DTLS
7222
Hanno Becker56cdfd12018-08-17 13:42:15 +01007223run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7224 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007225 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7226 hs_timeout=2500-60000" \
7227 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7228 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007229 0 \
7230 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007231 -c "Next handshake message has been buffered - load"\
7232 -S "Buffering HS message" \
7233 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007234 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007235 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007236 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007237 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007238
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007239run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7240 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007241 "$P_SRV mtu=512 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 Beckerdc1e9502018-08-28 16:02:33 +01007245 0 \
7246 -c "Buffering HS message" \
7247 -c "found fragmented DTLS handshake message"\
7248 -c "Next handshake message 1 not or only partially bufffered" \
7249 -c "Next handshake message has been buffered - load"\
7250 -S "Buffering HS message" \
7251 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007252 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007253 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007254 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007255 -S "Remember CCS message"
7256
Hanno Beckera1adcca2018-08-24 14:41:07 +01007257# The client buffers the ServerKeyExchange before receiving the fragmented
7258# Certificate message; at the time of writing, together these are aroudn 1200b
7259# in size, so that the bound below ensures that the certificate can be reassembled
7260# while keeping the ServerKeyExchange.
7261requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7262run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007263 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007264 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7265 hs_timeout=2500-60000" \
7266 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7267 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007268 0 \
7269 -c "Buffering HS message" \
7270 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007271 -C "attempt to make space by freeing buffered messages" \
7272 -S "Buffering HS message" \
7273 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007274 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007275 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007276 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007277 -S "Remember CCS message"
7278
7279# The size constraints ensure that the delayed certificate message can't
7280# be reassembled while keeping the ServerKeyExchange message, but it can
7281# when dropping it first.
7282requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7283requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7284run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7285 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007286 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7287 hs_timeout=2500-60000" \
7288 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7289 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007290 0 \
7291 -c "Buffering HS message" \
7292 -c "attempt to make space by freeing buffered future messages" \
7293 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007294 -S "Buffering HS message" \
7295 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007296 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007297 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007298 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007299 -S "Remember CCS message"
7300
Hanno Becker56cdfd12018-08-17 13:42:15 +01007301run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7302 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007303 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7304 hs_timeout=2500-60000" \
7305 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7306 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007307 0 \
7308 -C "Buffering HS message" \
7309 -C "Next handshake message has been buffered - load"\
7310 -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 Becker56cdfd12018-08-17 13:42:15 +01007313 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007314 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007315 -S "Remember CCS message"
7316
7317run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7318 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007319 "$P_SRV dgram_packing=0 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 server"\
7334 -p "$P_PXY delay_cli=ClientKeyExchange" \
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
Hanno Beckera1adcca2018-08-24 14:41:07 +01007349run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007350 -p "$P_PXY delay_ccs=1" \
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 Beckerb34149c2018-08-16 15:29:06 +01007355 0 \
7356 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007357 -s "Found buffered record from current epoch - load" \
7358 -c "Buffer record from epoch 1" \
7359 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007360
Hanno Beckera1adcca2018-08-24 14:41:07 +01007361# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7362# from the server are delayed, so that the encrypted Finished message
7363# is received and buffered. When the fragmented NewSessionTicket comes
7364# in afterwards, the encrypted Finished message must be freed in order
7365# to make space for the NewSessionTicket to be reassembled.
7366# This works only in very particular circumstances:
7367# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7368# of the NewSessionTicket, but small enough to also allow buffering of
7369# the encrypted Finished message.
7370# - The MTU setting on the server must be so small that the NewSessionTicket
7371# needs to be fragmented.
7372# - All messages sent by the server must be small enough to be either sent
7373# without fragmentation or be reassembled within the bounds of
7374# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7375# handshake, omitting CRTs.
7376requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7377requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7378run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7379 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7380 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7381 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7382 0 \
7383 -s "Buffer record from epoch 1" \
7384 -s "Found buffered record from current epoch - load" \
7385 -c "Buffer record from epoch 1" \
7386 -C "Found buffered record from current epoch - load" \
7387 -c "Enough space available after freeing future epoch record"
7388
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007389# Tests for "randomly unreliable connection": try a variety of flows and peers
7390
7391client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007392run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7393 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007394 "$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 +02007395 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007396 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007397 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7398 0 \
7399 -s "Extra-header:" \
7400 -c "HTTP/1.0 200 OK"
7401
Janos Follath74537a62016-09-02 13:45:28 +01007402client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007403run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7404 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007405 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7406 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007407 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7408 0 \
7409 -s "Extra-header:" \
7410 -c "HTTP/1.0 200 OK"
7411
Janos Follath74537a62016-09-02 13:45:28 +01007412client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007413run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7414 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007415 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7416 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007417 0 \
7418 -s "Extra-header:" \
7419 -c "HTTP/1.0 200 OK"
7420
Janos Follath74537a62016-09-02 13:45:28 +01007421client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007422run_test "DTLS proxy: 3d, FS, client auth" \
7423 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007424 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7425 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007426 0 \
7427 -s "Extra-header:" \
7428 -c "HTTP/1.0 200 OK"
7429
Janos Follath74537a62016-09-02 13:45:28 +01007430client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007431run_test "DTLS proxy: 3d, FS, ticket" \
7432 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007433 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7434 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007435 0 \
7436 -s "Extra-header:" \
7437 -c "HTTP/1.0 200 OK"
7438
Janos Follath74537a62016-09-02 13:45:28 +01007439client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007440run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007442 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7443 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007444 0 \
7445 -s "Extra-header:" \
7446 -c "HTTP/1.0 200 OK"
7447
Janos Follath74537a62016-09-02 13:45:28 +01007448client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007449run_test "DTLS proxy: 3d, max handshake, nbio" \
7450 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007451 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007452 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007453 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007454 0 \
7455 -s "Extra-header:" \
7456 -c "HTTP/1.0 200 OK"
7457
Janos Follath74537a62016-09-02 13:45:28 +01007458client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007459run_test "DTLS proxy: 3d, min handshake, resumption" \
7460 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007461 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007462 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007463 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007464 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007465 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7466 0 \
7467 -s "a session has been resumed" \
7468 -c "a session has been resumed" \
7469 -s "Extra-header:" \
7470 -c "HTTP/1.0 200 OK"
7471
Janos Follath74537a62016-09-02 13:45:28 +01007472client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007473run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7474 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007475 "$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 +02007476 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007477 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007478 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007479 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7480 0 \
7481 -s "a session has been resumed" \
7482 -c "a session has been resumed" \
7483 -s "Extra-header:" \
7484 -c "HTTP/1.0 200 OK"
7485
Janos Follath74537a62016-09-02 13:45:28 +01007486client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007487requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007488run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007489 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007490 "$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 +02007491 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007492 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007493 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007494 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7495 0 \
7496 -c "=> renegotiate" \
7497 -s "=> renegotiate" \
7498 -s "Extra-header:" \
7499 -c "HTTP/1.0 200 OK"
7500
Janos Follath74537a62016-09-02 13:45:28 +01007501client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007502requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007503run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7504 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007505 "$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 +02007506 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007507 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007508 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007509 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7510 0 \
7511 -c "=> renegotiate" \
7512 -s "=> renegotiate" \
7513 -s "Extra-header:" \
7514 -c "HTTP/1.0 200 OK"
7515
Janos Follath74537a62016-09-02 13:45:28 +01007516client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007518run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007519 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007520 "$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 +02007521 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007522 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é-Gonnarda6ace042014-10-15 12:44:41 +02007524 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +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, nbio" \
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 nbio=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 nbio=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
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007548## Interop tests with OpenSSL might trigger a bug in recent versions (including
7549## all versions installed on the CI machines), reported here:
7550## Bug report: https://github.com/openssl/openssl/issues/6902
7551## They should be re-enabled once a fixed version of OpenSSL is available
7552## (this should happen in some 1.1.1_ release according to the ticket).
7553skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007554client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007555not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007556run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007557 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7558 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007559 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007560 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007561 -c "HTTP/1.0 200 OK"
7562
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007563skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007564client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007565not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007566run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7567 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7568 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007569 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007570 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007571 -c "HTTP/1.0 200 OK"
7572
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007573skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007574client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007575not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007576run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7577 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7578 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007579 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007580 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007581 -c "HTTP/1.0 200 OK"
7582
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007583requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007584client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007585not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007586run_test "DTLS proxy: 3d, gnutls server" \
7587 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7588 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007589 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007590 0 \
7591 -s "Extra-header:" \
7592 -c "Extra-header:"
7593
k-stachowiakabb843e2019-02-18 16:14:03 +01007594requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007595client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007596not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007597run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7598 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007599 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007600 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007601 0 \
7602 -s "Extra-header:" \
7603 -c "Extra-header:"
7604
k-stachowiakabb843e2019-02-18 16:14:03 +01007605requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007606client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007607not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007608run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7609 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007610 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007611 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007612 0 \
7613 -s "Extra-header:" \
7614 -c "Extra-header:"
7615
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007616# Final report
7617
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007618echo "------------------------------------------------------------------------"
7619
7620if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007621 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007622else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007623 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007624fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007625PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007626echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007627
7628exit $FAILS