blob: 9d4f650e800f60ca725a6d17c755477c09eeba99 [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#
Simon Butcher58eddef2016-05-19 23:43:11 +01005# Copyright (c) 2016, ARM Limited, All Rights Reserved
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#
Bence Szépkúti51b41d52020-05-26 01:54:15 +020047# This file is part of Mbed TLS (https://tls.mbed.org)
Simon Butcher58eddef2016-05-19 23:43:11 +010048#
49# Purpose
50#
51# Executes tests to prove various TLS/SSL options and extensions.
52#
53# The goal is not to cover every ciphersuite/version, but instead to cover
54# specific options (max fragment length, truncated hmac, etc) or procedures
55# (session resumption from cache or ticket, renego, etc).
56#
57# The tests assume a build with default options, with exceptions expressed
58# with a dependency. The tests focus on functionality and do not consider
59# performance.
60#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010061
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010062set -u
63
Jaeden Ameroa258ccd2019-07-03 13:51:04 +010064# Limit the size of each log to 10 GiB, in case of failures with this script
65# where it may output seemingly unlimited length error logs.
66ulimit -f 20971520
67
Angus Grattonc4dd0732018-04-11 16:28:39 +100068if cd $( dirname $0 ); then :; else
69 echo "cd $( dirname $0 ) failed" >&2
70 exit 1
71fi
72
Antonin Décimod5f47592019-01-23 15:24:37 +010073# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010074: ${P_SRV:=../programs/ssl/ssl_server2}
75: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020076: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010077: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020078: ${GNUTLS_CLI:=gnutls-cli}
79: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020080: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010081
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020082O_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 +010083O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020084G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010085G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020086TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010087
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020088# alternative versions of OpenSSL and GnuTLS (no default path)
89
90if [ -n "${OPENSSL_LEGACY:-}" ]; then
91 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
92 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
93else
94 O_LEGACY_SRV=false
95 O_LEGACY_CLI=false
96fi
97
Hanno Becker58e9dc32018-08-17 15:53:21 +010098if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020099 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
100else
101 G_NEXT_SRV=false
102fi
103
Hanno Becker58e9dc32018-08-17 15:53:21 +0100104if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200105 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
106else
107 G_NEXT_CLI=false
108fi
109
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100110TESTS=0
111FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200112SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100113
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000114CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +0200115
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100116MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100117FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200118EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100119
Paul Bakkere20310a2016-05-10 11:18:17 +0100120SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100121RUN_TEST_NUMBER=''
122
Paul Bakkeracaac852016-05-10 11:47:13 +0100123PRESERVE_LOGS=0
124
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200125# Pick a "unique" server port in the range 10000-19999, and a proxy
126# port which is this plus 10000. Each port number may be independently
127# overridden by a command line option.
128SRV_PORT=$(($$ % 10000 + 10000))
129PXY_PORT=$((SRV_PORT + 10000))
130
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100131print_usage() {
132 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100133 printf " -h|--help\tPrint this help.\n"
134 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200135 printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
136 printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100137 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100138 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100139 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200140 printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
141 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Andres AGf04f54d2016-10-10 15:46:20 +0100142 printf " --seed\tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100143}
144
145get_options() {
146 while [ $# -gt 0 ]; do
147 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100148 -f|--filter)
149 shift; FILTER=$1
150 ;;
151 -e|--exclude)
152 shift; EXCLUDE=$1
153 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100154 -m|--memcheck)
155 MEMCHECK=1
156 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100157 -n|--number)
158 shift; RUN_TEST_NUMBER=$1
159 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100160 -s|--show-numbers)
161 SHOW_TEST_NUMBER=1
162 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100163 -p|--preserve-logs)
164 PRESERVE_LOGS=1
165 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200166 --port)
167 shift; SRV_PORT=$1
168 ;;
169 --proxy-port)
170 shift; PXY_PORT=$1
171 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100172 --seed)
173 shift; SEED="$1"
174 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100175 -h|--help)
176 print_usage
177 exit 0
178 ;;
179 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200180 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100181 print_usage
182 exit 1
183 ;;
184 esac
185 shift
186 done
187}
188
Hanno Becker3b8b40c2018-08-28 10:25:41 +0100189# Skip next test; use this macro to skip tests which are legitimate
190# in theory and expected to be re-introduced at some point, but
191# aren't expected to succeed at the moment due to problems outside
192# our control (such as bugs in other TLS implementations).
193skip_next_test() {
194 SKIP_NEXT="YES"
195}
196
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100197# skip next test if the flag is not enabled in config.h
198requires_config_enabled() {
199 if grep "^#define $1" $CONFIG_H > /dev/null; then :; else
200 SKIP_NEXT="YES"
201 fi
202}
203
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200204# skip next test if the flag is enabled in config.h
205requires_config_disabled() {
206 if grep "^#define $1" $CONFIG_H > /dev/null; then
207 SKIP_NEXT="YES"
208 fi
209}
210
Hanno Becker7c48dd12018-08-28 16:09:22 +0100211get_config_value_or_default() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100212 # This function uses the query_config command line option to query the
213 # required Mbed TLS compile time configuration from the ssl_server2
214 # program. The command will always return a success value if the
215 # configuration is defined and the value will be printed to stdout.
216 #
217 # Note that if the configuration is not defined or is defined to nothing,
218 # the output of this function will be an empty string.
219 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100220}
221
222requires_config_value_at_least() {
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100223 VAL="$( get_config_value_or_default "$1" )"
224 if [ -z "$VAL" ]; then
225 # Should never happen
226 echo "Mbed TLS configuration $1 is not defined"
227 exit 1
228 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100229 SKIP_NEXT="YES"
230 fi
231}
232
233requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100234 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia06446782018-10-16 21:29:07 +0100235 if [ -z "$VAL" ]; then
236 # Should never happen
237 echo "Mbed TLS configuration $1 is not defined"
238 exit 1
239 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100240 SKIP_NEXT="YES"
241 fi
242}
243
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200244# skip next test if OpenSSL doesn't support FALLBACK_SCSV
245requires_openssl_with_fallback_scsv() {
246 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
247 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
248 then
249 OPENSSL_HAS_FBSCSV="YES"
250 else
251 OPENSSL_HAS_FBSCSV="NO"
252 fi
253 fi
254 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
255 SKIP_NEXT="YES"
256 fi
257}
258
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200259# skip next test if GnuTLS isn't available
260requires_gnutls() {
261 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200262 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200263 GNUTLS_AVAILABLE="YES"
264 else
265 GNUTLS_AVAILABLE="NO"
266 fi
267 fi
268 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
269 SKIP_NEXT="YES"
270 fi
271}
272
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200273# skip next test if GnuTLS-next isn't available
274requires_gnutls_next() {
275 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
276 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
277 GNUTLS_NEXT_AVAILABLE="YES"
278 else
279 GNUTLS_NEXT_AVAILABLE="NO"
280 fi
281 fi
282 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
283 SKIP_NEXT="YES"
284 fi
285}
286
287# skip next test if OpenSSL-legacy isn't available
288requires_openssl_legacy() {
289 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
290 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
291 OPENSSL_LEGACY_AVAILABLE="YES"
292 else
293 OPENSSL_LEGACY_AVAILABLE="NO"
294 fi
295 fi
296 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
297 SKIP_NEXT="YES"
298 fi
299}
300
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200301# skip next test if IPv6 isn't available on this host
302requires_ipv6() {
303 if [ -z "${HAS_IPV6:-}" ]; then
304 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
305 SRV_PID=$!
306 sleep 1
307 kill $SRV_PID >/dev/null 2>&1
308 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
309 HAS_IPV6="NO"
310 else
311 HAS_IPV6="YES"
312 fi
313 rm -r $SRV_OUT
314 fi
315
316 if [ "$HAS_IPV6" = "NO" ]; then
317 SKIP_NEXT="YES"
318 fi
319}
320
Andrzej Kurekb4593462018-10-11 08:43:30 -0400321# skip next test if it's i686 or uname is not available
322requires_not_i686() {
323 if [ -z "${IS_I686:-}" ]; then
324 IS_I686="YES"
325 if which "uname" >/dev/null 2>&1; then
326 if [ -z "$(uname -a | grep i686)" ]; then
327 IS_I686="NO"
328 fi
329 fi
330 fi
331 if [ "$IS_I686" = "YES" ]; then
332 SKIP_NEXT="YES"
333 fi
334}
335
Angus Grattonc4dd0732018-04-11 16:28:39 +1000336# Calculate the input & output maximum content lengths set in the config
337MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
338MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
339MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
340
341if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
342 MAX_CONTENT_LEN="$MAX_IN_LEN"
343fi
344if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
345 MAX_CONTENT_LEN="$MAX_OUT_LEN"
346fi
347
348# skip the next test if the SSL output buffer is less than 16KB
349requires_full_size_output_buffer() {
350 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
351 SKIP_NEXT="YES"
352 fi
353}
354
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200355# skip the next test if valgrind is in use
356not_with_valgrind() {
357 if [ "$MEMCHECK" -gt 0 ]; then
358 SKIP_NEXT="YES"
359 fi
360}
361
Paul Bakker362689d2016-05-13 10:33:25 +0100362# skip the next test if valgrind is NOT in use
363only_with_valgrind() {
364 if [ "$MEMCHECK" -eq 0 ]; then
365 SKIP_NEXT="YES"
366 fi
367}
368
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200369# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100370client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200371 CLI_DELAY_FACTOR=$1
372}
373
Janos Follath74537a62016-09-02 13:45:28 +0100374# wait for the given seconds after the client finished in the next test
375server_needs_more_time() {
376 SRV_DELAY_SECONDS=$1
377}
378
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100379# print_name <name>
380print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100381 TESTS=$(( $TESTS + 1 ))
382 LINE=""
383
384 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
385 LINE="$TESTS "
386 fi
387
388 LINE="$LINE$1"
389 printf "$LINE "
390 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100391 for i in `seq 1 $LEN`; do printf '.'; done
392 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100393
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100394}
395
396# fail <message>
397fail() {
398 echo "FAIL"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100399 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100400
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200401 mv $SRV_OUT o-srv-${TESTS}.log
402 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200403 if [ -n "$PXY_CMD" ]; then
404 mv $PXY_OUT o-pxy-${TESTS}.log
405 fi
406 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100407
Azim Khan19d13732018-03-29 11:04:20 +0100408 if [ "X${USER:-}" = Xbuildbot -o "X${LOGNAME:-}" = Xbuildbot -o "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200409 echo " ! server output:"
410 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200411 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200412 echo " ! client output:"
413 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200414 if [ -n "$PXY_CMD" ]; then
415 echo " ! ========================================================"
416 echo " ! proxy output:"
417 cat o-pxy-${TESTS}.log
418 fi
419 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200420 fi
421
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200422 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100423}
424
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100425# is_polar <cmd_line>
426is_polar() {
427 echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null
428}
429
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200430# openssl s_server doesn't have -www with DTLS
431check_osrv_dtls() {
432 if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then
433 NEEDS_INPUT=1
434 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )"
435 else
436 NEEDS_INPUT=0
437 fi
438}
439
440# provide input to commands that need it
441provide_input() {
442 if [ $NEEDS_INPUT -eq 0 ]; then
443 return
444 fi
445
446 while true; do
447 echo "HTTP/1.0 200 OK"
448 sleep 1
449 done
450}
451
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100452# has_mem_err <log_file_name>
453has_mem_err() {
454 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
455 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
456 then
457 return 1 # false: does not have errors
458 else
459 return 0 # true: has errors
460 fi
461}
462
Unknown43dc0d62019-09-02 10:42:57 -0400463# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100464if type lsof >/dev/null 2>/dev/null; then
Unknown43dc0d62019-09-02 10:42:57 -0400465 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100466 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200467 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100468 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200469 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100470 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200471 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100472 # Make a tight loop, server normally takes less than 1s to start.
473 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
474 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknown43dc0d62019-09-02 10:42:57 -0400475 echo "$3 START TIMEOUT"
476 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100477 break
478 fi
479 # Linux and *BSD support decimal arguments to sleep. On other
480 # OSes this may be a tight loop.
481 sleep 0.1 2>/dev/null || true
482 done
483 }
484else
Unknown43dc0d62019-09-02 10:42:57 -0400485 echo "Warning: lsof not available, wait_app_start = sleep"
486 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200487 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100488 }
489fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200490
Unknown43dc0d62019-09-02 10:42:57 -0400491# Wait for server process $2 to be listening on port $1.
492wait_server_start() {
493 wait_app_start $1 $2 "SERVER" $SRV_OUT
494}
495
496# Wait for proxy process $2 to be listening on port $1.
497wait_proxy_start() {
498 wait_app_start $1 $2 "PROXY" $PXY_OUT
499}
500
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100501# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100502# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100503# acceptable bounds
504check_server_hello_time() {
505 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100506 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100507 # Get the Unix timestamp for now
508 CUR_TIME=$(date +'%s')
509 THRESHOLD_IN_SECS=300
510
511 # Check if the ServerHello time was printed
512 if [ -z "$SERVER_HELLO_TIME" ]; then
513 return 1
514 fi
515
516 # Check the time in ServerHello is within acceptable bounds
517 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
518 # The time in ServerHello is at least 5 minutes before now
519 return 1
520 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100521 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100522 return 1
523 else
524 return 0
525 fi
526}
527
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200528# wait for client to terminate and set CLI_EXIT
529# must be called right after starting the client
530wait_client_done() {
531 CLI_PID=$!
532
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200533 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
534 CLI_DELAY_FACTOR=1
535
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200536 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200537 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200538
539 wait $CLI_PID
540 CLI_EXIT=$?
541
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200542 kill $DOG_PID >/dev/null 2>&1
543 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200544
545 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100546
547 sleep $SRV_DELAY_SECONDS
548 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200549}
550
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200551# check if the given command uses dtls and sets global variable DTLS
552detect_dtls() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200553 if echo "$1" | grep 'dtls=1\|-dtls1\|-u' >/dev/null; then
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200554 DTLS=1
555 else
556 DTLS=0
557 fi
558}
559
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200560# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100561# Options: -s pattern pattern that must be present in server output
562# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100563# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100564# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100565# -S pattern pattern that must be absent in server output
566# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100567# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100568# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100569run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100570 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200571 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100572
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100573 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
574 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200575 SKIP_NEXT="NO"
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100576 return
577 fi
578
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100579 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100580
Paul Bakkerb7584a52016-05-10 10:50:43 +0100581 # Do we only run numbered tests?
582 if [ "X$RUN_TEST_NUMBER" = "X" ]; then :
583 elif echo ",$RUN_TEST_NUMBER," | grep ",$TESTS," >/dev/null; then :
584 else
585 SKIP_NEXT="YES"
586 fi
587
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200588 # should we skip?
589 if [ "X$SKIP_NEXT" = "XYES" ]; then
590 SKIP_NEXT="NO"
591 echo "SKIP"
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200592 SKIPS=$(( $SKIPS + 1 ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200593 return
594 fi
595
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200596 # does this test use a proxy?
597 if [ "X$1" = "X-p" ]; then
598 PXY_CMD="$2"
599 shift 2
600 else
601 PXY_CMD=""
602 fi
603
604 # get commands and client output
605 SRV_CMD="$1"
606 CLI_CMD="$2"
607 CLI_EXPECT="$3"
608 shift 3
609
Hanno Becker7a11e722019-05-10 14:38:42 +0100610 # Check if test uses files
611 TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" )
612 if [ ! -z "$TEST_USES_FILES" ]; then
613 requires_config_enabled MBEDTLS_FS_IO
614 fi
615
616 # should we skip?
617 if [ "X$SKIP_NEXT" = "XYES" ]; then
618 SKIP_NEXT="NO"
619 echo "SKIP"
620 SKIPS=$(( $SKIPS + 1 ))
621 return
622 fi
623
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200624 # fix client port
625 if [ -n "$PXY_CMD" ]; then
626 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
627 else
628 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
629 fi
630
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200631 # update DTLS variable
632 detect_dtls "$SRV_CMD"
633
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100634 # prepend valgrind to our commands if active
635 if [ "$MEMCHECK" -gt 0 ]; then
636 if is_polar "$SRV_CMD"; then
637 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
638 fi
639 if is_polar "$CLI_CMD"; then
640 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
641 fi
642 fi
643
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200644 TIMES_LEFT=2
645 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200646 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200647
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200648 # run the commands
649 if [ -n "$PXY_CMD" ]; then
650 echo "$PXY_CMD" > $PXY_OUT
651 $PXY_CMD >> $PXY_OUT 2>&1 &
652 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400653 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200654 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200655
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200656 check_osrv_dtls
657 echo "$SRV_CMD" > $SRV_OUT
658 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
659 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100660 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200661
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200662 echo "$CLI_CMD" > $CLI_OUT
663 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
664 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100665
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100666 sleep 0.05
667
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200668 # terminate the server (and the proxy)
669 kill $SRV_PID
670 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100671
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200672 if [ -n "$PXY_CMD" ]; then
673 kill $PXY_PID >/dev/null 2>&1
674 wait $PXY_PID
675 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100676
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200677 # retry only on timeouts
678 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
679 printf "RETRY "
680 else
681 TIMES_LEFT=0
682 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200683 done
684
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100685 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200686 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100687 # expected client exit to incorrectly succeed in case of catastrophic
688 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100689 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200690 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100691 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100692 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100693 return
694 fi
695 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100696 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200697 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100698 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100699 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100700 return
701 fi
702 fi
703
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100704 # check server exit code
705 if [ $? != 0 ]; then
706 fail "server fail"
707 return
708 fi
709
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100710 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100711 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
712 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100713 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200714 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100715 return
716 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100717
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100718 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200719 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100720 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100721 while [ $# -gt 0 ]
722 do
723 case $1 in
724 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100725 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 +0100726 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100727 return
728 fi
729 ;;
730
731 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100732 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 +0100733 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100734 return
735 fi
736 ;;
737
738 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100739 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 +0100740 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100741 return
742 fi
743 ;;
744
745 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100746 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 +0100747 fail "pattern '$2' MUST NOT be present in the Client output"
748 return
749 fi
750 ;;
751
752 # The filtering in the following two options (-u and -U) do the following
753 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100754 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100755 # - keep one of each non-unique line
756 # - count how many lines remain
757 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
758 # if there were no duplicates.
759 "-U")
760 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
761 fail "lines following pattern '$2' must be unique in Server output"
762 return
763 fi
764 ;;
765
766 "-u")
767 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
768 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100769 return
770 fi
771 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100772 "-F")
773 if ! $2 "$SRV_OUT"; then
774 fail "function call to '$2' failed on Server output"
775 return
776 fi
777 ;;
778 "-f")
779 if ! $2 "$CLI_OUT"; then
780 fail "function call to '$2' failed on Client output"
781 return
782 fi
783 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100784
785 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200786 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100787 exit 1
788 esac
789 shift 2
790 done
791
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100792 # check valgrind's results
793 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200794 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100795 fail "Server has memory errors"
796 return
797 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200798 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100799 fail "Client has memory errors"
800 return
801 fi
802 fi
803
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100804 # if we're here, everything is ok
805 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100806 if [ "$PRESERVE_LOGS" -gt 0 ]; then
807 mv $SRV_OUT o-srv-${TESTS}.log
808 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100809 if [ -n "$PXY_CMD" ]; then
810 mv $PXY_OUT o-pxy-${TESTS}.log
811 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100812 fi
813
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200814 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100815}
816
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100817cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200818 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200819 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
820 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
821 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
822 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100823 exit 1
824}
825
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100826#
827# MAIN
828#
829
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100830get_options "$@"
831
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100832# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100833P_SRV_BIN="${P_SRV%%[ ]*}"
834P_CLI_BIN="${P_CLI%%[ ]*}"
835P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100836if [ ! -x "$P_SRV_BIN" ]; then
837 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100838 exit 1
839fi
Hanno Becker17c04932017-10-10 14:44:53 +0100840if [ ! -x "$P_CLI_BIN" ]; then
841 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100842 exit 1
843fi
Hanno Becker17c04932017-10-10 14:44:53 +0100844if [ ! -x "$P_PXY_BIN" ]; then
845 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200846 exit 1
847fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100848if [ "$MEMCHECK" -gt 0 ]; then
849 if which valgrind >/dev/null 2>&1; then :; else
850 echo "Memcheck not possible. Valgrind not found"
851 exit 1
852 fi
853fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100854if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
855 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100856 exit 1
857fi
858
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200859# used by watchdog
860MAIN_PID="$$"
861
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100862# We use somewhat arbitrary delays for tests:
863# - how long do we wait for the server to start (when lsof not available)?
864# - how long do we allow for the client to finish?
865# (not to check performance, just to avoid waiting indefinitely)
866# Things are slower with valgrind, so give extra time here.
867#
868# Note: without lsof, there is a trade-off between the running time of this
869# script and the risk of spurious errors because we didn't wait long enough.
870# The watchdog delay on the other hand doesn't affect normal running time of
871# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200872if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100873 START_DELAY=6
874 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200875else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100876 START_DELAY=2
877 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200878fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100879
880# some particular tests need more time:
881# - for the client, we multiply the usual watchdog limit by a factor
882# - for the server, we sleep for a number of seconds after the client exits
883# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200884CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100885SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200886
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200887# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000888# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200889P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
890P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100891P_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"}"
Manuel Pégourié-Gonnard61957672015-06-18 17:54:58 +0200892O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200893O_CLI="$O_CLI -connect localhost:+SRV_PORT"
894G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200895G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200896
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200897if [ -n "${OPENSSL_LEGACY:-}" ]; then
898 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
899 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
900fi
901
Hanno Becker58e9dc32018-08-17 15:53:21 +0100902if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200903 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
904fi
905
Hanno Becker58e9dc32018-08-17 15:53:21 +0100906if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200907 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200908fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100909
Gilles Peskine62469d92017-05-10 10:13:59 +0200910# Allow SHA-1, because many of our test certificates use it
911P_SRV="$P_SRV allow_sha1=1"
912P_CLI="$P_CLI allow_sha1=1"
913
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200914# Also pick a unique name for intermediate files
915SRV_OUT="srv_out.$$"
916CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200917PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200918SESSION="session.$$"
919
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200920SKIP_NEXT="NO"
921
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100922trap cleanup INT TERM HUP
923
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200924# Basic test
925
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200926# Checks that:
927# - things work with all ciphersuites active (used with config-full in all.sh)
928# - the expected (highest security) parameters are selected
929# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200930run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200931 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200932 "$P_CLI" \
933 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200934 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200935 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200936 -s "client hello v3, signature_algorithm ext: 6" \
937 -s "ECDHE curve: secp521r1" \
938 -S "error" \
939 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200940
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000941run_test "Default, DTLS" \
942 "$P_SRV dtls=1" \
943 "$P_CLI dtls=1" \
944 0 \
945 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200946 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000947
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +0100948requires_config_enabled MBEDTLS_ZLIB_SUPPORT
949run_test "Default (compression enabled)" \
950 "$P_SRV debug_level=3" \
951 "$P_CLI debug_level=3" \
952 0 \
953 -s "Allocating compression buffer" \
954 -c "Allocating compression buffer" \
955 -s "Record expansion is unknown (compression)" \
956 -c "Record expansion is unknown (compression)" \
957 -S "error" \
958 -C "error"
959
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100960# Test current time in ServerHello
961requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200962run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100963 "$P_SRV debug_level=3" \
964 "$P_CLI debug_level=3" \
965 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100966 -f "check_server_hello_time" \
967 -F "check_server_hello_time"
968
Simon Butcher8e004102016-10-14 00:48:33 +0100969# Test for uniqueness of IVs in AEAD ciphersuites
970run_test "Unique IV in GCM" \
971 "$P_SRV exchanges=20 debug_level=4" \
972 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
973 0 \
974 -u "IV used" \
975 -U "IV used"
976
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100977# Tests for rc4 option
978
Simon Butchera410af52016-05-19 22:12:18 +0100979requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100980run_test "RC4: server disabled, client enabled" \
981 "$P_SRV" \
982 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
983 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100984 -s "SSL - The server has no ciphersuites in common"
985
Simon Butchera410af52016-05-19 22:12:18 +0100986requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100987run_test "RC4: server half, client enabled" \
988 "$P_SRV arc4=1" \
989 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
990 1 \
991 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100992
993run_test "RC4: server enabled, client disabled" \
994 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
995 "$P_CLI" \
996 1 \
997 -s "SSL - The server has no ciphersuites in common"
998
999run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001000 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001001 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1002 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001003 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001004 -S "SSL - The server has no ciphersuites in common"
1005
Hanno Beckerd26bb202018-08-17 09:54:10 +01001006# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1007
1008requires_gnutls
1009requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1010run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1011 "$G_SRV"\
1012 "$P_CLI force_version=tls1_1" \
1013 0
1014
1015requires_gnutls
1016requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1017run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1018 "$G_SRV"\
1019 "$P_CLI force_version=tls1" \
1020 0
1021
Gilles Peskinebc70a182017-05-09 15:59:24 +02001022# Tests for SHA-1 support
1023
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001024requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001025run_test "SHA-1 forbidden by default in server certificate" \
1026 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1027 "$P_CLI debug_level=2 allow_sha1=0" \
1028 1 \
1029 -c "The certificate is signed with an unacceptable hash"
1030
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001031requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1032run_test "SHA-1 forbidden by default in server certificate" \
1033 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1034 "$P_CLI debug_level=2 allow_sha1=0" \
1035 0
1036
Gilles Peskinebc70a182017-05-09 15:59:24 +02001037run_test "SHA-1 explicitly allowed in server certificate" \
1038 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1039 "$P_CLI allow_sha1=1" \
1040 0
1041
1042run_test "SHA-256 allowed by default in server certificate" \
1043 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1044 "$P_CLI allow_sha1=0" \
1045 0
1046
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001047requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001048run_test "SHA-1 forbidden by default in client certificate" \
1049 "$P_SRV auth_mode=required allow_sha1=0" \
1050 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1051 1 \
1052 -s "The certificate is signed with an unacceptable hash"
1053
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001054requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1055run_test "SHA-1 forbidden by default in client certificate" \
1056 "$P_SRV auth_mode=required allow_sha1=0" \
1057 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1058 0
1059
Gilles Peskinebc70a182017-05-09 15:59:24 +02001060run_test "SHA-1 explicitly allowed in client certificate" \
1061 "$P_SRV auth_mode=required allow_sha1=1" \
1062 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1063 0
1064
1065run_test "SHA-256 allowed by default in client certificate" \
1066 "$P_SRV auth_mode=required allow_sha1=0" \
1067 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1068 0
1069
Hanno Becker7ae8a762018-08-14 15:43:35 +01001070# Tests for datagram packing
1071run_test "DTLS: multiple records in same datagram, client and server" \
1072 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1073 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1074 0 \
1075 -c "next record in same datagram" \
1076 -s "next record in same datagram"
1077
1078run_test "DTLS: multiple records in same datagram, client only" \
1079 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1080 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1081 0 \
1082 -s "next record in same datagram" \
1083 -C "next record in same datagram"
1084
1085run_test "DTLS: multiple records in same datagram, server only" \
1086 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1087 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1088 0 \
1089 -S "next record in same datagram" \
1090 -c "next record in same datagram"
1091
1092run_test "DTLS: multiple records in same datagram, neither client nor server" \
1093 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1094 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1095 0 \
1096 -S "next record in same datagram" \
1097 -C "next record in same datagram"
1098
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001099# Tests for Truncated HMAC extension
1100
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001101run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001102 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001103 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001104 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001105 -s "dumping 'expected mac' (20 bytes)" \
1106 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001107
Hanno Becker32c55012017-11-10 08:42:54 +00001108requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001109run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001110 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001111 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001112 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001113 -s "dumping 'expected mac' (20 bytes)" \
1114 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001115
Hanno Becker32c55012017-11-10 08:42:54 +00001116requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001117run_test "Truncated HMAC: client enabled, server default" \
1118 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001119 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001120 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001121 -s "dumping 'expected mac' (20 bytes)" \
1122 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001123
Hanno Becker32c55012017-11-10 08:42:54 +00001124requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001125run_test "Truncated HMAC: client enabled, server disabled" \
1126 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001127 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001128 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001129 -s "dumping 'expected mac' (20 bytes)" \
1130 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001131
Hanno Becker32c55012017-11-10 08:42:54 +00001132requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001133run_test "Truncated HMAC: client disabled, server enabled" \
1134 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001135 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001136 0 \
1137 -s "dumping 'expected mac' (20 bytes)" \
1138 -S "dumping 'expected mac' (10 bytes)"
1139
1140requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001141run_test "Truncated HMAC: client enabled, server enabled" \
1142 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001143 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001144 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001145 -S "dumping 'expected mac' (20 bytes)" \
1146 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001147
Hanno Becker4c4f4102017-11-10 09:16:05 +00001148run_test "Truncated HMAC, DTLS: client default, server default" \
1149 "$P_SRV dtls=1 debug_level=4" \
1150 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1151 0 \
1152 -s "dumping 'expected mac' (20 bytes)" \
1153 -S "dumping 'expected mac' (10 bytes)"
1154
1155requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1156run_test "Truncated HMAC, DTLS: client disabled, server default" \
1157 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001158 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001159 0 \
1160 -s "dumping 'expected mac' (20 bytes)" \
1161 -S "dumping 'expected mac' (10 bytes)"
1162
1163requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1164run_test "Truncated HMAC, DTLS: client enabled, server default" \
1165 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001166 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001167 0 \
1168 -s "dumping 'expected mac' (20 bytes)" \
1169 -S "dumping 'expected mac' (10 bytes)"
1170
1171requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1172run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1173 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001174 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001175 0 \
1176 -s "dumping 'expected mac' (20 bytes)" \
1177 -S "dumping 'expected mac' (10 bytes)"
1178
1179requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1180run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1181 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001182 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001183 0 \
1184 -s "dumping 'expected mac' (20 bytes)" \
1185 -S "dumping 'expected mac' (10 bytes)"
1186
1187requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1188run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1189 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001190 "$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 +01001191 0 \
1192 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001193 -s "dumping 'expected mac' (10 bytes)"
1194
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001195# Tests for Encrypt-then-MAC extension
1196
1197run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001198 "$P_SRV debug_level=3 \
1199 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001200 "$P_CLI debug_level=3" \
1201 0 \
1202 -c "client hello, adding encrypt_then_mac extension" \
1203 -s "found encrypt then mac extension" \
1204 -s "server hello, adding encrypt then mac extension" \
1205 -c "found encrypt_then_mac extension" \
1206 -c "using encrypt then mac" \
1207 -s "using encrypt then mac"
1208
1209run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001210 "$P_SRV debug_level=3 etm=0 \
1211 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001212 "$P_CLI debug_level=3 etm=1" \
1213 0 \
1214 -c "client hello, adding encrypt_then_mac extension" \
1215 -s "found encrypt then mac extension" \
1216 -S "server hello, adding encrypt then mac extension" \
1217 -C "found encrypt_then_mac extension" \
1218 -C "using encrypt then mac" \
1219 -S "using encrypt then mac"
1220
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001221run_test "Encrypt then MAC: client enabled, aead cipher" \
1222 "$P_SRV debug_level=3 etm=1 \
1223 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1224 "$P_CLI debug_level=3 etm=1" \
1225 0 \
1226 -c "client hello, adding encrypt_then_mac extension" \
1227 -s "found encrypt then mac extension" \
1228 -S "server hello, adding encrypt then mac extension" \
1229 -C "found encrypt_then_mac extension" \
1230 -C "using encrypt then mac" \
1231 -S "using encrypt then mac"
1232
1233run_test "Encrypt then MAC: client enabled, stream cipher" \
1234 "$P_SRV debug_level=3 etm=1 \
1235 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001236 "$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 +01001237 0 \
1238 -c "client hello, adding encrypt_then_mac extension" \
1239 -s "found encrypt then mac extension" \
1240 -S "server hello, adding encrypt then mac extension" \
1241 -C "found encrypt_then_mac extension" \
1242 -C "using encrypt then mac" \
1243 -S "using encrypt then mac"
1244
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001245run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001246 "$P_SRV debug_level=3 etm=1 \
1247 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001248 "$P_CLI debug_level=3 etm=0" \
1249 0 \
1250 -C "client hello, adding encrypt_then_mac extension" \
1251 -S "found encrypt then mac extension" \
1252 -S "server hello, adding encrypt then mac extension" \
1253 -C "found encrypt_then_mac extension" \
1254 -C "using encrypt then mac" \
1255 -S "using encrypt then mac"
1256
Janos Follathe2681a42016-03-07 15:57:05 +00001257requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001258run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001259 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001260 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001261 "$P_CLI debug_level=3 force_version=ssl3" \
1262 0 \
1263 -C "client hello, adding encrypt_then_mac extension" \
1264 -S "found encrypt then mac extension" \
1265 -S "server hello, adding encrypt then mac extension" \
1266 -C "found encrypt_then_mac extension" \
1267 -C "using encrypt then mac" \
1268 -S "using encrypt then mac"
1269
Janos Follathe2681a42016-03-07 15:57:05 +00001270requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001271run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001272 "$P_SRV debug_level=3 force_version=ssl3 \
1273 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001274 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001275 0 \
1276 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001277 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001278 -S "server hello, adding encrypt then mac extension" \
1279 -C "found encrypt_then_mac extension" \
1280 -C "using encrypt then mac" \
1281 -S "using encrypt then mac"
1282
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001283# Tests for Extended Master Secret extension
1284
1285run_test "Extended Master Secret: default" \
1286 "$P_SRV debug_level=3" \
1287 "$P_CLI debug_level=3" \
1288 0 \
1289 -c "client hello, adding extended_master_secret extension" \
1290 -s "found extended master secret extension" \
1291 -s "server hello, adding extended master secret extension" \
1292 -c "found extended_master_secret extension" \
1293 -c "using extended master secret" \
1294 -s "using extended master secret"
1295
1296run_test "Extended Master Secret: client enabled, server disabled" \
1297 "$P_SRV debug_level=3 extended_ms=0" \
1298 "$P_CLI debug_level=3 extended_ms=1" \
1299 0 \
1300 -c "client hello, adding extended_master_secret extension" \
1301 -s "found extended master secret extension" \
1302 -S "server hello, adding extended master secret extension" \
1303 -C "found extended_master_secret extension" \
1304 -C "using extended master secret" \
1305 -S "using extended master secret"
1306
1307run_test "Extended Master Secret: client disabled, server enabled" \
1308 "$P_SRV debug_level=3 extended_ms=1" \
1309 "$P_CLI debug_level=3 extended_ms=0" \
1310 0 \
1311 -C "client hello, adding extended_master_secret extension" \
1312 -S "found extended master secret extension" \
1313 -S "server hello, adding extended master secret extension" \
1314 -C "found extended_master_secret extension" \
1315 -C "using extended master secret" \
1316 -S "using extended master secret"
1317
Janos Follathe2681a42016-03-07 15:57:05 +00001318requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001319run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001320 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001321 "$P_CLI debug_level=3 force_version=ssl3" \
1322 0 \
1323 -C "client hello, adding extended_master_secret extension" \
1324 -S "found extended master secret extension" \
1325 -S "server hello, adding extended master secret extension" \
1326 -C "found extended_master_secret extension" \
1327 -C "using extended master secret" \
1328 -S "using extended master secret"
1329
Janos Follathe2681a42016-03-07 15:57:05 +00001330requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001331run_test "Extended Master Secret: client enabled, server SSLv3" \
1332 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001333 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001334 0 \
1335 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001336 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001337 -S "server hello, adding extended master secret extension" \
1338 -C "found extended_master_secret extension" \
1339 -C "using extended master secret" \
1340 -S "using extended master secret"
1341
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001342# Tests for FALLBACK_SCSV
1343
1344run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001345 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001346 "$P_CLI debug_level=3 force_version=tls1_1" \
1347 0 \
1348 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001349 -S "received FALLBACK_SCSV" \
1350 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001351 -C "is a fatal alert message (msg 86)"
1352
1353run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001354 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001355 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1356 0 \
1357 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001358 -S "received FALLBACK_SCSV" \
1359 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001360 -C "is a fatal alert message (msg 86)"
1361
1362run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001363 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001364 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001365 1 \
1366 -c "adding FALLBACK_SCSV" \
1367 -s "received FALLBACK_SCSV" \
1368 -s "inapropriate fallback" \
1369 -c "is a fatal alert message (msg 86)"
1370
1371run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001372 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001373 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001374 0 \
1375 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001376 -s "received FALLBACK_SCSV" \
1377 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001378 -C "is a fatal alert message (msg 86)"
1379
1380requires_openssl_with_fallback_scsv
1381run_test "Fallback SCSV: default, openssl server" \
1382 "$O_SRV" \
1383 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1384 0 \
1385 -C "adding FALLBACK_SCSV" \
1386 -C "is a fatal alert message (msg 86)"
1387
1388requires_openssl_with_fallback_scsv
1389run_test "Fallback SCSV: enabled, openssl server" \
1390 "$O_SRV" \
1391 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1392 1 \
1393 -c "adding FALLBACK_SCSV" \
1394 -c "is a fatal alert message (msg 86)"
1395
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001396requires_openssl_with_fallback_scsv
1397run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001398 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001399 "$O_CLI -tls1_1" \
1400 0 \
1401 -S "received FALLBACK_SCSV" \
1402 -S "inapropriate fallback"
1403
1404requires_openssl_with_fallback_scsv
1405run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001406 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001407 "$O_CLI -tls1_1 -fallback_scsv" \
1408 1 \
1409 -s "received FALLBACK_SCSV" \
1410 -s "inapropriate fallback"
1411
1412requires_openssl_with_fallback_scsv
1413run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001414 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001415 "$O_CLI -fallback_scsv" \
1416 0 \
1417 -s "received FALLBACK_SCSV" \
1418 -S "inapropriate fallback"
1419
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001420# Test sending and receiving empty application data records
1421
1422run_test "Encrypt then MAC: empty application data record" \
1423 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1424 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1425 0 \
1426 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1427 -s "dumping 'input payload after decrypt' (0 bytes)" \
1428 -c "0 bytes written in 1 fragments"
1429
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001430run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001431 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1432 "$P_CLI auth_mode=none etm=0 request_size=0" \
1433 0 \
1434 -s "dumping 'input payload after decrypt' (0 bytes)" \
1435 -c "0 bytes written in 1 fragments"
1436
1437run_test "Encrypt then MAC, DTLS: empty application data record" \
1438 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1439 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1440 0 \
1441 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1442 -s "dumping 'input payload after decrypt' (0 bytes)" \
1443 -c "0 bytes written in 1 fragments"
1444
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001445run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001446 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1447 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1448 0 \
1449 -s "dumping 'input payload after decrypt' (0 bytes)" \
1450 -c "0 bytes written in 1 fragments"
1451
Gilles Peskined50177f2017-05-16 17:53:03 +02001452## ClientHello generated with
1453## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1454## then manually twiddling the ciphersuite list.
1455## The ClientHello content is spelled out below as a hex string as
1456## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1457## The expected response is an inappropriate_fallback alert.
1458requires_openssl_with_fallback_scsv
1459run_test "Fallback SCSV: beginning of list" \
1460 "$P_SRV debug_level=2" \
1461 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1462 0 \
1463 -s "received FALLBACK_SCSV" \
1464 -s "inapropriate fallback"
1465
1466requires_openssl_with_fallback_scsv
1467run_test "Fallback SCSV: end of list" \
1468 "$P_SRV debug_level=2" \
1469 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1470 0 \
1471 -s "received FALLBACK_SCSV" \
1472 -s "inapropriate fallback"
1473
1474## Here the expected response is a valid ServerHello prefix, up to the random.
1475requires_openssl_with_fallback_scsv
1476run_test "Fallback SCSV: not in list" \
1477 "$P_SRV debug_level=2" \
1478 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1479 0 \
1480 -S "received FALLBACK_SCSV" \
1481 -S "inapropriate fallback"
1482
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001483# Tests for CBC 1/n-1 record splitting
1484
1485run_test "CBC Record splitting: TLS 1.2, no splitting" \
1486 "$P_SRV" \
1487 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1488 request_size=123 force_version=tls1_2" \
1489 0 \
1490 -s "Read from client: 123 bytes read" \
1491 -S "Read from client: 1 bytes read" \
1492 -S "122 bytes read"
1493
1494run_test "CBC Record splitting: TLS 1.1, no splitting" \
1495 "$P_SRV" \
1496 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1497 request_size=123 force_version=tls1_1" \
1498 0 \
1499 -s "Read from client: 123 bytes read" \
1500 -S "Read from client: 1 bytes read" \
1501 -S "122 bytes read"
1502
1503run_test "CBC Record splitting: TLS 1.0, splitting" \
1504 "$P_SRV" \
1505 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1506 request_size=123 force_version=tls1" \
1507 0 \
1508 -S "Read from client: 123 bytes read" \
1509 -s "Read from client: 1 bytes read" \
1510 -s "122 bytes read"
1511
Janos Follathe2681a42016-03-07 15:57:05 +00001512requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001513run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001514 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001515 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1516 request_size=123 force_version=ssl3" \
1517 0 \
1518 -S "Read from client: 123 bytes read" \
1519 -s "Read from client: 1 bytes read" \
1520 -s "122 bytes read"
1521
1522run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001523 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001524 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1525 request_size=123 force_version=tls1" \
1526 0 \
1527 -s "Read from client: 123 bytes read" \
1528 -S "Read from client: 1 bytes read" \
1529 -S "122 bytes read"
1530
1531run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1532 "$P_SRV" \
1533 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1534 request_size=123 force_version=tls1 recsplit=0" \
1535 0 \
1536 -s "Read from client: 123 bytes read" \
1537 -S "Read from client: 1 bytes read" \
1538 -S "122 bytes read"
1539
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001540run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1541 "$P_SRV nbio=2" \
1542 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1543 request_size=123 force_version=tls1" \
1544 0 \
1545 -S "Read from client: 123 bytes read" \
1546 -s "Read from client: 1 bytes read" \
1547 -s "122 bytes read"
1548
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001549# Tests for Session Tickets
1550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001551run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001552 "$P_SRV debug_level=3 tickets=1" \
1553 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001554 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001555 -c "client hello, adding session ticket extension" \
1556 -s "found session ticket extension" \
1557 -s "server hello, adding session ticket extension" \
1558 -c "found session_ticket extension" \
1559 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001560 -S "session successfully restored from cache" \
1561 -s "session successfully restored from ticket" \
1562 -s "a session has been resumed" \
1563 -c "a session has been resumed"
1564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001565run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001566 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1567 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001568 0 \
1569 -c "client hello, adding session ticket extension" \
1570 -s "found session ticket extension" \
1571 -s "server hello, adding session ticket extension" \
1572 -c "found session_ticket extension" \
1573 -c "parse new session ticket" \
1574 -S "session successfully restored from cache" \
1575 -s "session successfully restored from ticket" \
1576 -s "a session has been resumed" \
1577 -c "a session has been resumed"
1578
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001579run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001580 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1581 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001582 0 \
1583 -c "client hello, adding session ticket extension" \
1584 -s "found session ticket extension" \
1585 -s "server hello, adding session ticket extension" \
1586 -c "found session_ticket extension" \
1587 -c "parse new session ticket" \
1588 -S "session successfully restored from cache" \
1589 -S "session successfully restored from ticket" \
1590 -S "a session has been resumed" \
1591 -C "a session has been resumed"
1592
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001593run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001594 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001595 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001596 0 \
1597 -c "client hello, adding session ticket extension" \
1598 -c "found session_ticket extension" \
1599 -c "parse new session ticket" \
1600 -c "a session has been resumed"
1601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001602run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001603 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001604 "( $O_CLI -sess_out $SESSION; \
1605 $O_CLI -sess_in $SESSION; \
1606 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001607 0 \
1608 -s "found session ticket extension" \
1609 -s "server hello, adding session ticket extension" \
1610 -S "session successfully restored from cache" \
1611 -s "session successfully restored from ticket" \
1612 -s "a session has been resumed"
1613
Hanno Becker1d739932018-08-21 13:55:22 +01001614# Tests for Session Tickets with DTLS
1615
1616run_test "Session resume using tickets, DTLS: basic" \
1617 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001618 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001619 0 \
1620 -c "client hello, adding session ticket extension" \
1621 -s "found session ticket extension" \
1622 -s "server hello, adding session ticket extension" \
1623 -c "found session_ticket extension" \
1624 -c "parse new session ticket" \
1625 -S "session successfully restored from cache" \
1626 -s "session successfully restored from ticket" \
1627 -s "a session has been resumed" \
1628 -c "a session has been resumed"
1629
1630run_test "Session resume using tickets, DTLS: cache disabled" \
1631 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001632 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001633 0 \
1634 -c "client hello, adding session ticket extension" \
1635 -s "found session ticket extension" \
1636 -s "server hello, adding session ticket extension" \
1637 -c "found session_ticket extension" \
1638 -c "parse new session ticket" \
1639 -S "session successfully restored from cache" \
1640 -s "session successfully restored from ticket" \
1641 -s "a session has been resumed" \
1642 -c "a session has been resumed"
1643
1644run_test "Session resume using tickets, DTLS: timeout" \
1645 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001646 "$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 +01001647 0 \
1648 -c "client hello, adding session ticket extension" \
1649 -s "found session ticket extension" \
1650 -s "server hello, adding session ticket extension" \
1651 -c "found session_ticket extension" \
1652 -c "parse new session ticket" \
1653 -S "session successfully restored from cache" \
1654 -S "session successfully restored from ticket" \
1655 -S "a session has been resumed" \
1656 -C "a session has been resumed"
1657
1658run_test "Session resume using tickets, DTLS: openssl server" \
1659 "$O_SRV -dtls1" \
1660 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1661 0 \
1662 -c "client hello, adding session ticket extension" \
1663 -c "found session_ticket extension" \
1664 -c "parse new session ticket" \
1665 -c "a session has been resumed"
1666
1667run_test "Session resume using tickets, DTLS: openssl client" \
1668 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1669 "( $O_CLI -dtls1 -sess_out $SESSION; \
1670 $O_CLI -dtls1 -sess_in $SESSION; \
1671 rm -f $SESSION )" \
1672 0 \
1673 -s "found session ticket extension" \
1674 -s "server hello, adding session ticket extension" \
1675 -S "session successfully restored from cache" \
1676 -s "session successfully restored from ticket" \
1677 -s "a session has been resumed"
1678
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001679# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001680
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001681run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001682 "$P_SRV debug_level=3 tickets=0" \
1683 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001684 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001685 -c "client hello, adding session ticket extension" \
1686 -s "found session ticket extension" \
1687 -S "server hello, adding session ticket extension" \
1688 -C "found session_ticket extension" \
1689 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001690 -s "session successfully restored from cache" \
1691 -S "session successfully restored from ticket" \
1692 -s "a session has been resumed" \
1693 -c "a session has been resumed"
1694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001695run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001696 "$P_SRV debug_level=3 tickets=1" \
1697 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001698 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001699 -C "client hello, adding session ticket extension" \
1700 -S "found session ticket extension" \
1701 -S "server hello, adding session ticket extension" \
1702 -C "found session_ticket extension" \
1703 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001704 -s "session successfully restored from cache" \
1705 -S "session successfully restored from ticket" \
1706 -s "a session has been resumed" \
1707 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001709run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001710 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1711 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001712 0 \
1713 -S "session successfully restored from cache" \
1714 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001715 -S "a session has been resumed" \
1716 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001718run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001719 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1720 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001721 0 \
1722 -s "session successfully restored from cache" \
1723 -S "session successfully restored from ticket" \
1724 -s "a session has been resumed" \
1725 -c "a session has been resumed"
1726
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001727run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001728 "$P_SRV debug_level=3 tickets=0" \
1729 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001730 0 \
1731 -s "session successfully restored from cache" \
1732 -S "session successfully restored from ticket" \
1733 -s "a session has been resumed" \
1734 -c "a session has been resumed"
1735
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001736run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001737 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1738 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001739 0 \
1740 -S "session successfully restored from cache" \
1741 -S "session successfully restored from ticket" \
1742 -S "a session has been resumed" \
1743 -C "a session has been resumed"
1744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001745run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001746 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1747 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001748 0 \
1749 -s "session successfully restored from cache" \
1750 -S "session successfully restored from ticket" \
1751 -s "a session has been resumed" \
1752 -c "a session has been resumed"
1753
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001754run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001755 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001756 "( $O_CLI -sess_out $SESSION; \
1757 $O_CLI -sess_in $SESSION; \
1758 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001759 0 \
1760 -s "found session ticket extension" \
1761 -S "server hello, adding session ticket extension" \
1762 -s "session successfully restored from cache" \
1763 -S "session successfully restored from ticket" \
1764 -s "a session has been resumed"
1765
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001766run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001767 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001768 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001769 0 \
1770 -C "found session_ticket extension" \
1771 -C "parse new session ticket" \
1772 -c "a session has been resumed"
1773
Hanno Becker1d739932018-08-21 13:55:22 +01001774# Tests for Session Resume based on session-ID and cache, DTLS
1775
1776run_test "Session resume using cache, DTLS: tickets enabled on client" \
1777 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001778 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001779 0 \
1780 -c "client hello, adding session ticket extension" \
1781 -s "found session ticket extension" \
1782 -S "server hello, adding session ticket extension" \
1783 -C "found session_ticket extension" \
1784 -C "parse new session ticket" \
1785 -s "session successfully restored from cache" \
1786 -S "session successfully restored from ticket" \
1787 -s "a session has been resumed" \
1788 -c "a session has been resumed"
1789
1790run_test "Session resume using cache, DTLS: tickets enabled on server" \
1791 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001792 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001793 0 \
1794 -C "client hello, adding session ticket extension" \
1795 -S "found session ticket extension" \
1796 -S "server hello, adding session ticket extension" \
1797 -C "found session_ticket extension" \
1798 -C "parse new session ticket" \
1799 -s "session successfully restored from cache" \
1800 -S "session successfully restored from ticket" \
1801 -s "a session has been resumed" \
1802 -c "a session has been resumed"
1803
1804run_test "Session resume using cache, DTLS: cache_max=0" \
1805 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001806 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001807 0 \
1808 -S "session successfully restored from cache" \
1809 -S "session successfully restored from ticket" \
1810 -S "a session has been resumed" \
1811 -C "a session has been resumed"
1812
1813run_test "Session resume using cache, DTLS: cache_max=1" \
1814 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001815 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001816 0 \
1817 -s "session successfully restored from cache" \
1818 -S "session successfully restored from ticket" \
1819 -s "a session has been resumed" \
1820 -c "a session has been resumed"
1821
1822run_test "Session resume using cache, DTLS: timeout > delay" \
1823 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001824 "$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 +01001825 0 \
1826 -s "session successfully restored from cache" \
1827 -S "session successfully restored from ticket" \
1828 -s "a session has been resumed" \
1829 -c "a session has been resumed"
1830
1831run_test "Session resume using cache, DTLS: timeout < delay" \
1832 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001833 "$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 +01001834 0 \
1835 -S "session successfully restored from cache" \
1836 -S "session successfully restored from ticket" \
1837 -S "a session has been resumed" \
1838 -C "a session has been resumed"
1839
1840run_test "Session resume using cache, DTLS: no timeout" \
1841 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001842 "$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 +01001843 0 \
1844 -s "session successfully restored from cache" \
1845 -S "session successfully restored from ticket" \
1846 -s "a session has been resumed" \
1847 -c "a session has been resumed"
1848
1849run_test "Session resume using cache, DTLS: openssl client" \
1850 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1851 "( $O_CLI -dtls1 -sess_out $SESSION; \
1852 $O_CLI -dtls1 -sess_in $SESSION; \
1853 rm -f $SESSION )" \
1854 0 \
1855 -s "found session ticket extension" \
1856 -S "server hello, adding session ticket extension" \
1857 -s "session successfully restored from cache" \
1858 -S "session successfully restored from ticket" \
1859 -s "a session has been resumed"
1860
1861run_test "Session resume using cache, DTLS: openssl server" \
1862 "$O_SRV -dtls1" \
1863 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1864 0 \
1865 -C "found session_ticket extension" \
1866 -C "parse new session ticket" \
1867 -c "a session has been resumed"
1868
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001869# Tests for Max Fragment Length extension
1870
Angus Grattonc4dd0732018-04-11 16:28:39 +10001871if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1872 printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n"
Hanno Becker6428f8d2017-09-22 16:58:50 +01001873 exit 1
1874fi
1875
Angus Grattonc4dd0732018-04-11 16:28:39 +10001876if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1877 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1878fi
1879
Hanno Becker4aed27e2017-09-18 15:00:34 +01001880requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001881run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001882 "$P_SRV debug_level=3" \
1883 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001884 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001885 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1886 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001887 -C "client hello, adding max_fragment_length extension" \
1888 -S "found max fragment length extension" \
1889 -S "server hello, max_fragment_length extension" \
1890 -C "found max_fragment_length extension"
1891
Hanno Becker4aed27e2017-09-18 15:00:34 +01001892requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001893run_test "Max fragment length: enabled, default, larger message" \
1894 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001895 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001896 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001897 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1898 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001899 -C "client hello, adding max_fragment_length extension" \
1900 -S "found max fragment length extension" \
1901 -S "server hello, max_fragment_length extension" \
1902 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001903 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1904 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001905 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001906
1907requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1908run_test "Max fragment length, DTLS: enabled, default, larger message" \
1909 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001910 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001911 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001912 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1913 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001914 -C "client hello, adding max_fragment_length extension" \
1915 -S "found max fragment length extension" \
1916 -S "server hello, max_fragment_length extension" \
1917 -C "found max_fragment_length extension" \
1918 -c "fragment larger than.*maximum "
1919
Angus Grattonc4dd0732018-04-11 16:28:39 +10001920# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1921# (session fragment length will be 16384 regardless of mbedtls
1922# content length configuration.)
1923
Hanno Beckerc5266962017-09-18 15:01:50 +01001924requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1925run_test "Max fragment length: disabled, larger message" \
1926 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001927 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001928 0 \
1929 -C "Maximum fragment length is 16384" \
1930 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001931 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1932 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001933 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001934
1935requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1936run_test "Max fragment length DTLS: disabled, larger message" \
1937 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001938 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001939 1 \
1940 -C "Maximum fragment length is 16384" \
1941 -S "Maximum fragment length is 16384" \
1942 -c "fragment larger than.*maximum "
1943
1944requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001945run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001946 "$P_SRV debug_level=3" \
1947 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001948 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001949 -c "Maximum fragment length is 4096" \
1950 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001951 -c "client hello, adding max_fragment_length extension" \
1952 -s "found max fragment length extension" \
1953 -s "server hello, max_fragment_length extension" \
1954 -c "found max_fragment_length extension"
1955
Hanno Becker4aed27e2017-09-18 15:00:34 +01001956requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001957run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001958 "$P_SRV debug_level=3 max_frag_len=4096" \
1959 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001960 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001961 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001962 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001963 -C "client hello, adding max_fragment_length extension" \
1964 -S "found max fragment length extension" \
1965 -S "server hello, max_fragment_length extension" \
1966 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001967
Hanno Becker4aed27e2017-09-18 15:00:34 +01001968requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001969requires_gnutls
1970run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001971 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001972 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001973 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001974 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001975 -c "client hello, adding max_fragment_length extension" \
1976 -c "found max_fragment_length extension"
1977
Hanno Becker4aed27e2017-09-18 15:00:34 +01001978requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001979run_test "Max fragment length: client, message just fits" \
1980 "$P_SRV debug_level=3" \
1981 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1982 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001983 -c "Maximum fragment length is 2048" \
1984 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001985 -c "client hello, adding max_fragment_length extension" \
1986 -s "found max fragment length extension" \
1987 -s "server hello, max_fragment_length extension" \
1988 -c "found max_fragment_length extension" \
1989 -c "2048 bytes written in 1 fragments" \
1990 -s "2048 bytes read"
1991
Hanno Becker4aed27e2017-09-18 15:00:34 +01001992requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001993run_test "Max fragment length: client, larger message" \
1994 "$P_SRV debug_level=3" \
1995 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
1996 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001997 -c "Maximum fragment length is 2048" \
1998 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001999 -c "client hello, adding max_fragment_length extension" \
2000 -s "found max fragment length extension" \
2001 -s "server hello, max_fragment_length extension" \
2002 -c "found max_fragment_length extension" \
2003 -c "2345 bytes written in 2 fragments" \
2004 -s "2048 bytes read" \
2005 -s "297 bytes read"
2006
Hanno Becker4aed27e2017-09-18 15:00:34 +01002007requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002008run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002009 "$P_SRV debug_level=3 dtls=1" \
2010 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2011 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002012 -c "Maximum fragment length is 2048" \
2013 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002014 -c "client hello, adding max_fragment_length extension" \
2015 -s "found max fragment length extension" \
2016 -s "server hello, max_fragment_length extension" \
2017 -c "found max_fragment_length extension" \
2018 -c "fragment larger than.*maximum"
2019
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002020# Tests for renegotiation
2021
Hanno Becker6a243642017-10-12 15:18:45 +01002022# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002023run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002024 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002025 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002026 0 \
2027 -C "client hello, adding renegotiation extension" \
2028 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2029 -S "found renegotiation extension" \
2030 -s "server hello, secure renegotiation extension" \
2031 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002032 -C "=> renegotiate" \
2033 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002034 -S "write hello request"
2035
Hanno Becker6a243642017-10-12 15:18:45 +01002036requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002037run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002038 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002039 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002040 0 \
2041 -c "client hello, adding renegotiation extension" \
2042 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2043 -s "found renegotiation extension" \
2044 -s "server hello, secure renegotiation extension" \
2045 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002046 -c "=> renegotiate" \
2047 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002048 -S "write hello request"
2049
Hanno Becker6a243642017-10-12 15:18:45 +01002050requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002051run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002052 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002053 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002054 0 \
2055 -c "client hello, adding renegotiation extension" \
2056 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2057 -s "found renegotiation extension" \
2058 -s "server hello, secure renegotiation extension" \
2059 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002060 -c "=> renegotiate" \
2061 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002062 -s "write hello request"
2063
Janos Follathb0f148c2017-10-05 12:29:42 +01002064# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2065# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2066# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002067requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002068run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2069 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2070 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2071 0 \
2072 -c "client hello, adding renegotiation extension" \
2073 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2074 -s "found renegotiation extension" \
2075 -s "server hello, secure renegotiation extension" \
2076 -c "found renegotiation extension" \
2077 -c "=> renegotiate" \
2078 -s "=> renegotiate" \
2079 -S "write hello request" \
2080 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2081
2082# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2083# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2084# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002085requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002086run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2087 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2088 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2089 0 \
2090 -c "client hello, adding renegotiation extension" \
2091 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2092 -s "found renegotiation extension" \
2093 -s "server hello, secure renegotiation extension" \
2094 -c "found renegotiation extension" \
2095 -c "=> renegotiate" \
2096 -s "=> renegotiate" \
2097 -s "write hello request" \
2098 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2099
Hanno Becker6a243642017-10-12 15:18:45 +01002100requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002101run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002102 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002103 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002104 0 \
2105 -c "client hello, adding renegotiation extension" \
2106 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2107 -s "found renegotiation extension" \
2108 -s "server hello, secure renegotiation extension" \
2109 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002110 -c "=> renegotiate" \
2111 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002112 -s "write hello request"
2113
Hanno Becker6a243642017-10-12 15:18:45 +01002114requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002115run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002116 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002117 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002118 1 \
2119 -c "client hello, adding renegotiation extension" \
2120 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2121 -S "found renegotiation extension" \
2122 -s "server hello, secure renegotiation extension" \
2123 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002124 -c "=> renegotiate" \
2125 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002126 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002127 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002128 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002129
Hanno Becker6a243642017-10-12 15:18:45 +01002130requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002131run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002132 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002133 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002134 0 \
2135 -C "client hello, adding renegotiation extension" \
2136 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2137 -S "found renegotiation extension" \
2138 -s "server hello, secure renegotiation extension" \
2139 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002140 -C "=> renegotiate" \
2141 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002142 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002143 -S "SSL - An unexpected message was received from our peer" \
2144 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002145
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: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002148 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002149 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002150 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002151 0 \
2152 -C "client hello, adding renegotiation extension" \
2153 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2154 -S "found renegotiation extension" \
2155 -s "server hello, secure renegotiation extension" \
2156 -c "found renegotiation extension" \
2157 -C "=> renegotiate" \
2158 -S "=> renegotiate" \
2159 -s "write hello request" \
2160 -S "SSL - An unexpected message was received from our peer" \
2161 -S "failed"
2162
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002163# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002164requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002165run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002166 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002167 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002168 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002169 0 \
2170 -C "client hello, adding renegotiation extension" \
2171 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2172 -S "found renegotiation extension" \
2173 -s "server hello, secure renegotiation extension" \
2174 -c "found renegotiation extension" \
2175 -C "=> renegotiate" \
2176 -S "=> renegotiate" \
2177 -s "write hello request" \
2178 -S "SSL - An unexpected message was received from our peer" \
2179 -S "failed"
2180
Hanno Becker6a243642017-10-12 15:18:45 +01002181requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002182run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002183 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002184 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002185 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002186 0 \
2187 -C "client hello, adding renegotiation extension" \
2188 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2189 -S "found renegotiation extension" \
2190 -s "server hello, secure renegotiation extension" \
2191 -c "found renegotiation extension" \
2192 -C "=> renegotiate" \
2193 -S "=> renegotiate" \
2194 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002195 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002196
Hanno Becker6a243642017-10-12 15:18:45 +01002197requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002198run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002199 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002200 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002201 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002202 0 \
2203 -c "client hello, adding renegotiation extension" \
2204 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2205 -s "found renegotiation extension" \
2206 -s "server hello, secure renegotiation extension" \
2207 -c "found renegotiation extension" \
2208 -c "=> renegotiate" \
2209 -s "=> renegotiate" \
2210 -s "write hello request" \
2211 -S "SSL - An unexpected message was received from our peer" \
2212 -S "failed"
2213
Hanno Becker6a243642017-10-12 15:18:45 +01002214requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002215run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002216 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002217 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2218 0 \
2219 -C "client hello, adding renegotiation extension" \
2220 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2221 -S "found renegotiation extension" \
2222 -s "server hello, secure renegotiation extension" \
2223 -c "found renegotiation extension" \
2224 -S "record counter limit reached: renegotiate" \
2225 -C "=> renegotiate" \
2226 -S "=> renegotiate" \
2227 -S "write hello request" \
2228 -S "SSL - An unexpected message was received from our peer" \
2229 -S "failed"
2230
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002231# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002232requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002233run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002234 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002235 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002236 0 \
2237 -c "client hello, adding renegotiation extension" \
2238 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2239 -s "found renegotiation extension" \
2240 -s "server hello, secure renegotiation extension" \
2241 -c "found renegotiation extension" \
2242 -s "record counter limit reached: renegotiate" \
2243 -c "=> renegotiate" \
2244 -s "=> renegotiate" \
2245 -s "write hello request" \
2246 -S "SSL - An unexpected message was received from our peer" \
2247 -S "failed"
2248
Hanno Becker6a243642017-10-12 15:18:45 +01002249requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002250run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002251 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002252 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002253 0 \
2254 -c "client hello, adding renegotiation extension" \
2255 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2256 -s "found renegotiation extension" \
2257 -s "server hello, secure renegotiation extension" \
2258 -c "found renegotiation extension" \
2259 -s "record counter limit reached: renegotiate" \
2260 -c "=> renegotiate" \
2261 -s "=> renegotiate" \
2262 -s "write hello request" \
2263 -S "SSL - An unexpected message was received from our peer" \
2264 -S "failed"
2265
Hanno Becker6a243642017-10-12 15:18:45 +01002266requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002267run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002268 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002269 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2270 0 \
2271 -C "client hello, adding renegotiation extension" \
2272 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2273 -S "found renegotiation extension" \
2274 -s "server hello, secure renegotiation extension" \
2275 -c "found renegotiation extension" \
2276 -S "record counter limit reached: renegotiate" \
2277 -C "=> renegotiate" \
2278 -S "=> renegotiate" \
2279 -S "write hello request" \
2280 -S "SSL - An unexpected message was received from our peer" \
2281 -S "failed"
2282
Hanno Becker6a243642017-10-12 15:18:45 +01002283requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002284run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002285 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002286 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002287 0 \
2288 -c "client hello, adding renegotiation extension" \
2289 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2290 -s "found renegotiation extension" \
2291 -s "server hello, secure renegotiation extension" \
2292 -c "found renegotiation extension" \
2293 -c "=> renegotiate" \
2294 -s "=> renegotiate" \
2295 -S "write hello request"
2296
Hanno Becker6a243642017-10-12 15:18:45 +01002297requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002298run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002299 "$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 +02002300 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002301 0 \
2302 -c "client hello, adding renegotiation extension" \
2303 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2304 -s "found renegotiation extension" \
2305 -s "server hello, secure renegotiation extension" \
2306 -c "found renegotiation extension" \
2307 -c "=> renegotiate" \
2308 -s "=> renegotiate" \
2309 -s "write hello request"
2310
Hanno Becker6a243642017-10-12 15:18:45 +01002311requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002312run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002313 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002314 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002315 0 \
2316 -c "client hello, adding renegotiation extension" \
2317 -c "found renegotiation extension" \
2318 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002319 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002320 -C "error" \
2321 -c "HTTP/1.0 200 [Oo][Kk]"
2322
Paul Bakker539d9722015-02-08 16:18:35 +01002323requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002324requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002325run_test "Renegotiation: gnutls server strict, client-initiated" \
2326 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002327 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002328 0 \
2329 -c "client hello, adding renegotiation extension" \
2330 -c "found renegotiation extension" \
2331 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002332 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002333 -C "error" \
2334 -c "HTTP/1.0 200 [Oo][Kk]"
2335
Paul Bakker539d9722015-02-08 16:18:35 +01002336requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002337requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002338run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2339 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2340 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2341 1 \
2342 -c "client hello, adding renegotiation extension" \
2343 -C "found renegotiation extension" \
2344 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002345 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002346 -c "error" \
2347 -C "HTTP/1.0 200 [Oo][Kk]"
2348
Paul Bakker539d9722015-02-08 16:18:35 +01002349requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002350requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002351run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2352 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2353 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2354 allow_legacy=0" \
2355 1 \
2356 -c "client hello, adding renegotiation extension" \
2357 -C "found renegotiation extension" \
2358 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002359 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002360 -c "error" \
2361 -C "HTTP/1.0 200 [Oo][Kk]"
2362
Paul Bakker539d9722015-02-08 16:18:35 +01002363requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002364requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002365run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2366 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2367 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2368 allow_legacy=1" \
2369 0 \
2370 -c "client hello, adding renegotiation extension" \
2371 -C "found renegotiation extension" \
2372 -c "=> renegotiate" \
2373 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002374 -C "error" \
2375 -c "HTTP/1.0 200 [Oo][Kk]"
2376
Hanno Becker6a243642017-10-12 15:18:45 +01002377requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002378run_test "Renegotiation: DTLS, client-initiated" \
2379 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2380 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2381 0 \
2382 -c "client hello, adding renegotiation extension" \
2383 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2384 -s "found renegotiation extension" \
2385 -s "server hello, secure renegotiation extension" \
2386 -c "found renegotiation extension" \
2387 -c "=> renegotiate" \
2388 -s "=> renegotiate" \
2389 -S "write hello request"
2390
Hanno Becker6a243642017-10-12 15:18:45 +01002391requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002392run_test "Renegotiation: DTLS, server-initiated" \
2393 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002394 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2395 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002396 0 \
2397 -c "client hello, adding renegotiation extension" \
2398 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2399 -s "found renegotiation extension" \
2400 -s "server hello, secure renegotiation extension" \
2401 -c "found renegotiation extension" \
2402 -c "=> renegotiate" \
2403 -s "=> renegotiate" \
2404 -s "write hello request"
2405
Hanno Becker6a243642017-10-12 15:18:45 +01002406requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002407run_test "Renegotiation: DTLS, renego_period overflow" \
2408 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2409 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2410 0 \
2411 -c "client hello, adding renegotiation extension" \
2412 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2413 -s "found renegotiation extension" \
2414 -s "server hello, secure renegotiation extension" \
2415 -s "record counter limit reached: renegotiate" \
2416 -c "=> renegotiate" \
2417 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002418 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002419
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002420requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002421requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002422run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2423 "$G_SRV -u --mtu 4096" \
2424 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2425 0 \
2426 -c "client hello, adding renegotiation extension" \
2427 -c "found renegotiation extension" \
2428 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002429 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002430 -C "error" \
2431 -s "Extra-header:"
2432
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002433# Test for the "secure renegotation" extension only (no actual renegotiation)
2434
Paul Bakker539d9722015-02-08 16:18:35 +01002435requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002436run_test "Renego ext: gnutls server strict, client default" \
2437 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2438 "$P_CLI debug_level=3" \
2439 0 \
2440 -c "found renegotiation extension" \
2441 -C "error" \
2442 -c "HTTP/1.0 200 [Oo][Kk]"
2443
Paul Bakker539d9722015-02-08 16:18:35 +01002444requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002445run_test "Renego ext: gnutls server unsafe, client default" \
2446 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2447 "$P_CLI debug_level=3" \
2448 0 \
2449 -C "found renegotiation extension" \
2450 -C "error" \
2451 -c "HTTP/1.0 200 [Oo][Kk]"
2452
Paul Bakker539d9722015-02-08 16:18:35 +01002453requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002454run_test "Renego ext: gnutls server unsafe, client break legacy" \
2455 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2456 "$P_CLI debug_level=3 allow_legacy=-1" \
2457 1 \
2458 -C "found renegotiation extension" \
2459 -c "error" \
2460 -C "HTTP/1.0 200 [Oo][Kk]"
2461
Paul Bakker539d9722015-02-08 16:18:35 +01002462requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002463run_test "Renego ext: gnutls client strict, server default" \
2464 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002465 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002466 0 \
2467 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2468 -s "server hello, secure renegotiation extension"
2469
Paul Bakker539d9722015-02-08 16:18:35 +01002470requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002471run_test "Renego ext: gnutls client unsafe, server default" \
2472 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002473 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002474 0 \
2475 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2476 -S "server hello, secure renegotiation extension"
2477
Paul Bakker539d9722015-02-08 16:18:35 +01002478requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002479run_test "Renego ext: gnutls client unsafe, server break legacy" \
2480 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002481 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002482 1 \
2483 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2484 -S "server hello, secure renegotiation extension"
2485
Janos Follath0b242342016-02-17 10:11:21 +00002486# Tests for silently dropping trailing extra bytes in .der certificates
2487
2488requires_gnutls
2489run_test "DER format: no trailing bytes" \
2490 "$P_SRV crt_file=data_files/server5-der0.crt \
2491 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002492 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002493 0 \
2494 -c "Handshake was completed" \
2495
2496requires_gnutls
2497run_test "DER format: with a trailing zero byte" \
2498 "$P_SRV crt_file=data_files/server5-der1a.crt \
2499 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002500 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002501 0 \
2502 -c "Handshake was completed" \
2503
2504requires_gnutls
2505run_test "DER format: with a trailing random byte" \
2506 "$P_SRV crt_file=data_files/server5-der1b.crt \
2507 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002508 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002509 0 \
2510 -c "Handshake was completed" \
2511
2512requires_gnutls
2513run_test "DER format: with 2 trailing random bytes" \
2514 "$P_SRV crt_file=data_files/server5-der2.crt \
2515 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002516 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002517 0 \
2518 -c "Handshake was completed" \
2519
2520requires_gnutls
2521run_test "DER format: with 4 trailing random bytes" \
2522 "$P_SRV crt_file=data_files/server5-der4.crt \
2523 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002524 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002525 0 \
2526 -c "Handshake was completed" \
2527
2528requires_gnutls
2529run_test "DER format: with 8 trailing random bytes" \
2530 "$P_SRV crt_file=data_files/server5-der8.crt \
2531 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002532 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002533 0 \
2534 -c "Handshake was completed" \
2535
2536requires_gnutls
2537run_test "DER format: with 9 trailing random bytes" \
2538 "$P_SRV crt_file=data_files/server5-der9.crt \
2539 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002540 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002541 0 \
2542 -c "Handshake was completed" \
2543
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002544# Tests for auth_mode
2545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002546run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002547 "$P_SRV crt_file=data_files/server5-badsign.crt \
2548 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002549 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002550 1 \
2551 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002552 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002553 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002554 -c "X509 - Certificate verification failed"
2555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002556run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002557 "$P_SRV crt_file=data_files/server5-badsign.crt \
2558 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002559 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002560 0 \
2561 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002562 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002563 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002564 -C "X509 - Certificate verification failed"
2565
Hanno Beckere6706e62017-05-15 16:05:15 +01002566run_test "Authentication: server goodcert, client optional, no trusted CA" \
2567 "$P_SRV" \
2568 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2569 0 \
2570 -c "x509_verify_cert() returned" \
2571 -c "! The certificate is not correctly signed by the trusted CA" \
2572 -c "! Certificate verification flags"\
2573 -C "! mbedtls_ssl_handshake returned" \
2574 -C "X509 - Certificate verification failed" \
2575 -C "SSL - No CA Chain is set, but required to operate"
2576
2577run_test "Authentication: server goodcert, client required, no trusted CA" \
2578 "$P_SRV" \
2579 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2580 1 \
2581 -c "x509_verify_cert() returned" \
2582 -c "! The certificate is not correctly signed by the trusted CA" \
2583 -c "! Certificate verification flags"\
2584 -c "! mbedtls_ssl_handshake returned" \
2585 -c "SSL - No CA Chain is set, but required to operate"
2586
2587# The purpose of the next two tests is to test the client's behaviour when receiving a server
2588# certificate with an unsupported elliptic curve. This should usually not happen because
2589# the client informs the server about the supported curves - it does, though, in the
2590# corner case of a static ECDH suite, because the server doesn't check the curve on that
2591# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2592# different means to have the server ignoring the client's supported curve list.
2593
2594requires_config_enabled MBEDTLS_ECP_C
2595run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2596 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2597 crt_file=data_files/server5.ku-ka.crt" \
2598 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2599 1 \
2600 -c "bad certificate (EC key curve)"\
2601 -c "! Certificate verification flags"\
2602 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2603
2604requires_config_enabled MBEDTLS_ECP_C
2605run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2606 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2607 crt_file=data_files/server5.ku-ka.crt" \
2608 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2609 1 \
2610 -c "bad certificate (EC key curve)"\
2611 -c "! Certificate verification flags"\
2612 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2613
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002614run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002615 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002616 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002617 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002618 0 \
2619 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002620 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002621 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002622 -C "X509 - Certificate verification failed"
2623
Simon Butcher99000142016-10-13 17:21:01 +01002624run_test "Authentication: client SHA256, server required" \
2625 "$P_SRV auth_mode=required" \
2626 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2627 key_file=data_files/server6.key \
2628 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2629 0 \
2630 -c "Supported Signature Algorithm found: 4," \
2631 -c "Supported Signature Algorithm found: 5,"
2632
2633run_test "Authentication: client SHA384, server required" \
2634 "$P_SRV auth_mode=required" \
2635 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2636 key_file=data_files/server6.key \
2637 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2638 0 \
2639 -c "Supported Signature Algorithm found: 4," \
2640 -c "Supported Signature Algorithm found: 5,"
2641
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002642requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2643run_test "Authentication: client has no cert, server required (SSLv3)" \
2644 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2645 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2646 key_file=data_files/server5.key" \
2647 1 \
2648 -S "skip write certificate request" \
2649 -C "skip parse certificate request" \
2650 -c "got a certificate request" \
2651 -c "got no certificate to send" \
2652 -S "x509_verify_cert() returned" \
2653 -s "client has no certificate" \
2654 -s "! mbedtls_ssl_handshake returned" \
2655 -c "! mbedtls_ssl_handshake returned" \
2656 -s "No client certification received from the client, but required by the authentication mode"
2657
2658run_test "Authentication: client has no cert, server required (TLS)" \
2659 "$P_SRV debug_level=3 auth_mode=required" \
2660 "$P_CLI debug_level=3 crt_file=none \
2661 key_file=data_files/server5.key" \
2662 1 \
2663 -S "skip write certificate request" \
2664 -C "skip parse certificate request" \
2665 -c "got a certificate request" \
2666 -c "= write certificate$" \
2667 -C "skip write certificate$" \
2668 -S "x509_verify_cert() returned" \
2669 -s "client has no certificate" \
2670 -s "! mbedtls_ssl_handshake returned" \
2671 -c "! mbedtls_ssl_handshake returned" \
2672 -s "No client certification received from the client, but required by the authentication mode"
2673
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002674run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002675 "$P_SRV debug_level=3 auth_mode=required" \
2676 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002677 key_file=data_files/server5.key" \
2678 1 \
2679 -S "skip write certificate request" \
2680 -C "skip parse certificate request" \
2681 -c "got a certificate request" \
2682 -C "skip write certificate" \
2683 -C "skip write certificate verify" \
2684 -S "skip parse certificate verify" \
2685 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002686 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002687 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002688 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002689 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002690 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002691# We don't check that the client receives the alert because it might
2692# detect that its write end of the connection is closed and abort
2693# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002694
Janos Follath89baba22017-04-10 14:34:35 +01002695run_test "Authentication: client cert not trusted, server required" \
2696 "$P_SRV debug_level=3 auth_mode=required" \
2697 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2698 key_file=data_files/server5.key" \
2699 1 \
2700 -S "skip write certificate request" \
2701 -C "skip parse certificate request" \
2702 -c "got a certificate request" \
2703 -C "skip write certificate" \
2704 -C "skip write certificate verify" \
2705 -S "skip parse certificate verify" \
2706 -s "x509_verify_cert() returned" \
2707 -s "! The certificate is not correctly signed by the trusted CA" \
2708 -s "! mbedtls_ssl_handshake returned" \
2709 -c "! mbedtls_ssl_handshake returned" \
2710 -s "X509 - Certificate verification failed"
2711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002712run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002713 "$P_SRV debug_level=3 auth_mode=optional" \
2714 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002715 key_file=data_files/server5.key" \
2716 0 \
2717 -S "skip write certificate request" \
2718 -C "skip parse certificate request" \
2719 -c "got a certificate request" \
2720 -C "skip write certificate" \
2721 -C "skip write certificate verify" \
2722 -S "skip parse certificate verify" \
2723 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002724 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002725 -S "! mbedtls_ssl_handshake returned" \
2726 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002727 -S "X509 - Certificate verification failed"
2728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002729run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002730 "$P_SRV debug_level=3 auth_mode=none" \
2731 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002732 key_file=data_files/server5.key" \
2733 0 \
2734 -s "skip write certificate request" \
2735 -C "skip parse certificate request" \
2736 -c "got no certificate request" \
2737 -c "skip write certificate" \
2738 -c "skip write certificate verify" \
2739 -s "skip parse certificate verify" \
2740 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002741 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002742 -S "! mbedtls_ssl_handshake returned" \
2743 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002744 -S "X509 - Certificate verification failed"
2745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002746run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002747 "$P_SRV debug_level=3 auth_mode=optional" \
2748 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002749 0 \
2750 -S "skip write certificate request" \
2751 -C "skip parse certificate request" \
2752 -c "got a certificate request" \
2753 -C "skip write certificate$" \
2754 -C "got no certificate to send" \
2755 -S "SSLv3 client has no certificate" \
2756 -c "skip write certificate verify" \
2757 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002758 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002759 -S "! mbedtls_ssl_handshake returned" \
2760 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002761 -S "X509 - Certificate verification failed"
2762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002763run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002764 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002765 "$O_CLI" \
2766 0 \
2767 -S "skip write certificate request" \
2768 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002769 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002770 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002771 -S "X509 - Certificate verification failed"
2772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002773run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002774 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002775 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002776 0 \
2777 -C "skip parse certificate request" \
2778 -c "got a certificate request" \
2779 -C "skip write certificate$" \
2780 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002781 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002782
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002783run_test "Authentication: client no cert, openssl server required" \
2784 "$O_SRV -Verify 10" \
2785 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2786 1 \
2787 -C "skip parse certificate request" \
2788 -c "got a certificate request" \
2789 -C "skip write certificate$" \
2790 -c "skip write certificate verify" \
2791 -c "! mbedtls_ssl_handshake returned"
2792
Janos Follathe2681a42016-03-07 15:57:05 +00002793requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002794run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002795 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002796 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002797 0 \
2798 -S "skip write certificate request" \
2799 -C "skip parse certificate request" \
2800 -c "got a certificate request" \
2801 -C "skip write certificate$" \
2802 -c "skip write certificate verify" \
2803 -c "got no certificate to send" \
2804 -s "SSLv3 client has no certificate" \
2805 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002806 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002807 -S "! mbedtls_ssl_handshake returned" \
2808 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002809 -S "X509 - Certificate verification failed"
2810
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002811# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2812# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002813
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002814MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002815MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002816
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002817if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002818 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002819 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002820 printf "test value of ${MAX_IM_CA}. \n"
2821 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002822 printf "The tests assume this value and if it changes, the tests in this\n"
2823 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002824 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002825
2826 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002827fi
2828
Angus Grattonc4dd0732018-04-11 16:28:39 +10002829requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002830run_test "Authentication: server max_int chain, client default" \
2831 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2832 key_file=data_files/dir-maxpath/09.key" \
2833 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2834 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002835 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002836
Angus Grattonc4dd0732018-04-11 16:28:39 +10002837requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002838run_test "Authentication: server max_int+1 chain, client default" \
2839 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2840 key_file=data_files/dir-maxpath/10.key" \
2841 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2842 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002843 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002844
Angus Grattonc4dd0732018-04-11 16:28:39 +10002845requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002846run_test "Authentication: server max_int+1 chain, client optional" \
2847 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2848 key_file=data_files/dir-maxpath/10.key" \
2849 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2850 auth_mode=optional" \
2851 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002852 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002853
Angus Grattonc4dd0732018-04-11 16:28:39 +10002854requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002855run_test "Authentication: server max_int+1 chain, client none" \
2856 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2857 key_file=data_files/dir-maxpath/10.key" \
2858 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2859 auth_mode=none" \
2860 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002861 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002862
Angus Grattonc4dd0732018-04-11 16:28:39 +10002863requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002864run_test "Authentication: client max_int+1 chain, server default" \
2865 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2866 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2867 key_file=data_files/dir-maxpath/10.key" \
2868 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002869 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002870
Angus Grattonc4dd0732018-04-11 16:28:39 +10002871requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002872run_test "Authentication: client max_int+1 chain, server optional" \
2873 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2874 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2875 key_file=data_files/dir-maxpath/10.key" \
2876 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002877 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002878
Angus Grattonc4dd0732018-04-11 16:28:39 +10002879requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002880run_test "Authentication: client max_int+1 chain, server required" \
2881 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2882 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2883 key_file=data_files/dir-maxpath/10.key" \
2884 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002885 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002886
Angus Grattonc4dd0732018-04-11 16:28:39 +10002887requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002888run_test "Authentication: client max_int chain, server required" \
2889 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2890 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2891 key_file=data_files/dir-maxpath/09.key" \
2892 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002893 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002894
Janos Follath89baba22017-04-10 14:34:35 +01002895# Tests for CA list in CertificateRequest messages
2896
2897run_test "Authentication: send CA list in CertificateRequest (default)" \
2898 "$P_SRV debug_level=3 auth_mode=required" \
2899 "$P_CLI crt_file=data_files/server6.crt \
2900 key_file=data_files/server6.key" \
2901 0 \
2902 -s "requested DN"
2903
2904run_test "Authentication: do not send CA list in CertificateRequest" \
2905 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2906 "$P_CLI crt_file=data_files/server6.crt \
2907 key_file=data_files/server6.key" \
2908 0 \
2909 -S "requested DN"
2910
2911run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2912 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2913 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2914 key_file=data_files/server5.key" \
2915 1 \
2916 -S "requested DN" \
2917 -s "x509_verify_cert() returned" \
2918 -s "! The certificate is not correctly signed by the trusted CA" \
2919 -s "! mbedtls_ssl_handshake returned" \
2920 -c "! mbedtls_ssl_handshake returned" \
2921 -s "X509 - Certificate verification failed"
2922
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002923# Tests for certificate selection based on SHA verson
2924
2925run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2926 "$P_SRV crt_file=data_files/server5.crt \
2927 key_file=data_files/server5.key \
2928 crt_file2=data_files/server5-sha1.crt \
2929 key_file2=data_files/server5.key" \
2930 "$P_CLI force_version=tls1_2" \
2931 0 \
2932 -c "signed using.*ECDSA with SHA256" \
2933 -C "signed using.*ECDSA with SHA1"
2934
2935run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2936 "$P_SRV crt_file=data_files/server5.crt \
2937 key_file=data_files/server5.key \
2938 crt_file2=data_files/server5-sha1.crt \
2939 key_file2=data_files/server5.key" \
2940 "$P_CLI force_version=tls1_1" \
2941 0 \
2942 -C "signed using.*ECDSA with SHA256" \
2943 -c "signed using.*ECDSA with SHA1"
2944
2945run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2946 "$P_SRV crt_file=data_files/server5.crt \
2947 key_file=data_files/server5.key \
2948 crt_file2=data_files/server5-sha1.crt \
2949 key_file2=data_files/server5.key" \
2950 "$P_CLI force_version=tls1" \
2951 0 \
2952 -C "signed using.*ECDSA with SHA256" \
2953 -c "signed using.*ECDSA with SHA1"
2954
2955run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2956 "$P_SRV crt_file=data_files/server5.crt \
2957 key_file=data_files/server5.key \
2958 crt_file2=data_files/server6.crt \
2959 key_file2=data_files/server6.key" \
2960 "$P_CLI force_version=tls1_1" \
2961 0 \
2962 -c "serial number.*09" \
2963 -c "signed using.*ECDSA with SHA256" \
2964 -C "signed using.*ECDSA with SHA1"
2965
2966run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2967 "$P_SRV crt_file=data_files/server6.crt \
2968 key_file=data_files/server6.key \
2969 crt_file2=data_files/server5.crt \
2970 key_file2=data_files/server5.key" \
2971 "$P_CLI force_version=tls1_1" \
2972 0 \
2973 -c "serial number.*0A" \
2974 -c "signed using.*ECDSA with SHA256" \
2975 -C "signed using.*ECDSA with SHA1"
2976
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002977# tests for SNI
2978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002979run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002980 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002981 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002982 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002983 0 \
2984 -S "parse ServerName extension" \
2985 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2986 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002988run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002989 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002990 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002991 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 +02002992 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002993 0 \
2994 -s "parse ServerName extension" \
2995 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
2996 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002997
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002998run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002999 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003000 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003001 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 +02003002 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003003 0 \
3004 -s "parse ServerName extension" \
3005 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3006 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003008run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003009 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003010 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003011 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 +02003012 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003013 1 \
3014 -s "parse ServerName extension" \
3015 -s "ssl_sni_wrapper() returned" \
3016 -s "mbedtls_ssl_handshake returned" \
3017 -c "mbedtls_ssl_handshake returned" \
3018 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003019
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003020run_test "SNI: client auth no override: optional" \
3021 "$P_SRV debug_level=3 auth_mode=optional \
3022 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3023 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3024 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003025 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003026 -S "skip write certificate request" \
3027 -C "skip parse certificate request" \
3028 -c "got a certificate request" \
3029 -C "skip write certificate" \
3030 -C "skip write certificate verify" \
3031 -S "skip parse certificate verify"
3032
3033run_test "SNI: client auth override: none -> optional" \
3034 "$P_SRV debug_level=3 auth_mode=none \
3035 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3036 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3037 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003038 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003039 -S "skip write certificate request" \
3040 -C "skip parse certificate request" \
3041 -c "got a certificate request" \
3042 -C "skip write certificate" \
3043 -C "skip write certificate verify" \
3044 -S "skip parse certificate verify"
3045
3046run_test "SNI: client auth override: optional -> none" \
3047 "$P_SRV debug_level=3 auth_mode=optional \
3048 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3049 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3050 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003051 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003052 -s "skip write certificate request" \
3053 -C "skip parse certificate request" \
3054 -c "got no certificate request" \
3055 -c "skip write certificate" \
3056 -c "skip write certificate verify" \
3057 -s "skip parse certificate verify"
3058
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003059run_test "SNI: CA no override" \
3060 "$P_SRV debug_level=3 auth_mode=optional \
3061 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3062 ca_file=data_files/test-ca.crt \
3063 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3064 "$P_CLI debug_level=3 server_name=localhost \
3065 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3066 1 \
3067 -S "skip write certificate request" \
3068 -C "skip parse certificate request" \
3069 -c "got a certificate request" \
3070 -C "skip write certificate" \
3071 -C "skip write certificate verify" \
3072 -S "skip parse certificate verify" \
3073 -s "x509_verify_cert() returned" \
3074 -s "! The certificate is not correctly signed by the trusted CA" \
3075 -S "The certificate has been revoked (is on a CRL)"
3076
3077run_test "SNI: CA override" \
3078 "$P_SRV debug_level=3 auth_mode=optional \
3079 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3080 ca_file=data_files/test-ca.crt \
3081 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3082 "$P_CLI debug_level=3 server_name=localhost \
3083 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3084 0 \
3085 -S "skip write certificate request" \
3086 -C "skip parse certificate request" \
3087 -c "got a certificate request" \
3088 -C "skip write certificate" \
3089 -C "skip write certificate verify" \
3090 -S "skip parse certificate verify" \
3091 -S "x509_verify_cert() returned" \
3092 -S "! The certificate is not correctly signed by the trusted CA" \
3093 -S "The certificate has been revoked (is on a CRL)"
3094
3095run_test "SNI: CA override with CRL" \
3096 "$P_SRV debug_level=3 auth_mode=optional \
3097 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3098 ca_file=data_files/test-ca.crt \
3099 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3100 "$P_CLI debug_level=3 server_name=localhost \
3101 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3102 1 \
3103 -S "skip write certificate request" \
3104 -C "skip parse certificate request" \
3105 -c "got a certificate request" \
3106 -C "skip write certificate" \
3107 -C "skip write certificate verify" \
3108 -S "skip parse certificate verify" \
3109 -s "x509_verify_cert() returned" \
3110 -S "! The certificate is not correctly signed by the trusted CA" \
3111 -s "The certificate has been revoked (is on a CRL)"
3112
Andres AG1a834452016-12-07 10:01:30 +00003113# Tests for SNI and DTLS
3114
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003115run_test "SNI: DTLS, no SNI callback" \
3116 "$P_SRV debug_level=3 dtls=1 \
3117 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3118 "$P_CLI server_name=localhost dtls=1" \
3119 0 \
3120 -S "parse ServerName extension" \
3121 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3122 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3123
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003124run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003125 "$P_SRV debug_level=3 dtls=1 \
3126 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3127 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3128 "$P_CLI server_name=localhost dtls=1" \
3129 0 \
3130 -s "parse ServerName extension" \
3131 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3132 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3133
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003134run_test "SNI: DTLS, matching cert 2" \
3135 "$P_SRV debug_level=3 dtls=1 \
3136 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3137 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3138 "$P_CLI server_name=polarssl.example dtls=1" \
3139 0 \
3140 -s "parse ServerName extension" \
3141 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3142 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3143
3144run_test "SNI: DTLS, no matching cert" \
3145 "$P_SRV debug_level=3 dtls=1 \
3146 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3147 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3148 "$P_CLI server_name=nonesuch.example dtls=1" \
3149 1 \
3150 -s "parse ServerName extension" \
3151 -s "ssl_sni_wrapper() returned" \
3152 -s "mbedtls_ssl_handshake returned" \
3153 -c "mbedtls_ssl_handshake returned" \
3154 -c "SSL - A fatal alert message was received from our peer"
3155
3156run_test "SNI: DTLS, client auth no override: optional" \
3157 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3158 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3159 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3160 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3161 0 \
3162 -S "skip write certificate request" \
3163 -C "skip parse certificate request" \
3164 -c "got a certificate request" \
3165 -C "skip write certificate" \
3166 -C "skip write certificate verify" \
3167 -S "skip parse certificate verify"
3168
3169run_test "SNI: DTLS, client auth override: none -> optional" \
3170 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3171 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3172 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3173 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3174 0 \
3175 -S "skip write certificate request" \
3176 -C "skip parse certificate request" \
3177 -c "got a certificate request" \
3178 -C "skip write certificate" \
3179 -C "skip write certificate verify" \
3180 -S "skip parse certificate verify"
3181
3182run_test "SNI: DTLS, client auth override: optional -> none" \
3183 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3184 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3185 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3186 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3187 0 \
3188 -s "skip write certificate request" \
3189 -C "skip parse certificate request" \
3190 -c "got no certificate request" \
3191 -c "skip write certificate" \
3192 -c "skip write certificate verify" \
3193 -s "skip parse certificate verify"
3194
3195run_test "SNI: DTLS, CA no override" \
3196 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3197 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3198 ca_file=data_files/test-ca.crt \
3199 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3200 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3201 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3202 1 \
3203 -S "skip write certificate request" \
3204 -C "skip parse certificate request" \
3205 -c "got a certificate request" \
3206 -C "skip write certificate" \
3207 -C "skip write certificate verify" \
3208 -S "skip parse certificate verify" \
3209 -s "x509_verify_cert() returned" \
3210 -s "! The certificate is not correctly signed by the trusted CA" \
3211 -S "The certificate has been revoked (is on a CRL)"
3212
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003213run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003214 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3215 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3216 ca_file=data_files/test-ca.crt \
3217 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3218 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3219 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3220 0 \
3221 -S "skip write certificate request" \
3222 -C "skip parse certificate request" \
3223 -c "got a certificate request" \
3224 -C "skip write certificate" \
3225 -C "skip write certificate verify" \
3226 -S "skip parse certificate verify" \
3227 -S "x509_verify_cert() returned" \
3228 -S "! The certificate is not correctly signed by the trusted CA" \
3229 -S "The certificate has been revoked (is on a CRL)"
3230
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003231run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003232 "$P_SRV debug_level=3 auth_mode=optional \
3233 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3234 ca_file=data_files/test-ca.crt \
3235 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3236 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3237 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3238 1 \
3239 -S "skip write certificate request" \
3240 -C "skip parse certificate request" \
3241 -c "got a certificate request" \
3242 -C "skip write certificate" \
3243 -C "skip write certificate verify" \
3244 -S "skip parse certificate verify" \
3245 -s "x509_verify_cert() returned" \
3246 -S "! The certificate is not correctly signed by the trusted CA" \
3247 -s "The certificate has been revoked (is on a CRL)"
3248
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003249# Tests for non-blocking I/O: exercise a variety of handshake flows
3250
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003251run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003252 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3253 "$P_CLI nbio=2 tickets=0" \
3254 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003255 -S "mbedtls_ssl_handshake returned" \
3256 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003257 -c "Read from server: .* bytes read"
3258
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003259run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003260 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3261 "$P_CLI nbio=2 tickets=0" \
3262 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003263 -S "mbedtls_ssl_handshake returned" \
3264 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003265 -c "Read from server: .* bytes read"
3266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003267run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003268 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3269 "$P_CLI nbio=2 tickets=1" \
3270 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003271 -S "mbedtls_ssl_handshake returned" \
3272 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003273 -c "Read from server: .* bytes read"
3274
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003275run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003276 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3277 "$P_CLI nbio=2 tickets=1" \
3278 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003279 -S "mbedtls_ssl_handshake returned" \
3280 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003281 -c "Read from server: .* bytes read"
3282
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003283run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003284 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3285 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3286 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003287 -S "mbedtls_ssl_handshake returned" \
3288 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003289 -c "Read from server: .* bytes read"
3290
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003291run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003292 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3293 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3294 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003295 -S "mbedtls_ssl_handshake returned" \
3296 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003297 -c "Read from server: .* bytes read"
3298
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003299run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003300 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3301 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3302 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003303 -S "mbedtls_ssl_handshake returned" \
3304 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003305 -c "Read from server: .* bytes read"
3306
Hanno Becker00076712017-11-15 16:39:08 +00003307# Tests for event-driven I/O: exercise a variety of handshake flows
3308
3309run_test "Event-driven I/O: basic handshake" \
3310 "$P_SRV event=1 tickets=0 auth_mode=none" \
3311 "$P_CLI event=1 tickets=0" \
3312 0 \
3313 -S "mbedtls_ssl_handshake returned" \
3314 -C "mbedtls_ssl_handshake returned" \
3315 -c "Read from server: .* bytes read"
3316
3317run_test "Event-driven I/O: client auth" \
3318 "$P_SRV event=1 tickets=0 auth_mode=required" \
3319 "$P_CLI event=1 tickets=0" \
3320 0 \
3321 -S "mbedtls_ssl_handshake returned" \
3322 -C "mbedtls_ssl_handshake returned" \
3323 -c "Read from server: .* bytes read"
3324
3325run_test "Event-driven I/O: ticket" \
3326 "$P_SRV event=1 tickets=1 auth_mode=none" \
3327 "$P_CLI event=1 tickets=1" \
3328 0 \
3329 -S "mbedtls_ssl_handshake returned" \
3330 -C "mbedtls_ssl_handshake returned" \
3331 -c "Read from server: .* bytes read"
3332
3333run_test "Event-driven I/O: ticket + client auth" \
3334 "$P_SRV event=1 tickets=1 auth_mode=required" \
3335 "$P_CLI event=1 tickets=1" \
3336 0 \
3337 -S "mbedtls_ssl_handshake returned" \
3338 -C "mbedtls_ssl_handshake returned" \
3339 -c "Read from server: .* bytes read"
3340
3341run_test "Event-driven I/O: ticket + client auth + resume" \
3342 "$P_SRV event=1 tickets=1 auth_mode=required" \
3343 "$P_CLI event=1 tickets=1 reconnect=1" \
3344 0 \
3345 -S "mbedtls_ssl_handshake returned" \
3346 -C "mbedtls_ssl_handshake returned" \
3347 -c "Read from server: .* bytes read"
3348
3349run_test "Event-driven I/O: ticket + resume" \
3350 "$P_SRV event=1 tickets=1 auth_mode=none" \
3351 "$P_CLI event=1 tickets=1 reconnect=1" \
3352 0 \
3353 -S "mbedtls_ssl_handshake returned" \
3354 -C "mbedtls_ssl_handshake returned" \
3355 -c "Read from server: .* bytes read"
3356
3357run_test "Event-driven I/O: session-id resume" \
3358 "$P_SRV event=1 tickets=0 auth_mode=none" \
3359 "$P_CLI event=1 tickets=0 reconnect=1" \
3360 0 \
3361 -S "mbedtls_ssl_handshake returned" \
3362 -C "mbedtls_ssl_handshake returned" \
3363 -c "Read from server: .* bytes read"
3364
Hanno Becker6a33f592018-03-13 11:38:46 +00003365run_test "Event-driven I/O, DTLS: basic handshake" \
3366 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3367 "$P_CLI dtls=1 event=1 tickets=0" \
3368 0 \
3369 -c "Read from server: .* bytes read"
3370
3371run_test "Event-driven I/O, DTLS: client auth" \
3372 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3373 "$P_CLI dtls=1 event=1 tickets=0" \
3374 0 \
3375 -c "Read from server: .* bytes read"
3376
3377run_test "Event-driven I/O, DTLS: ticket" \
3378 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3379 "$P_CLI dtls=1 event=1 tickets=1" \
3380 0 \
3381 -c "Read from server: .* bytes read"
3382
3383run_test "Event-driven I/O, DTLS: ticket + client auth" \
3384 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3385 "$P_CLI dtls=1 event=1 tickets=1" \
3386 0 \
3387 -c "Read from server: .* bytes read"
3388
3389run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3390 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003391 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003392 0 \
3393 -c "Read from server: .* bytes read"
3394
3395run_test "Event-driven I/O, DTLS: ticket + resume" \
3396 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003397 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003398 0 \
3399 -c "Read from server: .* bytes read"
3400
3401run_test "Event-driven I/O, DTLS: session-id resume" \
3402 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003403 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003404 0 \
3405 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003406
3407# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3408# During session resumption, the client will send its ApplicationData record
3409# within the same datagram as the Finished messages. In this situation, the
3410# server MUST NOT idle on the underlying transport after handshake completion,
3411# because the ApplicationData request has already been queued internally.
3412run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003413 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003414 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003415 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003416 0 \
3417 -c "Read from server: .* bytes read"
3418
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003419# Tests for version negotiation
3420
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003421run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003422 "$P_SRV" \
3423 "$P_CLI" \
3424 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003425 -S "mbedtls_ssl_handshake returned" \
3426 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003427 -s "Protocol is TLSv1.2" \
3428 -c "Protocol is TLSv1.2"
3429
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003430run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003431 "$P_SRV" \
3432 "$P_CLI max_version=tls1_1" \
3433 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003434 -S "mbedtls_ssl_handshake returned" \
3435 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003436 -s "Protocol is TLSv1.1" \
3437 -c "Protocol is TLSv1.1"
3438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003439run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003440 "$P_SRV max_version=tls1_1" \
3441 "$P_CLI" \
3442 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003443 -S "mbedtls_ssl_handshake returned" \
3444 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003445 -s "Protocol is TLSv1.1" \
3446 -c "Protocol is TLSv1.1"
3447
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003448run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003449 "$P_SRV max_version=tls1_1" \
3450 "$P_CLI max_version=tls1_1" \
3451 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003452 -S "mbedtls_ssl_handshake returned" \
3453 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003454 -s "Protocol is TLSv1.1" \
3455 -c "Protocol is TLSv1.1"
3456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003457run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003458 "$P_SRV min_version=tls1_1" \
3459 "$P_CLI max_version=tls1_1" \
3460 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003461 -S "mbedtls_ssl_handshake returned" \
3462 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003463 -s "Protocol is TLSv1.1" \
3464 -c "Protocol is TLSv1.1"
3465
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003466run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003467 "$P_SRV max_version=tls1_1" \
3468 "$P_CLI min_version=tls1_1" \
3469 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003470 -S "mbedtls_ssl_handshake returned" \
3471 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003472 -s "Protocol is TLSv1.1" \
3473 -c "Protocol is TLSv1.1"
3474
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003475run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003476 "$P_SRV max_version=tls1_1" \
3477 "$P_CLI min_version=tls1_2" \
3478 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003479 -s "mbedtls_ssl_handshake returned" \
3480 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003481 -c "SSL - Handshake protocol not within min/max boundaries"
3482
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003483run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003484 "$P_SRV min_version=tls1_2" \
3485 "$P_CLI max_version=tls1_1" \
3486 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003487 -s "mbedtls_ssl_handshake returned" \
3488 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003489 -s "SSL - Handshake protocol not within min/max boundaries"
3490
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003491# Tests for ALPN extension
3492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003493run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003494 "$P_SRV debug_level=3" \
3495 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003496 0 \
3497 -C "client hello, adding alpn extension" \
3498 -S "found alpn extension" \
3499 -C "got an alert message, type: \\[2:120]" \
3500 -S "server hello, adding alpn extension" \
3501 -C "found alpn extension " \
3502 -C "Application Layer Protocol is" \
3503 -S "Application Layer Protocol is"
3504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003505run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003506 "$P_SRV debug_level=3" \
3507 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003508 0 \
3509 -c "client hello, adding alpn extension" \
3510 -s "found alpn extension" \
3511 -C "got an alert message, type: \\[2:120]" \
3512 -S "server hello, adding alpn extension" \
3513 -C "found alpn extension " \
3514 -c "Application Layer Protocol is (none)" \
3515 -S "Application Layer Protocol is"
3516
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003517run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003518 "$P_SRV debug_level=3 alpn=abc,1234" \
3519 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003520 0 \
3521 -C "client hello, adding alpn extension" \
3522 -S "found alpn extension" \
3523 -C "got an alert message, type: \\[2:120]" \
3524 -S "server hello, adding alpn extension" \
3525 -C "found alpn extension " \
3526 -C "Application Layer Protocol is" \
3527 -s "Application Layer Protocol is (none)"
3528
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003529run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003530 "$P_SRV debug_level=3 alpn=abc,1234" \
3531 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003532 0 \
3533 -c "client hello, adding alpn extension" \
3534 -s "found alpn extension" \
3535 -C "got an alert message, type: \\[2:120]" \
3536 -s "server hello, adding alpn extension" \
3537 -c "found alpn extension" \
3538 -c "Application Layer Protocol is abc" \
3539 -s "Application Layer Protocol is abc"
3540
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003541run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003542 "$P_SRV debug_level=3 alpn=abc,1234" \
3543 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003544 0 \
3545 -c "client hello, adding alpn extension" \
3546 -s "found alpn extension" \
3547 -C "got an alert message, type: \\[2:120]" \
3548 -s "server hello, adding alpn extension" \
3549 -c "found alpn extension" \
3550 -c "Application Layer Protocol is abc" \
3551 -s "Application Layer Protocol is abc"
3552
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003553run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003554 "$P_SRV debug_level=3 alpn=abc,1234" \
3555 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003556 0 \
3557 -c "client hello, adding alpn extension" \
3558 -s "found alpn extension" \
3559 -C "got an alert message, type: \\[2:120]" \
3560 -s "server hello, adding alpn extension" \
3561 -c "found alpn extension" \
3562 -c "Application Layer Protocol is 1234" \
3563 -s "Application Layer Protocol is 1234"
3564
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003565run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003566 "$P_SRV debug_level=3 alpn=abc,123" \
3567 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003568 1 \
3569 -c "client hello, adding alpn extension" \
3570 -s "found alpn extension" \
3571 -c "got an alert message, type: \\[2:120]" \
3572 -S "server hello, adding alpn extension" \
3573 -C "found alpn extension" \
3574 -C "Application Layer Protocol is 1234" \
3575 -S "Application Layer Protocol is 1234"
3576
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003577
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003578# Tests for keyUsage in leaf certificates, part 1:
3579# server-side certificate/suite selection
3580
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003581run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003582 "$P_SRV key_file=data_files/server2.key \
3583 crt_file=data_files/server2.ku-ds.crt" \
3584 "$P_CLI" \
3585 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003586 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003587
3588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003589run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003590 "$P_SRV key_file=data_files/server2.key \
3591 crt_file=data_files/server2.ku-ke.crt" \
3592 "$P_CLI" \
3593 0 \
3594 -c "Ciphersuite is TLS-RSA-WITH-"
3595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003596run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003597 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003598 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003599 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003600 1 \
3601 -C "Ciphersuite is "
3602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003603run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003604 "$P_SRV key_file=data_files/server5.key \
3605 crt_file=data_files/server5.ku-ds.crt" \
3606 "$P_CLI" \
3607 0 \
3608 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3609
3610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003611run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003612 "$P_SRV key_file=data_files/server5.key \
3613 crt_file=data_files/server5.ku-ka.crt" \
3614 "$P_CLI" \
3615 0 \
3616 -c "Ciphersuite is TLS-ECDH-"
3617
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003618run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003619 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003620 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003621 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003622 1 \
3623 -C "Ciphersuite is "
3624
3625# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003626# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003628run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003629 "$O_SRV -key data_files/server2.key \
3630 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003631 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003632 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3633 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003634 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003635 -C "Processing of the Certificate handshake message failed" \
3636 -c "Ciphersuite is TLS-"
3637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003638run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003639 "$O_SRV -key data_files/server2.key \
3640 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003641 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003642 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3643 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003644 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003645 -C "Processing of the Certificate handshake message failed" \
3646 -c "Ciphersuite is TLS-"
3647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003648run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003649 "$O_SRV -key data_files/server2.key \
3650 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003651 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003652 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3653 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003654 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003655 -C "Processing of the Certificate handshake message failed" \
3656 -c "Ciphersuite is TLS-"
3657
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003658run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003659 "$O_SRV -key data_files/server2.key \
3660 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003661 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003662 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3663 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003664 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003665 -c "Processing of the Certificate handshake message failed" \
3666 -C "Ciphersuite is TLS-"
3667
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003668run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3669 "$O_SRV -key data_files/server2.key \
3670 -cert data_files/server2.ku-ke.crt" \
3671 "$P_CLI debug_level=1 auth_mode=optional \
3672 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3673 0 \
3674 -c "bad certificate (usage extensions)" \
3675 -C "Processing of the Certificate handshake message failed" \
3676 -c "Ciphersuite is TLS-" \
3677 -c "! Usage does not match the keyUsage extension"
3678
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003679run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003680 "$O_SRV -key data_files/server2.key \
3681 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003682 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003683 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3684 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003685 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003686 -C "Processing of the Certificate handshake message failed" \
3687 -c "Ciphersuite is TLS-"
3688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003689run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003690 "$O_SRV -key data_files/server2.key \
3691 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003692 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003693 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3694 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003695 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003696 -c "Processing of the Certificate handshake message failed" \
3697 -C "Ciphersuite is TLS-"
3698
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003699run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3700 "$O_SRV -key data_files/server2.key \
3701 -cert data_files/server2.ku-ds.crt" \
3702 "$P_CLI debug_level=1 auth_mode=optional \
3703 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3704 0 \
3705 -c "bad certificate (usage extensions)" \
3706 -C "Processing of the Certificate handshake message failed" \
3707 -c "Ciphersuite is TLS-" \
3708 -c "! Usage does not match the keyUsage extension"
3709
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003710# Tests for keyUsage in leaf certificates, part 3:
3711# server-side checking of client cert
3712
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003713run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003714 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003715 "$O_CLI -key data_files/server2.key \
3716 -cert data_files/server2.ku-ds.crt" \
3717 0 \
3718 -S "bad certificate (usage extensions)" \
3719 -S "Processing of the Certificate handshake message failed"
3720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003721run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003722 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003723 "$O_CLI -key data_files/server2.key \
3724 -cert data_files/server2.ku-ke.crt" \
3725 0 \
3726 -s "bad certificate (usage extensions)" \
3727 -S "Processing of the Certificate handshake message failed"
3728
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003729run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003730 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003731 "$O_CLI -key data_files/server2.key \
3732 -cert data_files/server2.ku-ke.crt" \
3733 1 \
3734 -s "bad certificate (usage extensions)" \
3735 -s "Processing of the Certificate handshake message failed"
3736
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003737run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003738 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003739 "$O_CLI -key data_files/server5.key \
3740 -cert data_files/server5.ku-ds.crt" \
3741 0 \
3742 -S "bad certificate (usage extensions)" \
3743 -S "Processing of the Certificate handshake message failed"
3744
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003745run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003746 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003747 "$O_CLI -key data_files/server5.key \
3748 -cert data_files/server5.ku-ka.crt" \
3749 0 \
3750 -s "bad certificate (usage extensions)" \
3751 -S "Processing of the Certificate handshake message failed"
3752
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003753# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003755run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003756 "$P_SRV key_file=data_files/server5.key \
3757 crt_file=data_files/server5.eku-srv.crt" \
3758 "$P_CLI" \
3759 0
3760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003761run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003762 "$P_SRV key_file=data_files/server5.key \
3763 crt_file=data_files/server5.eku-srv.crt" \
3764 "$P_CLI" \
3765 0
3766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003767run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003768 "$P_SRV key_file=data_files/server5.key \
3769 crt_file=data_files/server5.eku-cs_any.crt" \
3770 "$P_CLI" \
3771 0
3772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003773run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003774 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003775 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003776 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003777 1
3778
3779# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3780
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003781run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003782 "$O_SRV -key data_files/server5.key \
3783 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003784 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003785 0 \
3786 -C "bad certificate (usage extensions)" \
3787 -C "Processing of the Certificate handshake message failed" \
3788 -c "Ciphersuite is TLS-"
3789
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003790run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003791 "$O_SRV -key data_files/server5.key \
3792 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003793 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003794 0 \
3795 -C "bad certificate (usage extensions)" \
3796 -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 "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003800 "$O_SRV -key data_files/server5.key \
3801 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003802 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003803 0 \
3804 -C "bad certificate (usage extensions)" \
3805 -C "Processing of the Certificate handshake message failed" \
3806 -c "Ciphersuite is TLS-"
3807
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003808run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003809 "$O_SRV -key data_files/server5.key \
3810 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003811 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003812 1 \
3813 -c "bad certificate (usage extensions)" \
3814 -c "Processing of the Certificate handshake message failed" \
3815 -C "Ciphersuite is TLS-"
3816
3817# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3818
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003819run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003820 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003821 "$O_CLI -key data_files/server5.key \
3822 -cert data_files/server5.eku-cli.crt" \
3823 0 \
3824 -S "bad certificate (usage extensions)" \
3825 -S "Processing of the Certificate handshake message failed"
3826
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003827run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003828 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003829 "$O_CLI -key data_files/server5.key \
3830 -cert data_files/server5.eku-srv_cli.crt" \
3831 0 \
3832 -S "bad certificate (usage extensions)" \
3833 -S "Processing of the Certificate handshake message failed"
3834
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003835run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003836 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003837 "$O_CLI -key data_files/server5.key \
3838 -cert data_files/server5.eku-cs_any.crt" \
3839 0 \
3840 -S "bad certificate (usage extensions)" \
3841 -S "Processing of the Certificate handshake message failed"
3842
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003843run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003844 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003845 "$O_CLI -key data_files/server5.key \
3846 -cert data_files/server5.eku-cs.crt" \
3847 0 \
3848 -s "bad certificate (usage extensions)" \
3849 -S "Processing of the Certificate handshake message failed"
3850
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003851run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003852 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003853 "$O_CLI -key data_files/server5.key \
3854 -cert data_files/server5.eku-cs.crt" \
3855 1 \
3856 -s "bad certificate (usage extensions)" \
3857 -s "Processing of the Certificate handshake message failed"
3858
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003859# Tests for DHM parameters loading
3860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003861run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003862 "$P_SRV" \
3863 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3864 debug_level=3" \
3865 0 \
3866 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003867 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003868
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003869run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003870 "$P_SRV dhm_file=data_files/dhparams.pem" \
3871 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3872 debug_level=3" \
3873 0 \
3874 -c "value of 'DHM: P ' (1024 bits)" \
3875 -c "value of 'DHM: G ' (2 bits)"
3876
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003877# Tests for DHM client-side size checking
3878
3879run_test "DHM size: server default, client default, OK" \
3880 "$P_SRV" \
3881 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3882 debug_level=1" \
3883 0 \
3884 -C "DHM prime too short:"
3885
3886run_test "DHM size: server default, client 2048, OK" \
3887 "$P_SRV" \
3888 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3889 debug_level=1 dhmlen=2048" \
3890 0 \
3891 -C "DHM prime too short:"
3892
3893run_test "DHM size: server 1024, client default, OK" \
3894 "$P_SRV dhm_file=data_files/dhparams.pem" \
3895 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3896 debug_level=1" \
3897 0 \
3898 -C "DHM prime too short:"
3899
3900run_test "DHM size: server 1000, client default, rejected" \
3901 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3902 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3903 debug_level=1" \
3904 1 \
3905 -c "DHM prime too short:"
3906
3907run_test "DHM size: server default, client 2049, rejected" \
3908 "$P_SRV" \
3909 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3910 debug_level=1 dhmlen=2049" \
3911 1 \
3912 -c "DHM prime too short:"
3913
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003914# Tests for PSK callback
3915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003916run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003917 "$P_SRV psk=abc123 psk_identity=foo" \
3918 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3919 psk_identity=foo psk=abc123" \
3920 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003921 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003922 -S "SSL - Unknown identity received" \
3923 -S "SSL - Verification of the message MAC failed"
3924
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003925run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003926 "$P_SRV" \
3927 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3928 psk_identity=foo psk=abc123" \
3929 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003930 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003931 -S "SSL - Unknown identity received" \
3932 -S "SSL - Verification of the message MAC failed"
3933
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003934run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003935 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3936 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3937 psk_identity=foo psk=abc123" \
3938 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003939 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003940 -s "SSL - Unknown identity received" \
3941 -S "SSL - Verification of the message MAC failed"
3942
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003943run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003944 "$P_SRV psk_list=abc,dead,def,beef" \
3945 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3946 psk_identity=abc psk=dead" \
3947 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003948 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003949 -S "SSL - Unknown identity received" \
3950 -S "SSL - Verification of the message MAC failed"
3951
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003952run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003953 "$P_SRV psk_list=abc,dead,def,beef" \
3954 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3955 psk_identity=def psk=beef" \
3956 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003957 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003958 -S "SSL - Unknown identity received" \
3959 -S "SSL - Verification of the message MAC failed"
3960
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003961run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003962 "$P_SRV psk_list=abc,dead,def,beef" \
3963 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3964 psk_identity=ghi psk=beef" \
3965 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003966 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003967 -s "SSL - Unknown identity received" \
3968 -S "SSL - Verification of the message MAC failed"
3969
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003970run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003971 "$P_SRV psk_list=abc,dead,def,beef" \
3972 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3973 psk_identity=abc psk=beef" \
3974 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003975 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003976 -S "SSL - Unknown identity received" \
3977 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003978
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003979# Tests for EC J-PAKE
3980
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003981requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003982run_test "ECJPAKE: client not configured" \
3983 "$P_SRV debug_level=3" \
3984 "$P_CLI debug_level=3" \
3985 0 \
3986 -C "add ciphersuite: c0ff" \
3987 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003988 -S "found ecjpake kkpp extension" \
3989 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003990 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003991 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003992 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003993 -S "None of the common ciphersuites is usable"
3994
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003995requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003996run_test "ECJPAKE: server not configured" \
3997 "$P_SRV debug_level=3" \
3998 "$P_CLI debug_level=3 ecjpake_pw=bla \
3999 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4000 1 \
4001 -c "add ciphersuite: c0ff" \
4002 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004003 -s "found ecjpake kkpp extension" \
4004 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004005 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004006 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004007 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004008 -s "None of the common ciphersuites is usable"
4009
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004010requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004011run_test "ECJPAKE: working, TLS" \
4012 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4013 "$P_CLI debug_level=3 ecjpake_pw=bla \
4014 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004015 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004016 -c "add ciphersuite: c0ff" \
4017 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004018 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004019 -s "found ecjpake kkpp extension" \
4020 -S "skip ecjpake kkpp extension" \
4021 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004022 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004023 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004024 -S "None of the common ciphersuites is usable" \
4025 -S "SSL - Verification of the message MAC failed"
4026
Janos Follath74537a62016-09-02 13:45:28 +01004027server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004028requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004029run_test "ECJPAKE: password mismatch, TLS" \
4030 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4031 "$P_CLI debug_level=3 ecjpake_pw=bad \
4032 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4033 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004034 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004035 -s "SSL - Verification of the message MAC failed"
4036
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004037requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004038run_test "ECJPAKE: working, DTLS" \
4039 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4040 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4041 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4042 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004043 -c "re-using cached ecjpake parameters" \
4044 -S "SSL - Verification of the message MAC failed"
4045
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004046requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004047run_test "ECJPAKE: working, DTLS, no cookie" \
4048 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4049 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4050 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4051 0 \
4052 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004053 -S "SSL - Verification of the message MAC failed"
4054
Janos Follath74537a62016-09-02 13:45:28 +01004055server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004056requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004057run_test "ECJPAKE: password mismatch, DTLS" \
4058 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4059 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4060 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4061 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004062 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004063 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004064
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004065# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004066requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004067run_test "ECJPAKE: working, DTLS, nolog" \
4068 "$P_SRV dtls=1 ecjpake_pw=bla" \
4069 "$P_CLI dtls=1 ecjpake_pw=bla \
4070 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4071 0
4072
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004073# Tests for ciphersuites per version
4074
Janos Follathe2681a42016-03-07 15:57:05 +00004075requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004076requires_config_enabled MBEDTLS_CAMELLIA_C
4077requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004078run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004079 "$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 +02004080 "$P_CLI force_version=ssl3" \
4081 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004082 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004083
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004084requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4085requires_config_enabled MBEDTLS_CAMELLIA_C
4086requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004087run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004088 "$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 +01004089 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004090 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004091 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004092
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004093requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4094requires_config_enabled MBEDTLS_CAMELLIA_C
4095requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004096run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004097 "$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 +02004098 "$P_CLI force_version=tls1_1" \
4099 0 \
4100 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4101
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004102requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4103requires_config_enabled MBEDTLS_CAMELLIA_C
4104requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004105run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004106 "$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 +02004107 "$P_CLI force_version=tls1_2" \
4108 0 \
4109 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4110
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004111# Test for ClientHello without extensions
4112
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004113requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004114run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004115 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004116 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004117 0 \
4118 -s "dumping 'client hello extensions' (0 bytes)"
4119
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004120# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004121
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004122run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004123 "$P_SRV" \
4124 "$P_CLI request_size=100" \
4125 0 \
4126 -s "Read from client: 100 bytes read$"
4127
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004128run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004129 "$P_SRV" \
4130 "$P_CLI request_size=500" \
4131 0 \
4132 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004133
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004134# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004135
Janos Follathe2681a42016-03-07 15:57:05 +00004136requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004137run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004138 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004139 "$P_CLI request_size=1 force_version=ssl3 \
4140 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4141 0 \
4142 -s "Read from client: 1 bytes read"
4143
Janos Follathe2681a42016-03-07 15:57:05 +00004144requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004145run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004146 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004147 "$P_CLI request_size=1 force_version=ssl3 \
4148 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4149 0 \
4150 -s "Read from client: 1 bytes read"
4151
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004152run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004153 "$P_SRV" \
4154 "$P_CLI request_size=1 force_version=tls1 \
4155 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4156 0 \
4157 -s "Read from client: 1 bytes read"
4158
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004159run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004160 "$P_SRV" \
4161 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4162 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4163 0 \
4164 -s "Read from client: 1 bytes read"
4165
Hanno Becker32c55012017-11-10 08:42:54 +00004166requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004167run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004168 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004169 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004170 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004171 0 \
4172 -s "Read from client: 1 bytes read"
4173
Hanno Becker32c55012017-11-10 08:42:54 +00004174requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004175run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004176 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004177 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004178 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004179 0 \
4180 -s "Read from client: 1 bytes read"
4181
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004182run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004183 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004184 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004185 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4186 0 \
4187 -s "Read from client: 1 bytes read"
4188
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004189run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004190 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4191 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004192 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004193 0 \
4194 -s "Read from client: 1 bytes read"
4195
4196requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004197run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004198 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004199 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004200 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004201 0 \
4202 -s "Read from client: 1 bytes read"
4203
Hanno Becker8501f982017-11-10 08:59:04 +00004204requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004205run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004206 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4207 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4208 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004209 0 \
4210 -s "Read from client: 1 bytes read"
4211
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004212run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004213 "$P_SRV" \
4214 "$P_CLI request_size=1 force_version=tls1_1 \
4215 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4216 0 \
4217 -s "Read from client: 1 bytes read"
4218
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004219run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004220 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004221 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004222 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004223 0 \
4224 -s "Read from client: 1 bytes read"
4225
4226requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004227run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004228 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004229 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004230 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004231 0 \
4232 -s "Read from client: 1 bytes read"
4233
4234requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004235run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004236 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004237 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004238 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004239 0 \
4240 -s "Read from client: 1 bytes read"
4241
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004242run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004243 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004244 "$P_CLI request_size=1 force_version=tls1_1 \
4245 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4246 0 \
4247 -s "Read from client: 1 bytes read"
4248
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004249run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004250 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004251 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004252 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004253 0 \
4254 -s "Read from client: 1 bytes read"
4255
Hanno Becker8501f982017-11-10 08:59:04 +00004256requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004257run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004258 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004259 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004260 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004261 0 \
4262 -s "Read from client: 1 bytes read"
4263
Hanno Becker32c55012017-11-10 08:42:54 +00004264requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004265run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004266 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004267 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004268 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004269 0 \
4270 -s "Read from client: 1 bytes read"
4271
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004272run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004273 "$P_SRV" \
4274 "$P_CLI request_size=1 force_version=tls1_2 \
4275 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4276 0 \
4277 -s "Read from client: 1 bytes read"
4278
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004279run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004280 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004281 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004282 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004283 0 \
4284 -s "Read from client: 1 bytes read"
4285
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004286run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004287 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004288 "$P_CLI request_size=1 force_version=tls1_2 \
4289 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004290 0 \
4291 -s "Read from client: 1 bytes read"
4292
Hanno Becker32c55012017-11-10 08:42:54 +00004293requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004294run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004295 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004296 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004297 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004298 0 \
4299 -s "Read from client: 1 bytes read"
4300
Hanno Becker8501f982017-11-10 08:59:04 +00004301requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004302run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004303 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004304 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004305 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004306 0 \
4307 -s "Read from client: 1 bytes read"
4308
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004309run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004310 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004311 "$P_CLI request_size=1 force_version=tls1_2 \
4312 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4313 0 \
4314 -s "Read from client: 1 bytes read"
4315
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004316run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004317 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004318 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004319 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004320 0 \
4321 -s "Read from client: 1 bytes read"
4322
Hanno Becker32c55012017-11-10 08:42:54 +00004323requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004324run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004325 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004326 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004327 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004328 0 \
4329 -s "Read from client: 1 bytes read"
4330
Hanno Becker8501f982017-11-10 08:59:04 +00004331requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004332run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004333 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004334 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004335 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004336 0 \
4337 -s "Read from client: 1 bytes read"
4338
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004339run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004340 "$P_SRV" \
4341 "$P_CLI request_size=1 force_version=tls1_2 \
4342 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4343 0 \
4344 -s "Read from client: 1 bytes read"
4345
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004346run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004347 "$P_SRV" \
4348 "$P_CLI request_size=1 force_version=tls1_2 \
4349 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4350 0 \
4351 -s "Read from client: 1 bytes read"
4352
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004353# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004354
4355requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004356run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004357 "$P_SRV dtls=1 force_version=dtls1" \
4358 "$P_CLI dtls=1 request_size=1 \
4359 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4360 0 \
4361 -s "Read from client: 1 bytes read"
4362
4363requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004364run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004365 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4366 "$P_CLI dtls=1 request_size=1 \
4367 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4368 0 \
4369 -s "Read from client: 1 bytes read"
4370
4371requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4372requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004373run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004374 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4375 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004376 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4377 0 \
4378 -s "Read from client: 1 bytes read"
4379
4380requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4381requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004382run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004383 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004384 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004385 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004386 0 \
4387 -s "Read from client: 1 bytes read"
4388
4389requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004390run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004391 "$P_SRV dtls=1 force_version=dtls1_2" \
4392 "$P_CLI dtls=1 request_size=1 \
4393 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4394 0 \
4395 -s "Read from client: 1 bytes read"
4396
4397requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004398run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004399 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004400 "$P_CLI dtls=1 request_size=1 \
4401 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4402 0 \
4403 -s "Read from client: 1 bytes read"
4404
4405requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4406requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004407run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004408 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004409 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004410 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004411 0 \
4412 -s "Read from client: 1 bytes read"
4413
4414requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4415requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004416run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004417 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004418 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004419 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004420 0 \
4421 -s "Read from client: 1 bytes read"
4422
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004423# Tests for small server packets
4424
4425requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4426run_test "Small server packet SSLv3 BlockCipher" \
4427 "$P_SRV response_size=1 min_version=ssl3" \
4428 "$P_CLI force_version=ssl3 \
4429 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4430 0 \
4431 -c "Read from server: 1 bytes read"
4432
4433requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4434run_test "Small server packet SSLv3 StreamCipher" \
4435 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4436 "$P_CLI force_version=ssl3 \
4437 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4438 0 \
4439 -c "Read from server: 1 bytes read"
4440
4441run_test "Small server packet TLS 1.0 BlockCipher" \
4442 "$P_SRV response_size=1" \
4443 "$P_CLI force_version=tls1 \
4444 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4445 0 \
4446 -c "Read from server: 1 bytes read"
4447
4448run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4449 "$P_SRV response_size=1" \
4450 "$P_CLI force_version=tls1 etm=0 \
4451 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4452 0 \
4453 -c "Read from server: 1 bytes read"
4454
4455requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4456run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4457 "$P_SRV response_size=1 trunc_hmac=1" \
4458 "$P_CLI force_version=tls1 \
4459 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4460 0 \
4461 -c "Read from server: 1 bytes read"
4462
4463requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4464run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4465 "$P_SRV response_size=1 trunc_hmac=1" \
4466 "$P_CLI force_version=tls1 \
4467 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4468 0 \
4469 -c "Read from server: 1 bytes read"
4470
4471run_test "Small server packet TLS 1.0 StreamCipher" \
4472 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4473 "$P_CLI force_version=tls1 \
4474 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4475 0 \
4476 -c "Read from server: 1 bytes read"
4477
4478run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4479 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4480 "$P_CLI force_version=tls1 \
4481 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4482 0 \
4483 -c "Read from server: 1 bytes read"
4484
4485requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4486run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4487 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4488 "$P_CLI force_version=tls1 \
4489 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4490 0 \
4491 -c "Read from server: 1 bytes read"
4492
4493requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4494run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4495 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4496 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4497 trunc_hmac=1 etm=0" \
4498 0 \
4499 -c "Read from server: 1 bytes read"
4500
4501run_test "Small server packet TLS 1.1 BlockCipher" \
4502 "$P_SRV response_size=1" \
4503 "$P_CLI force_version=tls1_1 \
4504 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4505 0 \
4506 -c "Read from server: 1 bytes read"
4507
4508run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4509 "$P_SRV response_size=1" \
4510 "$P_CLI force_version=tls1_1 \
4511 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4512 0 \
4513 -c "Read from server: 1 bytes read"
4514
4515requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4516run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4517 "$P_SRV response_size=1 trunc_hmac=1" \
4518 "$P_CLI force_version=tls1_1 \
4519 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4520 0 \
4521 -c "Read from server: 1 bytes read"
4522
4523requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4524run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4525 "$P_SRV response_size=1 trunc_hmac=1" \
4526 "$P_CLI force_version=tls1_1 \
4527 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4528 0 \
4529 -c "Read from server: 1 bytes read"
4530
4531run_test "Small server packet TLS 1.1 StreamCipher" \
4532 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4533 "$P_CLI force_version=tls1_1 \
4534 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4535 0 \
4536 -c "Read from server: 1 bytes read"
4537
4538run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4539 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4540 "$P_CLI force_version=tls1_1 \
4541 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4542 0 \
4543 -c "Read from server: 1 bytes read"
4544
4545requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4546run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4547 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4548 "$P_CLI force_version=tls1_1 \
4549 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4550 0 \
4551 -c "Read from server: 1 bytes read"
4552
4553requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4554run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4555 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4556 "$P_CLI force_version=tls1_1 \
4557 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4558 0 \
4559 -c "Read from server: 1 bytes read"
4560
4561run_test "Small server packet TLS 1.2 BlockCipher" \
4562 "$P_SRV response_size=1" \
4563 "$P_CLI force_version=tls1_2 \
4564 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4565 0 \
4566 -c "Read from server: 1 bytes read"
4567
4568run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4569 "$P_SRV response_size=1" \
4570 "$P_CLI force_version=tls1_2 \
4571 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4572 0 \
4573 -c "Read from server: 1 bytes read"
4574
4575run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4576 "$P_SRV response_size=1" \
4577 "$P_CLI force_version=tls1_2 \
4578 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4579 0 \
4580 -c "Read from server: 1 bytes read"
4581
4582requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4583run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4584 "$P_SRV response_size=1 trunc_hmac=1" \
4585 "$P_CLI force_version=tls1_2 \
4586 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4587 0 \
4588 -c "Read from server: 1 bytes read"
4589
4590requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4591run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4592 "$P_SRV response_size=1 trunc_hmac=1" \
4593 "$P_CLI force_version=tls1_2 \
4594 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4595 0 \
4596 -c "Read from server: 1 bytes read"
4597
4598run_test "Small server packet TLS 1.2 StreamCipher" \
4599 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4600 "$P_CLI force_version=tls1_2 \
4601 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4602 0 \
4603 -c "Read from server: 1 bytes read"
4604
4605run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4606 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4607 "$P_CLI force_version=tls1_2 \
4608 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4609 0 \
4610 -c "Read from server: 1 bytes read"
4611
4612requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4613run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4614 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4615 "$P_CLI force_version=tls1_2 \
4616 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4617 0 \
4618 -c "Read from server: 1 bytes read"
4619
4620requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4621run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4622 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4623 "$P_CLI force_version=tls1_2 \
4624 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4625 0 \
4626 -c "Read from server: 1 bytes read"
4627
4628run_test "Small server packet TLS 1.2 AEAD" \
4629 "$P_SRV response_size=1" \
4630 "$P_CLI force_version=tls1_2 \
4631 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4632 0 \
4633 -c "Read from server: 1 bytes read"
4634
4635run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4636 "$P_SRV response_size=1" \
4637 "$P_CLI force_version=tls1_2 \
4638 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4639 0 \
4640 -c "Read from server: 1 bytes read"
4641
4642# Tests for small server packets in DTLS
4643
4644requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4645run_test "Small server packet DTLS 1.0" \
4646 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4647 "$P_CLI dtls=1 \
4648 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4649 0 \
4650 -c "Read from server: 1 bytes read"
4651
4652requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4653run_test "Small server packet DTLS 1.0, without EtM" \
4654 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4655 "$P_CLI dtls=1 \
4656 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4657 0 \
4658 -c "Read from server: 1 bytes read"
4659
4660requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4661requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4662run_test "Small server packet DTLS 1.0, truncated hmac" \
4663 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4664 "$P_CLI dtls=1 trunc_hmac=1 \
4665 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4666 0 \
4667 -c "Read from server: 1 bytes read"
4668
4669requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4670requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4671run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4672 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4673 "$P_CLI dtls=1 \
4674 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4675 0 \
4676 -c "Read from server: 1 bytes read"
4677
4678requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4679run_test "Small server packet DTLS 1.2" \
4680 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4681 "$P_CLI dtls=1 \
4682 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4683 0 \
4684 -c "Read from server: 1 bytes read"
4685
4686requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4687run_test "Small server packet DTLS 1.2, without EtM" \
4688 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4689 "$P_CLI dtls=1 \
4690 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4691 0 \
4692 -c "Read from server: 1 bytes read"
4693
4694requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4695requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4696run_test "Small server packet DTLS 1.2, truncated hmac" \
4697 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4698 "$P_CLI dtls=1 \
4699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4700 0 \
4701 -c "Read from server: 1 bytes read"
4702
4703requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4704requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4705run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4706 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4707 "$P_CLI dtls=1 \
4708 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4709 0 \
4710 -c "Read from server: 1 bytes read"
4711
Janos Follath00efff72016-05-06 13:48:23 +01004712# A test for extensions in SSLv3
4713
4714requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4715run_test "SSLv3 with extensions, server side" \
4716 "$P_SRV min_version=ssl3 debug_level=3" \
4717 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4718 0 \
4719 -S "dumping 'client hello extensions'" \
4720 -S "server hello, total extension length:"
4721
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004722# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004723
Angus Grattonc4dd0732018-04-11 16:28:39 +10004724# How many fragments do we expect to write $1 bytes?
4725fragments_for_write() {
4726 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4727}
4728
Janos Follathe2681a42016-03-07 15:57:05 +00004729requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004730run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004731 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004732 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004733 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4734 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004735 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4736 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004737
Janos Follathe2681a42016-03-07 15:57:05 +00004738requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004739run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004740 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004741 "$P_CLI request_size=16384 force_version=ssl3 \
4742 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4743 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004744 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4745 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004746
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004747run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004748 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004749 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004750 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4751 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004752 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4753 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004754
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004755run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004756 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004757 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4759 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004760 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004761
Hanno Becker32c55012017-11-10 08:42:54 +00004762requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004763run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004764 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004765 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004767 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004768 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4769 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004770
Hanno Becker32c55012017-11-10 08:42:54 +00004771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004772run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004773 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004774 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004776 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004777 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004778
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004779run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004780 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004781 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004782 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4783 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004784 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004785
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004786run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004787 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4788 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004789 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004790 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004791 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004792
4793requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004794run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004795 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004796 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004797 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004798 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004799 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004800
Hanno Becker278fc7a2017-11-10 09:16:28 +00004801requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004802run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004803 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004804 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004805 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004806 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004807 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4808 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004809
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004810run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004811 "$P_SRV" \
4812 "$P_CLI request_size=16384 force_version=tls1_1 \
4813 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4814 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004815 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4816 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004817
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004818run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004819 "$P_SRV" \
4820 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4821 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004822 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004823 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004824
Hanno Becker32c55012017-11-10 08:42:54 +00004825requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004826run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004827 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004828 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004829 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004830 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004831 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004832
Hanno Becker32c55012017-11-10 08:42:54 +00004833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004834run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004835 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004836 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004837 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004838 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004839 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004840
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004841run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004842 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4843 "$P_CLI request_size=16384 force_version=tls1_1 \
4844 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4845 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004846 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4847 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004848
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004849run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004850 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004851 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004852 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004853 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004854 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4855 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004856
Hanno Becker278fc7a2017-11-10 09:16:28 +00004857requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004858run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004859 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004860 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004861 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004862 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004863 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004864
Hanno Becker278fc7a2017-11-10 09:16:28 +00004865requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004866run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004867 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004868 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004869 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004870 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004871 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4872 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004873
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004874run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004875 "$P_SRV" \
4876 "$P_CLI request_size=16384 force_version=tls1_2 \
4877 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4878 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004879 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4880 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004881
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004882run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004883 "$P_SRV" \
4884 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4885 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4886 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004887 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004888
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004889run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004890 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004891 "$P_CLI request_size=16384 force_version=tls1_2 \
4892 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004893 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004894 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4895 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004896
Hanno Becker32c55012017-11-10 08:42:54 +00004897requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004898run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004899 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004900 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004901 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004902 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004903 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004904
Hanno Becker278fc7a2017-11-10 09:16:28 +00004905requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004906run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004907 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004908 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004909 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004910 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004911 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4912 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004913
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004914run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004915 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004916 "$P_CLI request_size=16384 force_version=tls1_2 \
4917 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4918 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004919 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4920 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004921
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004922run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004923 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004924 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004925 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4926 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004927 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004928
Hanno Becker32c55012017-11-10 08:42:54 +00004929requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004930run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004931 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004932 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004933 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004934 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004935 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004936
Hanno Becker278fc7a2017-11-10 09:16:28 +00004937requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004938run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004939 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004940 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004941 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004942 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004943 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4944 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004945
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004946run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004947 "$P_SRV" \
4948 "$P_CLI request_size=16384 force_version=tls1_2 \
4949 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4950 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004951 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4952 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004954run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004955 "$P_SRV" \
4956 "$P_CLI request_size=16384 force_version=tls1_2 \
4957 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4958 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004959 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4960 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004961
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004962# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004963requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4964run_test "Large server packet SSLv3 StreamCipher" \
4965 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4966 "$P_CLI force_version=ssl3 \
4967 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4968 0 \
4969 -c "Read from server: 16384 bytes read"
4970
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004971# Checking next 4 tests logs for 1n-1 split against BEAST too
4972requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4973run_test "Large server packet SSLv3 BlockCipher" \
4974 "$P_SRV response_size=16384 min_version=ssl3" \
4975 "$P_CLI force_version=ssl3 recsplit=0 \
4976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4977 0 \
4978 -c "Read from server: 1 bytes read"\
4979 -c "16383 bytes read"\
4980 -C "Read from server: 16384 bytes read"
4981
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004982run_test "Large server packet TLS 1.0 BlockCipher" \
4983 "$P_SRV response_size=16384" \
4984 "$P_CLI force_version=tls1 recsplit=0 \
4985 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4986 0 \
4987 -c "Read from server: 1 bytes read"\
4988 -c "16383 bytes read"\
4989 -C "Read from server: 16384 bytes read"
4990
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004991run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4992 "$P_SRV response_size=16384" \
4993 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
4994 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4995 0 \
4996 -c "Read from server: 1 bytes read"\
4997 -c "16383 bytes read"\
4998 -C "Read from server: 16384 bytes read"
4999
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005000requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5001run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5002 "$P_SRV response_size=16384" \
5003 "$P_CLI force_version=tls1 recsplit=0 \
5004 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5005 trunc_hmac=1" \
5006 0 \
5007 -c "Read from server: 1 bytes read"\
5008 -c "16383 bytes read"\
5009 -C "Read from server: 16384 bytes read"
5010
5011requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5012run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5013 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5014 "$P_CLI force_version=tls1 \
5015 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5016 trunc_hmac=1" \
5017 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005018 -s "16384 bytes written in 1 fragments" \
5019 -c "Read from server: 16384 bytes read"
5020
5021run_test "Large server packet TLS 1.0 StreamCipher" \
5022 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5023 "$P_CLI force_version=tls1 \
5024 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5025 0 \
5026 -s "16384 bytes written in 1 fragments" \
5027 -c "Read from server: 16384 bytes read"
5028
5029run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5030 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5031 "$P_CLI force_version=tls1 \
5032 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5033 0 \
5034 -s "16384 bytes written in 1 fragments" \
5035 -c "Read from server: 16384 bytes read"
5036
5037requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5038run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5039 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5040 "$P_CLI force_version=tls1 \
5041 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5042 0 \
5043 -s "16384 bytes written in 1 fragments" \
5044 -c "Read from server: 16384 bytes read"
5045
5046requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5047run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5048 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5049 "$P_CLI force_version=tls1 \
5050 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5051 0 \
5052 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005053 -c "Read from server: 16384 bytes read"
5054
5055run_test "Large server packet TLS 1.1 BlockCipher" \
5056 "$P_SRV response_size=16384" \
5057 "$P_CLI force_version=tls1_1 \
5058 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5059 0 \
5060 -c "Read from server: 16384 bytes read"
5061
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005062run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5063 "$P_SRV response_size=16384" \
5064 "$P_CLI force_version=tls1_1 etm=0 \
5065 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005066 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005067 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005068 -c "Read from server: 16384 bytes read"
5069
5070requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5071run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5072 "$P_SRV response_size=16384" \
5073 "$P_CLI force_version=tls1_1 \
5074 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5075 trunc_hmac=1" \
5076 0 \
5077 -c "Read from server: 16384 bytes read"
5078
5079requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005080run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5081 "$P_SRV response_size=16384 trunc_hmac=1" \
5082 "$P_CLI force_version=tls1_1 \
5083 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5084 0 \
5085 -s "16384 bytes written in 1 fragments" \
5086 -c "Read from server: 16384 bytes read"
5087
5088run_test "Large server packet TLS 1.1 StreamCipher" \
5089 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5090 "$P_CLI force_version=tls1_1 \
5091 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5092 0 \
5093 -c "Read from server: 16384 bytes read"
5094
5095run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5096 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5097 "$P_CLI force_version=tls1_1 \
5098 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5099 0 \
5100 -s "16384 bytes written in 1 fragments" \
5101 -c "Read from server: 16384 bytes read"
5102
5103requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005104run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5105 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5106 "$P_CLI force_version=tls1_1 \
5107 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5108 trunc_hmac=1" \
5109 0 \
5110 -c "Read from server: 16384 bytes read"
5111
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005112run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5113 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5114 "$P_CLI force_version=tls1_1 \
5115 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5116 0 \
5117 -s "16384 bytes written in 1 fragments" \
5118 -c "Read from server: 16384 bytes read"
5119
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005120run_test "Large server packet TLS 1.2 BlockCipher" \
5121 "$P_SRV response_size=16384" \
5122 "$P_CLI force_version=tls1_2 \
5123 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5124 0 \
5125 -c "Read from server: 16384 bytes read"
5126
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005127run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5128 "$P_SRV response_size=16384" \
5129 "$P_CLI force_version=tls1_2 etm=0 \
5130 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5131 0 \
5132 -s "16384 bytes written in 1 fragments" \
5133 -c "Read from server: 16384 bytes read"
5134
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005135run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5136 "$P_SRV response_size=16384" \
5137 "$P_CLI force_version=tls1_2 \
5138 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5139 0 \
5140 -c "Read from server: 16384 bytes read"
5141
5142requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5143run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5144 "$P_SRV response_size=16384" \
5145 "$P_CLI force_version=tls1_2 \
5146 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5147 trunc_hmac=1" \
5148 0 \
5149 -c "Read from server: 16384 bytes read"
5150
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005151run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5152 "$P_SRV response_size=16384 trunc_hmac=1" \
5153 "$P_CLI force_version=tls1_2 \
5154 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5155 0 \
5156 -s "16384 bytes written in 1 fragments" \
5157 -c "Read from server: 16384 bytes read"
5158
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005159run_test "Large server packet TLS 1.2 StreamCipher" \
5160 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5161 "$P_CLI force_version=tls1_2 \
5162 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
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.2 StreamCipher, without EtM" \
5168 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5169 "$P_CLI force_version=tls1_2 \
5170 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5171 0 \
5172 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005173 -c "Read from server: 16384 bytes read"
5174
5175requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5176run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5177 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5178 "$P_CLI force_version=tls1_2 \
5179 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5180 trunc_hmac=1" \
5181 0 \
5182 -c "Read from server: 16384 bytes read"
5183
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5185run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5186 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5187 "$P_CLI force_version=tls1_2 \
5188 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5189 0 \
5190 -s "16384 bytes written in 1 fragments" \
5191 -c "Read from server: 16384 bytes read"
5192
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005193run_test "Large server packet TLS 1.2 AEAD" \
5194 "$P_SRV response_size=16384" \
5195 "$P_CLI force_version=tls1_2 \
5196 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5197 0 \
5198 -c "Read from server: 16384 bytes read"
5199
5200run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5201 "$P_SRV response_size=16384" \
5202 "$P_CLI force_version=tls1_2 \
5203 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5204 0 \
5205 -c "Read from server: 16384 bytes read"
5206
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005207# Tests for restartable ECC
5208
5209requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5210run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005211 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005212 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005213 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005214 debug_level=1" \
5215 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005216 -C "x509_verify_cert.*4b00" \
5217 -C "mbedtls_pk_verify.*4b00" \
5218 -C "mbedtls_ecdh_make_public.*4b00" \
5219 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005220
5221requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5222run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005223 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005224 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005225 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005226 debug_level=1 ec_max_ops=0" \
5227 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005228 -C "x509_verify_cert.*4b00" \
5229 -C "mbedtls_pk_verify.*4b00" \
5230 -C "mbedtls_ecdh_make_public.*4b00" \
5231 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005232
5233requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5234run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005235 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005236 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005237 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005238 debug_level=1 ec_max_ops=65535" \
5239 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005240 -C "x509_verify_cert.*4b00" \
5241 -C "mbedtls_pk_verify.*4b00" \
5242 -C "mbedtls_ecdh_make_public.*4b00" \
5243 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005244
5245requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5246run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005247 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005248 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005249 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005250 debug_level=1 ec_max_ops=1000" \
5251 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005252 -c "x509_verify_cert.*4b00" \
5253 -c "mbedtls_pk_verify.*4b00" \
5254 -c "mbedtls_ecdh_make_public.*4b00" \
5255 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005256
5257requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005258run_test "EC restart: TLS, max_ops=1000, badsign" \
5259 "$P_SRV auth_mode=required \
5260 crt_file=data_files/server5-badsign.crt \
5261 key_file=data_files/server5.key" \
5262 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5263 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5264 debug_level=1 ec_max_ops=1000" \
5265 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005266 -c "x509_verify_cert.*4b00" \
5267 -C "mbedtls_pk_verify.*4b00" \
5268 -C "mbedtls_ecdh_make_public.*4b00" \
5269 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005270 -c "! The certificate is not correctly signed by the trusted CA" \
5271 -c "! mbedtls_ssl_handshake returned" \
5272 -c "X509 - Certificate verification failed"
5273
5274requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5275run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5276 "$P_SRV auth_mode=required \
5277 crt_file=data_files/server5-badsign.crt \
5278 key_file=data_files/server5.key" \
5279 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5280 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5281 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5282 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005283 -c "x509_verify_cert.*4b00" \
5284 -c "mbedtls_pk_verify.*4b00" \
5285 -c "mbedtls_ecdh_make_public.*4b00" \
5286 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005287 -c "! The certificate is not correctly signed by the trusted CA" \
5288 -C "! mbedtls_ssl_handshake returned" \
5289 -C "X509 - Certificate verification failed"
5290
5291requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5292run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5293 "$P_SRV auth_mode=required \
5294 crt_file=data_files/server5-badsign.crt \
5295 key_file=data_files/server5.key" \
5296 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5297 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5298 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5299 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005300 -C "x509_verify_cert.*4b00" \
5301 -c "mbedtls_pk_verify.*4b00" \
5302 -c "mbedtls_ecdh_make_public.*4b00" \
5303 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005304 -C "! The certificate is not correctly signed by the trusted CA" \
5305 -C "! mbedtls_ssl_handshake returned" \
5306 -C "X509 - Certificate verification failed"
5307
5308requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005309run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005310 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005311 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005312 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005313 dtls=1 debug_level=1 ec_max_ops=1000" \
5314 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005315 -c "x509_verify_cert.*4b00" \
5316 -c "mbedtls_pk_verify.*4b00" \
5317 -c "mbedtls_ecdh_make_public.*4b00" \
5318 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005319
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005320requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5321run_test "EC restart: TLS, max_ops=1000 no client auth" \
5322 "$P_SRV" \
5323 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5324 debug_level=1 ec_max_ops=1000" \
5325 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005326 -c "x509_verify_cert.*4b00" \
5327 -c "mbedtls_pk_verify.*4b00" \
5328 -c "mbedtls_ecdh_make_public.*4b00" \
5329 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005330
5331requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5332run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5333 "$P_SRV psk=abc123" \
5334 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5335 psk=abc123 debug_level=1 ec_max_ops=1000" \
5336 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005337 -C "x509_verify_cert.*4b00" \
5338 -C "mbedtls_pk_verify.*4b00" \
5339 -C "mbedtls_ecdh_make_public.*4b00" \
5340 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005341
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005342# Tests of asynchronous private key support in SSL
5343
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005344requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005345run_test "SSL async private: sign, delay=0" \
5346 "$P_SRV \
5347 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005348 "$P_CLI" \
5349 0 \
5350 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005351 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005352
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005353requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005354run_test "SSL async private: sign, delay=1" \
5355 "$P_SRV \
5356 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005357 "$P_CLI" \
5358 0 \
5359 -s "Async sign callback: using key slot " \
5360 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005361 -s "Async resume (slot [0-9]): sign done, status=0"
5362
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005363requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5364run_test "SSL async private: sign, delay=2" \
5365 "$P_SRV \
5366 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5367 "$P_CLI" \
5368 0 \
5369 -s "Async sign callback: using key slot " \
5370 -U "Async sign callback: using key slot " \
5371 -s "Async resume (slot [0-9]): call 1 more times." \
5372 -s "Async resume (slot [0-9]): call 0 more times." \
5373 -s "Async resume (slot [0-9]): sign done, status=0"
5374
Gilles Peskined3268832018-04-26 06:23:59 +02005375# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5376# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5377requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5378requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5379run_test "SSL async private: sign, RSA, TLS 1.1" \
5380 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5381 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5382 "$P_CLI force_version=tls1_1" \
5383 0 \
5384 -s "Async sign callback: using key slot " \
5385 -s "Async resume (slot [0-9]): sign done, status=0"
5386
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005387requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005388run_test "SSL async private: sign, SNI" \
5389 "$P_SRV debug_level=3 \
5390 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5391 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5392 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5393 "$P_CLI server_name=polarssl.example" \
5394 0 \
5395 -s "Async sign callback: using key slot " \
5396 -s "Async resume (slot [0-9]): sign done, status=0" \
5397 -s "parse ServerName extension" \
5398 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5399 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5400
5401requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005402run_test "SSL async private: decrypt, delay=0" \
5403 "$P_SRV \
5404 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5405 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5406 0 \
5407 -s "Async decrypt callback: using key slot " \
5408 -s "Async resume (slot [0-9]): decrypt done, status=0"
5409
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005410requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005411run_test "SSL async private: decrypt, delay=1" \
5412 "$P_SRV \
5413 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5414 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5415 0 \
5416 -s "Async decrypt callback: using key slot " \
5417 -s "Async resume (slot [0-9]): call 0 more times." \
5418 -s "Async resume (slot [0-9]): decrypt done, status=0"
5419
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005420requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005421run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5422 "$P_SRV psk=abc123 \
5423 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5424 "$P_CLI psk=abc123 \
5425 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5426 0 \
5427 -s "Async decrypt callback: using key slot " \
5428 -s "Async resume (slot [0-9]): decrypt done, status=0"
5429
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005430requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005431run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5432 "$P_SRV psk=abc123 \
5433 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5434 "$P_CLI psk=abc123 \
5435 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5436 0 \
5437 -s "Async decrypt callback: using key slot " \
5438 -s "Async resume (slot [0-9]): call 0 more times." \
5439 -s "Async resume (slot [0-9]): decrypt done, status=0"
5440
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005441requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005442run_test "SSL async private: sign callback not present" \
5443 "$P_SRV \
5444 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5445 "$P_CLI; [ \$? -eq 1 ] &&
5446 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5447 0 \
5448 -S "Async sign callback" \
5449 -s "! mbedtls_ssl_handshake returned" \
5450 -s "The own private key or pre-shared key is not set, but needed" \
5451 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5452 -s "Successful connection"
5453
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005454requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005455run_test "SSL async private: decrypt callback not present" \
5456 "$P_SRV debug_level=1 \
5457 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5458 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5459 [ \$? -eq 1 ] && $P_CLI" \
5460 0 \
5461 -S "Async decrypt callback" \
5462 -s "! mbedtls_ssl_handshake returned" \
5463 -s "got no RSA private key" \
5464 -s "Async resume (slot [0-9]): sign done, status=0" \
5465 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005466
5467# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005468requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005469run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005470 "$P_SRV \
5471 async_operations=s async_private_delay1=1 \
5472 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5473 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005474 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5475 0 \
5476 -s "Async sign callback: using key slot 0," \
5477 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005478 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005479
5480# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005481requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005482run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005483 "$P_SRV \
5484 async_operations=s async_private_delay2=1 \
5485 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5486 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005487 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5488 0 \
5489 -s "Async sign callback: using key slot 0," \
5490 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005491 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005492
5493# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005494requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005495run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005496 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005497 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005498 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5499 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005500 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5501 0 \
5502 -s "Async sign callback: using key slot 1," \
5503 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005504 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005505
5506# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005507requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005508run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005509 "$P_SRV \
5510 async_operations=s async_private_delay1=1 \
5511 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5512 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005513 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5514 0 \
5515 -s "Async sign callback: no key matches this certificate."
5516
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005517requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005518run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005519 "$P_SRV \
5520 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5521 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005522 "$P_CLI" \
5523 1 \
5524 -s "Async sign callback: injected error" \
5525 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005526 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005527 -s "! mbedtls_ssl_handshake returned"
5528
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005529requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005530run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005531 "$P_SRV \
5532 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5533 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005534 "$P_CLI" \
5535 1 \
5536 -s "Async sign callback: using key slot " \
5537 -S "Async resume" \
5538 -s "Async cancel"
5539
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005540requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005541run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005542 "$P_SRV \
5543 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5544 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005545 "$P_CLI" \
5546 1 \
5547 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005548 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005549 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005550 -s "! mbedtls_ssl_handshake returned"
5551
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005552requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005553run_test "SSL async private: decrypt, error in start" \
5554 "$P_SRV \
5555 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5556 async_private_error=1" \
5557 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5558 1 \
5559 -s "Async decrypt callback: injected error" \
5560 -S "Async resume" \
5561 -S "Async cancel" \
5562 -s "! mbedtls_ssl_handshake returned"
5563
5564requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5565run_test "SSL async private: decrypt, cancel after start" \
5566 "$P_SRV \
5567 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5568 async_private_error=2" \
5569 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5570 1 \
5571 -s "Async decrypt callback: using key slot " \
5572 -S "Async resume" \
5573 -s "Async cancel"
5574
5575requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5576run_test "SSL async private: decrypt, error in resume" \
5577 "$P_SRV \
5578 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5579 async_private_error=3" \
5580 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5581 1 \
5582 -s "Async decrypt callback: using key slot " \
5583 -s "Async resume callback: decrypt done but injected error" \
5584 -S "Async cancel" \
5585 -s "! mbedtls_ssl_handshake returned"
5586
5587requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005588run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005589 "$P_SRV \
5590 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5591 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005592 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5593 0 \
5594 -s "Async cancel" \
5595 -s "! mbedtls_ssl_handshake returned" \
5596 -s "Async resume" \
5597 -s "Successful connection"
5598
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005599requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005600run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005601 "$P_SRV \
5602 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5603 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005604 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5605 0 \
5606 -s "! mbedtls_ssl_handshake returned" \
5607 -s "Async resume" \
5608 -s "Successful connection"
5609
5610# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005611requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005612run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005613 "$P_SRV \
5614 async_operations=s async_private_delay1=1 async_private_error=-2 \
5615 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5616 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005617 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5618 [ \$? -eq 1 ] &&
5619 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5620 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005621 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005622 -S "Async resume" \
5623 -s "Async cancel" \
5624 -s "! mbedtls_ssl_handshake returned" \
5625 -s "Async sign callback: no key matches this certificate." \
5626 -s "Successful connection"
5627
5628# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005629requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005630run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005631 "$P_SRV \
5632 async_operations=s async_private_delay1=1 async_private_error=-3 \
5633 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5634 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005635 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5636 [ \$? -eq 1 ] &&
5637 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5638 0 \
5639 -s "Async resume" \
5640 -s "! mbedtls_ssl_handshake returned" \
5641 -s "Async sign callback: no key matches this certificate." \
5642 -s "Successful connection"
5643
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005644requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005645requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005646run_test "SSL async private: renegotiation: client-initiated; sign" \
5647 "$P_SRV \
5648 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005649 exchanges=2 renegotiation=1" \
5650 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5651 0 \
5652 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005653 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005654
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005655requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005656requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005657run_test "SSL async private: renegotiation: server-initiated; sign" \
5658 "$P_SRV \
5659 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005660 exchanges=2 renegotiation=1 renegotiate=1" \
5661 "$P_CLI exchanges=2 renegotiation=1" \
5662 0 \
5663 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005664 -s "Async resume (slot [0-9]): sign done, status=0"
5665
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005666requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005667requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5668run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5669 "$P_SRV \
5670 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5671 exchanges=2 renegotiation=1" \
5672 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5673 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5674 0 \
5675 -s "Async decrypt callback: using key slot " \
5676 -s "Async resume (slot [0-9]): decrypt done, status=0"
5677
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005678requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005679requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5680run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5681 "$P_SRV \
5682 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5683 exchanges=2 renegotiation=1 renegotiate=1" \
5684 "$P_CLI exchanges=2 renegotiation=1 \
5685 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5686 0 \
5687 -s "Async decrypt callback: using key slot " \
5688 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005689
Ron Eldor58093c82018-06-28 13:22:05 +03005690# Tests for ECC extensions (rfc 4492)
5691
Ron Eldor643df7c2018-06-28 16:17:00 +03005692requires_config_enabled MBEDTLS_AES_C
5693requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5694requires_config_enabled MBEDTLS_SHA256_C
5695requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005696run_test "Force a non ECC ciphersuite in the client side" \
5697 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005698 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005699 0 \
5700 -C "client hello, adding supported_elliptic_curves extension" \
5701 -C "client hello, adding supported_point_formats extension" \
5702 -S "found supported elliptic curves extension" \
5703 -S "found supported point formats extension"
5704
Ron Eldor643df7c2018-06-28 16:17:00 +03005705requires_config_enabled MBEDTLS_AES_C
5706requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5707requires_config_enabled MBEDTLS_SHA256_C
5708requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005709run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005710 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005711 "$P_CLI debug_level=3" \
5712 0 \
5713 -C "found supported_point_formats extension" \
5714 -S "server hello, supported_point_formats extension"
5715
Ron Eldor643df7c2018-06-28 16:17:00 +03005716requires_config_enabled MBEDTLS_AES_C
5717requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5718requires_config_enabled MBEDTLS_SHA256_C
5719requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005720run_test "Force an ECC ciphersuite in the client side" \
5721 "$P_SRV debug_level=3" \
5722 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5723 0 \
5724 -c "client hello, adding supported_elliptic_curves extension" \
5725 -c "client hello, adding supported_point_formats extension" \
5726 -s "found supported elliptic curves extension" \
5727 -s "found supported point formats extension"
5728
Ron Eldor643df7c2018-06-28 16:17:00 +03005729requires_config_enabled MBEDTLS_AES_C
5730requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5731requires_config_enabled MBEDTLS_SHA256_C
5732requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005733run_test "Force an ECC ciphersuite in the server side" \
5734 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5735 "$P_CLI debug_level=3" \
5736 0 \
5737 -c "found supported_point_formats extension" \
5738 -s "server hello, supported_point_formats extension"
5739
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005740# Tests for DTLS HelloVerifyRequest
5741
5742run_test "DTLS cookie: enabled" \
5743 "$P_SRV dtls=1 debug_level=2" \
5744 "$P_CLI dtls=1 debug_level=2" \
5745 0 \
5746 -s "cookie verification failed" \
5747 -s "cookie verification passed" \
5748 -S "cookie verification skipped" \
5749 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005750 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005751 -S "SSL - The requested feature is not available"
5752
5753run_test "DTLS cookie: disabled" \
5754 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5755 "$P_CLI dtls=1 debug_level=2" \
5756 0 \
5757 -S "cookie verification failed" \
5758 -S "cookie verification passed" \
5759 -s "cookie verification skipped" \
5760 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005761 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005762 -S "SSL - The requested feature is not available"
5763
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005764run_test "DTLS cookie: default (failing)" \
5765 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5766 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5767 1 \
5768 -s "cookie verification failed" \
5769 -S "cookie verification passed" \
5770 -S "cookie verification skipped" \
5771 -C "received hello verify request" \
5772 -S "hello verification requested" \
5773 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005774
5775requires_ipv6
5776run_test "DTLS cookie: enabled, IPv6" \
5777 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5778 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5779 0 \
5780 -s "cookie verification failed" \
5781 -s "cookie verification passed" \
5782 -S "cookie verification skipped" \
5783 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005784 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005785 -S "SSL - The requested feature is not available"
5786
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005787run_test "DTLS cookie: enabled, nbio" \
5788 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5789 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5790 0 \
5791 -s "cookie verification failed" \
5792 -s "cookie verification passed" \
5793 -S "cookie verification skipped" \
5794 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005795 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005796 -S "SSL - The requested feature is not available"
5797
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005798# Tests for client reconnecting from the same port with DTLS
5799
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005800not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005801run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005802 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5803 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005804 0 \
5805 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005806 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005807 -S "Client initiated reconnection from same port"
5808
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005809not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005810run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005811 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5812 "$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 +02005813 0 \
5814 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005815 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005816 -s "Client initiated reconnection from same port"
5817
Paul Bakker362689d2016-05-13 10:33:25 +01005818not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5819run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005820 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5821 "$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 +02005822 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005823 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005824 -s "Client initiated reconnection from same port"
5825
Paul Bakker362689d2016-05-13 10:33:25 +01005826only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5827run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5828 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5829 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5830 0 \
5831 -S "The operation timed out" \
5832 -s "Client initiated reconnection from same port"
5833
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005834run_test "DTLS client reconnect from same port: no cookies" \
5835 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005836 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5837 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005838 -s "The operation timed out" \
5839 -S "Client initiated reconnection from same port"
5840
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005841run_test "DTLS client reconnect from same port: attacker-injected" \
5842 -p "$P_PXY inject_clihlo=1" \
5843 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5844 "$P_CLI dtls=1 exchanges=2" \
5845 0 \
5846 -s "possible client reconnect from the same port" \
5847 -S "Client initiated reconnection from same port"
5848
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005849# Tests for various cases of client authentication with DTLS
5850# (focused on handshake flows and message parsing)
5851
5852run_test "DTLS client auth: required" \
5853 "$P_SRV dtls=1 auth_mode=required" \
5854 "$P_CLI dtls=1" \
5855 0 \
5856 -s "Verifying peer X.509 certificate... ok"
5857
5858run_test "DTLS client auth: optional, client has no cert" \
5859 "$P_SRV dtls=1 auth_mode=optional" \
5860 "$P_CLI dtls=1 crt_file=none key_file=none" \
5861 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005862 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005863
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005864run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005865 "$P_SRV dtls=1 auth_mode=none" \
5866 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5867 0 \
5868 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005869 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005870
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005871run_test "DTLS wrong PSK: badmac alert" \
5872 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5873 "$P_CLI dtls=1 psk=abc124" \
5874 1 \
5875 -s "SSL - Verification of the message MAC failed" \
5876 -c "SSL - A fatal alert message was received from our peer"
5877
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005878# Tests for receiving fragmented handshake messages with DTLS
5879
5880requires_gnutls
5881run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5882 "$G_SRV -u --mtu 2048 -a" \
5883 "$P_CLI dtls=1 debug_level=2" \
5884 0 \
5885 -C "found fragmented DTLS handshake message" \
5886 -C "error"
5887
5888requires_gnutls
5889run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5890 "$G_SRV -u --mtu 512" \
5891 "$P_CLI dtls=1 debug_level=2" \
5892 0 \
5893 -c "found fragmented DTLS handshake message" \
5894 -C "error"
5895
5896requires_gnutls
5897run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5898 "$G_SRV -u --mtu 128" \
5899 "$P_CLI dtls=1 debug_level=2" \
5900 0 \
5901 -c "found fragmented DTLS handshake message" \
5902 -C "error"
5903
5904requires_gnutls
5905run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5906 "$G_SRV -u --mtu 128" \
5907 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5908 0 \
5909 -c "found fragmented DTLS handshake message" \
5910 -C "error"
5911
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005912requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005913requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005914run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5915 "$G_SRV -u --mtu 256" \
5916 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5917 0 \
5918 -c "found fragmented DTLS handshake message" \
5919 -c "client hello, adding renegotiation extension" \
5920 -c "found renegotiation extension" \
5921 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005922 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005923 -C "error" \
5924 -s "Extra-header:"
5925
5926requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005927requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005928run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5929 "$G_SRV -u --mtu 256" \
5930 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5931 0 \
5932 -c "found fragmented DTLS handshake message" \
5933 -c "client hello, adding renegotiation extension" \
5934 -c "found renegotiation extension" \
5935 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005936 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005937 -C "error" \
5938 -s "Extra-header:"
5939
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005940run_test "DTLS reassembly: no fragmentation (openssl server)" \
5941 "$O_SRV -dtls1 -mtu 2048" \
5942 "$P_CLI dtls=1 debug_level=2" \
5943 0 \
5944 -C "found fragmented DTLS handshake message" \
5945 -C "error"
5946
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005947run_test "DTLS reassembly: some fragmentation (openssl server)" \
5948 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005949 "$P_CLI dtls=1 debug_level=2" \
5950 0 \
5951 -c "found fragmented DTLS handshake message" \
5952 -C "error"
5953
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005954run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005955 "$O_SRV -dtls1 -mtu 256" \
5956 "$P_CLI dtls=1 debug_level=2" \
5957 0 \
5958 -c "found fragmented DTLS handshake message" \
5959 -C "error"
5960
5961run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5962 "$O_SRV -dtls1 -mtu 256" \
5963 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5964 0 \
5965 -c "found fragmented DTLS handshake message" \
5966 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005967
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005968# Tests for sending fragmented handshake messages with DTLS
5969#
5970# Use client auth when we need the client to send large messages,
5971# and use large cert chains on both sides too (the long chains we have all use
5972# both RSA and ECDSA, but ideally we should have long chains with either).
5973# Sizes reached (UDP payload):
5974# - 2037B for server certificate
5975# - 1542B for client certificate
5976# - 1013B for newsessionticket
5977# - all others below 512B
5978# All those tests assume MAX_CONTENT_LEN is at least 2048
5979
5980requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5981requires_config_enabled MBEDTLS_RSA_C
5982requires_config_enabled MBEDTLS_ECDSA_C
5983requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
5984run_test "DTLS fragmenting: none (for reference)" \
5985 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5986 crt_file=data_files/server7_int-ca.crt \
5987 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005988 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005989 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005990 "$P_CLI dtls=1 debug_level=2 \
5991 crt_file=data_files/server8_int-ca2.crt \
5992 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005993 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005994 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005995 0 \
5996 -S "found fragmented DTLS handshake message" \
5997 -C "found fragmented DTLS handshake message" \
5998 -C "error"
5999
6000requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6001requires_config_enabled MBEDTLS_RSA_C
6002requires_config_enabled MBEDTLS_ECDSA_C
6003requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006004run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006005 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6006 crt_file=data_files/server7_int-ca.crt \
6007 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006008 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006009 max_frag_len=1024" \
6010 "$P_CLI dtls=1 debug_level=2 \
6011 crt_file=data_files/server8_int-ca2.crt \
6012 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006013 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006014 max_frag_len=2048" \
6015 0 \
6016 -S "found fragmented DTLS handshake message" \
6017 -c "found fragmented DTLS handshake message" \
6018 -C "error"
6019
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006020# With the MFL extension, the server has no way of forcing
6021# the client to not exceed a certain MTU; hence, the following
6022# test can't be replicated with an MTU proxy such as the one
6023# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006024requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6025requires_config_enabled MBEDTLS_RSA_C
6026requires_config_enabled MBEDTLS_ECDSA_C
6027requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006028run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006029 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6030 crt_file=data_files/server7_int-ca.crt \
6031 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006032 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006033 max_frag_len=512" \
6034 "$P_CLI dtls=1 debug_level=2 \
6035 crt_file=data_files/server8_int-ca2.crt \
6036 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006037 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006038 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006039 0 \
6040 -S "found fragmented DTLS handshake message" \
6041 -c "found fragmented DTLS handshake message" \
6042 -C "error"
6043
6044requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6045requires_config_enabled MBEDTLS_RSA_C
6046requires_config_enabled MBEDTLS_ECDSA_C
6047requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006048run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006049 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6050 crt_file=data_files/server7_int-ca.crt \
6051 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006052 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006053 max_frag_len=2048" \
6054 "$P_CLI dtls=1 debug_level=2 \
6055 crt_file=data_files/server8_int-ca2.crt \
6056 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006057 hs_timeout=2500-60000 \
6058 max_frag_len=1024" \
6059 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006060 -S "found fragmented DTLS handshake message" \
6061 -c "found fragmented DTLS handshake message" \
6062 -C "error"
6063
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006064# While not required by the standard defining the MFL extension
6065# (according to which it only applies to records, not to datagrams),
6066# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6067# as otherwise there wouldn't be any means to communicate MTU restrictions
6068# to the peer.
6069# The next test checks that no datagrams significantly larger than the
6070# negotiated MFL are sent.
6071requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6072requires_config_enabled MBEDTLS_RSA_C
6073requires_config_enabled MBEDTLS_ECDSA_C
6074requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6075run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006076 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006077 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6078 crt_file=data_files/server7_int-ca.crt \
6079 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006080 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006081 max_frag_len=2048" \
6082 "$P_CLI dtls=1 debug_level=2 \
6083 crt_file=data_files/server8_int-ca2.crt \
6084 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006085 hs_timeout=2500-60000 \
6086 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006087 0 \
6088 -S "found fragmented DTLS handshake message" \
6089 -c "found fragmented DTLS handshake message" \
6090 -C "error"
6091
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006092requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6093requires_config_enabled MBEDTLS_RSA_C
6094requires_config_enabled MBEDTLS_ECDSA_C
6095requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006096run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006097 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6098 crt_file=data_files/server7_int-ca.crt \
6099 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006100 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006101 max_frag_len=2048" \
6102 "$P_CLI dtls=1 debug_level=2 \
6103 crt_file=data_files/server8_int-ca2.crt \
6104 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006105 hs_timeout=2500-60000 \
6106 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006107 0 \
6108 -s "found fragmented DTLS handshake message" \
6109 -c "found fragmented DTLS handshake message" \
6110 -C "error"
6111
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006112# While not required by the standard defining the MFL extension
6113# (according to which it only applies to records, not to datagrams),
6114# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6115# as otherwise there wouldn't be any means to communicate MTU restrictions
6116# to the peer.
6117# The next test checks that no datagrams significantly larger than the
6118# negotiated MFL are sent.
6119requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6120requires_config_enabled MBEDTLS_RSA_C
6121requires_config_enabled MBEDTLS_ECDSA_C
6122requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6123run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006124 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006125 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6126 crt_file=data_files/server7_int-ca.crt \
6127 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006128 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006129 max_frag_len=2048" \
6130 "$P_CLI dtls=1 debug_level=2 \
6131 crt_file=data_files/server8_int-ca2.crt \
6132 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006133 hs_timeout=2500-60000 \
6134 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006135 0 \
6136 -s "found fragmented DTLS handshake message" \
6137 -c "found fragmented DTLS handshake message" \
6138 -C "error"
6139
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006140requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6141requires_config_enabled MBEDTLS_RSA_C
6142requires_config_enabled MBEDTLS_ECDSA_C
6143run_test "DTLS fragmenting: none (for reference) (MTU)" \
6144 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6145 crt_file=data_files/server7_int-ca.crt \
6146 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006147 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006148 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006149 "$P_CLI dtls=1 debug_level=2 \
6150 crt_file=data_files/server8_int-ca2.crt \
6151 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006152 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006153 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006154 0 \
6155 -S "found fragmented DTLS handshake message" \
6156 -C "found fragmented DTLS handshake message" \
6157 -C "error"
6158
6159requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6160requires_config_enabled MBEDTLS_RSA_C
6161requires_config_enabled MBEDTLS_ECDSA_C
6162run_test "DTLS fragmenting: client (MTU)" \
6163 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6164 crt_file=data_files/server7_int-ca.crt \
6165 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006166 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006167 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006168 "$P_CLI dtls=1 debug_level=2 \
6169 crt_file=data_files/server8_int-ca2.crt \
6170 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006171 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006172 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006173 0 \
6174 -s "found fragmented DTLS handshake message" \
6175 -C "found fragmented DTLS handshake message" \
6176 -C "error"
6177
6178requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6179requires_config_enabled MBEDTLS_RSA_C
6180requires_config_enabled MBEDTLS_ECDSA_C
6181run_test "DTLS fragmenting: server (MTU)" \
6182 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6183 crt_file=data_files/server7_int-ca.crt \
6184 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006185 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006186 mtu=512" \
6187 "$P_CLI dtls=1 debug_level=2 \
6188 crt_file=data_files/server8_int-ca2.crt \
6189 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006190 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006191 mtu=2048" \
6192 0 \
6193 -S "found fragmented DTLS handshake message" \
6194 -c "found fragmented DTLS handshake message" \
6195 -C "error"
6196
6197requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6198requires_config_enabled MBEDTLS_RSA_C
6199requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006200run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006201 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006202 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6203 crt_file=data_files/server7_int-ca.crt \
6204 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006205 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006206 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006207 "$P_CLI dtls=1 debug_level=2 \
6208 crt_file=data_files/server8_int-ca2.crt \
6209 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006210 hs_timeout=2500-60000 \
6211 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006212 0 \
6213 -s "found fragmented DTLS handshake message" \
6214 -c "found fragmented DTLS handshake message" \
6215 -C "error"
6216
Andrzej Kurek77826052018-10-11 07:34:08 -04006217# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006218requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6219requires_config_enabled MBEDTLS_RSA_C
6220requires_config_enabled MBEDTLS_ECDSA_C
6221requires_config_enabled MBEDTLS_SHA256_C
6222requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6223requires_config_enabled MBEDTLS_AES_C
6224requires_config_enabled MBEDTLS_GCM_C
6225run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006226 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006227 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6228 crt_file=data_files/server7_int-ca.crt \
6229 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006230 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006231 mtu=512" \
6232 "$P_CLI dtls=1 debug_level=2 \
6233 crt_file=data_files/server8_int-ca2.crt \
6234 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006235 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6236 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006237 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006238 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006239 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006240 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006241 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006242
Andrzej Kurek7311c782018-10-11 06:49:41 -04006243# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006244# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006245# The ratio of max/min timeout should ideally equal 4 to accept two
6246# retransmissions, but in some cases (like both the server and client using
6247# fragmentation and auto-reduction) an extra retransmission might occur,
6248# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006249not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006250requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6251requires_config_enabled MBEDTLS_RSA_C
6252requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006253requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6254requires_config_enabled MBEDTLS_AES_C
6255requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006256run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6257 -p "$P_PXY mtu=508" \
6258 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6259 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006260 key_file=data_files/server7.key \
6261 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006262 "$P_CLI dtls=1 debug_level=2 \
6263 crt_file=data_files/server8_int-ca2.crt \
6264 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006265 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6266 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006267 0 \
6268 -s "found fragmented DTLS handshake message" \
6269 -c "found fragmented DTLS handshake message" \
6270 -C "error"
6271
Andrzej Kurek77826052018-10-11 07:34:08 -04006272# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006273only_with_valgrind
6274requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6275requires_config_enabled MBEDTLS_RSA_C
6276requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006277requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6278requires_config_enabled MBEDTLS_AES_C
6279requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006280run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6281 -p "$P_PXY mtu=508" \
6282 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6283 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006284 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006285 hs_timeout=250-10000" \
6286 "$P_CLI dtls=1 debug_level=2 \
6287 crt_file=data_files/server8_int-ca2.crt \
6288 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006289 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006290 hs_timeout=250-10000" \
6291 0 \
6292 -s "found fragmented DTLS handshake message" \
6293 -c "found fragmented DTLS handshake message" \
6294 -C "error"
6295
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006296# 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 +02006297# OTOH the client might resend if the server is to slow to reset after sending
6298# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006299not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006300requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6301requires_config_enabled MBEDTLS_RSA_C
6302requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006303run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006304 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006305 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6306 crt_file=data_files/server7_int-ca.crt \
6307 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006308 hs_timeout=10000-60000 \
6309 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006310 "$P_CLI dtls=1 debug_level=2 \
6311 crt_file=data_files/server8_int-ca2.crt \
6312 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006313 hs_timeout=10000-60000 \
6314 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006315 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006316 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006317 -s "found fragmented DTLS handshake message" \
6318 -c "found fragmented DTLS handshake message" \
6319 -C "error"
6320
Andrzej Kurek77826052018-10-11 07:34:08 -04006321# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006322# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6323# OTOH the client might resend if the server is to slow to reset after sending
6324# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006325not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006326requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6327requires_config_enabled MBEDTLS_RSA_C
6328requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006329requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6330requires_config_enabled MBEDTLS_AES_C
6331requires_config_enabled MBEDTLS_GCM_C
6332run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006333 -p "$P_PXY mtu=512" \
6334 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6335 crt_file=data_files/server7_int-ca.crt \
6336 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006337 hs_timeout=10000-60000 \
6338 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006339 "$P_CLI dtls=1 debug_level=2 \
6340 crt_file=data_files/server8_int-ca2.crt \
6341 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006342 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6343 hs_timeout=10000-60000 \
6344 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006345 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006346 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006347 -s "found fragmented DTLS handshake message" \
6348 -c "found fragmented DTLS handshake message" \
6349 -C "error"
6350
Andrzej Kurek7311c782018-10-11 06:49:41 -04006351not_with_valgrind # spurious autoreduction due to timeout
6352requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6353requires_config_enabled MBEDTLS_RSA_C
6354requires_config_enabled MBEDTLS_ECDSA_C
6355run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006356 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006357 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6358 crt_file=data_files/server7_int-ca.crt \
6359 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006360 hs_timeout=10000-60000 \
6361 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006362 "$P_CLI dtls=1 debug_level=2 \
6363 crt_file=data_files/server8_int-ca2.crt \
6364 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006365 hs_timeout=10000-60000 \
6366 mtu=1024 nbio=2" \
6367 0 \
6368 -S "autoreduction" \
6369 -s "found fragmented DTLS handshake message" \
6370 -c "found fragmented DTLS handshake message" \
6371 -C "error"
6372
Andrzej Kurek77826052018-10-11 07:34:08 -04006373# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006374not_with_valgrind # spurious autoreduction due to timeout
6375requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6376requires_config_enabled MBEDTLS_RSA_C
6377requires_config_enabled MBEDTLS_ECDSA_C
6378requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6379requires_config_enabled MBEDTLS_AES_C
6380requires_config_enabled MBEDTLS_GCM_C
6381run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6382 -p "$P_PXY mtu=512" \
6383 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6384 crt_file=data_files/server7_int-ca.crt \
6385 key_file=data_files/server7.key \
6386 hs_timeout=10000-60000 \
6387 mtu=512 nbio=2" \
6388 "$P_CLI dtls=1 debug_level=2 \
6389 crt_file=data_files/server8_int-ca2.crt \
6390 key_file=data_files/server8.key \
6391 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6392 hs_timeout=10000-60000 \
6393 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006394 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006395 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006396 -s "found fragmented DTLS handshake message" \
6397 -c "found fragmented DTLS handshake message" \
6398 -C "error"
6399
Andrzej Kurek77826052018-10-11 07:34:08 -04006400# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006401# This ensures things still work after session_reset().
6402# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006403# Since we don't support reading fragmented ClientHello yet,
6404# up the MTU to 1450 (larger than ClientHello with session ticket,
6405# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006406# An autoreduction on the client-side might happen if the server is
6407# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006408# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006409# resumed listening, which would result in a spurious autoreduction.
6410not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006411requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6412requires_config_enabled MBEDTLS_RSA_C
6413requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006414requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6415requires_config_enabled MBEDTLS_AES_C
6416requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006417run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6418 -p "$P_PXY mtu=1450" \
6419 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6420 crt_file=data_files/server7_int-ca.crt \
6421 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006422 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006423 mtu=1450" \
6424 "$P_CLI dtls=1 debug_level=2 \
6425 crt_file=data_files/server8_int-ca2.crt \
6426 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006427 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006428 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006429 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006430 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006431 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006432 -s "found fragmented DTLS handshake message" \
6433 -c "found fragmented DTLS handshake message" \
6434 -C "error"
6435
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006436# An autoreduction on the client-side might happen if the server is
6437# slow to reset, therefore omitting '-C "autoreduction"' below.
6438not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006439requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6440requires_config_enabled MBEDTLS_RSA_C
6441requires_config_enabled MBEDTLS_ECDSA_C
6442requires_config_enabled MBEDTLS_SHA256_C
6443requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6444requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6445requires_config_enabled MBEDTLS_CHACHAPOLY_C
6446run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6447 -p "$P_PXY mtu=512" \
6448 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6449 crt_file=data_files/server7_int-ca.crt \
6450 key_file=data_files/server7.key \
6451 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006452 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006453 mtu=512" \
6454 "$P_CLI dtls=1 debug_level=2 \
6455 crt_file=data_files/server8_int-ca2.crt \
6456 key_file=data_files/server8.key \
6457 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006458 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006459 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006460 mtu=512" \
6461 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006462 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006463 -s "found fragmented DTLS handshake message" \
6464 -c "found fragmented DTLS handshake message" \
6465 -C "error"
6466
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006467# An autoreduction on the client-side might happen if the server is
6468# slow to reset, therefore omitting '-C "autoreduction"' below.
6469not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006470requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6471requires_config_enabled MBEDTLS_RSA_C
6472requires_config_enabled MBEDTLS_ECDSA_C
6473requires_config_enabled MBEDTLS_SHA256_C
6474requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6475requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6476requires_config_enabled MBEDTLS_AES_C
6477requires_config_enabled MBEDTLS_GCM_C
6478run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6479 -p "$P_PXY mtu=512" \
6480 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6481 crt_file=data_files/server7_int-ca.crt \
6482 key_file=data_files/server7.key \
6483 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006484 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006485 mtu=512" \
6486 "$P_CLI dtls=1 debug_level=2 \
6487 crt_file=data_files/server8_int-ca2.crt \
6488 key_file=data_files/server8.key \
6489 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006490 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006491 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006492 mtu=512" \
6493 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006494 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006495 -s "found fragmented DTLS handshake message" \
6496 -c "found fragmented DTLS handshake message" \
6497 -C "error"
6498
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006499# An autoreduction on the client-side might happen if the server is
6500# slow to reset, therefore omitting '-C "autoreduction"' below.
6501not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006502requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6503requires_config_enabled MBEDTLS_RSA_C
6504requires_config_enabled MBEDTLS_ECDSA_C
6505requires_config_enabled MBEDTLS_SHA256_C
6506requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6507requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6508requires_config_enabled MBEDTLS_AES_C
6509requires_config_enabled MBEDTLS_CCM_C
6510run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006511 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006512 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6513 crt_file=data_files/server7_int-ca.crt \
6514 key_file=data_files/server7.key \
6515 exchanges=2 renegotiation=1 \
6516 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006517 hs_timeout=10000-60000 \
6518 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006519 "$P_CLI dtls=1 debug_level=2 \
6520 crt_file=data_files/server8_int-ca2.crt \
6521 key_file=data_files/server8.key \
6522 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006523 hs_timeout=10000-60000 \
6524 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006525 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006526 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006527 -s "found fragmented DTLS handshake message" \
6528 -c "found fragmented DTLS handshake message" \
6529 -C "error"
6530
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006531# An autoreduction on the client-side might happen if the server is
6532# slow to reset, therefore omitting '-C "autoreduction"' below.
6533not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006534requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6535requires_config_enabled MBEDTLS_RSA_C
6536requires_config_enabled MBEDTLS_ECDSA_C
6537requires_config_enabled MBEDTLS_SHA256_C
6538requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6539requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6540requires_config_enabled MBEDTLS_AES_C
6541requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6542requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6543run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006544 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006545 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6546 crt_file=data_files/server7_int-ca.crt \
6547 key_file=data_files/server7.key \
6548 exchanges=2 renegotiation=1 \
6549 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006550 hs_timeout=10000-60000 \
6551 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006552 "$P_CLI dtls=1 debug_level=2 \
6553 crt_file=data_files/server8_int-ca2.crt \
6554 key_file=data_files/server8.key \
6555 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006556 hs_timeout=10000-60000 \
6557 mtu=1024" \
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 Kurek35f2f302018-10-09 08:52:14 -04006564# An autoreduction on the client-side might happen if the server is
6565# slow to reset, therefore omitting '-C "autoreduction"' below.
6566not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006567requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6568requires_config_enabled MBEDTLS_RSA_C
6569requires_config_enabled MBEDTLS_ECDSA_C
6570requires_config_enabled MBEDTLS_SHA256_C
6571requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6572requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6573requires_config_enabled MBEDTLS_AES_C
6574requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6575run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006576 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006577 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6578 crt_file=data_files/server7_int-ca.crt \
6579 key_file=data_files/server7.key \
6580 exchanges=2 renegotiation=1 \
6581 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006582 hs_timeout=10000-60000 \
6583 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006584 "$P_CLI dtls=1 debug_level=2 \
6585 crt_file=data_files/server8_int-ca2.crt \
6586 key_file=data_files/server8.key \
6587 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006588 hs_timeout=10000-60000 \
6589 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006590 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006591 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006592 -s "found fragmented DTLS handshake message" \
6593 -c "found fragmented DTLS handshake message" \
6594 -C "error"
6595
Andrzej Kurek77826052018-10-11 07:34:08 -04006596# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006597requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6598requires_config_enabled MBEDTLS_RSA_C
6599requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006600requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6601requires_config_enabled MBEDTLS_AES_C
6602requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006603client_needs_more_time 2
6604run_test "DTLS fragmenting: proxy MTU + 3d" \
6605 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006606 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006607 crt_file=data_files/server7_int-ca.crt \
6608 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006609 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006610 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006611 crt_file=data_files/server8_int-ca2.crt \
6612 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006613 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006614 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006615 0 \
6616 -s "found fragmented DTLS handshake message" \
6617 -c "found fragmented DTLS handshake message" \
6618 -C "error"
6619
Andrzej Kurek77826052018-10-11 07:34:08 -04006620# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006621requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6622requires_config_enabled MBEDTLS_RSA_C
6623requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006624requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6625requires_config_enabled MBEDTLS_AES_C
6626requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006627client_needs_more_time 2
6628run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6629 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6630 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6631 crt_file=data_files/server7_int-ca.crt \
6632 key_file=data_files/server7.key \
6633 hs_timeout=250-10000 mtu=512 nbio=2" \
6634 "$P_CLI dtls=1 debug_level=2 \
6635 crt_file=data_files/server8_int-ca2.crt \
6636 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006637 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006638 hs_timeout=250-10000 mtu=512 nbio=2" \
6639 0 \
6640 -s "found fragmented DTLS handshake message" \
6641 -c "found fragmented DTLS handshake message" \
6642 -C "error"
6643
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006644# interop tests for DTLS fragmentating with reliable connection
6645#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006646# here and below we just want to test that the we fragment in a way that
6647# pleases other implementations, so we don't need the peer to fragment
6648requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6649requires_config_enabled MBEDTLS_RSA_C
6650requires_config_enabled MBEDTLS_ECDSA_C
6651requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006652requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006653run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6654 "$G_SRV -u" \
6655 "$P_CLI dtls=1 debug_level=2 \
6656 crt_file=data_files/server8_int-ca2.crt \
6657 key_file=data_files/server8.key \
6658 mtu=512 force_version=dtls1_2" \
6659 0 \
6660 -c "fragmenting handshake message" \
6661 -C "error"
6662
6663requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6664requires_config_enabled MBEDTLS_RSA_C
6665requires_config_enabled MBEDTLS_ECDSA_C
6666requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006667requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006668run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6669 "$G_SRV -u" \
6670 "$P_CLI dtls=1 debug_level=2 \
6671 crt_file=data_files/server8_int-ca2.crt \
6672 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006673 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006674 0 \
6675 -c "fragmenting handshake message" \
6676 -C "error"
6677
Hanno Beckerb9a00862018-08-28 10:20:22 +01006678# We use --insecure for the GnuTLS client because it expects
6679# the hostname / IP it connects to to be the name used in the
6680# certificate obtained from the server. Here, however, it
6681# connects to 127.0.0.1 while our test certificates use 'localhost'
6682# as the server name in the certificate. This will make the
6683# certifiate validation fail, but passing --insecure makes
6684# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006685requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6686requires_config_enabled MBEDTLS_RSA_C
6687requires_config_enabled MBEDTLS_ECDSA_C
6688requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006689requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006690requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006691run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006692 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006693 crt_file=data_files/server7_int-ca.crt \
6694 key_file=data_files/server7.key \
6695 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006696 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006697 0 \
6698 -s "fragmenting handshake message"
6699
Hanno Beckerb9a00862018-08-28 10:20:22 +01006700# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006701requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6702requires_config_enabled MBEDTLS_RSA_C
6703requires_config_enabled MBEDTLS_ECDSA_C
6704requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006705requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006706requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006707run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006708 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006709 crt_file=data_files/server7_int-ca.crt \
6710 key_file=data_files/server7.key \
6711 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006712 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006713 0 \
6714 -s "fragmenting handshake message"
6715
6716requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6717requires_config_enabled MBEDTLS_RSA_C
6718requires_config_enabled MBEDTLS_ECDSA_C
6719requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6720run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6721 "$O_SRV -dtls1_2 -verify 10" \
6722 "$P_CLI dtls=1 debug_level=2 \
6723 crt_file=data_files/server8_int-ca2.crt \
6724 key_file=data_files/server8.key \
6725 mtu=512 force_version=dtls1_2" \
6726 0 \
6727 -c "fragmenting handshake message" \
6728 -C "error"
6729
6730requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6731requires_config_enabled MBEDTLS_RSA_C
6732requires_config_enabled MBEDTLS_ECDSA_C
6733requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6734run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6735 "$O_SRV -dtls1 -verify 10" \
6736 "$P_CLI dtls=1 debug_level=2 \
6737 crt_file=data_files/server8_int-ca2.crt \
6738 key_file=data_files/server8.key \
6739 mtu=512 force_version=dtls1" \
6740 0 \
6741 -c "fragmenting handshake message" \
6742 -C "error"
6743
6744requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6745requires_config_enabled MBEDTLS_RSA_C
6746requires_config_enabled MBEDTLS_ECDSA_C
6747requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6748run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6749 "$P_SRV dtls=1 debug_level=2 \
6750 crt_file=data_files/server7_int-ca.crt \
6751 key_file=data_files/server7.key \
6752 mtu=512 force_version=dtls1_2" \
6753 "$O_CLI -dtls1_2" \
6754 0 \
6755 -s "fragmenting handshake message"
6756
6757requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6758requires_config_enabled MBEDTLS_RSA_C
6759requires_config_enabled MBEDTLS_ECDSA_C
6760requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6761run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6762 "$P_SRV dtls=1 debug_level=2 \
6763 crt_file=data_files/server7_int-ca.crt \
6764 key_file=data_files/server7.key \
6765 mtu=512 force_version=dtls1" \
6766 "$O_CLI -dtls1" \
6767 0 \
6768 -s "fragmenting handshake message"
6769
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006770# interop tests for DTLS fragmentating with unreliable connection
6771#
6772# again we just want to test that the we fragment in a way that
6773# pleases other implementations, so we don't need the peer to fragment
6774requires_gnutls_next
6775requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6776requires_config_enabled MBEDTLS_RSA_C
6777requires_config_enabled MBEDTLS_ECDSA_C
6778requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006779client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006780run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6781 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6782 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006783 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006784 crt_file=data_files/server8_int-ca2.crt \
6785 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006786 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006787 0 \
6788 -c "fragmenting handshake message" \
6789 -C "error"
6790
6791requires_gnutls_next
6792requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6793requires_config_enabled MBEDTLS_RSA_C
6794requires_config_enabled MBEDTLS_ECDSA_C
6795requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006796client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006797run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6798 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6799 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006800 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006801 crt_file=data_files/server8_int-ca2.crt \
6802 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006803 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006804 0 \
6805 -c "fragmenting handshake message" \
6806 -C "error"
6807
k-stachowiakabb843e2019-02-18 16:14:03 +01006808requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006809requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6810requires_config_enabled MBEDTLS_RSA_C
6811requires_config_enabled MBEDTLS_ECDSA_C
6812requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6813client_needs_more_time 4
6814run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6815 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6816 "$P_SRV dtls=1 debug_level=2 \
6817 crt_file=data_files/server7_int-ca.crt \
6818 key_file=data_files/server7.key \
6819 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006820 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006821 0 \
6822 -s "fragmenting handshake message"
6823
k-stachowiakabb843e2019-02-18 16:14:03 +01006824requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006825requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6826requires_config_enabled MBEDTLS_RSA_C
6827requires_config_enabled MBEDTLS_ECDSA_C
6828requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6829client_needs_more_time 4
6830run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6831 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6832 "$P_SRV dtls=1 debug_level=2 \
6833 crt_file=data_files/server7_int-ca.crt \
6834 key_file=data_files/server7.key \
6835 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006836 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006837 0 \
6838 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006839
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006840## Interop test with OpenSSL might trigger a bug in recent versions (including
6841## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006842## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006843## They should be re-enabled once a fixed version of OpenSSL is available
6844## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006845skip_next_test
6846requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6847requires_config_enabled MBEDTLS_RSA_C
6848requires_config_enabled MBEDTLS_ECDSA_C
6849requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6850client_needs_more_time 4
6851run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6852 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6853 "$O_SRV -dtls1_2 -verify 10" \
6854 "$P_CLI dtls=1 debug_level=2 \
6855 crt_file=data_files/server8_int-ca2.crt \
6856 key_file=data_files/server8.key \
6857 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6858 0 \
6859 -c "fragmenting handshake message" \
6860 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006861
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006862skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006863requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6864requires_config_enabled MBEDTLS_RSA_C
6865requires_config_enabled MBEDTLS_ECDSA_C
6866requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006867client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006868run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6869 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006870 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006871 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006872 crt_file=data_files/server8_int-ca2.crt \
6873 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006874 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006875 0 \
6876 -c "fragmenting handshake message" \
6877 -C "error"
6878
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006879skip_next_test
6880requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6881requires_config_enabled MBEDTLS_RSA_C
6882requires_config_enabled MBEDTLS_ECDSA_C
6883requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6884client_needs_more_time 4
6885run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6886 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6887 "$P_SRV dtls=1 debug_level=2 \
6888 crt_file=data_files/server7_int-ca.crt \
6889 key_file=data_files/server7.key \
6890 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6891 "$O_CLI -dtls1_2" \
6892 0 \
6893 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006894
6895# -nbio is added to prevent s_client from blocking in case of duplicated
6896# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006897skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006898requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6899requires_config_enabled MBEDTLS_RSA_C
6900requires_config_enabled MBEDTLS_ECDSA_C
6901requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006902client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006903run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6904 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006905 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006906 crt_file=data_files/server7_int-ca.crt \
6907 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006908 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006909 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006910 0 \
6911 -s "fragmenting handshake message"
6912
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006913# Tests for specific things with "unreliable" UDP connection
6914
6915not_with_valgrind # spurious resend due to timeout
6916run_test "DTLS proxy: reference" \
6917 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006918 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6919 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006920 0 \
6921 -C "replayed record" \
6922 -S "replayed record" \
6923 -C "record from another epoch" \
6924 -S "record from another epoch" \
6925 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006926 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006927 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006928 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006929 -c "HTTP/1.0 200 OK"
6930
6931not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006932run_test "DTLS proxy: duplicate every packet" \
6933 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006934 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6935 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006936 0 \
6937 -c "replayed record" \
6938 -s "replayed record" \
6939 -c "record from another epoch" \
6940 -s "record from another epoch" \
6941 -S "resend" \
6942 -s "Extra-header:" \
6943 -c "HTTP/1.0 200 OK"
6944
6945run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6946 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006947 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6948 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006949 0 \
6950 -c "replayed record" \
6951 -S "replayed record" \
6952 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006953 -s "record from another epoch" \
6954 -c "resend" \
6955 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006956 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006957 -c "HTTP/1.0 200 OK"
6958
6959run_test "DTLS proxy: multiple records in same datagram" \
6960 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006961 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6962 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006963 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006964 -c "next record in same datagram" \
6965 -s "next record in same datagram"
6966
6967run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6968 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006969 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6970 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006971 0 \
6972 -c "next record in same datagram" \
6973 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006974
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006975run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6976 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006977 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6978 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006979 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006980 -c "discarding invalid record (mac)" \
6981 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006982 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006983 -c "HTTP/1.0 200 OK" \
6984 -S "too many records with bad MAC" \
6985 -S "Verification of the message MAC failed"
6986
6987run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
6988 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006989 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
6990 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006991 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006992 -C "discarding invalid record (mac)" \
6993 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006994 -S "Extra-header:" \
6995 -C "HTTP/1.0 200 OK" \
6996 -s "too many records with bad MAC" \
6997 -s "Verification of the message MAC failed"
6998
6999run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7000 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007001 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7002 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007003 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007004 -c "discarding invalid record (mac)" \
7005 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007006 -s "Extra-header:" \
7007 -c "HTTP/1.0 200 OK" \
7008 -S "too many records with bad MAC" \
7009 -S "Verification of the message MAC failed"
7010
7011run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7012 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007013 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7014 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007015 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007016 -c "discarding invalid record (mac)" \
7017 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007018 -s "Extra-header:" \
7019 -c "HTTP/1.0 200 OK" \
7020 -s "too many records with bad MAC" \
7021 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007022
7023run_test "DTLS proxy: delay ChangeCipherSpec" \
7024 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007025 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7026 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007027 0 \
7028 -c "record from another epoch" \
7029 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007030 -s "Extra-header:" \
7031 -c "HTTP/1.0 200 OK"
7032
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007033# Tests for reordering support with DTLS
7034
Hanno Becker56cdfd12018-08-17 13:42:15 +01007035run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7036 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007037 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7038 hs_timeout=2500-60000" \
7039 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7040 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007041 0 \
7042 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007043 -c "Next handshake message has been buffered - load"\
7044 -S "Buffering HS message" \
7045 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007046 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007047 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007048 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007049 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007050
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007051run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7052 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007053 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7054 hs_timeout=2500-60000" \
7055 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7056 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007057 0 \
7058 -c "Buffering HS message" \
7059 -c "found fragmented DTLS handshake message"\
7060 -c "Next handshake message 1 not or only partially bufffered" \
7061 -c "Next handshake message has been buffered - load"\
7062 -S "Buffering HS message" \
7063 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007064 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007065 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007066 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007067 -S "Remember CCS message"
7068
Hanno Beckera1adcca2018-08-24 14:41:07 +01007069# The client buffers the ServerKeyExchange before receiving the fragmented
7070# Certificate message; at the time of writing, together these are aroudn 1200b
7071# in size, so that the bound below ensures that the certificate can be reassembled
7072# while keeping the ServerKeyExchange.
7073requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7074run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007075 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007076 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7077 hs_timeout=2500-60000" \
7078 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7079 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007080 0 \
7081 -c "Buffering HS message" \
7082 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007083 -C "attempt to make space by freeing buffered messages" \
7084 -S "Buffering HS message" \
7085 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007086 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007087 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007088 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007089 -S "Remember CCS message"
7090
7091# The size constraints ensure that the delayed certificate message can't
7092# be reassembled while keeping the ServerKeyExchange message, but it can
7093# when dropping it first.
7094requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7095requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7096run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7097 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007098 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7099 hs_timeout=2500-60000" \
7100 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7101 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007102 0 \
7103 -c "Buffering HS message" \
7104 -c "attempt to make space by freeing buffered future messages" \
7105 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007106 -S "Buffering HS message" \
7107 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007108 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007109 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007110 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007111 -S "Remember CCS message"
7112
Hanno Becker56cdfd12018-08-17 13:42:15 +01007113run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7114 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007115 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7116 hs_timeout=2500-60000" \
7117 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7118 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007119 0 \
7120 -C "Buffering HS message" \
7121 -C "Next handshake message has been buffered - load"\
7122 -s "Buffering HS message" \
7123 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007124 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007125 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007126 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007127 -S "Remember CCS message"
7128
7129run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7130 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007131 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7132 hs_timeout=2500-60000" \
7133 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7134 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007135 0 \
7136 -C "Buffering HS message" \
7137 -C "Next handshake message has been buffered - load"\
7138 -S "Buffering HS message" \
7139 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007140 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007141 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007142 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007143 -S "Remember CCS message"
7144
7145run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7146 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007147 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7148 hs_timeout=2500-60000" \
7149 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7150 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007151 0 \
7152 -C "Buffering HS message" \
7153 -C "Next handshake message has been buffered - load"\
7154 -S "Buffering HS message" \
7155 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007156 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007157 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007158 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007159 -s "Remember CCS message"
7160
Hanno Beckera1adcca2018-08-24 14:41:07 +01007161run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007162 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007163 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7164 hs_timeout=2500-60000" \
7165 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7166 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007167 0 \
7168 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007169 -s "Found buffered record from current epoch - load" \
7170 -c "Buffer record from epoch 1" \
7171 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007172
Hanno Beckera1adcca2018-08-24 14:41:07 +01007173# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7174# from the server are delayed, so that the encrypted Finished message
7175# is received and buffered. When the fragmented NewSessionTicket comes
7176# in afterwards, the encrypted Finished message must be freed in order
7177# to make space for the NewSessionTicket to be reassembled.
7178# This works only in very particular circumstances:
7179# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7180# of the NewSessionTicket, but small enough to also allow buffering of
7181# the encrypted Finished message.
7182# - The MTU setting on the server must be so small that the NewSessionTicket
7183# needs to be fragmented.
7184# - All messages sent by the server must be small enough to be either sent
7185# without fragmentation or be reassembled within the bounds of
7186# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7187# handshake, omitting CRTs.
7188requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7189requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7190run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7191 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7192 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7193 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7194 0 \
7195 -s "Buffer record from epoch 1" \
7196 -s "Found buffered record from current epoch - load" \
7197 -c "Buffer record from epoch 1" \
7198 -C "Found buffered record from current epoch - load" \
7199 -c "Enough space available after freeing future epoch record"
7200
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007201# Tests for "randomly unreliable connection": try a variety of flows and peers
7202
7203client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007204run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7205 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007206 "$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 +02007207 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007208 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007209 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7210 0 \
7211 -s "Extra-header:" \
7212 -c "HTTP/1.0 200 OK"
7213
Janos Follath74537a62016-09-02 13:45:28 +01007214client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007215run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7216 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007217 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7218 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007219 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7220 0 \
7221 -s "Extra-header:" \
7222 -c "HTTP/1.0 200 OK"
7223
Janos Follath74537a62016-09-02 13:45:28 +01007224client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007225run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7226 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007227 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7228 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007229 0 \
7230 -s "Extra-header:" \
7231 -c "HTTP/1.0 200 OK"
7232
Janos Follath74537a62016-09-02 13:45:28 +01007233client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007234run_test "DTLS proxy: 3d, FS, client auth" \
7235 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007236 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7237 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007238 0 \
7239 -s "Extra-header:" \
7240 -c "HTTP/1.0 200 OK"
7241
Janos Follath74537a62016-09-02 13:45:28 +01007242client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007243run_test "DTLS proxy: 3d, FS, ticket" \
7244 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007245 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7246 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007247 0 \
7248 -s "Extra-header:" \
7249 -c "HTTP/1.0 200 OK"
7250
Janos Follath74537a62016-09-02 13:45:28 +01007251client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007252run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7253 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007254 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7255 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007256 0 \
7257 -s "Extra-header:" \
7258 -c "HTTP/1.0 200 OK"
7259
Janos Follath74537a62016-09-02 13:45:28 +01007260client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007261run_test "DTLS proxy: 3d, max handshake, nbio" \
7262 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007263 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007264 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007265 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007266 0 \
7267 -s "Extra-header:" \
7268 -c "HTTP/1.0 200 OK"
7269
Janos Follath74537a62016-09-02 13:45:28 +01007270client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007271run_test "DTLS proxy: 3d, min handshake, resumption" \
7272 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007273 "$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 +02007274 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007275 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007276 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007277 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7278 0 \
7279 -s "a session has been resumed" \
7280 -c "a session has been resumed" \
7281 -s "Extra-header:" \
7282 -c "HTTP/1.0 200 OK"
7283
Janos Follath74537a62016-09-02 13:45:28 +01007284client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007285run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7286 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007287 "$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 +02007288 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007289 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007290 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007291 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7292 0 \
7293 -s "a session has been resumed" \
7294 -c "a session has been resumed" \
7295 -s "Extra-header:" \
7296 -c "HTTP/1.0 200 OK"
7297
Janos Follath74537a62016-09-02 13:45:28 +01007298client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007299requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007300run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007301 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007302 "$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 +02007303 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007304 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007305 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007306 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7307 0 \
7308 -c "=> renegotiate" \
7309 -s "=> renegotiate" \
7310 -s "Extra-header:" \
7311 -c "HTTP/1.0 200 OK"
7312
Janos Follath74537a62016-09-02 13:45:28 +01007313client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007314requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007315run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7316 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007317 "$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 +02007318 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007319 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007320 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007321 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7322 0 \
7323 -c "=> renegotiate" \
7324 -s "=> renegotiate" \
7325 -s "Extra-header:" \
7326 -c "HTTP/1.0 200 OK"
7327
Janos Follath74537a62016-09-02 13:45:28 +01007328client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007329requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007330run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007331 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007332 "$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 +02007333 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007334 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007335 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007336 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007337 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7338 0 \
7339 -c "=> renegotiate" \
7340 -s "=> renegotiate" \
7341 -s "Extra-header:" \
7342 -c "HTTP/1.0 200 OK"
7343
Janos Follath74537a62016-09-02 13:45:28 +01007344client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007345requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007346run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007347 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007348 "$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 +02007349 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007350 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007351 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007352 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007353 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7354 0 \
7355 -c "=> renegotiate" \
7356 -s "=> renegotiate" \
7357 -s "Extra-header:" \
7358 -c "HTTP/1.0 200 OK"
7359
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007360## Interop tests with OpenSSL might trigger a bug in recent versions (including
7361## all versions installed on the CI machines), reported here:
7362## Bug report: https://github.com/openssl/openssl/issues/6902
7363## They should be re-enabled once a fixed version of OpenSSL is available
7364## (this should happen in some 1.1.1_ release according to the ticket).
7365skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007366client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007367not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007368run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007369 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7370 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007371 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007372 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007373 -c "HTTP/1.0 200 OK"
7374
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007375skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007376client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007377not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007378run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7379 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7380 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007381 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007382 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007383 -c "HTTP/1.0 200 OK"
7384
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007385skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007386client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007387not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007388run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7389 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7390 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007391 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007392 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007393 -c "HTTP/1.0 200 OK"
7394
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007395requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007396client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007397not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007398run_test "DTLS proxy: 3d, gnutls server" \
7399 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7400 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007401 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007402 0 \
7403 -s "Extra-header:" \
7404 -c "Extra-header:"
7405
k-stachowiakabb843e2019-02-18 16:14:03 +01007406requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007407client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007408not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007409run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7410 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007411 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007412 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007413 0 \
7414 -s "Extra-header:" \
7415 -c "Extra-header:"
7416
k-stachowiakabb843e2019-02-18 16:14:03 +01007417requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007418client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007419not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007420run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7421 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007422 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007423 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007424 0 \
7425 -s "Extra-header:" \
7426 -c "Extra-header:"
7427
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007428# Final report
7429
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007430echo "------------------------------------------------------------------------"
7431
7432if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007433 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007434else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007435 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007436fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007437PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007438echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007439
7440exit $FAILS