blob: f0151187958252eba30f848a6fa71ee2183550e3 [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
Manuel Pégourié-Gonnarde63fc6d2020-06-08 11:49:05 +0200408 if [ "${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é-Gonnard0eb6cab2014-07-23 20:17:47 +0200624 # update DTLS variable
625 detect_dtls "$SRV_CMD"
626
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200627 # if the test uses DTLS but no custom proxy, add a simple proxy
628 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard581af9f2020-06-25 09:54:46 +0200629 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200630 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard7442f842020-07-16 10:19:32 +0200631 case " $SRV_CMD " in
632 *' server_addr=::1 '*)
633 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
634 esac
Manuel Pégourié-Gonnardfcf6c162020-06-08 11:40:06 +0200635 fi
636
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200637 # fix client port
638 if [ -n "$PXY_CMD" ]; then
639 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
640 else
641 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
642 fi
643
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100644 # prepend valgrind to our commands if active
645 if [ "$MEMCHECK" -gt 0 ]; then
646 if is_polar "$SRV_CMD"; then
647 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
648 fi
649 if is_polar "$CLI_CMD"; then
650 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
651 fi
652 fi
653
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200654 TIMES_LEFT=2
655 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200656 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200657
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200658 # run the commands
659 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200660 printf "# $NAME\n$PXY_CMD\n" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200661 $PXY_CMD >> $PXY_OUT 2>&1 &
662 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400663 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200664 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200665
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200666 check_osrv_dtls
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200667 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200668 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
669 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100670 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200671
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200672 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200673 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
674 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100675
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100676 sleep 0.05
677
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200678 # terminate the server (and the proxy)
679 kill $SRV_PID
680 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100681
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200682 if [ -n "$PXY_CMD" ]; then
683 kill $PXY_PID >/dev/null 2>&1
684 wait $PXY_PID
685 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100686
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200687 # retry only on timeouts
688 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
689 printf "RETRY "
690 else
691 TIMES_LEFT=0
692 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200693 done
694
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100695 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200696 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100697 # expected client exit to incorrectly succeed in case of catastrophic
698 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100699 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200700 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100701 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100702 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100703 return
704 fi
705 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100706 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200707 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100708 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100709 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100710 return
711 fi
712 fi
713
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100714 # check server exit code
715 if [ $? != 0 ]; then
716 fail "server fail"
717 return
718 fi
719
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100720 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100721 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
722 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100723 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200724 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100725 return
726 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100727
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100728 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200729 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100730 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100731 while [ $# -gt 0 ]
732 do
733 case $1 in
734 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100735 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 +0100736 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100737 return
738 fi
739 ;;
740
741 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100742 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 +0100743 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100744 return
745 fi
746 ;;
747
748 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100749 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 +0100750 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100751 return
752 fi
753 ;;
754
755 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100756 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 +0100757 fail "pattern '$2' MUST NOT be present in the Client output"
758 return
759 fi
760 ;;
761
762 # The filtering in the following two options (-u and -U) do the following
763 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100764 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100765 # - keep one of each non-unique line
766 # - count how many lines remain
767 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
768 # if there were no duplicates.
769 "-U")
770 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
771 fail "lines following pattern '$2' must be unique in Server output"
772 return
773 fi
774 ;;
775
776 "-u")
777 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
778 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100779 return
780 fi
781 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100782 "-F")
783 if ! $2 "$SRV_OUT"; then
784 fail "function call to '$2' failed on Server output"
785 return
786 fi
787 ;;
788 "-f")
789 if ! $2 "$CLI_OUT"; then
790 fail "function call to '$2' failed on Client output"
791 return
792 fi
793 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100794
795 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200796 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100797 exit 1
798 esac
799 shift 2
800 done
801
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100802 # check valgrind's results
803 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200804 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100805 fail "Server has memory errors"
806 return
807 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200808 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100809 fail "Client has memory errors"
810 return
811 fi
812 fi
813
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100814 # if we're here, everything is ok
815 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100816 if [ "$PRESERVE_LOGS" -gt 0 ]; then
817 mv $SRV_OUT o-srv-${TESTS}.log
818 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100819 if [ -n "$PXY_CMD" ]; then
820 mv $PXY_OUT o-pxy-${TESTS}.log
821 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100822 fi
823
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200824 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100825}
826
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100827cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200828 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200829 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
830 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
831 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
832 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100833 exit 1
834}
835
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100836#
837# MAIN
838#
839
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100840get_options "$@"
841
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100842# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100843P_SRV_BIN="${P_SRV%%[ ]*}"
844P_CLI_BIN="${P_CLI%%[ ]*}"
845P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100846if [ ! -x "$P_SRV_BIN" ]; then
847 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100848 exit 1
849fi
Hanno Becker17c04932017-10-10 14:44:53 +0100850if [ ! -x "$P_CLI_BIN" ]; then
851 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100852 exit 1
853fi
Hanno Becker17c04932017-10-10 14:44:53 +0100854if [ ! -x "$P_PXY_BIN" ]; then
855 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200856 exit 1
857fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100858if [ "$MEMCHECK" -gt 0 ]; then
859 if which valgrind >/dev/null 2>&1; then :; else
860 echo "Memcheck not possible. Valgrind not found"
861 exit 1
862 fi
863fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100864if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
865 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100866 exit 1
867fi
868
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200869# used by watchdog
870MAIN_PID="$$"
871
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100872# We use somewhat arbitrary delays for tests:
873# - how long do we wait for the server to start (when lsof not available)?
874# - how long do we allow for the client to finish?
875# (not to check performance, just to avoid waiting indefinitely)
876# Things are slower with valgrind, so give extra time here.
877#
878# Note: without lsof, there is a trade-off between the running time of this
879# script and the risk of spurious errors because we didn't wait long enough.
880# The watchdog delay on the other hand doesn't affect normal running time of
881# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200882if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100883 START_DELAY=6
884 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200885else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100886 START_DELAY=2
887 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200888fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100889
890# some particular tests need more time:
891# - for the client, we multiply the usual watchdog limit by a factor
892# - for the server, we sleep for a number of seconds after the client exits
893# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200894CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100895SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200896
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200897# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000898# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200899P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
900P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100901P_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 +0200902O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200903O_CLI="$O_CLI -connect localhost:+SRV_PORT"
904G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200905G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200906
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200907if [ -n "${OPENSSL_LEGACY:-}" ]; then
908 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
909 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
910fi
911
Hanno Becker58e9dc32018-08-17 15:53:21 +0100912if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200913 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
914fi
915
Hanno Becker58e9dc32018-08-17 15:53:21 +0100916if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200917 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200918fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100919
Gilles Peskine62469d92017-05-10 10:13:59 +0200920# Allow SHA-1, because many of our test certificates use it
921P_SRV="$P_SRV allow_sha1=1"
922P_CLI="$P_CLI allow_sha1=1"
923
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200924# Also pick a unique name for intermediate files
925SRV_OUT="srv_out.$$"
926CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200927PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200928SESSION="session.$$"
929
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200930SKIP_NEXT="NO"
931
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100932trap cleanup INT TERM HUP
933
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200934# Basic test
935
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200936# Checks that:
937# - things work with all ciphersuites active (used with config-full in all.sh)
938# - the expected (highest security) parameters are selected
939# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200940run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200941 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200942 "$P_CLI" \
943 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200944 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200945 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200946 -s "client hello v3, signature_algorithm ext: 6" \
947 -s "ECDHE curve: secp521r1" \
948 -S "error" \
949 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200950
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000951run_test "Default, DTLS" \
952 "$P_SRV dtls=1" \
953 "$P_CLI dtls=1" \
954 0 \
955 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200956 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000957
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +0100958requires_config_enabled MBEDTLS_ZLIB_SUPPORT
959run_test "Default (compression enabled)" \
960 "$P_SRV debug_level=3" \
961 "$P_CLI debug_level=3" \
962 0 \
963 -s "Allocating compression buffer" \
964 -c "Allocating compression buffer" \
965 -s "Record expansion is unknown (compression)" \
966 -c "Record expansion is unknown (compression)" \
967 -S "error" \
968 -C "error"
969
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100970# Test current time in ServerHello
971requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200972run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100973 "$P_SRV debug_level=3" \
974 "$P_CLI debug_level=3" \
975 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100976 -f "check_server_hello_time" \
977 -F "check_server_hello_time"
978
Simon Butcher8e004102016-10-14 00:48:33 +0100979# Test for uniqueness of IVs in AEAD ciphersuites
980run_test "Unique IV in GCM" \
981 "$P_SRV exchanges=20 debug_level=4" \
982 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
983 0 \
984 -u "IV used" \
985 -U "IV used"
986
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100987# Tests for rc4 option
988
Simon Butchera410af52016-05-19 22:12:18 +0100989requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100990run_test "RC4: server disabled, client enabled" \
991 "$P_SRV" \
992 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
993 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100994 -s "SSL - The server has no ciphersuites in common"
995
Simon Butchera410af52016-05-19 22:12:18 +0100996requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100997run_test "RC4: server half, client enabled" \
998 "$P_SRV arc4=1" \
999 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1000 1 \
1001 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001002
1003run_test "RC4: server enabled, client disabled" \
1004 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1005 "$P_CLI" \
1006 1 \
1007 -s "SSL - The server has no ciphersuites in common"
1008
1009run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001010 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001011 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1012 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001013 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001014 -S "SSL - The server has no ciphersuites in common"
1015
Hanno Beckerd26bb202018-08-17 09:54:10 +01001016# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1017
1018requires_gnutls
1019requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1020run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1021 "$G_SRV"\
1022 "$P_CLI force_version=tls1_1" \
1023 0
1024
1025requires_gnutls
1026requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1027run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1028 "$G_SRV"\
1029 "$P_CLI force_version=tls1" \
1030 0
1031
Gilles Peskinebc70a182017-05-09 15:59:24 +02001032# Tests for SHA-1 support
1033
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001034requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001035run_test "SHA-1 forbidden by default in server certificate" \
1036 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1037 "$P_CLI debug_level=2 allow_sha1=0" \
1038 1 \
1039 -c "The certificate is signed with an unacceptable hash"
1040
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001041requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1042run_test "SHA-1 forbidden by default in server certificate" \
1043 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1044 "$P_CLI debug_level=2 allow_sha1=0" \
1045 0
1046
Gilles Peskinebc70a182017-05-09 15:59:24 +02001047run_test "SHA-1 explicitly allowed in server certificate" \
1048 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1049 "$P_CLI allow_sha1=1" \
1050 0
1051
1052run_test "SHA-256 allowed by default in server certificate" \
1053 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1054 "$P_CLI allow_sha1=0" \
1055 0
1056
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001057requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001058run_test "SHA-1 forbidden by default in client certificate" \
1059 "$P_SRV auth_mode=required allow_sha1=0" \
1060 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1061 1 \
1062 -s "The certificate is signed with an unacceptable hash"
1063
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001064requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1065run_test "SHA-1 forbidden 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-sha1.crt" \
1068 0
1069
Gilles Peskinebc70a182017-05-09 15:59:24 +02001070run_test "SHA-1 explicitly allowed in client certificate" \
1071 "$P_SRV auth_mode=required allow_sha1=1" \
1072 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1073 0
1074
1075run_test "SHA-256 allowed by default in client certificate" \
1076 "$P_SRV auth_mode=required allow_sha1=0" \
1077 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1078 0
1079
Hanno Becker7ae8a762018-08-14 15:43:35 +01001080# Tests for datagram packing
1081run_test "DTLS: multiple records in same datagram, client and server" \
1082 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1083 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1084 0 \
1085 -c "next record in same datagram" \
1086 -s "next record in same datagram"
1087
1088run_test "DTLS: multiple records in same datagram, client only" \
1089 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1090 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1091 0 \
1092 -s "next record in same datagram" \
1093 -C "next record in same datagram"
1094
1095run_test "DTLS: multiple records in same datagram, server only" \
1096 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1097 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1098 0 \
1099 -S "next record in same datagram" \
1100 -c "next record in same datagram"
1101
1102run_test "DTLS: multiple records in same datagram, neither client nor server" \
1103 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1104 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1105 0 \
1106 -S "next record in same datagram" \
1107 -C "next record in same datagram"
1108
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001109# Tests for Truncated HMAC extension
1110
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001111run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001112 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001113 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001114 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001115 -s "dumping 'expected mac' (20 bytes)" \
1116 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001117
Hanno Becker32c55012017-11-10 08:42:54 +00001118requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001119run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001120 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001121 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001122 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001123 -s "dumping 'expected mac' (20 bytes)" \
1124 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001125
Hanno Becker32c55012017-11-10 08:42:54 +00001126requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001127run_test "Truncated HMAC: client enabled, server default" \
1128 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001129 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001130 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001131 -s "dumping 'expected mac' (20 bytes)" \
1132 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001133
Hanno Becker32c55012017-11-10 08:42:54 +00001134requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001135run_test "Truncated HMAC: client enabled, server disabled" \
1136 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001137 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001138 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001139 -s "dumping 'expected mac' (20 bytes)" \
1140 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001141
Hanno Becker32c55012017-11-10 08:42:54 +00001142requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001143run_test "Truncated HMAC: client disabled, server enabled" \
1144 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001145 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001146 0 \
1147 -s "dumping 'expected mac' (20 bytes)" \
1148 -S "dumping 'expected mac' (10 bytes)"
1149
1150requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001151run_test "Truncated HMAC: client enabled, server enabled" \
1152 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001153 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001154 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001155 -S "dumping 'expected mac' (20 bytes)" \
1156 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001157
Hanno Becker4c4f4102017-11-10 09:16:05 +00001158run_test "Truncated HMAC, DTLS: client default, server default" \
1159 "$P_SRV dtls=1 debug_level=4" \
1160 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1161 0 \
1162 -s "dumping 'expected mac' (20 bytes)" \
1163 -S "dumping 'expected mac' (10 bytes)"
1164
1165requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1166run_test "Truncated HMAC, DTLS: client disabled, server default" \
1167 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001168 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001169 0 \
1170 -s "dumping 'expected mac' (20 bytes)" \
1171 -S "dumping 'expected mac' (10 bytes)"
1172
1173requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1174run_test "Truncated HMAC, DTLS: client enabled, server default" \
1175 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001176 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001177 0 \
1178 -s "dumping 'expected mac' (20 bytes)" \
1179 -S "dumping 'expected mac' (10 bytes)"
1180
1181requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1182run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1183 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001184 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001185 0 \
1186 -s "dumping 'expected mac' (20 bytes)" \
1187 -S "dumping 'expected mac' (10 bytes)"
1188
1189requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1190run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1191 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001192 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001193 0 \
1194 -s "dumping 'expected mac' (20 bytes)" \
1195 -S "dumping 'expected mac' (10 bytes)"
1196
1197requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1198run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1199 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001200 "$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 +01001201 0 \
1202 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001203 -s "dumping 'expected mac' (10 bytes)"
1204
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001205# Tests for Encrypt-then-MAC extension
1206
1207run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001208 "$P_SRV debug_level=3 \
1209 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001210 "$P_CLI debug_level=3" \
1211 0 \
1212 -c "client hello, adding encrypt_then_mac extension" \
1213 -s "found encrypt then mac extension" \
1214 -s "server hello, adding encrypt then mac extension" \
1215 -c "found encrypt_then_mac extension" \
1216 -c "using encrypt then mac" \
1217 -s "using encrypt then mac"
1218
1219run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001220 "$P_SRV debug_level=3 etm=0 \
1221 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001222 "$P_CLI debug_level=3 etm=1" \
1223 0 \
1224 -c "client hello, adding encrypt_then_mac extension" \
1225 -s "found encrypt then mac extension" \
1226 -S "server hello, adding encrypt then mac extension" \
1227 -C "found encrypt_then_mac extension" \
1228 -C "using encrypt then mac" \
1229 -S "using encrypt then mac"
1230
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001231run_test "Encrypt then MAC: client enabled, aead cipher" \
1232 "$P_SRV debug_level=3 etm=1 \
1233 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1234 "$P_CLI debug_level=3 etm=1" \
1235 0 \
1236 -c "client hello, adding encrypt_then_mac extension" \
1237 -s "found encrypt then mac extension" \
1238 -S "server hello, adding encrypt then mac extension" \
1239 -C "found encrypt_then_mac extension" \
1240 -C "using encrypt then mac" \
1241 -S "using encrypt then mac"
1242
1243run_test "Encrypt then MAC: client enabled, stream cipher" \
1244 "$P_SRV debug_level=3 etm=1 \
1245 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001246 "$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 +01001247 0 \
1248 -c "client hello, adding encrypt_then_mac extension" \
1249 -s "found encrypt then mac extension" \
1250 -S "server hello, adding encrypt then mac extension" \
1251 -C "found encrypt_then_mac extension" \
1252 -C "using encrypt then mac" \
1253 -S "using encrypt then mac"
1254
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001255run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001256 "$P_SRV debug_level=3 etm=1 \
1257 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001258 "$P_CLI debug_level=3 etm=0" \
1259 0 \
1260 -C "client hello, adding encrypt_then_mac extension" \
1261 -S "found encrypt then mac extension" \
1262 -S "server hello, adding encrypt then mac extension" \
1263 -C "found encrypt_then_mac extension" \
1264 -C "using encrypt then mac" \
1265 -S "using encrypt then mac"
1266
Janos Follathe2681a42016-03-07 15:57:05 +00001267requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001268run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001269 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001270 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001271 "$P_CLI debug_level=3 force_version=ssl3" \
1272 0 \
1273 -C "client hello, adding encrypt_then_mac extension" \
1274 -S "found encrypt then mac extension" \
1275 -S "server hello, adding encrypt then mac extension" \
1276 -C "found encrypt_then_mac extension" \
1277 -C "using encrypt then mac" \
1278 -S "using encrypt then mac"
1279
Janos Follathe2681a42016-03-07 15:57:05 +00001280requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001281run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001282 "$P_SRV debug_level=3 force_version=ssl3 \
1283 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001284 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001285 0 \
1286 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001287 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001288 -S "server hello, adding encrypt then mac extension" \
1289 -C "found encrypt_then_mac extension" \
1290 -C "using encrypt then mac" \
1291 -S "using encrypt then mac"
1292
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001293# Tests for Extended Master Secret extension
1294
1295run_test "Extended Master Secret: default" \
1296 "$P_SRV debug_level=3" \
1297 "$P_CLI debug_level=3" \
1298 0 \
1299 -c "client hello, adding extended_master_secret extension" \
1300 -s "found extended master secret extension" \
1301 -s "server hello, adding extended master secret extension" \
1302 -c "found extended_master_secret extension" \
1303 -c "using extended master secret" \
1304 -s "using extended master secret"
1305
1306run_test "Extended Master Secret: client enabled, server disabled" \
1307 "$P_SRV debug_level=3 extended_ms=0" \
1308 "$P_CLI debug_level=3 extended_ms=1" \
1309 0 \
1310 -c "client hello, adding extended_master_secret extension" \
1311 -s "found extended master secret extension" \
1312 -S "server hello, adding extended master secret extension" \
1313 -C "found extended_master_secret extension" \
1314 -C "using extended master secret" \
1315 -S "using extended master secret"
1316
1317run_test "Extended Master Secret: client disabled, server enabled" \
1318 "$P_SRV debug_level=3 extended_ms=1" \
1319 "$P_CLI debug_level=3 extended_ms=0" \
1320 0 \
1321 -C "client hello, adding extended_master_secret extension" \
1322 -S "found extended master secret extension" \
1323 -S "server hello, adding extended master secret extension" \
1324 -C "found extended_master_secret extension" \
1325 -C "using extended master secret" \
1326 -S "using extended master secret"
1327
Janos Follathe2681a42016-03-07 15:57:05 +00001328requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001329run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001330 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001331 "$P_CLI debug_level=3 force_version=ssl3" \
1332 0 \
1333 -C "client hello, adding extended_master_secret extension" \
1334 -S "found extended master secret extension" \
1335 -S "server hello, adding extended master secret extension" \
1336 -C "found extended_master_secret extension" \
1337 -C "using extended master secret" \
1338 -S "using extended master secret"
1339
Janos Follathe2681a42016-03-07 15:57:05 +00001340requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001341run_test "Extended Master Secret: client enabled, server SSLv3" \
1342 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001343 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001344 0 \
1345 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001346 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001347 -S "server hello, adding extended master secret extension" \
1348 -C "found extended_master_secret extension" \
1349 -C "using extended master secret" \
1350 -S "using extended master secret"
1351
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001352# Tests for FALLBACK_SCSV
1353
1354run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001355 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001356 "$P_CLI debug_level=3 force_version=tls1_1" \
1357 0 \
1358 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001359 -S "received FALLBACK_SCSV" \
1360 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001361 -C "is a fatal alert message (msg 86)"
1362
1363run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001364 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001365 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1366 0 \
1367 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001368 -S "received FALLBACK_SCSV" \
1369 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001370 -C "is a fatal alert message (msg 86)"
1371
1372run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001373 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001374 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001375 1 \
1376 -c "adding FALLBACK_SCSV" \
1377 -s "received FALLBACK_SCSV" \
1378 -s "inapropriate fallback" \
1379 -c "is a fatal alert message (msg 86)"
1380
1381run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001382 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001383 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001384 0 \
1385 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001386 -s "received FALLBACK_SCSV" \
1387 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001388 -C "is a fatal alert message (msg 86)"
1389
1390requires_openssl_with_fallback_scsv
1391run_test "Fallback SCSV: default, openssl server" \
1392 "$O_SRV" \
1393 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1394 0 \
1395 -C "adding FALLBACK_SCSV" \
1396 -C "is a fatal alert message (msg 86)"
1397
1398requires_openssl_with_fallback_scsv
1399run_test "Fallback SCSV: enabled, openssl server" \
1400 "$O_SRV" \
1401 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1402 1 \
1403 -c "adding FALLBACK_SCSV" \
1404 -c "is a fatal alert message (msg 86)"
1405
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001406requires_openssl_with_fallback_scsv
1407run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001408 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001409 "$O_CLI -tls1_1" \
1410 0 \
1411 -S "received FALLBACK_SCSV" \
1412 -S "inapropriate fallback"
1413
1414requires_openssl_with_fallback_scsv
1415run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001416 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001417 "$O_CLI -tls1_1 -fallback_scsv" \
1418 1 \
1419 -s "received FALLBACK_SCSV" \
1420 -s "inapropriate fallback"
1421
1422requires_openssl_with_fallback_scsv
1423run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001424 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001425 "$O_CLI -fallback_scsv" \
1426 0 \
1427 -s "received FALLBACK_SCSV" \
1428 -S "inapropriate fallback"
1429
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001430# Test sending and receiving empty application data records
1431
1432run_test "Encrypt then MAC: empty application data record" \
1433 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1434 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1435 0 \
1436 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1437 -s "dumping 'input payload after decrypt' (0 bytes)" \
1438 -c "0 bytes written in 1 fragments"
1439
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001440run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001441 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1442 "$P_CLI auth_mode=none etm=0 request_size=0" \
1443 0 \
1444 -s "dumping 'input payload after decrypt' (0 bytes)" \
1445 -c "0 bytes written in 1 fragments"
1446
1447run_test "Encrypt then MAC, DTLS: empty application data record" \
1448 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1449 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1450 0 \
1451 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1452 -s "dumping 'input payload after decrypt' (0 bytes)" \
1453 -c "0 bytes written in 1 fragments"
1454
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001455run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001456 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1457 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1458 0 \
1459 -s "dumping 'input payload after decrypt' (0 bytes)" \
1460 -c "0 bytes written in 1 fragments"
1461
Gilles Peskined50177f2017-05-16 17:53:03 +02001462## ClientHello generated with
1463## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1464## then manually twiddling the ciphersuite list.
1465## The ClientHello content is spelled out below as a hex string as
1466## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1467## The expected response is an inappropriate_fallback alert.
1468requires_openssl_with_fallback_scsv
1469run_test "Fallback SCSV: beginning of list" \
1470 "$P_SRV debug_level=2" \
1471 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1472 0 \
1473 -s "received FALLBACK_SCSV" \
1474 -s "inapropriate fallback"
1475
1476requires_openssl_with_fallback_scsv
1477run_test "Fallback SCSV: end of list" \
1478 "$P_SRV debug_level=2" \
1479 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1480 0 \
1481 -s "received FALLBACK_SCSV" \
1482 -s "inapropriate fallback"
1483
1484## Here the expected response is a valid ServerHello prefix, up to the random.
1485requires_openssl_with_fallback_scsv
1486run_test "Fallback SCSV: not in list" \
1487 "$P_SRV debug_level=2" \
1488 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1489 0 \
1490 -S "received FALLBACK_SCSV" \
1491 -S "inapropriate fallback"
1492
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001493# Tests for CBC 1/n-1 record splitting
1494
1495run_test "CBC Record splitting: TLS 1.2, no splitting" \
1496 "$P_SRV" \
1497 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1498 request_size=123 force_version=tls1_2" \
1499 0 \
1500 -s "Read from client: 123 bytes read" \
1501 -S "Read from client: 1 bytes read" \
1502 -S "122 bytes read"
1503
1504run_test "CBC Record splitting: TLS 1.1, no splitting" \
1505 "$P_SRV" \
1506 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1507 request_size=123 force_version=tls1_1" \
1508 0 \
1509 -s "Read from client: 123 bytes read" \
1510 -S "Read from client: 1 bytes read" \
1511 -S "122 bytes read"
1512
1513run_test "CBC Record splitting: TLS 1.0, splitting" \
1514 "$P_SRV" \
1515 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1516 request_size=123 force_version=tls1" \
1517 0 \
1518 -S "Read from client: 123 bytes read" \
1519 -s "Read from client: 1 bytes read" \
1520 -s "122 bytes read"
1521
Janos Follathe2681a42016-03-07 15:57:05 +00001522requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001523run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001524 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001525 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1526 request_size=123 force_version=ssl3" \
1527 0 \
1528 -S "Read from client: 123 bytes read" \
1529 -s "Read from client: 1 bytes read" \
1530 -s "122 bytes read"
1531
1532run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001533 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001534 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1535 request_size=123 force_version=tls1" \
1536 0 \
1537 -s "Read from client: 123 bytes read" \
1538 -S "Read from client: 1 bytes read" \
1539 -S "122 bytes read"
1540
1541run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1542 "$P_SRV" \
1543 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1544 request_size=123 force_version=tls1 recsplit=0" \
1545 0 \
1546 -s "Read from client: 123 bytes read" \
1547 -S "Read from client: 1 bytes read" \
1548 -S "122 bytes read"
1549
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001550run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1551 "$P_SRV nbio=2" \
1552 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1553 request_size=123 force_version=tls1" \
1554 0 \
1555 -S "Read from client: 123 bytes read" \
1556 -s "Read from client: 1 bytes read" \
1557 -s "122 bytes read"
1558
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001559# Tests for Session Tickets
1560
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001561run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001562 "$P_SRV debug_level=3 tickets=1" \
1563 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001564 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001565 -c "client hello, adding session ticket extension" \
1566 -s "found session ticket extension" \
1567 -s "server hello, adding session ticket extension" \
1568 -c "found session_ticket extension" \
1569 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001570 -S "session successfully restored from cache" \
1571 -s "session successfully restored from ticket" \
1572 -s "a session has been resumed" \
1573 -c "a session has been resumed"
1574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001575run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001576 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1577 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001578 0 \
1579 -c "client hello, adding session ticket extension" \
1580 -s "found session ticket extension" \
1581 -s "server hello, adding session ticket extension" \
1582 -c "found session_ticket extension" \
1583 -c "parse new session ticket" \
1584 -S "session successfully restored from cache" \
1585 -s "session successfully restored from ticket" \
1586 -s "a session has been resumed" \
1587 -c "a session has been resumed"
1588
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001589run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001590 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1591 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001592 0 \
1593 -c "client hello, adding session ticket extension" \
1594 -s "found session ticket extension" \
1595 -s "server hello, adding session ticket extension" \
1596 -c "found session_ticket extension" \
1597 -c "parse new session ticket" \
1598 -S "session successfully restored from cache" \
1599 -S "session successfully restored from ticket" \
1600 -S "a session has been resumed" \
1601 -C "a session has been resumed"
1602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001603run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001604 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001605 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001606 0 \
1607 -c "client hello, adding session ticket extension" \
1608 -c "found session_ticket extension" \
1609 -c "parse new session ticket" \
1610 -c "a session has been resumed"
1611
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001612run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001613 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001614 "( $O_CLI -sess_out $SESSION; \
1615 $O_CLI -sess_in $SESSION; \
1616 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001617 0 \
1618 -s "found session ticket extension" \
1619 -s "server hello, adding session ticket extension" \
1620 -S "session successfully restored from cache" \
1621 -s "session successfully restored from ticket" \
1622 -s "a session has been resumed"
1623
Hanno Becker1d739932018-08-21 13:55:22 +01001624# Tests for Session Tickets with DTLS
1625
1626run_test "Session resume using tickets, DTLS: basic" \
1627 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001628 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001629 0 \
1630 -c "client hello, adding session ticket extension" \
1631 -s "found session ticket extension" \
1632 -s "server hello, adding session ticket extension" \
1633 -c "found session_ticket extension" \
1634 -c "parse new session ticket" \
1635 -S "session successfully restored from cache" \
1636 -s "session successfully restored from ticket" \
1637 -s "a session has been resumed" \
1638 -c "a session has been resumed"
1639
1640run_test "Session resume using tickets, DTLS: cache disabled" \
1641 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001642 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001643 0 \
1644 -c "client hello, adding session ticket extension" \
1645 -s "found session ticket extension" \
1646 -s "server hello, adding session ticket extension" \
1647 -c "found session_ticket extension" \
1648 -c "parse new session ticket" \
1649 -S "session successfully restored from cache" \
1650 -s "session successfully restored from ticket" \
1651 -s "a session has been resumed" \
1652 -c "a session has been resumed"
1653
1654run_test "Session resume using tickets, DTLS: timeout" \
1655 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001656 "$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 +01001657 0 \
1658 -c "client hello, adding session ticket extension" \
1659 -s "found session ticket extension" \
1660 -s "server hello, adding session ticket extension" \
1661 -c "found session_ticket extension" \
1662 -c "parse new session ticket" \
1663 -S "session successfully restored from cache" \
1664 -S "session successfully restored from ticket" \
1665 -S "a session has been resumed" \
1666 -C "a session has been resumed"
1667
1668run_test "Session resume using tickets, DTLS: openssl server" \
1669 "$O_SRV -dtls1" \
1670 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1671 0 \
1672 -c "client hello, adding session ticket extension" \
1673 -c "found session_ticket extension" \
1674 -c "parse new session ticket" \
1675 -c "a session has been resumed"
1676
1677run_test "Session resume using tickets, DTLS: openssl client" \
1678 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1679 "( $O_CLI -dtls1 -sess_out $SESSION; \
1680 $O_CLI -dtls1 -sess_in $SESSION; \
1681 rm -f $SESSION )" \
1682 0 \
1683 -s "found session ticket extension" \
1684 -s "server hello, adding session ticket extension" \
1685 -S "session successfully restored from cache" \
1686 -s "session successfully restored from ticket" \
1687 -s "a session has been resumed"
1688
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001689# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001691run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001692 "$P_SRV debug_level=3 tickets=0" \
1693 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001694 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001695 -c "client hello, adding session ticket extension" \
1696 -s "found session ticket extension" \
1697 -S "server hello, adding session ticket extension" \
1698 -C "found session_ticket extension" \
1699 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001700 -s "session successfully restored from cache" \
1701 -S "session successfully restored from ticket" \
1702 -s "a session has been resumed" \
1703 -c "a session has been resumed"
1704
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001705run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001706 "$P_SRV debug_level=3 tickets=1" \
1707 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001708 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001709 -C "client hello, adding session ticket extension" \
1710 -S "found session ticket extension" \
1711 -S "server hello, adding session ticket extension" \
1712 -C "found session_ticket extension" \
1713 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001714 -s "session successfully restored from cache" \
1715 -S "session successfully restored from ticket" \
1716 -s "a session has been resumed" \
1717 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001719run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001720 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1721 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001722 0 \
1723 -S "session successfully restored from cache" \
1724 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001725 -S "a session has been resumed" \
1726 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001727
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001728run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001729 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1730 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001731 0 \
1732 -s "session successfully restored from cache" \
1733 -S "session successfully restored from ticket" \
1734 -s "a session has been resumed" \
1735 -c "a session has been resumed"
1736
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001737run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001738 "$P_SRV debug_level=3 tickets=0" \
1739 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001740 0 \
1741 -s "session successfully restored from cache" \
1742 -S "session successfully restored from ticket" \
1743 -s "a session has been resumed" \
1744 -c "a session has been resumed"
1745
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001746run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001747 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1748 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001749 0 \
1750 -S "session successfully restored from cache" \
1751 -S "session successfully restored from ticket" \
1752 -S "a session has been resumed" \
1753 -C "a session has been resumed"
1754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001755run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001756 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1757 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001758 0 \
1759 -s "session successfully restored from cache" \
1760 -S "session successfully restored from ticket" \
1761 -s "a session has been resumed" \
1762 -c "a session has been resumed"
1763
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001764run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001765 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001766 "( $O_CLI -sess_out $SESSION; \
1767 $O_CLI -sess_in $SESSION; \
1768 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001769 0 \
1770 -s "found session ticket extension" \
1771 -S "server hello, adding session ticket extension" \
1772 -s "session successfully restored from cache" \
1773 -S "session successfully restored from ticket" \
1774 -s "a session has been resumed"
1775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001776run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001777 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001778 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001779 0 \
1780 -C "found session_ticket extension" \
1781 -C "parse new session ticket" \
1782 -c "a session has been resumed"
1783
Hanno Becker1d739932018-08-21 13:55:22 +01001784# Tests for Session Resume based on session-ID and cache, DTLS
1785
1786run_test "Session resume using cache, DTLS: tickets enabled on client" \
1787 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001788 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001789 0 \
1790 -c "client hello, adding session ticket extension" \
1791 -s "found session ticket extension" \
1792 -S "server hello, adding session ticket extension" \
1793 -C "found session_ticket extension" \
1794 -C "parse new session ticket" \
1795 -s "session successfully restored from cache" \
1796 -S "session successfully restored from ticket" \
1797 -s "a session has been resumed" \
1798 -c "a session has been resumed"
1799
1800run_test "Session resume using cache, DTLS: tickets enabled on server" \
1801 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001802 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001803 0 \
1804 -C "client hello, adding session ticket extension" \
1805 -S "found session ticket extension" \
1806 -S "server hello, adding session ticket extension" \
1807 -C "found session_ticket extension" \
1808 -C "parse new session ticket" \
1809 -s "session successfully restored from cache" \
1810 -S "session successfully restored from ticket" \
1811 -s "a session has been resumed" \
1812 -c "a session has been resumed"
1813
1814run_test "Session resume using cache, DTLS: cache_max=0" \
1815 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001816 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001817 0 \
1818 -S "session successfully restored from cache" \
1819 -S "session successfully restored from ticket" \
1820 -S "a session has been resumed" \
1821 -C "a session has been resumed"
1822
1823run_test "Session resume using cache, DTLS: cache_max=1" \
1824 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001825 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001826 0 \
1827 -s "session successfully restored from cache" \
1828 -S "session successfully restored from ticket" \
1829 -s "a session has been resumed" \
1830 -c "a session has been resumed"
1831
1832run_test "Session resume using cache, DTLS: timeout > delay" \
1833 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001834 "$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 +01001835 0 \
1836 -s "session successfully restored from cache" \
1837 -S "session successfully restored from ticket" \
1838 -s "a session has been resumed" \
1839 -c "a session has been resumed"
1840
1841run_test "Session resume using cache, DTLS: timeout < delay" \
1842 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001843 "$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 +01001844 0 \
1845 -S "session successfully restored from cache" \
1846 -S "session successfully restored from ticket" \
1847 -S "a session has been resumed" \
1848 -C "a session has been resumed"
1849
1850run_test "Session resume using cache, DTLS: no timeout" \
1851 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001852 "$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 +01001853 0 \
1854 -s "session successfully restored from cache" \
1855 -S "session successfully restored from ticket" \
1856 -s "a session has been resumed" \
1857 -c "a session has been resumed"
1858
1859run_test "Session resume using cache, DTLS: openssl client" \
1860 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1861 "( $O_CLI -dtls1 -sess_out $SESSION; \
1862 $O_CLI -dtls1 -sess_in $SESSION; \
1863 rm -f $SESSION )" \
1864 0 \
1865 -s "found session ticket extension" \
1866 -S "server hello, adding session ticket extension" \
1867 -s "session successfully restored from cache" \
1868 -S "session successfully restored from ticket" \
1869 -s "a session has been resumed"
1870
1871run_test "Session resume using cache, DTLS: openssl server" \
1872 "$O_SRV -dtls1" \
1873 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1874 0 \
1875 -C "found session_ticket extension" \
1876 -C "parse new session ticket" \
1877 -c "a session has been resumed"
1878
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001879# Tests for Max Fragment Length extension
1880
Angus Grattonc4dd0732018-04-11 16:28:39 +10001881if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1882 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 +01001883 exit 1
1884fi
1885
Angus Grattonc4dd0732018-04-11 16:28:39 +10001886if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1887 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1888fi
1889
Hanno Becker4aed27e2017-09-18 15:00:34 +01001890requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001891run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001892 "$P_SRV debug_level=3" \
1893 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001894 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001895 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1896 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001897 -C "client hello, adding max_fragment_length extension" \
1898 -S "found max fragment length extension" \
1899 -S "server hello, max_fragment_length extension" \
1900 -C "found max_fragment_length extension"
1901
Hanno Becker4aed27e2017-09-18 15:00:34 +01001902requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001903run_test "Max fragment length: enabled, default, larger message" \
1904 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001905 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001906 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001907 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1908 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001909 -C "client hello, adding max_fragment_length extension" \
1910 -S "found max fragment length extension" \
1911 -S "server hello, max_fragment_length extension" \
1912 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001913 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1914 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001915 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001916
1917requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1918run_test "Max fragment length, DTLS: enabled, default, larger message" \
1919 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001920 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001921 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001922 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1923 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001924 -C "client hello, adding max_fragment_length extension" \
1925 -S "found max fragment length extension" \
1926 -S "server hello, max_fragment_length extension" \
1927 -C "found max_fragment_length extension" \
1928 -c "fragment larger than.*maximum "
1929
Angus Grattonc4dd0732018-04-11 16:28:39 +10001930# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1931# (session fragment length will be 16384 regardless of mbedtls
1932# content length configuration.)
1933
Hanno Beckerc5266962017-09-18 15:01:50 +01001934requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1935run_test "Max fragment length: disabled, larger message" \
1936 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001937 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001938 0 \
1939 -C "Maximum fragment length is 16384" \
1940 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001941 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1942 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001943 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001944
1945requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1946run_test "Max fragment length DTLS: disabled, larger message" \
1947 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001948 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001949 1 \
1950 -C "Maximum fragment length is 16384" \
1951 -S "Maximum fragment length is 16384" \
1952 -c "fragment larger than.*maximum "
1953
1954requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001955run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001956 "$P_SRV debug_level=3" \
1957 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001958 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001959 -c "Maximum fragment length is 4096" \
1960 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001961 -c "client hello, adding max_fragment_length extension" \
1962 -s "found max fragment length extension" \
1963 -s "server hello, max_fragment_length extension" \
1964 -c "found max_fragment_length extension"
1965
Hanno Becker4aed27e2017-09-18 15:00:34 +01001966requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001967run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001968 "$P_SRV debug_level=3 max_frag_len=4096" \
1969 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001970 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001971 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001972 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001973 -C "client hello, adding max_fragment_length extension" \
1974 -S "found max fragment length extension" \
1975 -S "server hello, max_fragment_length extension" \
1976 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001977
Hanno Becker4aed27e2017-09-18 15:00:34 +01001978requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001979requires_gnutls
1980run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001981 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001982 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001983 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001984 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001985 -c "client hello, adding max_fragment_length extension" \
1986 -c "found max_fragment_length extension"
1987
Hanno Becker4aed27e2017-09-18 15:00:34 +01001988requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001989run_test "Max fragment length: client, message just fits" \
1990 "$P_SRV debug_level=3" \
1991 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1992 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001993 -c "Maximum fragment length is 2048" \
1994 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001995 -c "client hello, adding max_fragment_length extension" \
1996 -s "found max fragment length extension" \
1997 -s "server hello, max_fragment_length extension" \
1998 -c "found max_fragment_length extension" \
1999 -c "2048 bytes written in 1 fragments" \
2000 -s "2048 bytes read"
2001
Hanno Becker4aed27e2017-09-18 15:00:34 +01002002requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002003run_test "Max fragment length: client, larger message" \
2004 "$P_SRV debug_level=3" \
2005 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2006 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002007 -c "Maximum fragment length is 2048" \
2008 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002009 -c "client hello, adding max_fragment_length extension" \
2010 -s "found max fragment length extension" \
2011 -s "server hello, max_fragment_length extension" \
2012 -c "found max_fragment_length extension" \
2013 -c "2345 bytes written in 2 fragments" \
2014 -s "2048 bytes read" \
2015 -s "297 bytes read"
2016
Hanno Becker4aed27e2017-09-18 15:00:34 +01002017requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002018run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002019 "$P_SRV debug_level=3 dtls=1" \
2020 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2021 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002022 -c "Maximum fragment length is 2048" \
2023 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002024 -c "client hello, adding max_fragment_length extension" \
2025 -s "found max fragment length extension" \
2026 -s "server hello, max_fragment_length extension" \
2027 -c "found max_fragment_length extension" \
2028 -c "fragment larger than.*maximum"
2029
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002030# Tests for renegotiation
2031
Hanno Becker6a243642017-10-12 15:18:45 +01002032# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002033run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002034 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002035 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002036 0 \
2037 -C "client hello, adding renegotiation extension" \
2038 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2039 -S "found renegotiation extension" \
2040 -s "server hello, secure renegotiation extension" \
2041 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002042 -C "=> renegotiate" \
2043 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002044 -S "write hello request"
2045
Hanno Becker6a243642017-10-12 15:18:45 +01002046requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002047run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002048 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002049 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002050 0 \
2051 -c "client hello, adding renegotiation extension" \
2052 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2053 -s "found renegotiation extension" \
2054 -s "server hello, secure renegotiation extension" \
2055 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002056 -c "=> renegotiate" \
2057 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002058 -S "write hello request"
2059
Hanno Becker6a243642017-10-12 15:18:45 +01002060requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002061run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002062 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002063 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002064 0 \
2065 -c "client hello, adding renegotiation extension" \
2066 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2067 -s "found renegotiation extension" \
2068 -s "server hello, secure renegotiation extension" \
2069 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002070 -c "=> renegotiate" \
2071 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002072 -s "write hello request"
2073
Janos Follathb0f148c2017-10-05 12:29:42 +01002074# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2075# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2076# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002077requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002078run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2079 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2080 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2081 0 \
2082 -c "client hello, adding renegotiation extension" \
2083 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2084 -s "found renegotiation extension" \
2085 -s "server hello, secure renegotiation extension" \
2086 -c "found renegotiation extension" \
2087 -c "=> renegotiate" \
2088 -s "=> renegotiate" \
2089 -S "write hello request" \
2090 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2091
2092# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2093# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2094# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002095requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002096run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2097 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2098 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2099 0 \
2100 -c "client hello, adding renegotiation extension" \
2101 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2102 -s "found renegotiation extension" \
2103 -s "server hello, secure renegotiation extension" \
2104 -c "found renegotiation extension" \
2105 -c "=> renegotiate" \
2106 -s "=> renegotiate" \
2107 -s "write hello request" \
2108 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2109
Hanno Becker6a243642017-10-12 15:18:45 +01002110requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002111run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002112 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002113 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002114 0 \
2115 -c "client hello, adding renegotiation extension" \
2116 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2117 -s "found renegotiation extension" \
2118 -s "server hello, secure renegotiation extension" \
2119 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002120 -c "=> renegotiate" \
2121 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002122 -s "write hello request"
2123
Hanno Becker6a243642017-10-12 15:18:45 +01002124requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002125run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002126 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002127 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002128 1 \
2129 -c "client hello, adding renegotiation extension" \
2130 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2131 -S "found renegotiation extension" \
2132 -s "server hello, secure renegotiation extension" \
2133 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002134 -c "=> renegotiate" \
2135 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002136 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002137 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002138 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002139
Hanno Becker6a243642017-10-12 15:18:45 +01002140requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002141run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002142 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002143 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002144 0 \
2145 -C "client hello, adding renegotiation extension" \
2146 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2147 -S "found renegotiation extension" \
2148 -s "server hello, secure renegotiation extension" \
2149 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002150 -C "=> renegotiate" \
2151 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002152 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002153 -S "SSL - An unexpected message was received from our peer" \
2154 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002155
Hanno Becker6a243642017-10-12 15:18:45 +01002156requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002157run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002158 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002159 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002160 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002161 0 \
2162 -C "client hello, adding renegotiation extension" \
2163 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2164 -S "found renegotiation extension" \
2165 -s "server hello, secure renegotiation extension" \
2166 -c "found renegotiation extension" \
2167 -C "=> renegotiate" \
2168 -S "=> renegotiate" \
2169 -s "write hello request" \
2170 -S "SSL - An unexpected message was received from our peer" \
2171 -S "failed"
2172
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002173# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002174requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002175run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002176 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002177 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002178 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002179 0 \
2180 -C "client hello, adding renegotiation extension" \
2181 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2182 -S "found renegotiation extension" \
2183 -s "server hello, secure renegotiation extension" \
2184 -c "found renegotiation extension" \
2185 -C "=> renegotiate" \
2186 -S "=> renegotiate" \
2187 -s "write hello request" \
2188 -S "SSL - An unexpected message was received from our peer" \
2189 -S "failed"
2190
Hanno Becker6a243642017-10-12 15:18:45 +01002191requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002192run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002193 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002194 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002195 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002196 0 \
2197 -C "client hello, adding renegotiation extension" \
2198 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2199 -S "found renegotiation extension" \
2200 -s "server hello, secure renegotiation extension" \
2201 -c "found renegotiation extension" \
2202 -C "=> renegotiate" \
2203 -S "=> renegotiate" \
2204 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002205 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002206
Hanno Becker6a243642017-10-12 15:18:45 +01002207requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002208run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002209 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002210 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002211 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002212 0 \
2213 -c "client hello, adding renegotiation extension" \
2214 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2215 -s "found renegotiation extension" \
2216 -s "server hello, secure renegotiation extension" \
2217 -c "found renegotiation extension" \
2218 -c "=> renegotiate" \
2219 -s "=> renegotiate" \
2220 -s "write hello request" \
2221 -S "SSL - An unexpected message was received from our peer" \
2222 -S "failed"
2223
Hanno Becker6a243642017-10-12 15:18:45 +01002224requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002225run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002226 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002227 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2228 0 \
2229 -C "client hello, adding renegotiation extension" \
2230 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2231 -S "found renegotiation extension" \
2232 -s "server hello, secure renegotiation extension" \
2233 -c "found renegotiation extension" \
2234 -S "record counter limit reached: renegotiate" \
2235 -C "=> renegotiate" \
2236 -S "=> renegotiate" \
2237 -S "write hello request" \
2238 -S "SSL - An unexpected message was received from our peer" \
2239 -S "failed"
2240
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002241# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002242requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002243run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002244 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002245 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002246 0 \
2247 -c "client hello, adding renegotiation extension" \
2248 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2249 -s "found renegotiation extension" \
2250 -s "server hello, secure renegotiation extension" \
2251 -c "found renegotiation extension" \
2252 -s "record counter limit reached: renegotiate" \
2253 -c "=> renegotiate" \
2254 -s "=> renegotiate" \
2255 -s "write hello request" \
2256 -S "SSL - An unexpected message was received from our peer" \
2257 -S "failed"
2258
Hanno Becker6a243642017-10-12 15:18:45 +01002259requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002260run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002261 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002262 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002263 0 \
2264 -c "client hello, adding renegotiation extension" \
2265 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2266 -s "found renegotiation extension" \
2267 -s "server hello, secure renegotiation extension" \
2268 -c "found renegotiation extension" \
2269 -s "record counter limit reached: renegotiate" \
2270 -c "=> renegotiate" \
2271 -s "=> renegotiate" \
2272 -s "write hello request" \
2273 -S "SSL - An unexpected message was received from our peer" \
2274 -S "failed"
2275
Hanno Becker6a243642017-10-12 15:18:45 +01002276requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002277run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002278 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002279 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2280 0 \
2281 -C "client hello, adding renegotiation extension" \
2282 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2283 -S "found renegotiation extension" \
2284 -s "server hello, secure renegotiation extension" \
2285 -c "found renegotiation extension" \
2286 -S "record counter limit reached: renegotiate" \
2287 -C "=> renegotiate" \
2288 -S "=> renegotiate" \
2289 -S "write hello request" \
2290 -S "SSL - An unexpected message was received from our peer" \
2291 -S "failed"
2292
Hanno Becker6a243642017-10-12 15:18:45 +01002293requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002294run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002295 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002296 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002297 0 \
2298 -c "client hello, adding renegotiation extension" \
2299 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2300 -s "found renegotiation extension" \
2301 -s "server hello, secure renegotiation extension" \
2302 -c "found renegotiation extension" \
2303 -c "=> renegotiate" \
2304 -s "=> renegotiate" \
2305 -S "write hello request"
2306
Hanno Becker6a243642017-10-12 15:18:45 +01002307requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002308run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002309 "$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 +02002310 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002311 0 \
2312 -c "client hello, adding renegotiation extension" \
2313 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2314 -s "found renegotiation extension" \
2315 -s "server hello, secure renegotiation extension" \
2316 -c "found renegotiation extension" \
2317 -c "=> renegotiate" \
2318 -s "=> renegotiate" \
2319 -s "write hello request"
2320
Hanno Becker6a243642017-10-12 15:18:45 +01002321requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002322run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002323 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002324 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002325 0 \
2326 -c "client hello, adding renegotiation extension" \
2327 -c "found renegotiation extension" \
2328 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002329 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002330 -C "error" \
2331 -c "HTTP/1.0 200 [Oo][Kk]"
2332
Paul Bakker539d9722015-02-08 16:18:35 +01002333requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002334requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002335run_test "Renegotiation: gnutls server strict, client-initiated" \
2336 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002337 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002338 0 \
2339 -c "client hello, adding renegotiation extension" \
2340 -c "found renegotiation extension" \
2341 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002342 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002343 -C "error" \
2344 -c "HTTP/1.0 200 [Oo][Kk]"
2345
Paul Bakker539d9722015-02-08 16:18:35 +01002346requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002347requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002348run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2349 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2350 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2351 1 \
2352 -c "client hello, adding renegotiation extension" \
2353 -C "found renegotiation extension" \
2354 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002355 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002356 -c "error" \
2357 -C "HTTP/1.0 200 [Oo][Kk]"
2358
Paul Bakker539d9722015-02-08 16:18:35 +01002359requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002360requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002361run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2362 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2363 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2364 allow_legacy=0" \
2365 1 \
2366 -c "client hello, adding renegotiation extension" \
2367 -C "found renegotiation extension" \
2368 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002369 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002370 -c "error" \
2371 -C "HTTP/1.0 200 [Oo][Kk]"
2372
Paul Bakker539d9722015-02-08 16:18:35 +01002373requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002374requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002375run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2376 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2377 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2378 allow_legacy=1" \
2379 0 \
2380 -c "client hello, adding renegotiation extension" \
2381 -C "found renegotiation extension" \
2382 -c "=> renegotiate" \
2383 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002384 -C "error" \
2385 -c "HTTP/1.0 200 [Oo][Kk]"
2386
Hanno Becker6a243642017-10-12 15:18:45 +01002387requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002388run_test "Renegotiation: DTLS, client-initiated" \
2389 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2390 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2391 0 \
2392 -c "client hello, adding renegotiation extension" \
2393 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2394 -s "found renegotiation extension" \
2395 -s "server hello, secure renegotiation extension" \
2396 -c "found renegotiation extension" \
2397 -c "=> renegotiate" \
2398 -s "=> renegotiate" \
2399 -S "write hello request"
2400
Hanno Becker6a243642017-10-12 15:18:45 +01002401requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002402run_test "Renegotiation: DTLS, server-initiated" \
2403 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002404 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2405 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002406 0 \
2407 -c "client hello, adding renegotiation extension" \
2408 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2409 -s "found renegotiation extension" \
2410 -s "server hello, secure renegotiation extension" \
2411 -c "found renegotiation extension" \
2412 -c "=> renegotiate" \
2413 -s "=> renegotiate" \
2414 -s "write hello request"
2415
Hanno Becker6a243642017-10-12 15:18:45 +01002416requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002417run_test "Renegotiation: DTLS, renego_period overflow" \
2418 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2419 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2420 0 \
2421 -c "client hello, adding renegotiation extension" \
2422 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2423 -s "found renegotiation extension" \
2424 -s "server hello, secure renegotiation extension" \
2425 -s "record counter limit reached: renegotiate" \
2426 -c "=> renegotiate" \
2427 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002428 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002429
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002430requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002431requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002432run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2433 "$G_SRV -u --mtu 4096" \
2434 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2435 0 \
2436 -c "client hello, adding renegotiation extension" \
2437 -c "found renegotiation extension" \
2438 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002439 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002440 -C "error" \
2441 -s "Extra-header:"
2442
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002443# Test for the "secure renegotation" extension only (no actual renegotiation)
2444
Paul Bakker539d9722015-02-08 16:18:35 +01002445requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002446run_test "Renego ext: gnutls server strict, client default" \
2447 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2448 "$P_CLI debug_level=3" \
2449 0 \
2450 -c "found renegotiation extension" \
2451 -C "error" \
2452 -c "HTTP/1.0 200 [Oo][Kk]"
2453
Paul Bakker539d9722015-02-08 16:18:35 +01002454requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002455run_test "Renego ext: gnutls server unsafe, client default" \
2456 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2457 "$P_CLI debug_level=3" \
2458 0 \
2459 -C "found renegotiation extension" \
2460 -C "error" \
2461 -c "HTTP/1.0 200 [Oo][Kk]"
2462
Paul Bakker539d9722015-02-08 16:18:35 +01002463requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002464run_test "Renego ext: gnutls server unsafe, client break legacy" \
2465 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2466 "$P_CLI debug_level=3 allow_legacy=-1" \
2467 1 \
2468 -C "found renegotiation extension" \
2469 -c "error" \
2470 -C "HTTP/1.0 200 [Oo][Kk]"
2471
Paul Bakker539d9722015-02-08 16:18:35 +01002472requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002473run_test "Renego ext: gnutls client strict, server default" \
2474 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002475 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002476 0 \
2477 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2478 -s "server hello, secure renegotiation extension"
2479
Paul Bakker539d9722015-02-08 16:18:35 +01002480requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002481run_test "Renego ext: gnutls client unsafe, server default" \
2482 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002483 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002484 0 \
2485 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2486 -S "server hello, secure renegotiation extension"
2487
Paul Bakker539d9722015-02-08 16:18:35 +01002488requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002489run_test "Renego ext: gnutls client unsafe, server break legacy" \
2490 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002491 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002492 1 \
2493 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2494 -S "server hello, secure renegotiation extension"
2495
Janos Follath0b242342016-02-17 10:11:21 +00002496# Tests for silently dropping trailing extra bytes in .der certificates
2497
2498requires_gnutls
2499run_test "DER format: no trailing bytes" \
2500 "$P_SRV crt_file=data_files/server5-der0.crt \
2501 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002502 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002503 0 \
2504 -c "Handshake was completed" \
2505
2506requires_gnutls
2507run_test "DER format: with a trailing zero byte" \
2508 "$P_SRV crt_file=data_files/server5-der1a.crt \
2509 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002510 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002511 0 \
2512 -c "Handshake was completed" \
2513
2514requires_gnutls
2515run_test "DER format: with a trailing random byte" \
2516 "$P_SRV crt_file=data_files/server5-der1b.crt \
2517 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002518 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002519 0 \
2520 -c "Handshake was completed" \
2521
2522requires_gnutls
2523run_test "DER format: with 2 trailing random bytes" \
2524 "$P_SRV crt_file=data_files/server5-der2.crt \
2525 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002526 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002527 0 \
2528 -c "Handshake was completed" \
2529
2530requires_gnutls
2531run_test "DER format: with 4 trailing random bytes" \
2532 "$P_SRV crt_file=data_files/server5-der4.crt \
2533 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002534 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002535 0 \
2536 -c "Handshake was completed" \
2537
2538requires_gnutls
2539run_test "DER format: with 8 trailing random bytes" \
2540 "$P_SRV crt_file=data_files/server5-der8.crt \
2541 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002542 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002543 0 \
2544 -c "Handshake was completed" \
2545
2546requires_gnutls
2547run_test "DER format: with 9 trailing random bytes" \
2548 "$P_SRV crt_file=data_files/server5-der9.crt \
2549 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002550 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002551 0 \
2552 -c "Handshake was completed" \
2553
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002554# Tests for auth_mode
2555
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002556run_test "Authentication: server badcert, client required" \
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=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002560 1 \
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
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002566run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002567 "$P_SRV crt_file=data_files/server5-badsign.crt \
2568 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002569 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002570 0 \
2571 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002572 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002573 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002574 -C "X509 - Certificate verification failed"
2575
Hanno Beckere6706e62017-05-15 16:05:15 +01002576run_test "Authentication: server goodcert, client optional, no trusted CA" \
2577 "$P_SRV" \
2578 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2579 0 \
2580 -c "x509_verify_cert() returned" \
2581 -c "! The certificate is not correctly signed by the trusted CA" \
2582 -c "! Certificate verification flags"\
2583 -C "! mbedtls_ssl_handshake returned" \
2584 -C "X509 - Certificate verification failed" \
2585 -C "SSL - No CA Chain is set, but required to operate"
2586
2587run_test "Authentication: server goodcert, client required, no trusted CA" \
2588 "$P_SRV" \
2589 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2590 1 \
2591 -c "x509_verify_cert() returned" \
2592 -c "! The certificate is not correctly signed by the trusted CA" \
2593 -c "! Certificate verification flags"\
2594 -c "! mbedtls_ssl_handshake returned" \
2595 -c "SSL - No CA Chain is set, but required to operate"
2596
2597# The purpose of the next two tests is to test the client's behaviour when receiving a server
2598# certificate with an unsupported elliptic curve. This should usually not happen because
2599# the client informs the server about the supported curves - it does, though, in the
2600# corner case of a static ECDH suite, because the server doesn't check the curve on that
2601# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2602# different means to have the server ignoring the client's supported curve list.
2603
2604requires_config_enabled MBEDTLS_ECP_C
2605run_test "Authentication: server ECDH p256v1, client required, 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=required 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 at earlier verification stage
2613
2614requires_config_enabled MBEDTLS_ECP_C
2615run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2616 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2617 crt_file=data_files/server5.ku-ka.crt" \
2618 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2619 1 \
2620 -c "bad certificate (EC key curve)"\
2621 -c "! Certificate verification flags"\
2622 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002624run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002625 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002626 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002627 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002628 0 \
2629 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002630 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002631 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002632 -C "X509 - Certificate verification failed"
2633
Simon Butcher99000142016-10-13 17:21:01 +01002634run_test "Authentication: client SHA256, server required" \
2635 "$P_SRV auth_mode=required" \
2636 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2637 key_file=data_files/server6.key \
2638 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2639 0 \
2640 -c "Supported Signature Algorithm found: 4," \
2641 -c "Supported Signature Algorithm found: 5,"
2642
2643run_test "Authentication: client SHA384, server required" \
2644 "$P_SRV auth_mode=required" \
2645 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2646 key_file=data_files/server6.key \
2647 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2648 0 \
2649 -c "Supported Signature Algorithm found: 4," \
2650 -c "Supported Signature Algorithm found: 5,"
2651
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002652requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2653run_test "Authentication: client has no cert, server required (SSLv3)" \
2654 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2655 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2656 key_file=data_files/server5.key" \
2657 1 \
2658 -S "skip write certificate request" \
2659 -C "skip parse certificate request" \
2660 -c "got a certificate request" \
2661 -c "got no certificate to send" \
2662 -S "x509_verify_cert() returned" \
2663 -s "client has no certificate" \
2664 -s "! mbedtls_ssl_handshake returned" \
2665 -c "! mbedtls_ssl_handshake returned" \
2666 -s "No client certification received from the client, but required by the authentication mode"
2667
2668run_test "Authentication: client has no cert, server required (TLS)" \
2669 "$P_SRV debug_level=3 auth_mode=required" \
2670 "$P_CLI debug_level=3 crt_file=none \
2671 key_file=data_files/server5.key" \
2672 1 \
2673 -S "skip write certificate request" \
2674 -C "skip parse certificate request" \
2675 -c "got a certificate request" \
2676 -c "= write certificate$" \
2677 -C "skip write certificate$" \
2678 -S "x509_verify_cert() returned" \
2679 -s "client has no certificate" \
2680 -s "! mbedtls_ssl_handshake returned" \
2681 -c "! mbedtls_ssl_handshake returned" \
2682 -s "No client certification received from the client, but required by the authentication mode"
2683
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002684run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002685 "$P_SRV debug_level=3 auth_mode=required" \
2686 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002687 key_file=data_files/server5.key" \
2688 1 \
2689 -S "skip write certificate request" \
2690 -C "skip parse certificate request" \
2691 -c "got a certificate request" \
2692 -C "skip write certificate" \
2693 -C "skip write certificate verify" \
2694 -S "skip parse certificate verify" \
2695 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002696 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002697 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002698 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002699 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002700 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002701# We don't check that the client receives the alert because it might
2702# detect that its write end of the connection is closed and abort
2703# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002704
Janos Follath89baba22017-04-10 14:34:35 +01002705run_test "Authentication: client cert not trusted, server required" \
2706 "$P_SRV debug_level=3 auth_mode=required" \
2707 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2708 key_file=data_files/server5.key" \
2709 1 \
2710 -S "skip write certificate request" \
2711 -C "skip parse certificate request" \
2712 -c "got a certificate request" \
2713 -C "skip write certificate" \
2714 -C "skip write certificate verify" \
2715 -S "skip parse certificate verify" \
2716 -s "x509_verify_cert() returned" \
2717 -s "! The certificate is not correctly signed by the trusted CA" \
2718 -s "! mbedtls_ssl_handshake returned" \
2719 -c "! mbedtls_ssl_handshake returned" \
2720 -s "X509 - Certificate verification failed"
2721
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002722run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002723 "$P_SRV debug_level=3 auth_mode=optional" \
2724 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002725 key_file=data_files/server5.key" \
2726 0 \
2727 -S "skip write certificate request" \
2728 -C "skip parse certificate request" \
2729 -c "got a certificate request" \
2730 -C "skip write certificate" \
2731 -C "skip write certificate verify" \
2732 -S "skip parse certificate verify" \
2733 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002734 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002735 -S "! mbedtls_ssl_handshake returned" \
2736 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002737 -S "X509 - Certificate verification failed"
2738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002739run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002740 "$P_SRV debug_level=3 auth_mode=none" \
2741 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002742 key_file=data_files/server5.key" \
2743 0 \
2744 -s "skip write certificate request" \
2745 -C "skip parse certificate request" \
2746 -c "got no certificate request" \
2747 -c "skip write certificate" \
2748 -c "skip write certificate verify" \
2749 -s "skip parse certificate verify" \
2750 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002751 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002752 -S "! mbedtls_ssl_handshake returned" \
2753 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002754 -S "X509 - Certificate verification failed"
2755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002756run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002757 "$P_SRV debug_level=3 auth_mode=optional" \
2758 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002759 0 \
2760 -S "skip write certificate request" \
2761 -C "skip parse certificate request" \
2762 -c "got a certificate request" \
2763 -C "skip write certificate$" \
2764 -C "got no certificate to send" \
2765 -S "SSLv3 client has no certificate" \
2766 -c "skip write certificate verify" \
2767 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002768 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002769 -S "! mbedtls_ssl_handshake returned" \
2770 -C "! 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: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002774 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002775 "$O_CLI" \
2776 0 \
2777 -S "skip write certificate request" \
2778 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002779 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002780 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002781 -S "X509 - Certificate verification failed"
2782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002783run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002784 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002785 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002786 0 \
2787 -C "skip parse certificate request" \
2788 -c "got a certificate request" \
2789 -C "skip write certificate$" \
2790 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002791 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002792
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002793run_test "Authentication: client no cert, openssl server required" \
2794 "$O_SRV -Verify 10" \
2795 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2796 1 \
2797 -C "skip parse certificate request" \
2798 -c "got a certificate request" \
2799 -C "skip write certificate$" \
2800 -c "skip write certificate verify" \
2801 -c "! mbedtls_ssl_handshake returned"
2802
Janos Follathe2681a42016-03-07 15:57:05 +00002803requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002804run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002805 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002806 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002807 0 \
2808 -S "skip write certificate request" \
2809 -C "skip parse certificate request" \
2810 -c "got a certificate request" \
2811 -C "skip write certificate$" \
2812 -c "skip write certificate verify" \
2813 -c "got no certificate to send" \
2814 -s "SSLv3 client has no certificate" \
2815 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002816 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002817 -S "! mbedtls_ssl_handshake returned" \
2818 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002819 -S "X509 - Certificate verification failed"
2820
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002821# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2822# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002823
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002824MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002825MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002826
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002827if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002828 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002829 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002830 printf "test value of ${MAX_IM_CA}. \n"
2831 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002832 printf "The tests assume this value and if it changes, the tests in this\n"
2833 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002834 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002835
2836 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002837fi
2838
Angus Grattonc4dd0732018-04-11 16:28:39 +10002839requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002840run_test "Authentication: server max_int chain, client default" \
2841 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2842 key_file=data_files/dir-maxpath/09.key" \
2843 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2844 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002845 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002846
Angus Grattonc4dd0732018-04-11 16:28:39 +10002847requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002848run_test "Authentication: server max_int+1 chain, client default" \
2849 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2850 key_file=data_files/dir-maxpath/10.key" \
2851 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2852 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002853 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002854
Angus Grattonc4dd0732018-04-11 16:28:39 +10002855requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002856run_test "Authentication: server max_int+1 chain, client optional" \
2857 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2858 key_file=data_files/dir-maxpath/10.key" \
2859 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2860 auth_mode=optional" \
2861 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002862 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002863
Angus Grattonc4dd0732018-04-11 16:28:39 +10002864requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002865run_test "Authentication: server max_int+1 chain, client none" \
2866 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2867 key_file=data_files/dir-maxpath/10.key" \
2868 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2869 auth_mode=none" \
2870 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002871 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002872
Angus Grattonc4dd0732018-04-11 16:28:39 +10002873requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002874run_test "Authentication: client max_int+1 chain, server default" \
2875 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2876 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2877 key_file=data_files/dir-maxpath/10.key" \
2878 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002879 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002880
Angus Grattonc4dd0732018-04-11 16:28:39 +10002881requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002882run_test "Authentication: client max_int+1 chain, server optional" \
2883 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2884 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2885 key_file=data_files/dir-maxpath/10.key" \
2886 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002887 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002888
Angus Grattonc4dd0732018-04-11 16:28:39 +10002889requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002890run_test "Authentication: client max_int+1 chain, server required" \
2891 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2892 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2893 key_file=data_files/dir-maxpath/10.key" \
2894 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002895 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002896
Angus Grattonc4dd0732018-04-11 16:28:39 +10002897requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002898run_test "Authentication: client max_int chain, server required" \
2899 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2900 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2901 key_file=data_files/dir-maxpath/09.key" \
2902 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002903 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002904
Janos Follath89baba22017-04-10 14:34:35 +01002905# Tests for CA list in CertificateRequest messages
2906
2907run_test "Authentication: send CA list in CertificateRequest (default)" \
2908 "$P_SRV debug_level=3 auth_mode=required" \
2909 "$P_CLI crt_file=data_files/server6.crt \
2910 key_file=data_files/server6.key" \
2911 0 \
2912 -s "requested DN"
2913
2914run_test "Authentication: do not send CA list in CertificateRequest" \
2915 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2916 "$P_CLI crt_file=data_files/server6.crt \
2917 key_file=data_files/server6.key" \
2918 0 \
2919 -S "requested DN"
2920
2921run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2922 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2923 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2924 key_file=data_files/server5.key" \
2925 1 \
2926 -S "requested DN" \
2927 -s "x509_verify_cert() returned" \
2928 -s "! The certificate is not correctly signed by the trusted CA" \
2929 -s "! mbedtls_ssl_handshake returned" \
2930 -c "! mbedtls_ssl_handshake returned" \
2931 -s "X509 - Certificate verification failed"
2932
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002933# Tests for certificate selection based on SHA verson
2934
2935run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
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_2" \
2941 0 \
2942 -c "signed using.*ECDSA with SHA256" \
2943 -C "signed using.*ECDSA with SHA1"
2944
2945run_test "Certificate hash: client TLS 1.1 -> 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_1" \
2951 0 \
2952 -C "signed using.*ECDSA with SHA256" \
2953 -c "signed using.*ECDSA with SHA1"
2954
2955run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2956 "$P_SRV crt_file=data_files/server5.crt \
2957 key_file=data_files/server5.key \
2958 crt_file2=data_files/server5-sha1.crt \
2959 key_file2=data_files/server5.key" \
2960 "$P_CLI force_version=tls1" \
2961 0 \
2962 -C "signed using.*ECDSA with SHA256" \
2963 -c "signed using.*ECDSA with SHA1"
2964
2965run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2966 "$P_SRV crt_file=data_files/server5.crt \
2967 key_file=data_files/server5.key \
2968 crt_file2=data_files/server6.crt \
2969 key_file2=data_files/server6.key" \
2970 "$P_CLI force_version=tls1_1" \
2971 0 \
2972 -c "serial number.*09" \
2973 -c "signed using.*ECDSA with SHA256" \
2974 -C "signed using.*ECDSA with SHA1"
2975
2976run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2977 "$P_SRV crt_file=data_files/server6.crt \
2978 key_file=data_files/server6.key \
2979 crt_file2=data_files/server5.crt \
2980 key_file2=data_files/server5.key" \
2981 "$P_CLI force_version=tls1_1" \
2982 0 \
2983 -c "serial number.*0A" \
2984 -c "signed using.*ECDSA with SHA256" \
2985 -C "signed using.*ECDSA with SHA1"
2986
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002987# tests for SNI
2988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002989run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002990 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002991 crt_file=data_files/server5.crt key_file=data_files/server5.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 EC 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 1" \
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=localhost" \
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=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003007
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003008run_test "SNI: matching cert 2" \
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=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003013 0 \
3014 -s "parse ServerName extension" \
3015 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3016 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003018run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003019 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003020 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003021 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 +02003022 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003023 1 \
3024 -s "parse ServerName extension" \
3025 -s "ssl_sni_wrapper() returned" \
3026 -s "mbedtls_ssl_handshake returned" \
3027 -c "mbedtls_ssl_handshake returned" \
3028 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003029
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003030run_test "SNI: client auth no override: optional" \
3031 "$P_SRV debug_level=3 auth_mode=optional \
3032 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3033 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3034 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003035 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003036 -S "skip write certificate request" \
3037 -C "skip parse certificate request" \
3038 -c "got a certificate request" \
3039 -C "skip write certificate" \
3040 -C "skip write certificate verify" \
3041 -S "skip parse certificate verify"
3042
3043run_test "SNI: client auth override: none -> optional" \
3044 "$P_SRV debug_level=3 auth_mode=none \
3045 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3046 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3047 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003048 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003049 -S "skip write certificate request" \
3050 -C "skip parse certificate request" \
3051 -c "got a certificate request" \
3052 -C "skip write certificate" \
3053 -C "skip write certificate verify" \
3054 -S "skip parse certificate verify"
3055
3056run_test "SNI: client auth override: optional -> none" \
3057 "$P_SRV debug_level=3 auth_mode=optional \
3058 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3059 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3060 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003061 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003062 -s "skip write certificate request" \
3063 -C "skip parse certificate request" \
3064 -c "got no certificate request" \
3065 -c "skip write certificate" \
3066 -c "skip write certificate verify" \
3067 -s "skip parse certificate verify"
3068
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003069run_test "SNI: CA no override" \
3070 "$P_SRV debug_level=3 auth_mode=optional \
3071 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3072 ca_file=data_files/test-ca.crt \
3073 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3074 "$P_CLI debug_level=3 server_name=localhost \
3075 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3076 1 \
3077 -S "skip write certificate request" \
3078 -C "skip parse certificate request" \
3079 -c "got a certificate request" \
3080 -C "skip write certificate" \
3081 -C "skip write certificate verify" \
3082 -S "skip parse certificate verify" \
3083 -s "x509_verify_cert() returned" \
3084 -s "! The certificate is not correctly signed by the trusted CA" \
3085 -S "The certificate has been revoked (is on a CRL)"
3086
3087run_test "SNI: CA override" \
3088 "$P_SRV debug_level=3 auth_mode=optional \
3089 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3090 ca_file=data_files/test-ca.crt \
3091 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3092 "$P_CLI debug_level=3 server_name=localhost \
3093 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3094 0 \
3095 -S "skip write certificate request" \
3096 -C "skip parse certificate request" \
3097 -c "got a certificate request" \
3098 -C "skip write certificate" \
3099 -C "skip write certificate verify" \
3100 -S "skip parse certificate verify" \
3101 -S "x509_verify_cert() returned" \
3102 -S "! The certificate is not correctly signed by the trusted CA" \
3103 -S "The certificate has been revoked (is on a CRL)"
3104
3105run_test "SNI: CA override with CRL" \
3106 "$P_SRV debug_level=3 auth_mode=optional \
3107 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3108 ca_file=data_files/test-ca.crt \
3109 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3110 "$P_CLI debug_level=3 server_name=localhost \
3111 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3112 1 \
3113 -S "skip write certificate request" \
3114 -C "skip parse certificate request" \
3115 -c "got a certificate request" \
3116 -C "skip write certificate" \
3117 -C "skip write certificate verify" \
3118 -S "skip parse certificate verify" \
3119 -s "x509_verify_cert() returned" \
3120 -S "! The certificate is not correctly signed by the trusted CA" \
3121 -s "The certificate has been revoked (is on a CRL)"
3122
Andres AG1a834452016-12-07 10:01:30 +00003123# Tests for SNI and DTLS
3124
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003125run_test "SNI: DTLS, no SNI callback" \
3126 "$P_SRV debug_level=3 dtls=1 \
3127 crt_file=data_files/server5.crt key_file=data_files/server5.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 EC CA" \
3132 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3133
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003134run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003135 "$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=localhost 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=localhost"
3143
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003144run_test "SNI: DTLS, matching cert 2" \
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=polarssl.example dtls=1" \
3149 0 \
3150 -s "parse ServerName extension" \
3151 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3152 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3153
3154run_test "SNI: DTLS, no matching cert" \
3155 "$P_SRV debug_level=3 dtls=1 \
3156 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3157 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3158 "$P_CLI server_name=nonesuch.example dtls=1" \
3159 1 \
3160 -s "parse ServerName extension" \
3161 -s "ssl_sni_wrapper() returned" \
3162 -s "mbedtls_ssl_handshake returned" \
3163 -c "mbedtls_ssl_handshake returned" \
3164 -c "SSL - A fatal alert message was received from our peer"
3165
3166run_test "SNI: DTLS, client auth no override: optional" \
3167 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3168 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3169 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3170 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3171 0 \
3172 -S "skip write certificate request" \
3173 -C "skip parse certificate request" \
3174 -c "got a certificate request" \
3175 -C "skip write certificate" \
3176 -C "skip write certificate verify" \
3177 -S "skip parse certificate verify"
3178
3179run_test "SNI: DTLS, client auth override: none -> optional" \
3180 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3181 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3182 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3183 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3184 0 \
3185 -S "skip write certificate request" \
3186 -C "skip parse certificate request" \
3187 -c "got a certificate request" \
3188 -C "skip write certificate" \
3189 -C "skip write certificate verify" \
3190 -S "skip parse certificate verify"
3191
3192run_test "SNI: DTLS, client auth override: optional -> none" \
3193 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3194 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3195 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3196 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3197 0 \
3198 -s "skip write certificate request" \
3199 -C "skip parse certificate request" \
3200 -c "got no certificate request" \
3201 -c "skip write certificate" \
3202 -c "skip write certificate verify" \
3203 -s "skip parse certificate verify"
3204
3205run_test "SNI: DTLS, CA no override" \
3206 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3207 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3208 ca_file=data_files/test-ca.crt \
3209 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3210 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3211 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3212 1 \
3213 -S "skip write certificate request" \
3214 -C "skip parse certificate request" \
3215 -c "got a certificate request" \
3216 -C "skip write certificate" \
3217 -C "skip write certificate verify" \
3218 -S "skip parse certificate verify" \
3219 -s "x509_verify_cert() returned" \
3220 -s "! The certificate is not correctly signed by the trusted CA" \
3221 -S "The certificate has been revoked (is on a CRL)"
3222
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003223run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003224 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3225 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3226 ca_file=data_files/test-ca.crt \
3227 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3228 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3229 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3230 0 \
3231 -S "skip write certificate request" \
3232 -C "skip parse certificate request" \
3233 -c "got a certificate request" \
3234 -C "skip write certificate" \
3235 -C "skip write certificate verify" \
3236 -S "skip parse certificate verify" \
3237 -S "x509_verify_cert() returned" \
3238 -S "! The certificate is not correctly signed by the trusted CA" \
3239 -S "The certificate has been revoked (is on a CRL)"
3240
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003241run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003242 "$P_SRV debug_level=3 auth_mode=optional \
3243 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3244 ca_file=data_files/test-ca.crt \
3245 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3246 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3247 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3248 1 \
3249 -S "skip write certificate request" \
3250 -C "skip parse certificate request" \
3251 -c "got a certificate request" \
3252 -C "skip write certificate" \
3253 -C "skip write certificate verify" \
3254 -S "skip parse certificate verify" \
3255 -s "x509_verify_cert() returned" \
3256 -S "! The certificate is not correctly signed by the trusted CA" \
3257 -s "The certificate has been revoked (is on a CRL)"
3258
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003259# Tests for non-blocking I/O: exercise a variety of handshake flows
3260
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003261run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003262 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3263 "$P_CLI nbio=2 tickets=0" \
3264 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003265 -S "mbedtls_ssl_handshake returned" \
3266 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003267 -c "Read from server: .* bytes read"
3268
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003269run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003270 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3271 "$P_CLI nbio=2 tickets=0" \
3272 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003273 -S "mbedtls_ssl_handshake returned" \
3274 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003275 -c "Read from server: .* bytes read"
3276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003277run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003278 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3279 "$P_CLI nbio=2 tickets=1" \
3280 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003281 -S "mbedtls_ssl_handshake returned" \
3282 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003283 -c "Read from server: .* bytes read"
3284
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003285run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003286 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3287 "$P_CLI nbio=2 tickets=1" \
3288 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003289 -S "mbedtls_ssl_handshake returned" \
3290 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003291 -c "Read from server: .* bytes read"
3292
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003293run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003294 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3295 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3296 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003297 -S "mbedtls_ssl_handshake returned" \
3298 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003299 -c "Read from server: .* bytes read"
3300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003301run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003302 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3303 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3304 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003305 -S "mbedtls_ssl_handshake returned" \
3306 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003307 -c "Read from server: .* bytes read"
3308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003309run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003310 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3311 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3312 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003313 -S "mbedtls_ssl_handshake returned" \
3314 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003315 -c "Read from server: .* bytes read"
3316
Hanno Becker00076712017-11-15 16:39:08 +00003317# Tests for event-driven I/O: exercise a variety of handshake flows
3318
3319run_test "Event-driven I/O: basic handshake" \
3320 "$P_SRV event=1 tickets=0 auth_mode=none" \
3321 "$P_CLI event=1 tickets=0" \
3322 0 \
3323 -S "mbedtls_ssl_handshake returned" \
3324 -C "mbedtls_ssl_handshake returned" \
3325 -c "Read from server: .* bytes read"
3326
3327run_test "Event-driven I/O: client auth" \
3328 "$P_SRV event=1 tickets=0 auth_mode=required" \
3329 "$P_CLI event=1 tickets=0" \
3330 0 \
3331 -S "mbedtls_ssl_handshake returned" \
3332 -C "mbedtls_ssl_handshake returned" \
3333 -c "Read from server: .* bytes read"
3334
3335run_test "Event-driven I/O: ticket" \
3336 "$P_SRV event=1 tickets=1 auth_mode=none" \
3337 "$P_CLI event=1 tickets=1" \
3338 0 \
3339 -S "mbedtls_ssl_handshake returned" \
3340 -C "mbedtls_ssl_handshake returned" \
3341 -c "Read from server: .* bytes read"
3342
3343run_test "Event-driven I/O: ticket + client auth" \
3344 "$P_SRV event=1 tickets=1 auth_mode=required" \
3345 "$P_CLI event=1 tickets=1" \
3346 0 \
3347 -S "mbedtls_ssl_handshake returned" \
3348 -C "mbedtls_ssl_handshake returned" \
3349 -c "Read from server: .* bytes read"
3350
3351run_test "Event-driven I/O: ticket + client auth + resume" \
3352 "$P_SRV event=1 tickets=1 auth_mode=required" \
3353 "$P_CLI event=1 tickets=1 reconnect=1" \
3354 0 \
3355 -S "mbedtls_ssl_handshake returned" \
3356 -C "mbedtls_ssl_handshake returned" \
3357 -c "Read from server: .* bytes read"
3358
3359run_test "Event-driven I/O: ticket + resume" \
3360 "$P_SRV event=1 tickets=1 auth_mode=none" \
3361 "$P_CLI event=1 tickets=1 reconnect=1" \
3362 0 \
3363 -S "mbedtls_ssl_handshake returned" \
3364 -C "mbedtls_ssl_handshake returned" \
3365 -c "Read from server: .* bytes read"
3366
3367run_test "Event-driven I/O: session-id resume" \
3368 "$P_SRV event=1 tickets=0 auth_mode=none" \
3369 "$P_CLI event=1 tickets=0 reconnect=1" \
3370 0 \
3371 -S "mbedtls_ssl_handshake returned" \
3372 -C "mbedtls_ssl_handshake returned" \
3373 -c "Read from server: .* bytes read"
3374
Hanno Becker6a33f592018-03-13 11:38:46 +00003375run_test "Event-driven I/O, DTLS: basic handshake" \
3376 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3377 "$P_CLI dtls=1 event=1 tickets=0" \
3378 0 \
3379 -c "Read from server: .* bytes read"
3380
3381run_test "Event-driven I/O, DTLS: client auth" \
3382 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3383 "$P_CLI dtls=1 event=1 tickets=0" \
3384 0 \
3385 -c "Read from server: .* bytes read"
3386
3387run_test "Event-driven I/O, DTLS: ticket" \
3388 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3389 "$P_CLI dtls=1 event=1 tickets=1" \
3390 0 \
3391 -c "Read from server: .* bytes read"
3392
3393run_test "Event-driven I/O, DTLS: ticket + client auth" \
3394 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3395 "$P_CLI dtls=1 event=1 tickets=1" \
3396 0 \
3397 -c "Read from server: .* bytes read"
3398
3399run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3400 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003401 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003402 0 \
3403 -c "Read from server: .* bytes read"
3404
3405run_test "Event-driven I/O, DTLS: ticket + resume" \
3406 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003407 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003408 0 \
3409 -c "Read from server: .* bytes read"
3410
3411run_test "Event-driven I/O, DTLS: session-id resume" \
3412 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003413 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003414 0 \
3415 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003416
3417# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3418# During session resumption, the client will send its ApplicationData record
3419# within the same datagram as the Finished messages. In this situation, the
3420# server MUST NOT idle on the underlying transport after handshake completion,
3421# because the ApplicationData request has already been queued internally.
3422run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003423 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003424 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003425 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003426 0 \
3427 -c "Read from server: .* bytes read"
3428
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003429# Tests for version negotiation
3430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003431run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003432 "$P_SRV" \
3433 "$P_CLI" \
3434 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003435 -S "mbedtls_ssl_handshake returned" \
3436 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003437 -s "Protocol is TLSv1.2" \
3438 -c "Protocol is TLSv1.2"
3439
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003440run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003441 "$P_SRV" \
3442 "$P_CLI max_version=tls1_1" \
3443 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003444 -S "mbedtls_ssl_handshake returned" \
3445 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003446 -s "Protocol is TLSv1.1" \
3447 -c "Protocol is TLSv1.1"
3448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003449run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003450 "$P_SRV max_version=tls1_1" \
3451 "$P_CLI" \
3452 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003453 -S "mbedtls_ssl_handshake returned" \
3454 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003455 -s "Protocol is TLSv1.1" \
3456 -c "Protocol is TLSv1.1"
3457
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003458run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003459 "$P_SRV max_version=tls1_1" \
3460 "$P_CLI max_version=tls1_1" \
3461 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003462 -S "mbedtls_ssl_handshake returned" \
3463 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003464 -s "Protocol is TLSv1.1" \
3465 -c "Protocol is TLSv1.1"
3466
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003467run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003468 "$P_SRV min_version=tls1_1" \
3469 "$P_CLI max_version=tls1_1" \
3470 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003471 -S "mbedtls_ssl_handshake returned" \
3472 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003473 -s "Protocol is TLSv1.1" \
3474 -c "Protocol is TLSv1.1"
3475
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003476run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003477 "$P_SRV max_version=tls1_1" \
3478 "$P_CLI min_version=tls1_1" \
3479 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003480 -S "mbedtls_ssl_handshake returned" \
3481 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003482 -s "Protocol is TLSv1.1" \
3483 -c "Protocol is TLSv1.1"
3484
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003485run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003486 "$P_SRV max_version=tls1_1" \
3487 "$P_CLI min_version=tls1_2" \
3488 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003489 -s "mbedtls_ssl_handshake returned" \
3490 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003491 -c "SSL - Handshake protocol not within min/max boundaries"
3492
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003493run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003494 "$P_SRV min_version=tls1_2" \
3495 "$P_CLI max_version=tls1_1" \
3496 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003497 -s "mbedtls_ssl_handshake returned" \
3498 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003499 -s "SSL - Handshake protocol not within min/max boundaries"
3500
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003501# Tests for ALPN extension
3502
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003503run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003504 "$P_SRV debug_level=3" \
3505 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003506 0 \
3507 -C "client hello, adding alpn extension" \
3508 -S "found alpn extension" \
3509 -C "got an alert message, type: \\[2:120]" \
3510 -S "server hello, adding alpn extension" \
3511 -C "found alpn extension " \
3512 -C "Application Layer Protocol is" \
3513 -S "Application Layer Protocol is"
3514
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003515run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003516 "$P_SRV debug_level=3" \
3517 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003518 0 \
3519 -c "client hello, adding alpn extension" \
3520 -s "found alpn extension" \
3521 -C "got an alert message, type: \\[2:120]" \
3522 -S "server hello, adding alpn extension" \
3523 -C "found alpn extension " \
3524 -c "Application Layer Protocol is (none)" \
3525 -S "Application Layer Protocol is"
3526
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003527run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003528 "$P_SRV debug_level=3 alpn=abc,1234" \
3529 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003530 0 \
3531 -C "client hello, adding alpn extension" \
3532 -S "found alpn extension" \
3533 -C "got an alert message, type: \\[2:120]" \
3534 -S "server hello, adding alpn extension" \
3535 -C "found alpn extension " \
3536 -C "Application Layer Protocol is" \
3537 -s "Application Layer Protocol is (none)"
3538
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003539run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003540 "$P_SRV debug_level=3 alpn=abc,1234" \
3541 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003542 0 \
3543 -c "client hello, adding alpn extension" \
3544 -s "found alpn extension" \
3545 -C "got an alert message, type: \\[2:120]" \
3546 -s "server hello, adding alpn extension" \
3547 -c "found alpn extension" \
3548 -c "Application Layer Protocol is abc" \
3549 -s "Application Layer Protocol is abc"
3550
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003551run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003552 "$P_SRV debug_level=3 alpn=abc,1234" \
3553 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003554 0 \
3555 -c "client hello, adding alpn extension" \
3556 -s "found alpn extension" \
3557 -C "got an alert message, type: \\[2:120]" \
3558 -s "server hello, adding alpn extension" \
3559 -c "found alpn extension" \
3560 -c "Application Layer Protocol is abc" \
3561 -s "Application Layer Protocol is abc"
3562
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003563run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003564 "$P_SRV debug_level=3 alpn=abc,1234" \
3565 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003566 0 \
3567 -c "client hello, adding alpn extension" \
3568 -s "found alpn extension" \
3569 -C "got an alert message, type: \\[2:120]" \
3570 -s "server hello, adding alpn extension" \
3571 -c "found alpn extension" \
3572 -c "Application Layer Protocol is 1234" \
3573 -s "Application Layer Protocol is 1234"
3574
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003575run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003576 "$P_SRV debug_level=3 alpn=abc,123" \
3577 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003578 1 \
3579 -c "client hello, adding alpn extension" \
3580 -s "found alpn extension" \
3581 -c "got an alert message, type: \\[2:120]" \
3582 -S "server hello, adding alpn extension" \
3583 -C "found alpn extension" \
3584 -C "Application Layer Protocol is 1234" \
3585 -S "Application Layer Protocol is 1234"
3586
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003587
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003588# Tests for keyUsage in leaf certificates, part 1:
3589# server-side certificate/suite selection
3590
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003591run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003592 "$P_SRV key_file=data_files/server2.key \
3593 crt_file=data_files/server2.ku-ds.crt" \
3594 "$P_CLI" \
3595 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003596 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003597
3598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003599run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003600 "$P_SRV key_file=data_files/server2.key \
3601 crt_file=data_files/server2.ku-ke.crt" \
3602 "$P_CLI" \
3603 0 \
3604 -c "Ciphersuite is TLS-RSA-WITH-"
3605
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003606run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003607 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003608 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003609 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003610 1 \
3611 -C "Ciphersuite is "
3612
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003613run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003614 "$P_SRV key_file=data_files/server5.key \
3615 crt_file=data_files/server5.ku-ds.crt" \
3616 "$P_CLI" \
3617 0 \
3618 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3619
3620
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003621run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003622 "$P_SRV key_file=data_files/server5.key \
3623 crt_file=data_files/server5.ku-ka.crt" \
3624 "$P_CLI" \
3625 0 \
3626 -c "Ciphersuite is TLS-ECDH-"
3627
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003628run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003629 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003630 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003631 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003632 1 \
3633 -C "Ciphersuite is "
3634
3635# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003636# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003637
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003638run_test "keyUsage cli: DigitalSignature+KeyEncipherment, 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-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: DigitalSignature+KeyEncipherment, DHE-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-ds_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-DHE-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, RSA: OK" \
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-RSA-WITH-AES-128-CBC-SHA" \
3663 0 \
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é-Gonnard8e03c712014-08-30 21:42:40 +02003668run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003669 "$O_SRV -key data_files/server2.key \
3670 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003671 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003672 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3673 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003674 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003675 -c "Processing of the Certificate handshake message failed" \
3676 -C "Ciphersuite is TLS-"
3677
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003678run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3679 "$O_SRV -key data_files/server2.key \
3680 -cert data_files/server2.ku-ke.crt" \
3681 "$P_CLI debug_level=1 auth_mode=optional \
3682 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3683 0 \
3684 -c "bad certificate (usage extensions)" \
3685 -C "Processing of the Certificate handshake message failed" \
3686 -c "Ciphersuite is TLS-" \
3687 -c "! Usage does not match the keyUsage extension"
3688
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003689run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
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-DHE-RSA-WITH-AES-128-CBC-SHA" \
3694 0 \
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é-Gonnard8e03c712014-08-30 21:42:40 +02003699run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003700 "$O_SRV -key data_files/server2.key \
3701 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003702 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003703 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3704 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003705 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003706 -c "Processing of the Certificate handshake message failed" \
3707 -C "Ciphersuite is TLS-"
3708
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003709run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3710 "$O_SRV -key data_files/server2.key \
3711 -cert data_files/server2.ku-ds.crt" \
3712 "$P_CLI debug_level=1 auth_mode=optional \
3713 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3714 0 \
3715 -c "bad certificate (usage extensions)" \
3716 -C "Processing of the Certificate handshake message failed" \
3717 -c "Ciphersuite is TLS-" \
3718 -c "! Usage does not match the keyUsage extension"
3719
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003720# Tests for keyUsage in leaf certificates, part 3:
3721# server-side checking of client cert
3722
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003723run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003724 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003725 "$O_CLI -key data_files/server2.key \
3726 -cert data_files/server2.ku-ds.crt" \
3727 0 \
3728 -S "bad certificate (usage extensions)" \
3729 -S "Processing of the Certificate handshake message failed"
3730
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003731run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003732 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003733 "$O_CLI -key data_files/server2.key \
3734 -cert data_files/server2.ku-ke.crt" \
3735 0 \
3736 -s "bad certificate (usage extensions)" \
3737 -S "Processing of the Certificate handshake message failed"
3738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003739run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003740 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003741 "$O_CLI -key data_files/server2.key \
3742 -cert data_files/server2.ku-ke.crt" \
3743 1 \
3744 -s "bad certificate (usage extensions)" \
3745 -s "Processing of the Certificate handshake message failed"
3746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003747run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003748 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003749 "$O_CLI -key data_files/server5.key \
3750 -cert data_files/server5.ku-ds.crt" \
3751 0 \
3752 -S "bad certificate (usage extensions)" \
3753 -S "Processing of the Certificate handshake message failed"
3754
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003755run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003756 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003757 "$O_CLI -key data_files/server5.key \
3758 -cert data_files/server5.ku-ka.crt" \
3759 0 \
3760 -s "bad certificate (usage extensions)" \
3761 -S "Processing of the Certificate handshake message failed"
3762
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003763# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003765run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003766 "$P_SRV key_file=data_files/server5.key \
3767 crt_file=data_files/server5.eku-srv.crt" \
3768 "$P_CLI" \
3769 0
3770
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003771run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003772 "$P_SRV key_file=data_files/server5.key \
3773 crt_file=data_files/server5.eku-srv.crt" \
3774 "$P_CLI" \
3775 0
3776
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003777run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003778 "$P_SRV key_file=data_files/server5.key \
3779 crt_file=data_files/server5.eku-cs_any.crt" \
3780 "$P_CLI" \
3781 0
3782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003783run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003784 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003785 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003786 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003787 1
3788
3789# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3790
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003791run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003792 "$O_SRV -key data_files/server5.key \
3793 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003794 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003795 0 \
3796 -C "bad certificate (usage extensions)" \
3797 -C "Processing of the Certificate handshake message failed" \
3798 -c "Ciphersuite is TLS-"
3799
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003800run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003801 "$O_SRV -key data_files/server5.key \
3802 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003803 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003804 0 \
3805 -C "bad certificate (usage extensions)" \
3806 -C "Processing of the Certificate handshake message failed" \
3807 -c "Ciphersuite is TLS-"
3808
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003809run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003810 "$O_SRV -key data_files/server5.key \
3811 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003812 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003813 0 \
3814 -C "bad certificate (usage extensions)" \
3815 -C "Processing of the Certificate handshake message failed" \
3816 -c "Ciphersuite is TLS-"
3817
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003818run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003819 "$O_SRV -key data_files/server5.key \
3820 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003821 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003822 1 \
3823 -c "bad certificate (usage extensions)" \
3824 -c "Processing of the Certificate handshake message failed" \
3825 -C "Ciphersuite is TLS-"
3826
3827# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3828
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003829run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003830 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003831 "$O_CLI -key data_files/server5.key \
3832 -cert data_files/server5.eku-cli.crt" \
3833 0 \
3834 -S "bad certificate (usage extensions)" \
3835 -S "Processing of the Certificate handshake message failed"
3836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003837run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003838 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003839 "$O_CLI -key data_files/server5.key \
3840 -cert data_files/server5.eku-srv_cli.crt" \
3841 0 \
3842 -S "bad certificate (usage extensions)" \
3843 -S "Processing of the Certificate handshake message failed"
3844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003845run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003846 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003847 "$O_CLI -key data_files/server5.key \
3848 -cert data_files/server5.eku-cs_any.crt" \
3849 0 \
3850 -S "bad certificate (usage extensions)" \
3851 -S "Processing of the Certificate handshake message failed"
3852
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003853run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003854 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003855 "$O_CLI -key data_files/server5.key \
3856 -cert data_files/server5.eku-cs.crt" \
3857 0 \
3858 -s "bad certificate (usage extensions)" \
3859 -S "Processing of the Certificate handshake message failed"
3860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003861run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003862 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003863 "$O_CLI -key data_files/server5.key \
3864 -cert data_files/server5.eku-cs.crt" \
3865 1 \
3866 -s "bad certificate (usage extensions)" \
3867 -s "Processing of the Certificate handshake message failed"
3868
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003869# Tests for DHM parameters loading
3870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003871run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003872 "$P_SRV" \
3873 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3874 debug_level=3" \
3875 0 \
3876 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003877 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003879run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003880 "$P_SRV dhm_file=data_files/dhparams.pem" \
3881 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3882 debug_level=3" \
3883 0 \
3884 -c "value of 'DHM: P ' (1024 bits)" \
3885 -c "value of 'DHM: G ' (2 bits)"
3886
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003887# Tests for DHM client-side size checking
3888
3889run_test "DHM size: server default, client default, OK" \
3890 "$P_SRV" \
3891 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3892 debug_level=1" \
3893 0 \
3894 -C "DHM prime too short:"
3895
3896run_test "DHM size: server default, client 2048, OK" \
3897 "$P_SRV" \
3898 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3899 debug_level=1 dhmlen=2048" \
3900 0 \
3901 -C "DHM prime too short:"
3902
3903run_test "DHM size: server 1024, client default, OK" \
3904 "$P_SRV dhm_file=data_files/dhparams.pem" \
3905 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3906 debug_level=1" \
3907 0 \
3908 -C "DHM prime too short:"
3909
3910run_test "DHM size: server 1000, client default, rejected" \
3911 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3912 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3913 debug_level=1" \
3914 1 \
3915 -c "DHM prime too short:"
3916
3917run_test "DHM size: server default, client 2049, rejected" \
3918 "$P_SRV" \
3919 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3920 debug_level=1 dhmlen=2049" \
3921 1 \
3922 -c "DHM prime too short:"
3923
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003924# Tests for PSK callback
3925
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003926run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003927 "$P_SRV psk=abc123 psk_identity=foo" \
3928 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3929 psk_identity=foo psk=abc123" \
3930 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003931 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003932 -S "SSL - Unknown identity received" \
3933 -S "SSL - Verification of the message MAC failed"
3934
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003935run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003936 "$P_SRV" \
3937 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3938 psk_identity=foo psk=abc123" \
3939 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003940 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003941 -S "SSL - Unknown identity received" \
3942 -S "SSL - Verification of the message MAC failed"
3943
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003944run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003945 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3946 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3947 psk_identity=foo psk=abc123" \
3948 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003949 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003950 -s "SSL - Unknown identity received" \
3951 -S "SSL - Verification of the message MAC failed"
3952
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003953run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003954 "$P_SRV psk_list=abc,dead,def,beef" \
3955 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3956 psk_identity=abc psk=dead" \
3957 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003958 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003959 -S "SSL - Unknown identity received" \
3960 -S "SSL - Verification of the message MAC failed"
3961
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003962run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003963 "$P_SRV psk_list=abc,dead,def,beef" \
3964 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3965 psk_identity=def psk=beef" \
3966 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003967 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003968 -S "SSL - Unknown identity received" \
3969 -S "SSL - Verification of the message MAC failed"
3970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003971run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003972 "$P_SRV psk_list=abc,dead,def,beef" \
3973 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3974 psk_identity=ghi psk=beef" \
3975 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003976 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003977 -s "SSL - Unknown identity received" \
3978 -S "SSL - Verification of the message MAC failed"
3979
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003980run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003981 "$P_SRV psk_list=abc,dead,def,beef" \
3982 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3983 psk_identity=abc psk=beef" \
3984 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003985 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003986 -S "SSL - Unknown identity received" \
3987 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003988
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003989# Tests for EC J-PAKE
3990
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003991requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003992run_test "ECJPAKE: client not configured" \
3993 "$P_SRV debug_level=3" \
3994 "$P_CLI debug_level=3" \
3995 0 \
3996 -C "add ciphersuite: c0ff" \
3997 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003998 -S "found ecjpake kkpp extension" \
3999 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004000 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004001 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004002 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004003 -S "None of the common ciphersuites is usable"
4004
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004005requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004006run_test "ECJPAKE: server not configured" \
4007 "$P_SRV debug_level=3" \
4008 "$P_CLI debug_level=3 ecjpake_pw=bla \
4009 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4010 1 \
4011 -c "add ciphersuite: c0ff" \
4012 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004013 -s "found ecjpake kkpp extension" \
4014 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004015 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004016 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004017 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004018 -s "None of the common ciphersuites is usable"
4019
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004020requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004021run_test "ECJPAKE: working, TLS" \
4022 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4023 "$P_CLI debug_level=3 ecjpake_pw=bla \
4024 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004025 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004026 -c "add ciphersuite: c0ff" \
4027 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004028 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004029 -s "found ecjpake kkpp extension" \
4030 -S "skip ecjpake kkpp extension" \
4031 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004032 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004033 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004034 -S "None of the common ciphersuites is usable" \
4035 -S "SSL - Verification of the message MAC failed"
4036
Janos Follath74537a62016-09-02 13:45:28 +01004037server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004038requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004039run_test "ECJPAKE: password mismatch, TLS" \
4040 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4041 "$P_CLI debug_level=3 ecjpake_pw=bad \
4042 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4043 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004044 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004045 -s "SSL - Verification of the message MAC failed"
4046
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004047requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004048run_test "ECJPAKE: working, DTLS" \
4049 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4050 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4051 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4052 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004053 -c "re-using cached ecjpake parameters" \
4054 -S "SSL - Verification of the message MAC failed"
4055
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004056requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004057run_test "ECJPAKE: working, DTLS, no cookie" \
4058 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4059 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4060 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4061 0 \
4062 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004063 -S "SSL - Verification of the message MAC failed"
4064
Janos Follath74537a62016-09-02 13:45:28 +01004065server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004066requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004067run_test "ECJPAKE: password mismatch, DTLS" \
4068 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4069 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4070 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4071 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004072 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004073 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004074
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004075# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004076requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004077run_test "ECJPAKE: working, DTLS, nolog" \
4078 "$P_SRV dtls=1 ecjpake_pw=bla" \
4079 "$P_CLI dtls=1 ecjpake_pw=bla \
4080 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4081 0
4082
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004083# Tests for ciphersuites per version
4084
Janos Follathe2681a42016-03-07 15:57:05 +00004085requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004086requires_config_enabled MBEDTLS_CAMELLIA_C
4087requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004088run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004089 "$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 +02004090 "$P_CLI force_version=ssl3" \
4091 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004092 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004093
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004094requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4095requires_config_enabled MBEDTLS_CAMELLIA_C
4096requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004097run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004098 "$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 +01004099 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004100 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004101 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004102
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004103requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4104requires_config_enabled MBEDTLS_CAMELLIA_C
4105requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004106run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004107 "$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 +02004108 "$P_CLI force_version=tls1_1" \
4109 0 \
4110 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4111
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004112requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4113requires_config_enabled MBEDTLS_CAMELLIA_C
4114requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004115run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004116 "$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 +02004117 "$P_CLI force_version=tls1_2" \
4118 0 \
4119 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4120
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004121# Test for ClientHello without extensions
4122
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004123requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004124run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004125 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004126 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004127 0 \
4128 -s "dumping 'client hello extensions' (0 bytes)"
4129
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004130# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004131
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004132run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004133 "$P_SRV" \
4134 "$P_CLI request_size=100" \
4135 0 \
4136 -s "Read from client: 100 bytes read$"
4137
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004138run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004139 "$P_SRV" \
4140 "$P_CLI request_size=500" \
4141 0 \
4142 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004143
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004144# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004145
Janos Follathe2681a42016-03-07 15:57:05 +00004146requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004147run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004148 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004149 "$P_CLI request_size=1 force_version=ssl3 \
4150 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4151 0 \
4152 -s "Read from client: 1 bytes read"
4153
Janos Follathe2681a42016-03-07 15:57:05 +00004154requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004155run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004156 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004157 "$P_CLI request_size=1 force_version=ssl3 \
4158 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4159 0 \
4160 -s "Read from client: 1 bytes read"
4161
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004162run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004163 "$P_SRV" \
4164 "$P_CLI request_size=1 force_version=tls1 \
4165 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4166 0 \
4167 -s "Read from client: 1 bytes read"
4168
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004169run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004170 "$P_SRV" \
4171 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4172 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4173 0 \
4174 -s "Read from client: 1 bytes read"
4175
Hanno Becker32c55012017-11-10 08:42:54 +00004176requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004177run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004178 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004179 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004180 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004181 0 \
4182 -s "Read from client: 1 bytes read"
4183
Hanno Becker32c55012017-11-10 08:42:54 +00004184requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004185run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004186 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004187 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004188 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004189 0 \
4190 -s "Read from client: 1 bytes read"
4191
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004192run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004193 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004194 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004195 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4196 0 \
4197 -s "Read from client: 1 bytes read"
4198
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004199run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004200 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4201 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004202 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004203 0 \
4204 -s "Read from client: 1 bytes read"
4205
4206requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004207run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004208 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004209 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004210 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004211 0 \
4212 -s "Read from client: 1 bytes read"
4213
Hanno Becker8501f982017-11-10 08:59:04 +00004214requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004215run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004216 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4217 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4218 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004219 0 \
4220 -s "Read from client: 1 bytes read"
4221
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004222run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004223 "$P_SRV" \
4224 "$P_CLI request_size=1 force_version=tls1_1 \
4225 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4226 0 \
4227 -s "Read from client: 1 bytes read"
4228
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004229run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004230 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004231 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004232 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004233 0 \
4234 -s "Read from client: 1 bytes read"
4235
4236requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004237run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004238 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004239 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004240 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004241 0 \
4242 -s "Read from client: 1 bytes read"
4243
4244requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004245run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004246 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004247 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004248 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004249 0 \
4250 -s "Read from client: 1 bytes read"
4251
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004252run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004253 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004254 "$P_CLI request_size=1 force_version=tls1_1 \
4255 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4256 0 \
4257 -s "Read from client: 1 bytes read"
4258
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004259run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004260 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004261 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004262 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004263 0 \
4264 -s "Read from client: 1 bytes read"
4265
Hanno Becker8501f982017-11-10 08:59:04 +00004266requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004267run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004268 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004269 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004270 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004271 0 \
4272 -s "Read from client: 1 bytes read"
4273
Hanno Becker32c55012017-11-10 08:42:54 +00004274requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004275run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004276 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004277 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004278 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004279 0 \
4280 -s "Read from client: 1 bytes read"
4281
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004282run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004283 "$P_SRV" \
4284 "$P_CLI request_size=1 force_version=tls1_2 \
4285 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4286 0 \
4287 -s "Read from client: 1 bytes read"
4288
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004289run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004290 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004291 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004292 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004293 0 \
4294 -s "Read from client: 1 bytes read"
4295
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004296run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004297 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004298 "$P_CLI request_size=1 force_version=tls1_2 \
4299 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004300 0 \
4301 -s "Read from client: 1 bytes read"
4302
Hanno Becker32c55012017-11-10 08:42:54 +00004303requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004304run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004305 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004306 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004307 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004308 0 \
4309 -s "Read from client: 1 bytes read"
4310
Hanno Becker8501f982017-11-10 08:59:04 +00004311requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004312run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004313 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004314 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004315 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004316 0 \
4317 -s "Read from client: 1 bytes read"
4318
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004319run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004320 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004321 "$P_CLI request_size=1 force_version=tls1_2 \
4322 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4323 0 \
4324 -s "Read from client: 1 bytes read"
4325
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004326run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004327 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004328 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004329 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004330 0 \
4331 -s "Read from client: 1 bytes read"
4332
Hanno Becker32c55012017-11-10 08:42:54 +00004333requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004334run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004335 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004336 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004337 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004338 0 \
4339 -s "Read from client: 1 bytes read"
4340
Hanno Becker8501f982017-11-10 08:59:04 +00004341requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004342run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004343 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004344 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004345 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004346 0 \
4347 -s "Read from client: 1 bytes read"
4348
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004349run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004350 "$P_SRV" \
4351 "$P_CLI request_size=1 force_version=tls1_2 \
4352 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4353 0 \
4354 -s "Read from client: 1 bytes read"
4355
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004356run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004357 "$P_SRV" \
4358 "$P_CLI request_size=1 force_version=tls1_2 \
4359 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4360 0 \
4361 -s "Read from client: 1 bytes read"
4362
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004363# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004364
4365requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004366run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004367 "$P_SRV dtls=1 force_version=dtls1" \
4368 "$P_CLI dtls=1 request_size=1 \
4369 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4370 0 \
4371 -s "Read from client: 1 bytes read"
4372
4373requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004374run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004375 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4376 "$P_CLI dtls=1 request_size=1 \
4377 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4378 0 \
4379 -s "Read from client: 1 bytes read"
4380
4381requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4382requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004383run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004384 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4385 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004386 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4387 0 \
4388 -s "Read from client: 1 bytes read"
4389
4390requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4391requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004392run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004393 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004394 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004395 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004396 0 \
4397 -s "Read from client: 1 bytes read"
4398
4399requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004400run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004401 "$P_SRV dtls=1 force_version=dtls1_2" \
4402 "$P_CLI dtls=1 request_size=1 \
4403 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4404 0 \
4405 -s "Read from client: 1 bytes read"
4406
4407requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004408run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004409 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004410 "$P_CLI dtls=1 request_size=1 \
4411 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4412 0 \
4413 -s "Read from client: 1 bytes read"
4414
4415requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4416requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004417run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004418 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004419 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004420 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004421 0 \
4422 -s "Read from client: 1 bytes read"
4423
4424requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4425requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004426run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004427 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004428 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004429 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004430 0 \
4431 -s "Read from client: 1 bytes read"
4432
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004433# Tests for small server packets
4434
4435requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4436run_test "Small server packet SSLv3 BlockCipher" \
4437 "$P_SRV response_size=1 min_version=ssl3" \
4438 "$P_CLI force_version=ssl3 \
4439 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4440 0 \
4441 -c "Read from server: 1 bytes read"
4442
4443requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4444run_test "Small server packet SSLv3 StreamCipher" \
4445 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4446 "$P_CLI force_version=ssl3 \
4447 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4448 0 \
4449 -c "Read from server: 1 bytes read"
4450
4451run_test "Small server packet TLS 1.0 BlockCipher" \
4452 "$P_SRV response_size=1" \
4453 "$P_CLI force_version=tls1 \
4454 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4455 0 \
4456 -c "Read from server: 1 bytes read"
4457
4458run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4459 "$P_SRV response_size=1" \
4460 "$P_CLI force_version=tls1 etm=0 \
4461 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4462 0 \
4463 -c "Read from server: 1 bytes read"
4464
4465requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4466run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4467 "$P_SRV response_size=1 trunc_hmac=1" \
4468 "$P_CLI force_version=tls1 \
4469 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4470 0 \
4471 -c "Read from server: 1 bytes read"
4472
4473requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4474run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4475 "$P_SRV response_size=1 trunc_hmac=1" \
4476 "$P_CLI force_version=tls1 \
4477 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4478 0 \
4479 -c "Read from server: 1 bytes read"
4480
4481run_test "Small server packet TLS 1.0 StreamCipher" \
4482 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4483 "$P_CLI force_version=tls1 \
4484 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4485 0 \
4486 -c "Read from server: 1 bytes read"
4487
4488run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4489 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4490 "$P_CLI force_version=tls1 \
4491 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4492 0 \
4493 -c "Read from server: 1 bytes read"
4494
4495requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4496run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4497 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4498 "$P_CLI force_version=tls1 \
4499 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4500 0 \
4501 -c "Read from server: 1 bytes read"
4502
4503requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4504run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4505 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4506 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4507 trunc_hmac=1 etm=0" \
4508 0 \
4509 -c "Read from server: 1 bytes read"
4510
4511run_test "Small server packet TLS 1.1 BlockCipher" \
4512 "$P_SRV response_size=1" \
4513 "$P_CLI force_version=tls1_1 \
4514 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4515 0 \
4516 -c "Read from server: 1 bytes read"
4517
4518run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4519 "$P_SRV response_size=1" \
4520 "$P_CLI force_version=tls1_1 \
4521 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4522 0 \
4523 -c "Read from server: 1 bytes read"
4524
4525requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4526run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4527 "$P_SRV response_size=1 trunc_hmac=1" \
4528 "$P_CLI force_version=tls1_1 \
4529 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4530 0 \
4531 -c "Read from server: 1 bytes read"
4532
4533requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4534run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4535 "$P_SRV response_size=1 trunc_hmac=1" \
4536 "$P_CLI force_version=tls1_1 \
4537 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4538 0 \
4539 -c "Read from server: 1 bytes read"
4540
4541run_test "Small server packet TLS 1.1 StreamCipher" \
4542 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4543 "$P_CLI force_version=tls1_1 \
4544 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4545 0 \
4546 -c "Read from server: 1 bytes read"
4547
4548run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4549 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4550 "$P_CLI force_version=tls1_1 \
4551 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4552 0 \
4553 -c "Read from server: 1 bytes read"
4554
4555requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4556run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4557 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4558 "$P_CLI force_version=tls1_1 \
4559 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4560 0 \
4561 -c "Read from server: 1 bytes read"
4562
4563requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4564run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4565 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4566 "$P_CLI force_version=tls1_1 \
4567 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4568 0 \
4569 -c "Read from server: 1 bytes read"
4570
4571run_test "Small server packet TLS 1.2 BlockCipher" \
4572 "$P_SRV response_size=1" \
4573 "$P_CLI force_version=tls1_2 \
4574 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4575 0 \
4576 -c "Read from server: 1 bytes read"
4577
4578run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4579 "$P_SRV response_size=1" \
4580 "$P_CLI force_version=tls1_2 \
4581 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4582 0 \
4583 -c "Read from server: 1 bytes read"
4584
4585run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4586 "$P_SRV response_size=1" \
4587 "$P_CLI force_version=tls1_2 \
4588 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4589 0 \
4590 -c "Read from server: 1 bytes read"
4591
4592requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4593run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4594 "$P_SRV response_size=1 trunc_hmac=1" \
4595 "$P_CLI force_version=tls1_2 \
4596 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4597 0 \
4598 -c "Read from server: 1 bytes read"
4599
4600requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4601run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4602 "$P_SRV response_size=1 trunc_hmac=1" \
4603 "$P_CLI force_version=tls1_2 \
4604 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4605 0 \
4606 -c "Read from server: 1 bytes read"
4607
4608run_test "Small server packet TLS 1.2 StreamCipher" \
4609 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4610 "$P_CLI force_version=tls1_2 \
4611 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4612 0 \
4613 -c "Read from server: 1 bytes read"
4614
4615run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4616 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4617 "$P_CLI force_version=tls1_2 \
4618 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4619 0 \
4620 -c "Read from server: 1 bytes read"
4621
4622requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4623run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4624 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4625 "$P_CLI force_version=tls1_2 \
4626 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4627 0 \
4628 -c "Read from server: 1 bytes read"
4629
4630requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4631run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4632 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4633 "$P_CLI force_version=tls1_2 \
4634 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4635 0 \
4636 -c "Read from server: 1 bytes read"
4637
4638run_test "Small server packet TLS 1.2 AEAD" \
4639 "$P_SRV response_size=1" \
4640 "$P_CLI force_version=tls1_2 \
4641 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4642 0 \
4643 -c "Read from server: 1 bytes read"
4644
4645run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4646 "$P_SRV response_size=1" \
4647 "$P_CLI force_version=tls1_2 \
4648 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4649 0 \
4650 -c "Read from server: 1 bytes read"
4651
4652# Tests for small server packets in DTLS
4653
4654requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4655run_test "Small server packet DTLS 1.0" \
4656 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4657 "$P_CLI dtls=1 \
4658 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4659 0 \
4660 -c "Read from server: 1 bytes read"
4661
4662requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4663run_test "Small server packet DTLS 1.0, without EtM" \
4664 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4665 "$P_CLI dtls=1 \
4666 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4667 0 \
4668 -c "Read from server: 1 bytes read"
4669
4670requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4671requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4672run_test "Small server packet DTLS 1.0, truncated hmac" \
4673 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4674 "$P_CLI dtls=1 trunc_hmac=1 \
4675 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4676 0 \
4677 -c "Read from server: 1 bytes read"
4678
4679requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4680requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4681run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4682 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4683 "$P_CLI dtls=1 \
4684 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4685 0 \
4686 -c "Read from server: 1 bytes read"
4687
4688requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4689run_test "Small server packet DTLS 1.2" \
4690 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4691 "$P_CLI dtls=1 \
4692 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4693 0 \
4694 -c "Read from server: 1 bytes read"
4695
4696requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4697run_test "Small server packet DTLS 1.2, without EtM" \
4698 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4699 "$P_CLI dtls=1 \
4700 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4701 0 \
4702 -c "Read from server: 1 bytes read"
4703
4704requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4705requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4706run_test "Small server packet DTLS 1.2, truncated hmac" \
4707 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4708 "$P_CLI dtls=1 \
4709 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4710 0 \
4711 -c "Read from server: 1 bytes read"
4712
4713requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4714requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4715run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4716 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4717 "$P_CLI dtls=1 \
4718 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4719 0 \
4720 -c "Read from server: 1 bytes read"
4721
Janos Follath00efff72016-05-06 13:48:23 +01004722# A test for extensions in SSLv3
4723
4724requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4725run_test "SSLv3 with extensions, server side" \
4726 "$P_SRV min_version=ssl3 debug_level=3" \
4727 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4728 0 \
4729 -S "dumping 'client hello extensions'" \
4730 -S "server hello, total extension length:"
4731
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004732# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004733
Angus Grattonc4dd0732018-04-11 16:28:39 +10004734# How many fragments do we expect to write $1 bytes?
4735fragments_for_write() {
4736 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4737}
4738
Janos Follathe2681a42016-03-07 15:57:05 +00004739requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004740run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004741 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004742 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004743 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4744 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004745 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4746 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004747
Janos Follathe2681a42016-03-07 15:57:05 +00004748requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004749run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004750 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004751 "$P_CLI request_size=16384 force_version=ssl3 \
4752 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4753 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004754 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4755 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004756
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004757run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004758 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004759 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004760 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4761 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004762 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4763 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004764
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004765run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004766 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004767 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4768 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4769 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004770 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004771
Hanno Becker32c55012017-11-10 08:42:54 +00004772requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004773run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004774 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004775 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004776 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004777 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004778 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4779 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004780
Hanno Becker32c55012017-11-10 08:42:54 +00004781requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004782run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004783 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004784 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004785 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004786 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004787 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004788
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004789run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004790 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004791 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004792 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4793 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004794 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004795
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004796run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004797 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4798 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004799 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004800 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004801 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004802
4803requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004804run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004805 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004806 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004807 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004808 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004809 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004810
Hanno Becker278fc7a2017-11-10 09:16:28 +00004811requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004812run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004813 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004814 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004815 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004816 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004817 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4818 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004819
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004820run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004821 "$P_SRV" \
4822 "$P_CLI request_size=16384 force_version=tls1_1 \
4823 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4824 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004825 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4826 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004827
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004828run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004829 "$P_SRV" \
4830 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4831 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004832 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004833 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004834
Hanno Becker32c55012017-11-10 08:42:54 +00004835requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004836run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004837 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004838 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004839 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004840 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004841 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004842
Hanno Becker32c55012017-11-10 08:42:54 +00004843requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004844run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004845 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004846 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004847 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004848 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004849 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004850
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004851run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004852 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4853 "$P_CLI request_size=16384 force_version=tls1_1 \
4854 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4855 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004856 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4857 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004858
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004859run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004860 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004861 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004862 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004863 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004864 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4865 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004866
Hanno Becker278fc7a2017-11-10 09:16:28 +00004867requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004868run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004869 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004870 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004871 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004872 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004873 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004874
Hanno Becker278fc7a2017-11-10 09:16:28 +00004875requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004876run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004877 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004878 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004879 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004880 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004881 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4882 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004883
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004884run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004885 "$P_SRV" \
4886 "$P_CLI request_size=16384 force_version=tls1_2 \
4887 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4888 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004889 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4890 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004891
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004892run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004893 "$P_SRV" \
4894 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4895 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4896 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004897 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004898
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004899run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004900 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004901 "$P_CLI request_size=16384 force_version=tls1_2 \
4902 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004903 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004904 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4905 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004906
Hanno Becker32c55012017-11-10 08:42:54 +00004907requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004908run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004909 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004910 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004911 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004912 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004913 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004914
Hanno Becker278fc7a2017-11-10 09:16:28 +00004915requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004916run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004917 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004918 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004919 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004920 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004921 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4922 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004923
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004924run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004925 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004926 "$P_CLI request_size=16384 force_version=tls1_2 \
4927 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4928 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004929 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4930 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004931
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004932run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004933 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004934 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004935 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4936 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004937 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004938
Hanno Becker32c55012017-11-10 08:42:54 +00004939requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004940run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004941 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004942 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004943 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004944 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004945 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004946
Hanno Becker278fc7a2017-11-10 09:16:28 +00004947requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004948run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004949 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004950 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004951 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004952 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004953 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4954 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004955
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004956run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004957 "$P_SRV" \
4958 "$P_CLI request_size=16384 force_version=tls1_2 \
4959 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4960 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004961 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4962 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004963
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004964run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004965 "$P_SRV" \
4966 "$P_CLI request_size=16384 force_version=tls1_2 \
4967 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4968 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004969 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4970 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004971
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004972# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004973requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4974run_test "Large server packet SSLv3 StreamCipher" \
4975 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4976 "$P_CLI force_version=ssl3 \
4977 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4978 0 \
4979 -c "Read from server: 16384 bytes read"
4980
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004981# Checking next 4 tests logs for 1n-1 split against BEAST too
4982requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4983run_test "Large server packet SSLv3 BlockCipher" \
4984 "$P_SRV response_size=16384 min_version=ssl3" \
4985 "$P_CLI force_version=ssl3 recsplit=0 \
4986 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4987 0 \
4988 -c "Read from server: 1 bytes read"\
4989 -c "16383 bytes read"\
4990 -C "Read from server: 16384 bytes read"
4991
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004992run_test "Large server packet TLS 1.0 BlockCipher" \
4993 "$P_SRV response_size=16384" \
4994 "$P_CLI force_version=tls1 recsplit=0 \
4995 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4996 0 \
4997 -c "Read from server: 1 bytes read"\
4998 -c "16383 bytes read"\
4999 -C "Read from server: 16384 bytes read"
5000
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005001run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
5002 "$P_SRV response_size=16384" \
5003 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5004 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5005 0 \
5006 -c "Read from server: 1 bytes read"\
5007 -c "16383 bytes read"\
5008 -C "Read from server: 16384 bytes read"
5009
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005010requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5011run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5012 "$P_SRV response_size=16384" \
5013 "$P_CLI force_version=tls1 recsplit=0 \
5014 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5015 trunc_hmac=1" \
5016 0 \
5017 -c "Read from server: 1 bytes read"\
5018 -c "16383 bytes read"\
5019 -C "Read from server: 16384 bytes read"
5020
5021requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5022run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5023 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5024 "$P_CLI force_version=tls1 \
5025 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5026 trunc_hmac=1" \
5027 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005028 -s "16384 bytes written in 1 fragments" \
5029 -c "Read from server: 16384 bytes read"
5030
5031run_test "Large server packet TLS 1.0 StreamCipher" \
5032 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5033 "$P_CLI force_version=tls1 \
5034 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5035 0 \
5036 -s "16384 bytes written in 1 fragments" \
5037 -c "Read from server: 16384 bytes read"
5038
5039run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5040 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5041 "$P_CLI force_version=tls1 \
5042 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5043 0 \
5044 -s "16384 bytes written in 1 fragments" \
5045 -c "Read from server: 16384 bytes read"
5046
5047requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5048run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5049 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5050 "$P_CLI force_version=tls1 \
5051 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5052 0 \
5053 -s "16384 bytes written in 1 fragments" \
5054 -c "Read from server: 16384 bytes read"
5055
5056requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5057run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5058 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5059 "$P_CLI force_version=tls1 \
5060 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5061 0 \
5062 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005063 -c "Read from server: 16384 bytes read"
5064
5065run_test "Large server packet TLS 1.1 BlockCipher" \
5066 "$P_SRV response_size=16384" \
5067 "$P_CLI force_version=tls1_1 \
5068 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5069 0 \
5070 -c "Read from server: 16384 bytes read"
5071
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005072run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5073 "$P_SRV response_size=16384" \
5074 "$P_CLI force_version=tls1_1 etm=0 \
5075 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005076 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005077 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005078 -c "Read from server: 16384 bytes read"
5079
5080requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5081run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5082 "$P_SRV response_size=16384" \
5083 "$P_CLI force_version=tls1_1 \
5084 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5085 trunc_hmac=1" \
5086 0 \
5087 -c "Read from server: 16384 bytes read"
5088
5089requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005090run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5091 "$P_SRV response_size=16384 trunc_hmac=1" \
5092 "$P_CLI force_version=tls1_1 \
5093 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5094 0 \
5095 -s "16384 bytes written in 1 fragments" \
5096 -c "Read from server: 16384 bytes read"
5097
5098run_test "Large server packet TLS 1.1 StreamCipher" \
5099 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5100 "$P_CLI force_version=tls1_1 \
5101 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5102 0 \
5103 -c "Read from server: 16384 bytes read"
5104
5105run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5106 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5107 "$P_CLI force_version=tls1_1 \
5108 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5109 0 \
5110 -s "16384 bytes written in 1 fragments" \
5111 -c "Read from server: 16384 bytes read"
5112
5113requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005114run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5115 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5116 "$P_CLI force_version=tls1_1 \
5117 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5118 trunc_hmac=1" \
5119 0 \
5120 -c "Read from server: 16384 bytes read"
5121
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005122run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5123 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5124 "$P_CLI force_version=tls1_1 \
5125 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5126 0 \
5127 -s "16384 bytes written in 1 fragments" \
5128 -c "Read from server: 16384 bytes read"
5129
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005130run_test "Large server packet TLS 1.2 BlockCipher" \
5131 "$P_SRV response_size=16384" \
5132 "$P_CLI force_version=tls1_2 \
5133 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5134 0 \
5135 -c "Read from server: 16384 bytes read"
5136
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005137run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5138 "$P_SRV response_size=16384" \
5139 "$P_CLI force_version=tls1_2 etm=0 \
5140 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5141 0 \
5142 -s "16384 bytes written in 1 fragments" \
5143 -c "Read from server: 16384 bytes read"
5144
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005145run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5146 "$P_SRV response_size=16384" \
5147 "$P_CLI force_version=tls1_2 \
5148 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5149 0 \
5150 -c "Read from server: 16384 bytes read"
5151
5152requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5153run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5154 "$P_SRV response_size=16384" \
5155 "$P_CLI force_version=tls1_2 \
5156 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5157 trunc_hmac=1" \
5158 0 \
5159 -c "Read from server: 16384 bytes read"
5160
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005161run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5162 "$P_SRV response_size=16384 trunc_hmac=1" \
5163 "$P_CLI force_version=tls1_2 \
5164 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5165 0 \
5166 -s "16384 bytes written in 1 fragments" \
5167 -c "Read from server: 16384 bytes read"
5168
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005169run_test "Large server packet TLS 1.2 StreamCipher" \
5170 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5171 "$P_CLI force_version=tls1_2 \
5172 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5173 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005174 -s "16384 bytes written in 1 fragments" \
5175 -c "Read from server: 16384 bytes read"
5176
5177run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5178 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5179 "$P_CLI force_version=tls1_2 \
5180 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5181 0 \
5182 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005183 -c "Read from server: 16384 bytes read"
5184
5185requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5186run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5187 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5188 "$P_CLI force_version=tls1_2 \
5189 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5190 trunc_hmac=1" \
5191 0 \
5192 -c "Read from server: 16384 bytes read"
5193
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005194requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5195run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5196 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5197 "$P_CLI force_version=tls1_2 \
5198 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5199 0 \
5200 -s "16384 bytes written in 1 fragments" \
5201 -c "Read from server: 16384 bytes read"
5202
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005203run_test "Large server packet TLS 1.2 AEAD" \
5204 "$P_SRV response_size=16384" \
5205 "$P_CLI force_version=tls1_2 \
5206 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5207 0 \
5208 -c "Read from server: 16384 bytes read"
5209
5210run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5211 "$P_SRV response_size=16384" \
5212 "$P_CLI force_version=tls1_2 \
5213 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5214 0 \
5215 -c "Read from server: 16384 bytes read"
5216
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005217# Tests for restartable ECC
5218
5219requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5220run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005221 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005222 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005223 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005224 debug_level=1" \
5225 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005226 -C "x509_verify_cert.*4b00" \
5227 -C "mbedtls_pk_verify.*4b00" \
5228 -C "mbedtls_ecdh_make_public.*4b00" \
5229 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005230
5231requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5232run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005233 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005234 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005235 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005236 debug_level=1 ec_max_ops=0" \
5237 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005238 -C "x509_verify_cert.*4b00" \
5239 -C "mbedtls_pk_verify.*4b00" \
5240 -C "mbedtls_ecdh_make_public.*4b00" \
5241 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005242
5243requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5244run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005245 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005246 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005247 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005248 debug_level=1 ec_max_ops=65535" \
5249 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005250 -C "x509_verify_cert.*4b00" \
5251 -C "mbedtls_pk_verify.*4b00" \
5252 -C "mbedtls_ecdh_make_public.*4b00" \
5253 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005254
5255requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5256run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005257 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005258 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005259 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005260 debug_level=1 ec_max_ops=1000" \
5261 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005262 -c "x509_verify_cert.*4b00" \
5263 -c "mbedtls_pk_verify.*4b00" \
5264 -c "mbedtls_ecdh_make_public.*4b00" \
5265 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005266
5267requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005268run_test "EC restart: TLS, max_ops=1000, badsign" \
5269 "$P_SRV auth_mode=required \
5270 crt_file=data_files/server5-badsign.crt \
5271 key_file=data_files/server5.key" \
5272 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5273 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5274 debug_level=1 ec_max_ops=1000" \
5275 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005276 -c "x509_verify_cert.*4b00" \
5277 -C "mbedtls_pk_verify.*4b00" \
5278 -C "mbedtls_ecdh_make_public.*4b00" \
5279 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005280 -c "! The certificate is not correctly signed by the trusted CA" \
5281 -c "! mbedtls_ssl_handshake returned" \
5282 -c "X509 - Certificate verification failed"
5283
5284requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5285run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5286 "$P_SRV auth_mode=required \
5287 crt_file=data_files/server5-badsign.crt \
5288 key_file=data_files/server5.key" \
5289 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5290 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5291 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5292 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005293 -c "x509_verify_cert.*4b00" \
5294 -c "mbedtls_pk_verify.*4b00" \
5295 -c "mbedtls_ecdh_make_public.*4b00" \
5296 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005297 -c "! The certificate is not correctly signed by the trusted CA" \
5298 -C "! mbedtls_ssl_handshake returned" \
5299 -C "X509 - Certificate verification failed"
5300
5301requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5302run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5303 "$P_SRV auth_mode=required \
5304 crt_file=data_files/server5-badsign.crt \
5305 key_file=data_files/server5.key" \
5306 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5307 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5308 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5309 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005310 -C "x509_verify_cert.*4b00" \
5311 -c "mbedtls_pk_verify.*4b00" \
5312 -c "mbedtls_ecdh_make_public.*4b00" \
5313 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005314 -C "! The certificate is not correctly signed by the trusted CA" \
5315 -C "! mbedtls_ssl_handshake returned" \
5316 -C "X509 - Certificate verification failed"
5317
5318requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005319run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005320 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005321 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005322 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005323 dtls=1 debug_level=1 ec_max_ops=1000" \
5324 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005325 -c "x509_verify_cert.*4b00" \
5326 -c "mbedtls_pk_verify.*4b00" \
5327 -c "mbedtls_ecdh_make_public.*4b00" \
5328 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005329
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005330requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5331run_test "EC restart: TLS, max_ops=1000 no client auth" \
5332 "$P_SRV" \
5333 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5334 debug_level=1 ec_max_ops=1000" \
5335 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005336 -c "x509_verify_cert.*4b00" \
5337 -c "mbedtls_pk_verify.*4b00" \
5338 -c "mbedtls_ecdh_make_public.*4b00" \
5339 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005340
5341requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5342run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5343 "$P_SRV psk=abc123" \
5344 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5345 psk=abc123 debug_level=1 ec_max_ops=1000" \
5346 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005347 -C "x509_verify_cert.*4b00" \
5348 -C "mbedtls_pk_verify.*4b00" \
5349 -C "mbedtls_ecdh_make_public.*4b00" \
5350 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005351
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005352# Tests of asynchronous private key support in SSL
5353
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005354requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005355run_test "SSL async private: sign, delay=0" \
5356 "$P_SRV \
5357 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005358 "$P_CLI" \
5359 0 \
5360 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005361 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005362
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005363requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005364run_test "SSL async private: sign, delay=1" \
5365 "$P_SRV \
5366 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005367 "$P_CLI" \
5368 0 \
5369 -s "Async sign callback: using key slot " \
5370 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005371 -s "Async resume (slot [0-9]): sign done, status=0"
5372
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005373requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5374run_test "SSL async private: sign, delay=2" \
5375 "$P_SRV \
5376 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5377 "$P_CLI" \
5378 0 \
5379 -s "Async sign callback: using key slot " \
5380 -U "Async sign callback: using key slot " \
5381 -s "Async resume (slot [0-9]): call 1 more times." \
5382 -s "Async resume (slot [0-9]): call 0 more times." \
5383 -s "Async resume (slot [0-9]): sign done, status=0"
5384
Gilles Peskined3268832018-04-26 06:23:59 +02005385# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5386# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5387requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5388requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5389run_test "SSL async private: sign, RSA, TLS 1.1" \
5390 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5391 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5392 "$P_CLI force_version=tls1_1" \
5393 0 \
5394 -s "Async sign callback: using key slot " \
5395 -s "Async resume (slot [0-9]): sign done, status=0"
5396
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005397requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005398run_test "SSL async private: sign, SNI" \
5399 "$P_SRV debug_level=3 \
5400 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5401 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5402 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5403 "$P_CLI server_name=polarssl.example" \
5404 0 \
5405 -s "Async sign callback: using key slot " \
5406 -s "Async resume (slot [0-9]): sign done, status=0" \
5407 -s "parse ServerName extension" \
5408 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5409 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5410
5411requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005412run_test "SSL async private: decrypt, delay=0" \
5413 "$P_SRV \
5414 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5415 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5416 0 \
5417 -s "Async decrypt callback: using key slot " \
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, delay=1" \
5422 "$P_SRV \
5423 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5424 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5425 0 \
5426 -s "Async decrypt callback: using key slot " \
5427 -s "Async resume (slot [0-9]): call 0 more times." \
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=0" \
5432 "$P_SRV psk=abc123 \
5433 async_operations=d async_private_delay1=0 async_private_delay2=0" \
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]): decrypt done, status=0"
5439
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005440requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005441run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5442 "$P_SRV psk=abc123 \
5443 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5444 "$P_CLI psk=abc123 \
5445 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5446 0 \
5447 -s "Async decrypt callback: using key slot " \
5448 -s "Async resume (slot [0-9]): call 0 more times." \
5449 -s "Async resume (slot [0-9]): decrypt done, status=0"
5450
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005451requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005452run_test "SSL async private: sign callback not present" \
5453 "$P_SRV \
5454 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5455 "$P_CLI; [ \$? -eq 1 ] &&
5456 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5457 0 \
5458 -S "Async sign callback" \
5459 -s "! mbedtls_ssl_handshake returned" \
5460 -s "The own private key or pre-shared key is not set, but needed" \
5461 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5462 -s "Successful connection"
5463
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005464requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005465run_test "SSL async private: decrypt callback not present" \
5466 "$P_SRV debug_level=1 \
5467 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5468 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5469 [ \$? -eq 1 ] && $P_CLI" \
5470 0 \
5471 -S "Async decrypt callback" \
5472 -s "! mbedtls_ssl_handshake returned" \
5473 -s "got no RSA private key" \
5474 -s "Async resume (slot [0-9]): sign done, status=0" \
5475 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005476
5477# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005478requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005479run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005480 "$P_SRV \
5481 async_operations=s async_private_delay1=1 \
5482 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5483 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005484 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5485 0 \
5486 -s "Async sign callback: using key slot 0," \
5487 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005488 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005489
5490# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005491requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005492run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005493 "$P_SRV \
5494 async_operations=s async_private_delay2=1 \
5495 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5496 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005497 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5498 0 \
5499 -s "Async sign callback: using key slot 0," \
5500 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005501 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005502
5503# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005504requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005505run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005506 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005507 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005508 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5509 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005510 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5511 0 \
5512 -s "Async sign callback: using key slot 1," \
5513 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005514 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005515
5516# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005517requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005518run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005519 "$P_SRV \
5520 async_operations=s async_private_delay1=1 \
5521 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5522 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005523 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5524 0 \
5525 -s "Async sign callback: no key matches this certificate."
5526
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005527requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005528run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005529 "$P_SRV \
5530 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5531 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005532 "$P_CLI" \
5533 1 \
5534 -s "Async sign callback: injected error" \
5535 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005536 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005537 -s "! mbedtls_ssl_handshake returned"
5538
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005539requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005540run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005541 "$P_SRV \
5542 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5543 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005544 "$P_CLI" \
5545 1 \
5546 -s "Async sign callback: using key slot " \
5547 -S "Async resume" \
5548 -s "Async cancel"
5549
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005550requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005551run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005552 "$P_SRV \
5553 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5554 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005555 "$P_CLI" \
5556 1 \
5557 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005558 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005559 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005560 -s "! mbedtls_ssl_handshake returned"
5561
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005562requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005563run_test "SSL async private: decrypt, error in start" \
5564 "$P_SRV \
5565 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5566 async_private_error=1" \
5567 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5568 1 \
5569 -s "Async decrypt callback: injected error" \
5570 -S "Async resume" \
5571 -S "Async cancel" \
5572 -s "! mbedtls_ssl_handshake returned"
5573
5574requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5575run_test "SSL async private: decrypt, cancel after start" \
5576 "$P_SRV \
5577 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5578 async_private_error=2" \
5579 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5580 1 \
5581 -s "Async decrypt callback: using key slot " \
5582 -S "Async resume" \
5583 -s "Async cancel"
5584
5585requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5586run_test "SSL async private: decrypt, error in resume" \
5587 "$P_SRV \
5588 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5589 async_private_error=3" \
5590 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5591 1 \
5592 -s "Async decrypt callback: using key slot " \
5593 -s "Async resume callback: decrypt done but injected error" \
5594 -S "Async cancel" \
5595 -s "! mbedtls_ssl_handshake returned"
5596
5597requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005598run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005599 "$P_SRV \
5600 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5601 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005602 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5603 0 \
5604 -s "Async cancel" \
5605 -s "! mbedtls_ssl_handshake returned" \
5606 -s "Async resume" \
5607 -s "Successful connection"
5608
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005609requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005610run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005611 "$P_SRV \
5612 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5613 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005614 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5615 0 \
5616 -s "! mbedtls_ssl_handshake returned" \
5617 -s "Async resume" \
5618 -s "Successful connection"
5619
5620# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005621requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005622run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005623 "$P_SRV \
5624 async_operations=s async_private_delay1=1 async_private_error=-2 \
5625 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5626 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005627 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5628 [ \$? -eq 1 ] &&
5629 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5630 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005631 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005632 -S "Async resume" \
5633 -s "Async cancel" \
5634 -s "! mbedtls_ssl_handshake returned" \
5635 -s "Async sign callback: no key matches this certificate." \
5636 -s "Successful connection"
5637
5638# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005639requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005640run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005641 "$P_SRV \
5642 async_operations=s async_private_delay1=1 async_private_error=-3 \
5643 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5644 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005645 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5646 [ \$? -eq 1 ] &&
5647 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5648 0 \
5649 -s "Async resume" \
5650 -s "! mbedtls_ssl_handshake returned" \
5651 -s "Async sign callback: no key matches this certificate." \
5652 -s "Successful connection"
5653
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005654requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005655requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005656run_test "SSL async private: renegotiation: client-initiated; sign" \
5657 "$P_SRV \
5658 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005659 exchanges=2 renegotiation=1" \
5660 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5661 0 \
5662 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005663 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005664
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005665requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005666requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005667run_test "SSL async private: renegotiation: server-initiated; sign" \
5668 "$P_SRV \
5669 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005670 exchanges=2 renegotiation=1 renegotiate=1" \
5671 "$P_CLI exchanges=2 renegotiation=1" \
5672 0 \
5673 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005674 -s "Async resume (slot [0-9]): sign done, status=0"
5675
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005676requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005677requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5678run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5679 "$P_SRV \
5680 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5681 exchanges=2 renegotiation=1" \
5682 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5683 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5684 0 \
5685 -s "Async decrypt callback: using key slot " \
5686 -s "Async resume (slot [0-9]): decrypt done, status=0"
5687
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005688requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005689requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5690run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5691 "$P_SRV \
5692 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5693 exchanges=2 renegotiation=1 renegotiate=1" \
5694 "$P_CLI exchanges=2 renegotiation=1 \
5695 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5696 0 \
5697 -s "Async decrypt callback: using key slot " \
5698 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005699
Ron Eldor58093c82018-06-28 13:22:05 +03005700# Tests for ECC extensions (rfc 4492)
5701
Ron Eldor643df7c2018-06-28 16:17:00 +03005702requires_config_enabled MBEDTLS_AES_C
5703requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5704requires_config_enabled MBEDTLS_SHA256_C
5705requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005706run_test "Force a non ECC ciphersuite in the client side" \
5707 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005708 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005709 0 \
5710 -C "client hello, adding supported_elliptic_curves extension" \
5711 -C "client hello, adding supported_point_formats extension" \
5712 -S "found supported elliptic curves extension" \
5713 -S "found supported point formats extension"
5714
Ron Eldor643df7c2018-06-28 16:17:00 +03005715requires_config_enabled MBEDTLS_AES_C
5716requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5717requires_config_enabled MBEDTLS_SHA256_C
5718requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005719run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005720 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005721 "$P_CLI debug_level=3" \
5722 0 \
5723 -C "found supported_point_formats extension" \
5724 -S "server hello, supported_point_formats extension"
5725
Ron Eldor643df7c2018-06-28 16:17:00 +03005726requires_config_enabled MBEDTLS_AES_C
5727requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5728requires_config_enabled MBEDTLS_SHA256_C
5729requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005730run_test "Force an ECC ciphersuite in the client side" \
5731 "$P_SRV debug_level=3" \
5732 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5733 0 \
5734 -c "client hello, adding supported_elliptic_curves extension" \
5735 -c "client hello, adding supported_point_formats extension" \
5736 -s "found supported elliptic curves extension" \
5737 -s "found supported point formats extension"
5738
Ron Eldor643df7c2018-06-28 16:17:00 +03005739requires_config_enabled MBEDTLS_AES_C
5740requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5741requires_config_enabled MBEDTLS_SHA256_C
5742requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005743run_test "Force an ECC ciphersuite in the server side" \
5744 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5745 "$P_CLI debug_level=3" \
5746 0 \
5747 -c "found supported_point_formats extension" \
5748 -s "server hello, supported_point_formats extension"
5749
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005750# Tests for DTLS HelloVerifyRequest
5751
5752run_test "DTLS cookie: enabled" \
5753 "$P_SRV dtls=1 debug_level=2" \
5754 "$P_CLI dtls=1 debug_level=2" \
5755 0 \
5756 -s "cookie verification failed" \
5757 -s "cookie verification passed" \
5758 -S "cookie verification skipped" \
5759 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005760 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005761 -S "SSL - The requested feature is not available"
5762
5763run_test "DTLS cookie: disabled" \
5764 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5765 "$P_CLI dtls=1 debug_level=2" \
5766 0 \
5767 -S "cookie verification failed" \
5768 -S "cookie verification passed" \
5769 -s "cookie verification skipped" \
5770 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005771 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005772 -S "SSL - The requested feature is not available"
5773
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005774run_test "DTLS cookie: default (failing)" \
5775 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5776 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5777 1 \
5778 -s "cookie verification failed" \
5779 -S "cookie verification passed" \
5780 -S "cookie verification skipped" \
5781 -C "received hello verify request" \
5782 -S "hello verification requested" \
5783 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005784
5785requires_ipv6
5786run_test "DTLS cookie: enabled, IPv6" \
5787 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5788 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5789 0 \
5790 -s "cookie verification failed" \
5791 -s "cookie verification passed" \
5792 -S "cookie verification skipped" \
5793 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005794 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005795 -S "SSL - The requested feature is not available"
5796
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005797run_test "DTLS cookie: enabled, nbio" \
5798 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5799 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5800 0 \
5801 -s "cookie verification failed" \
5802 -s "cookie verification passed" \
5803 -S "cookie verification skipped" \
5804 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005805 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005806 -S "SSL - The requested feature is not available"
5807
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005808# Tests for client reconnecting from the same port with DTLS
5809
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005810not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005811run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005812 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5813 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005814 0 \
5815 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005816 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005817 -S "Client initiated reconnection from same port"
5818
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005819not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005820run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005821 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5822 "$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 +02005823 0 \
5824 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005825 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005826 -s "Client initiated reconnection from same port"
5827
Paul Bakker362689d2016-05-13 10:33:25 +01005828not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5829run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005830 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5831 "$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 +02005832 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005833 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005834 -s "Client initiated reconnection from same port"
5835
Paul Bakker362689d2016-05-13 10:33:25 +01005836only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5837run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5838 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5839 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5840 0 \
5841 -S "The operation timed out" \
5842 -s "Client initiated reconnection from same port"
5843
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005844run_test "DTLS client reconnect from same port: no cookies" \
5845 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005846 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5847 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005848 -s "The operation timed out" \
5849 -S "Client initiated reconnection from same port"
5850
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005851run_test "DTLS client reconnect from same port: attacker-injected" \
5852 -p "$P_PXY inject_clihlo=1" \
5853 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5854 "$P_CLI dtls=1 exchanges=2" \
5855 0 \
5856 -s "possible client reconnect from the same port" \
5857 -S "Client initiated reconnection from same port"
5858
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005859# Tests for various cases of client authentication with DTLS
5860# (focused on handshake flows and message parsing)
5861
5862run_test "DTLS client auth: required" \
5863 "$P_SRV dtls=1 auth_mode=required" \
5864 "$P_CLI dtls=1" \
5865 0 \
5866 -s "Verifying peer X.509 certificate... ok"
5867
5868run_test "DTLS client auth: optional, client has no cert" \
5869 "$P_SRV dtls=1 auth_mode=optional" \
5870 "$P_CLI dtls=1 crt_file=none key_file=none" \
5871 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005872 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005873
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005874run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005875 "$P_SRV dtls=1 auth_mode=none" \
5876 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5877 0 \
5878 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005879 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005880
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005881run_test "DTLS wrong PSK: badmac alert" \
5882 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5883 "$P_CLI dtls=1 psk=abc124" \
5884 1 \
5885 -s "SSL - Verification of the message MAC failed" \
5886 -c "SSL - A fatal alert message was received from our peer"
5887
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005888# Tests for receiving fragmented handshake messages with DTLS
5889
5890requires_gnutls
5891run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5892 "$G_SRV -u --mtu 2048 -a" \
5893 "$P_CLI dtls=1 debug_level=2" \
5894 0 \
5895 -C "found fragmented DTLS handshake message" \
5896 -C "error"
5897
5898requires_gnutls
5899run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5900 "$G_SRV -u --mtu 512" \
5901 "$P_CLI dtls=1 debug_level=2" \
5902 0 \
5903 -c "found fragmented DTLS handshake message" \
5904 -C "error"
5905
5906requires_gnutls
5907run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5908 "$G_SRV -u --mtu 128" \
5909 "$P_CLI dtls=1 debug_level=2" \
5910 0 \
5911 -c "found fragmented DTLS handshake message" \
5912 -C "error"
5913
5914requires_gnutls
5915run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5916 "$G_SRV -u --mtu 128" \
5917 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5918 0 \
5919 -c "found fragmented DTLS handshake message" \
5920 -C "error"
5921
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005922requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005923requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005924run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5925 "$G_SRV -u --mtu 256" \
5926 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5927 0 \
5928 -c "found fragmented DTLS handshake message" \
5929 -c "client hello, adding renegotiation extension" \
5930 -c "found renegotiation extension" \
5931 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005932 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005933 -C "error" \
5934 -s "Extra-header:"
5935
5936requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005937requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005938run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5939 "$G_SRV -u --mtu 256" \
5940 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5941 0 \
5942 -c "found fragmented DTLS handshake message" \
5943 -c "client hello, adding renegotiation extension" \
5944 -c "found renegotiation extension" \
5945 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005946 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005947 -C "error" \
5948 -s "Extra-header:"
5949
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005950run_test "DTLS reassembly: no fragmentation (openssl server)" \
5951 "$O_SRV -dtls1 -mtu 2048" \
5952 "$P_CLI dtls=1 debug_level=2" \
5953 0 \
5954 -C "found fragmented DTLS handshake message" \
5955 -C "error"
5956
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005957run_test "DTLS reassembly: some fragmentation (openssl server)" \
5958 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005959 "$P_CLI dtls=1 debug_level=2" \
5960 0 \
5961 -c "found fragmented DTLS handshake message" \
5962 -C "error"
5963
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005964run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005965 "$O_SRV -dtls1 -mtu 256" \
5966 "$P_CLI dtls=1 debug_level=2" \
5967 0 \
5968 -c "found fragmented DTLS handshake message" \
5969 -C "error"
5970
5971run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5972 "$O_SRV -dtls1 -mtu 256" \
5973 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5974 0 \
5975 -c "found fragmented DTLS handshake message" \
5976 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005977
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005978# Tests for sending fragmented handshake messages with DTLS
5979#
5980# Use client auth when we need the client to send large messages,
5981# and use large cert chains on both sides too (the long chains we have all use
5982# both RSA and ECDSA, but ideally we should have long chains with either).
5983# Sizes reached (UDP payload):
5984# - 2037B for server certificate
5985# - 1542B for client certificate
5986# - 1013B for newsessionticket
5987# - all others below 512B
5988# All those tests assume MAX_CONTENT_LEN is at least 2048
5989
5990requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5991requires_config_enabled MBEDTLS_RSA_C
5992requires_config_enabled MBEDTLS_ECDSA_C
5993requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
5994run_test "DTLS fragmenting: none (for reference)" \
5995 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5996 crt_file=data_files/server7_int-ca.crt \
5997 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005998 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005999 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006000 "$P_CLI dtls=1 debug_level=2 \
6001 crt_file=data_files/server8_int-ca2.crt \
6002 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006003 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006004 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006005 0 \
6006 -S "found fragmented DTLS handshake message" \
6007 -C "found fragmented DTLS handshake message" \
6008 -C "error"
6009
6010requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6011requires_config_enabled MBEDTLS_RSA_C
6012requires_config_enabled MBEDTLS_ECDSA_C
6013requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006014run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006015 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6016 crt_file=data_files/server7_int-ca.crt \
6017 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006018 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006019 max_frag_len=1024" \
6020 "$P_CLI dtls=1 debug_level=2 \
6021 crt_file=data_files/server8_int-ca2.crt \
6022 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006023 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006024 max_frag_len=2048" \
6025 0 \
6026 -S "found fragmented DTLS handshake message" \
6027 -c "found fragmented DTLS handshake message" \
6028 -C "error"
6029
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006030# With the MFL extension, the server has no way of forcing
6031# the client to not exceed a certain MTU; hence, the following
6032# test can't be replicated with an MTU proxy such as the one
6033# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006034requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6035requires_config_enabled MBEDTLS_RSA_C
6036requires_config_enabled MBEDTLS_ECDSA_C
6037requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006038run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006039 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6040 crt_file=data_files/server7_int-ca.crt \
6041 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006042 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006043 max_frag_len=512" \
6044 "$P_CLI dtls=1 debug_level=2 \
6045 crt_file=data_files/server8_int-ca2.crt \
6046 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006047 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006048 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006049 0 \
6050 -S "found fragmented DTLS handshake message" \
6051 -c "found fragmented DTLS handshake message" \
6052 -C "error"
6053
6054requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6055requires_config_enabled MBEDTLS_RSA_C
6056requires_config_enabled MBEDTLS_ECDSA_C
6057requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006058run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006059 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6060 crt_file=data_files/server7_int-ca.crt \
6061 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006062 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006063 max_frag_len=2048" \
6064 "$P_CLI dtls=1 debug_level=2 \
6065 crt_file=data_files/server8_int-ca2.crt \
6066 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006067 hs_timeout=2500-60000 \
6068 max_frag_len=1024" \
6069 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006070 -S "found fragmented DTLS handshake message" \
6071 -c "found fragmented DTLS handshake message" \
6072 -C "error"
6073
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006074# While not required by the standard defining the MFL extension
6075# (according to which it only applies to records, not to datagrams),
6076# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6077# as otherwise there wouldn't be any means to communicate MTU restrictions
6078# to the peer.
6079# The next test checks that no datagrams significantly larger than the
6080# negotiated MFL are sent.
6081requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6082requires_config_enabled MBEDTLS_RSA_C
6083requires_config_enabled MBEDTLS_ECDSA_C
6084requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6085run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006086 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006087 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6088 crt_file=data_files/server7_int-ca.crt \
6089 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006090 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006091 max_frag_len=2048" \
6092 "$P_CLI dtls=1 debug_level=2 \
6093 crt_file=data_files/server8_int-ca2.crt \
6094 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006095 hs_timeout=2500-60000 \
6096 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006097 0 \
6098 -S "found fragmented DTLS handshake message" \
6099 -c "found fragmented DTLS handshake message" \
6100 -C "error"
6101
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006102requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6103requires_config_enabled MBEDTLS_RSA_C
6104requires_config_enabled MBEDTLS_ECDSA_C
6105requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006106run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006107 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6108 crt_file=data_files/server7_int-ca.crt \
6109 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006110 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006111 max_frag_len=2048" \
6112 "$P_CLI dtls=1 debug_level=2 \
6113 crt_file=data_files/server8_int-ca2.crt \
6114 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006115 hs_timeout=2500-60000 \
6116 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006117 0 \
6118 -s "found fragmented DTLS handshake message" \
6119 -c "found fragmented DTLS handshake message" \
6120 -C "error"
6121
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006122# While not required by the standard defining the MFL extension
6123# (according to which it only applies to records, not to datagrams),
6124# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6125# as otherwise there wouldn't be any means to communicate MTU restrictions
6126# to the peer.
6127# The next test checks that no datagrams significantly larger than the
6128# negotiated MFL are sent.
6129requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6130requires_config_enabled MBEDTLS_RSA_C
6131requires_config_enabled MBEDTLS_ECDSA_C
6132requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6133run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006134 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006135 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6136 crt_file=data_files/server7_int-ca.crt \
6137 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006138 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006139 max_frag_len=2048" \
6140 "$P_CLI dtls=1 debug_level=2 \
6141 crt_file=data_files/server8_int-ca2.crt \
6142 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006143 hs_timeout=2500-60000 \
6144 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006145 0 \
6146 -s "found fragmented DTLS handshake message" \
6147 -c "found fragmented DTLS handshake message" \
6148 -C "error"
6149
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006150requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6151requires_config_enabled MBEDTLS_RSA_C
6152requires_config_enabled MBEDTLS_ECDSA_C
6153run_test "DTLS fragmenting: none (for reference) (MTU)" \
6154 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6155 crt_file=data_files/server7_int-ca.crt \
6156 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006157 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006158 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006159 "$P_CLI dtls=1 debug_level=2 \
6160 crt_file=data_files/server8_int-ca2.crt \
6161 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006162 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006163 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006164 0 \
6165 -S "found fragmented DTLS handshake message" \
6166 -C "found fragmented DTLS handshake message" \
6167 -C "error"
6168
6169requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6170requires_config_enabled MBEDTLS_RSA_C
6171requires_config_enabled MBEDTLS_ECDSA_C
6172run_test "DTLS fragmenting: client (MTU)" \
6173 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6174 crt_file=data_files/server7_int-ca.crt \
6175 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006176 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006177 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006178 "$P_CLI dtls=1 debug_level=2 \
6179 crt_file=data_files/server8_int-ca2.crt \
6180 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006181 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006182 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006183 0 \
6184 -s "found fragmented DTLS handshake message" \
6185 -C "found fragmented DTLS handshake message" \
6186 -C "error"
6187
6188requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6189requires_config_enabled MBEDTLS_RSA_C
6190requires_config_enabled MBEDTLS_ECDSA_C
6191run_test "DTLS fragmenting: server (MTU)" \
6192 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6193 crt_file=data_files/server7_int-ca.crt \
6194 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006195 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006196 mtu=512" \
6197 "$P_CLI dtls=1 debug_level=2 \
6198 crt_file=data_files/server8_int-ca2.crt \
6199 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006200 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006201 mtu=2048" \
6202 0 \
6203 -S "found fragmented DTLS handshake message" \
6204 -c "found fragmented DTLS handshake message" \
6205 -C "error"
6206
6207requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6208requires_config_enabled MBEDTLS_RSA_C
6209requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006210run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006211 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006212 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6213 crt_file=data_files/server7_int-ca.crt \
6214 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006215 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006216 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006217 "$P_CLI dtls=1 debug_level=2 \
6218 crt_file=data_files/server8_int-ca2.crt \
6219 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006220 hs_timeout=2500-60000 \
6221 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006222 0 \
6223 -s "found fragmented DTLS handshake message" \
6224 -c "found fragmented DTLS handshake message" \
6225 -C "error"
6226
Andrzej Kurek77826052018-10-11 07:34:08 -04006227# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006228requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6229requires_config_enabled MBEDTLS_RSA_C
6230requires_config_enabled MBEDTLS_ECDSA_C
6231requires_config_enabled MBEDTLS_SHA256_C
6232requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6233requires_config_enabled MBEDTLS_AES_C
6234requires_config_enabled MBEDTLS_GCM_C
6235run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006236 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006237 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6238 crt_file=data_files/server7_int-ca.crt \
6239 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006240 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006241 mtu=512" \
6242 "$P_CLI dtls=1 debug_level=2 \
6243 crt_file=data_files/server8_int-ca2.crt \
6244 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006245 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6246 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006247 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006248 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006249 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006250 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006251 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006252
Andrzej Kurek7311c782018-10-11 06:49:41 -04006253# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006254# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006255# The ratio of max/min timeout should ideally equal 4 to accept two
6256# retransmissions, but in some cases (like both the server and client using
6257# fragmentation and auto-reduction) an extra retransmission might occur,
6258# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006259not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006260requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6261requires_config_enabled MBEDTLS_RSA_C
6262requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006263requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6264requires_config_enabled MBEDTLS_AES_C
6265requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006266run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6267 -p "$P_PXY mtu=508" \
6268 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6269 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006270 key_file=data_files/server7.key \
6271 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006272 "$P_CLI dtls=1 debug_level=2 \
6273 crt_file=data_files/server8_int-ca2.crt \
6274 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006275 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6276 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006277 0 \
6278 -s "found fragmented DTLS handshake message" \
6279 -c "found fragmented DTLS handshake message" \
6280 -C "error"
6281
Andrzej Kurek77826052018-10-11 07:34:08 -04006282# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006283only_with_valgrind
6284requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6285requires_config_enabled MBEDTLS_RSA_C
6286requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006287requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6288requires_config_enabled MBEDTLS_AES_C
6289requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006290run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6291 -p "$P_PXY mtu=508" \
6292 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6293 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006294 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006295 hs_timeout=250-10000" \
6296 "$P_CLI dtls=1 debug_level=2 \
6297 crt_file=data_files/server8_int-ca2.crt \
6298 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006299 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006300 hs_timeout=250-10000" \
6301 0 \
6302 -s "found fragmented DTLS handshake message" \
6303 -c "found fragmented DTLS handshake message" \
6304 -C "error"
6305
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006306# 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 +02006307# OTOH the client might resend if the server is to slow to reset after sending
6308# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006309not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006310requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6311requires_config_enabled MBEDTLS_RSA_C
6312requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006313run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006314 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006315 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6316 crt_file=data_files/server7_int-ca.crt \
6317 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006318 hs_timeout=10000-60000 \
6319 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006320 "$P_CLI dtls=1 debug_level=2 \
6321 crt_file=data_files/server8_int-ca2.crt \
6322 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006323 hs_timeout=10000-60000 \
6324 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006325 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006326 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006327 -s "found fragmented DTLS handshake message" \
6328 -c "found fragmented DTLS handshake message" \
6329 -C "error"
6330
Andrzej Kurek77826052018-10-11 07:34:08 -04006331# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006332# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6333# OTOH the client might resend if the server is to slow to reset after sending
6334# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006335not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006336requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6337requires_config_enabled MBEDTLS_RSA_C
6338requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006339requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6340requires_config_enabled MBEDTLS_AES_C
6341requires_config_enabled MBEDTLS_GCM_C
6342run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006343 -p "$P_PXY mtu=512" \
6344 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6345 crt_file=data_files/server7_int-ca.crt \
6346 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006347 hs_timeout=10000-60000 \
6348 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006349 "$P_CLI dtls=1 debug_level=2 \
6350 crt_file=data_files/server8_int-ca2.crt \
6351 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006352 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6353 hs_timeout=10000-60000 \
6354 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006355 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006356 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006357 -s "found fragmented DTLS handshake message" \
6358 -c "found fragmented DTLS handshake message" \
6359 -C "error"
6360
Andrzej Kurek7311c782018-10-11 06:49:41 -04006361not_with_valgrind # spurious autoreduction due to timeout
6362requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6363requires_config_enabled MBEDTLS_RSA_C
6364requires_config_enabled MBEDTLS_ECDSA_C
6365run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006366 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006367 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6368 crt_file=data_files/server7_int-ca.crt \
6369 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006370 hs_timeout=10000-60000 \
6371 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006372 "$P_CLI dtls=1 debug_level=2 \
6373 crt_file=data_files/server8_int-ca2.crt \
6374 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006375 hs_timeout=10000-60000 \
6376 mtu=1024 nbio=2" \
6377 0 \
6378 -S "autoreduction" \
6379 -s "found fragmented DTLS handshake message" \
6380 -c "found fragmented DTLS handshake message" \
6381 -C "error"
6382
Andrzej Kurek77826052018-10-11 07:34:08 -04006383# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006384not_with_valgrind # spurious autoreduction due to timeout
6385requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6386requires_config_enabled MBEDTLS_RSA_C
6387requires_config_enabled MBEDTLS_ECDSA_C
6388requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6389requires_config_enabled MBEDTLS_AES_C
6390requires_config_enabled MBEDTLS_GCM_C
6391run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6392 -p "$P_PXY mtu=512" \
6393 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6394 crt_file=data_files/server7_int-ca.crt \
6395 key_file=data_files/server7.key \
6396 hs_timeout=10000-60000 \
6397 mtu=512 nbio=2" \
6398 "$P_CLI dtls=1 debug_level=2 \
6399 crt_file=data_files/server8_int-ca2.crt \
6400 key_file=data_files/server8.key \
6401 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6402 hs_timeout=10000-60000 \
6403 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006404 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006405 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006406 -s "found fragmented DTLS handshake message" \
6407 -c "found fragmented DTLS handshake message" \
6408 -C "error"
6409
Andrzej Kurek77826052018-10-11 07:34:08 -04006410# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006411# This ensures things still work after session_reset().
6412# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006413# Since we don't support reading fragmented ClientHello yet,
6414# up the MTU to 1450 (larger than ClientHello with session ticket,
6415# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006416# An autoreduction on the client-side might happen if the server is
6417# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006418# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006419# resumed listening, which would result in a spurious autoreduction.
6420not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006421requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6422requires_config_enabled MBEDTLS_RSA_C
6423requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006424requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6425requires_config_enabled MBEDTLS_AES_C
6426requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006427run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6428 -p "$P_PXY mtu=1450" \
6429 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6430 crt_file=data_files/server7_int-ca.crt \
6431 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006432 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006433 mtu=1450" \
6434 "$P_CLI dtls=1 debug_level=2 \
6435 crt_file=data_files/server8_int-ca2.crt \
6436 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006437 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006438 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006439 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006440 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006441 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006442 -s "found fragmented DTLS handshake message" \
6443 -c "found fragmented DTLS handshake message" \
6444 -C "error"
6445
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006446# An autoreduction on the client-side might happen if the server is
6447# slow to reset, therefore omitting '-C "autoreduction"' below.
6448not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006449requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6450requires_config_enabled MBEDTLS_RSA_C
6451requires_config_enabled MBEDTLS_ECDSA_C
6452requires_config_enabled MBEDTLS_SHA256_C
6453requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6455requires_config_enabled MBEDTLS_CHACHAPOLY_C
6456run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6457 -p "$P_PXY mtu=512" \
6458 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6459 crt_file=data_files/server7_int-ca.crt \
6460 key_file=data_files/server7.key \
6461 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006462 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006463 mtu=512" \
6464 "$P_CLI dtls=1 debug_level=2 \
6465 crt_file=data_files/server8_int-ca2.crt \
6466 key_file=data_files/server8.key \
6467 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006468 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006469 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006470 mtu=512" \
6471 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006472 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006473 -s "found fragmented DTLS handshake message" \
6474 -c "found fragmented DTLS handshake message" \
6475 -C "error"
6476
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006477# An autoreduction on the client-side might happen if the server is
6478# slow to reset, therefore omitting '-C "autoreduction"' below.
6479not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006480requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6481requires_config_enabled MBEDTLS_RSA_C
6482requires_config_enabled MBEDTLS_ECDSA_C
6483requires_config_enabled MBEDTLS_SHA256_C
6484requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6485requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6486requires_config_enabled MBEDTLS_AES_C
6487requires_config_enabled MBEDTLS_GCM_C
6488run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6489 -p "$P_PXY mtu=512" \
6490 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6491 crt_file=data_files/server7_int-ca.crt \
6492 key_file=data_files/server7.key \
6493 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006494 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006495 mtu=512" \
6496 "$P_CLI dtls=1 debug_level=2 \
6497 crt_file=data_files/server8_int-ca2.crt \
6498 key_file=data_files/server8.key \
6499 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006500 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006501 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006502 mtu=512" \
6503 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006504 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006505 -s "found fragmented DTLS handshake message" \
6506 -c "found fragmented DTLS handshake message" \
6507 -C "error"
6508
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006509# An autoreduction on the client-side might happen if the server is
6510# slow to reset, therefore omitting '-C "autoreduction"' below.
6511not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006512requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6513requires_config_enabled MBEDTLS_RSA_C
6514requires_config_enabled MBEDTLS_ECDSA_C
6515requires_config_enabled MBEDTLS_SHA256_C
6516requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6517requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6518requires_config_enabled MBEDTLS_AES_C
6519requires_config_enabled MBEDTLS_CCM_C
6520run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006521 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006522 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6523 crt_file=data_files/server7_int-ca.crt \
6524 key_file=data_files/server7.key \
6525 exchanges=2 renegotiation=1 \
6526 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006527 hs_timeout=10000-60000 \
6528 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006529 "$P_CLI dtls=1 debug_level=2 \
6530 crt_file=data_files/server8_int-ca2.crt \
6531 key_file=data_files/server8.key \
6532 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006533 hs_timeout=10000-60000 \
6534 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006535 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006536 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006537 -s "found fragmented DTLS handshake message" \
6538 -c "found fragmented DTLS handshake message" \
6539 -C "error"
6540
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006541# An autoreduction on the client-side might happen if the server is
6542# slow to reset, therefore omitting '-C "autoreduction"' below.
6543not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006544requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6545requires_config_enabled MBEDTLS_RSA_C
6546requires_config_enabled MBEDTLS_ECDSA_C
6547requires_config_enabled MBEDTLS_SHA256_C
6548requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6550requires_config_enabled MBEDTLS_AES_C
6551requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6552requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6553run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006554 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006555 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6556 crt_file=data_files/server7_int-ca.crt \
6557 key_file=data_files/server7.key \
6558 exchanges=2 renegotiation=1 \
6559 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006560 hs_timeout=10000-60000 \
6561 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006562 "$P_CLI dtls=1 debug_level=2 \
6563 crt_file=data_files/server8_int-ca2.crt \
6564 key_file=data_files/server8.key \
6565 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006566 hs_timeout=10000-60000 \
6567 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006568 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006569 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006570 -s "found fragmented DTLS handshake message" \
6571 -c "found fragmented DTLS handshake message" \
6572 -C "error"
6573
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006574# An autoreduction on the client-side might happen if the server is
6575# slow to reset, therefore omitting '-C "autoreduction"' below.
6576not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006577requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6578requires_config_enabled MBEDTLS_RSA_C
6579requires_config_enabled MBEDTLS_ECDSA_C
6580requires_config_enabled MBEDTLS_SHA256_C
6581requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6582requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6583requires_config_enabled MBEDTLS_AES_C
6584requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6585run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006586 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006587 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6588 crt_file=data_files/server7_int-ca.crt \
6589 key_file=data_files/server7.key \
6590 exchanges=2 renegotiation=1 \
6591 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006592 hs_timeout=10000-60000 \
6593 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006594 "$P_CLI dtls=1 debug_level=2 \
6595 crt_file=data_files/server8_int-ca2.crt \
6596 key_file=data_files/server8.key \
6597 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006598 hs_timeout=10000-60000 \
6599 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006600 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006601 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006602 -s "found fragmented DTLS handshake message" \
6603 -c "found fragmented DTLS handshake message" \
6604 -C "error"
6605
Andrzej Kurek77826052018-10-11 07:34:08 -04006606# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006607requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6608requires_config_enabled MBEDTLS_RSA_C
6609requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006610requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6611requires_config_enabled MBEDTLS_AES_C
6612requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006613client_needs_more_time 2
6614run_test "DTLS fragmenting: proxy MTU + 3d" \
6615 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006616 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006617 crt_file=data_files/server7_int-ca.crt \
6618 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006619 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006620 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006621 crt_file=data_files/server8_int-ca2.crt \
6622 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006623 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006624 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006625 0 \
6626 -s "found fragmented DTLS handshake message" \
6627 -c "found fragmented DTLS handshake message" \
6628 -C "error"
6629
Andrzej Kurek77826052018-10-11 07:34:08 -04006630# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006631requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6632requires_config_enabled MBEDTLS_RSA_C
6633requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006634requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6635requires_config_enabled MBEDTLS_AES_C
6636requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006637client_needs_more_time 2
6638run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6639 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6640 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6641 crt_file=data_files/server7_int-ca.crt \
6642 key_file=data_files/server7.key \
6643 hs_timeout=250-10000 mtu=512 nbio=2" \
6644 "$P_CLI dtls=1 debug_level=2 \
6645 crt_file=data_files/server8_int-ca2.crt \
6646 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006647 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006648 hs_timeout=250-10000 mtu=512 nbio=2" \
6649 0 \
6650 -s "found fragmented DTLS handshake message" \
6651 -c "found fragmented DTLS handshake message" \
6652 -C "error"
6653
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006654# interop tests for DTLS fragmentating with reliable connection
6655#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006656# here and below we just want to test that the we fragment in a way that
6657# pleases other implementations, so we don't need the peer to fragment
6658requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6659requires_config_enabled MBEDTLS_RSA_C
6660requires_config_enabled MBEDTLS_ECDSA_C
6661requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006662requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006663run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6664 "$G_SRV -u" \
6665 "$P_CLI dtls=1 debug_level=2 \
6666 crt_file=data_files/server8_int-ca2.crt \
6667 key_file=data_files/server8.key \
6668 mtu=512 force_version=dtls1_2" \
6669 0 \
6670 -c "fragmenting handshake message" \
6671 -C "error"
6672
6673requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6674requires_config_enabled MBEDTLS_RSA_C
6675requires_config_enabled MBEDTLS_ECDSA_C
6676requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006677requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006678run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6679 "$G_SRV -u" \
6680 "$P_CLI dtls=1 debug_level=2 \
6681 crt_file=data_files/server8_int-ca2.crt \
6682 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006683 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006684 0 \
6685 -c "fragmenting handshake message" \
6686 -C "error"
6687
Hanno Beckerb9a00862018-08-28 10:20:22 +01006688# We use --insecure for the GnuTLS client because it expects
6689# the hostname / IP it connects to to be the name used in the
6690# certificate obtained from the server. Here, however, it
6691# connects to 127.0.0.1 while our test certificates use 'localhost'
6692# as the server name in the certificate. This will make the
6693# certifiate validation fail, but passing --insecure makes
6694# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006695requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6696requires_config_enabled MBEDTLS_RSA_C
6697requires_config_enabled MBEDTLS_ECDSA_C
6698requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006699requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006700requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006701run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006702 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006703 crt_file=data_files/server7_int-ca.crt \
6704 key_file=data_files/server7.key \
6705 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006706 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006707 0 \
6708 -s "fragmenting handshake message"
6709
Hanno Beckerb9a00862018-08-28 10:20:22 +01006710# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006711requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6712requires_config_enabled MBEDTLS_RSA_C
6713requires_config_enabled MBEDTLS_ECDSA_C
6714requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006715requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006716requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006717run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006718 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006719 crt_file=data_files/server7_int-ca.crt \
6720 key_file=data_files/server7.key \
6721 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006722 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006723 0 \
6724 -s "fragmenting handshake message"
6725
6726requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6727requires_config_enabled MBEDTLS_RSA_C
6728requires_config_enabled MBEDTLS_ECDSA_C
6729requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6730run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6731 "$O_SRV -dtls1_2 -verify 10" \
6732 "$P_CLI dtls=1 debug_level=2 \
6733 crt_file=data_files/server8_int-ca2.crt \
6734 key_file=data_files/server8.key \
6735 mtu=512 force_version=dtls1_2" \
6736 0 \
6737 -c "fragmenting handshake message" \
6738 -C "error"
6739
6740requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6741requires_config_enabled MBEDTLS_RSA_C
6742requires_config_enabled MBEDTLS_ECDSA_C
6743requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6744run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6745 "$O_SRV -dtls1 -verify 10" \
6746 "$P_CLI dtls=1 debug_level=2 \
6747 crt_file=data_files/server8_int-ca2.crt \
6748 key_file=data_files/server8.key \
6749 mtu=512 force_version=dtls1" \
6750 0 \
6751 -c "fragmenting handshake message" \
6752 -C "error"
6753
6754requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6755requires_config_enabled MBEDTLS_RSA_C
6756requires_config_enabled MBEDTLS_ECDSA_C
6757requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6758run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6759 "$P_SRV dtls=1 debug_level=2 \
6760 crt_file=data_files/server7_int-ca.crt \
6761 key_file=data_files/server7.key \
6762 mtu=512 force_version=dtls1_2" \
6763 "$O_CLI -dtls1_2" \
6764 0 \
6765 -s "fragmenting handshake message"
6766
6767requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6768requires_config_enabled MBEDTLS_RSA_C
6769requires_config_enabled MBEDTLS_ECDSA_C
6770requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6771run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6772 "$P_SRV dtls=1 debug_level=2 \
6773 crt_file=data_files/server7_int-ca.crt \
6774 key_file=data_files/server7.key \
6775 mtu=512 force_version=dtls1" \
6776 "$O_CLI -dtls1" \
6777 0 \
6778 -s "fragmenting handshake message"
6779
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006780# interop tests for DTLS fragmentating with unreliable connection
6781#
6782# again we just want to test that the we fragment in a way that
6783# pleases other implementations, so we don't need the peer to fragment
6784requires_gnutls_next
6785requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6786requires_config_enabled MBEDTLS_RSA_C
6787requires_config_enabled MBEDTLS_ECDSA_C
6788requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006789client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006790run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6791 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6792 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006793 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006794 crt_file=data_files/server8_int-ca2.crt \
6795 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006796 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006797 0 \
6798 -c "fragmenting handshake message" \
6799 -C "error"
6800
6801requires_gnutls_next
6802requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6803requires_config_enabled MBEDTLS_RSA_C
6804requires_config_enabled MBEDTLS_ECDSA_C
6805requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006806client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006807run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6808 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6809 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006810 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006811 crt_file=data_files/server8_int-ca2.crt \
6812 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006813 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006814 0 \
6815 -c "fragmenting handshake message" \
6816 -C "error"
6817
k-stachowiakabb843e2019-02-18 16:14:03 +01006818requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006819requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6820requires_config_enabled MBEDTLS_RSA_C
6821requires_config_enabled MBEDTLS_ECDSA_C
6822requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6823client_needs_more_time 4
6824run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6825 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6826 "$P_SRV dtls=1 debug_level=2 \
6827 crt_file=data_files/server7_int-ca.crt \
6828 key_file=data_files/server7.key \
6829 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006830 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006831 0 \
6832 -s "fragmenting handshake message"
6833
k-stachowiakabb843e2019-02-18 16:14:03 +01006834requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006835requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6836requires_config_enabled MBEDTLS_RSA_C
6837requires_config_enabled MBEDTLS_ECDSA_C
6838requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6839client_needs_more_time 4
6840run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6841 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6842 "$P_SRV dtls=1 debug_level=2 \
6843 crt_file=data_files/server7_int-ca.crt \
6844 key_file=data_files/server7.key \
6845 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006846 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006847 0 \
6848 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006849
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006850## Interop test with OpenSSL might trigger a bug in recent versions (including
6851## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006852## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006853## They should be re-enabled once a fixed version of OpenSSL is available
6854## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006855skip_next_test
6856requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6857requires_config_enabled MBEDTLS_RSA_C
6858requires_config_enabled MBEDTLS_ECDSA_C
6859requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6860client_needs_more_time 4
6861run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6862 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6863 "$O_SRV -dtls1_2 -verify 10" \
6864 "$P_CLI dtls=1 debug_level=2 \
6865 crt_file=data_files/server8_int-ca2.crt \
6866 key_file=data_files/server8.key \
6867 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6868 0 \
6869 -c "fragmenting handshake message" \
6870 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006871
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006872skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006873requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6874requires_config_enabled MBEDTLS_RSA_C
6875requires_config_enabled MBEDTLS_ECDSA_C
6876requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006877client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006878run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6879 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006880 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006881 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006882 crt_file=data_files/server8_int-ca2.crt \
6883 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006884 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006885 0 \
6886 -c "fragmenting handshake message" \
6887 -C "error"
6888
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006889skip_next_test
6890requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6891requires_config_enabled MBEDTLS_RSA_C
6892requires_config_enabled MBEDTLS_ECDSA_C
6893requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6894client_needs_more_time 4
6895run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6896 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6897 "$P_SRV dtls=1 debug_level=2 \
6898 crt_file=data_files/server7_int-ca.crt \
6899 key_file=data_files/server7.key \
6900 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6901 "$O_CLI -dtls1_2" \
6902 0 \
6903 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006904
6905# -nbio is added to prevent s_client from blocking in case of duplicated
6906# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006907skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006908requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6909requires_config_enabled MBEDTLS_RSA_C
6910requires_config_enabled MBEDTLS_ECDSA_C
6911requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006912client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006913run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6914 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006915 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006916 crt_file=data_files/server7_int-ca.crt \
6917 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006918 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006919 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006920 0 \
6921 -s "fragmenting handshake message"
6922
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006923# Tests for specific things with "unreliable" UDP connection
6924
6925not_with_valgrind # spurious resend due to timeout
6926run_test "DTLS proxy: reference" \
6927 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006928 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6929 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006930 0 \
6931 -C "replayed record" \
6932 -S "replayed record" \
6933 -C "record from another epoch" \
6934 -S "record from another epoch" \
6935 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006936 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006937 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006938 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006939 -c "HTTP/1.0 200 OK"
6940
6941not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006942run_test "DTLS proxy: duplicate every packet" \
6943 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006944 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6945 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006946 0 \
6947 -c "replayed record" \
6948 -s "replayed record" \
6949 -c "record from another epoch" \
6950 -s "record from another epoch" \
6951 -S "resend" \
6952 -s "Extra-header:" \
6953 -c "HTTP/1.0 200 OK"
6954
6955run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6956 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006957 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6958 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006959 0 \
6960 -c "replayed record" \
6961 -S "replayed record" \
6962 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006963 -s "record from another epoch" \
6964 -c "resend" \
6965 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006966 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006967 -c "HTTP/1.0 200 OK"
6968
6969run_test "DTLS proxy: multiple records in same datagram" \
6970 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006971 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6972 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006973 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006974 -c "next record in same datagram" \
6975 -s "next record in same datagram"
6976
6977run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6978 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006979 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6980 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006981 0 \
6982 -c "next record in same datagram" \
6983 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006984
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006985run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6986 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006987 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6988 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006989 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006990 -c "discarding invalid record (mac)" \
6991 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006992 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006993 -c "HTTP/1.0 200 OK" \
6994 -S "too many records with bad MAC" \
6995 -S "Verification of the message MAC failed"
6996
6997run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
6998 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006999 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7000 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007001 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007002 -C "discarding invalid record (mac)" \
7003 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007004 -S "Extra-header:" \
7005 -C "HTTP/1.0 200 OK" \
7006 -s "too many records with bad MAC" \
7007 -s "Verification of the message MAC failed"
7008
7009run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7010 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007011 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7012 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007013 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007014 -c "discarding invalid record (mac)" \
7015 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007016 -s "Extra-header:" \
7017 -c "HTTP/1.0 200 OK" \
7018 -S "too many records with bad MAC" \
7019 -S "Verification of the message MAC failed"
7020
7021run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7022 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007023 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7024 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007025 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007026 -c "discarding invalid record (mac)" \
7027 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007028 -s "Extra-header:" \
7029 -c "HTTP/1.0 200 OK" \
7030 -s "too many records with bad MAC" \
7031 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007032
7033run_test "DTLS proxy: delay ChangeCipherSpec" \
7034 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007035 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7036 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007037 0 \
7038 -c "record from another epoch" \
7039 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007040 -s "Extra-header:" \
7041 -c "HTTP/1.0 200 OK"
7042
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007043# Tests for reordering support with DTLS
7044
Hanno Becker56cdfd12018-08-17 13:42:15 +01007045run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7046 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007047 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7048 hs_timeout=2500-60000" \
7049 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7050 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007051 0 \
7052 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007053 -c "Next handshake message has been buffered - load"\
7054 -S "Buffering HS message" \
7055 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007056 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007057 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007058 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007059 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007060
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007061run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7062 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007063 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7064 hs_timeout=2500-60000" \
7065 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7066 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007067 0 \
7068 -c "Buffering HS message" \
7069 -c "found fragmented DTLS handshake message"\
7070 -c "Next handshake message 1 not or only partially bufffered" \
7071 -c "Next handshake message has been buffered - load"\
7072 -S "Buffering HS message" \
7073 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007074 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007075 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007076 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007077 -S "Remember CCS message"
7078
Hanno Beckera1adcca2018-08-24 14:41:07 +01007079# The client buffers the ServerKeyExchange before receiving the fragmented
7080# Certificate message; at the time of writing, together these are aroudn 1200b
7081# in size, so that the bound below ensures that the certificate can be reassembled
7082# while keeping the ServerKeyExchange.
7083requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7084run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007085 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007086 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7087 hs_timeout=2500-60000" \
7088 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7089 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007090 0 \
7091 -c "Buffering HS message" \
7092 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007093 -C "attempt to make space by freeing buffered messages" \
7094 -S "Buffering HS message" \
7095 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007096 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007097 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007098 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007099 -S "Remember CCS message"
7100
7101# The size constraints ensure that the delayed certificate message can't
7102# be reassembled while keeping the ServerKeyExchange message, but it can
7103# when dropping it first.
7104requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7105requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7106run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7107 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007108 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7109 hs_timeout=2500-60000" \
7110 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7111 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007112 0 \
7113 -c "Buffering HS message" \
7114 -c "attempt to make space by freeing buffered future messages" \
7115 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007116 -S "Buffering HS message" \
7117 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007118 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007119 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007120 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007121 -S "Remember CCS message"
7122
Hanno Becker56cdfd12018-08-17 13:42:15 +01007123run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7124 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007125 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7126 hs_timeout=2500-60000" \
7127 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7128 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007129 0 \
7130 -C "Buffering HS message" \
7131 -C "Next handshake message has been buffered - load"\
7132 -s "Buffering HS message" \
7133 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007134 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007135 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007136 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007137 -S "Remember CCS message"
7138
7139run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7140 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007141 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7142 hs_timeout=2500-60000" \
7143 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7144 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007145 0 \
7146 -C "Buffering HS message" \
7147 -C "Next handshake message has been buffered - load"\
7148 -S "Buffering HS message" \
7149 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007150 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007151 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007152 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007153 -S "Remember CCS message"
7154
7155run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7156 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007157 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7158 hs_timeout=2500-60000" \
7159 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7160 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007161 0 \
7162 -C "Buffering HS message" \
7163 -C "Next handshake message has been buffered - load"\
7164 -S "Buffering HS message" \
7165 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007166 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007167 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007168 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007169 -s "Remember CCS message"
7170
Hanno Beckera1adcca2018-08-24 14:41:07 +01007171run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007172 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007173 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7174 hs_timeout=2500-60000" \
7175 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7176 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007177 0 \
7178 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007179 -s "Found buffered record from current epoch - load" \
7180 -c "Buffer record from epoch 1" \
7181 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007182
Hanno Beckera1adcca2018-08-24 14:41:07 +01007183# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7184# from the server are delayed, so that the encrypted Finished message
7185# is received and buffered. When the fragmented NewSessionTicket comes
7186# in afterwards, the encrypted Finished message must be freed in order
7187# to make space for the NewSessionTicket to be reassembled.
7188# This works only in very particular circumstances:
7189# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7190# of the NewSessionTicket, but small enough to also allow buffering of
7191# the encrypted Finished message.
7192# - The MTU setting on the server must be so small that the NewSessionTicket
7193# needs to be fragmented.
7194# - All messages sent by the server must be small enough to be either sent
7195# without fragmentation or be reassembled within the bounds of
7196# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7197# handshake, omitting CRTs.
7198requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7199requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7200run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7201 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7202 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7203 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7204 0 \
7205 -s "Buffer record from epoch 1" \
7206 -s "Found buffered record from current epoch - load" \
7207 -c "Buffer record from epoch 1" \
7208 -C "Found buffered record from current epoch - load" \
7209 -c "Enough space available after freeing future epoch record"
7210
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007211# Tests for "randomly unreliable connection": try a variety of flows and peers
7212
7213client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007214run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7215 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007216 "$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 +02007217 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007218 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007219 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
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\" RSA 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 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7230 0 \
7231 -s "Extra-header:" \
7232 -c "HTTP/1.0 200 OK"
7233
Janos Follath74537a62016-09-02 13:45:28 +01007234client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007235run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7236 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007237 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7238 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007239 0 \
7240 -s "Extra-header:" \
7241 -c "HTTP/1.0 200 OK"
7242
Janos Follath74537a62016-09-02 13:45:28 +01007243client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007244run_test "DTLS proxy: 3d, FS, client auth" \
7245 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007246 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7247 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007248 0 \
7249 -s "Extra-header:" \
7250 -c "HTTP/1.0 200 OK"
7251
Janos Follath74537a62016-09-02 13:45:28 +01007252client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007253run_test "DTLS proxy: 3d, FS, ticket" \
7254 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007255 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7256 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007257 0 \
7258 -s "Extra-header:" \
7259 -c "HTTP/1.0 200 OK"
7260
Janos Follath74537a62016-09-02 13:45:28 +01007261client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007262run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7263 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007264 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7265 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +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 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007271run_test "DTLS proxy: 3d, max handshake, nbio" \
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 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007274 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007275 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007276 0 \
7277 -s "Extra-header:" \
7278 -c "HTTP/1.0 200 OK"
7279
Janos Follath74537a62016-09-02 13:45:28 +01007280client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007281run_test "DTLS proxy: 3d, min handshake, resumption" \
7282 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007283 "$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 +02007284 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007285 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007286 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007287 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7288 0 \
7289 -s "a session has been resumed" \
7290 -c "a session has been resumed" \
7291 -s "Extra-header:" \
7292 -c "HTTP/1.0 200 OK"
7293
Janos Follath74537a62016-09-02 13:45:28 +01007294client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007295run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7296 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007297 "$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 +02007298 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007299 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007300 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007301 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7302 0 \
7303 -s "a session has been resumed" \
7304 -c "a session has been resumed" \
7305 -s "Extra-header:" \
7306 -c "HTTP/1.0 200 OK"
7307
Janos Follath74537a62016-09-02 13:45:28 +01007308client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007309requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007310run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007311 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007312 "$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 +02007313 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007314 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007315 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007316 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7317 0 \
7318 -c "=> renegotiate" \
7319 -s "=> renegotiate" \
7320 -s "Extra-header:" \
7321 -c "HTTP/1.0 200 OK"
7322
Janos Follath74537a62016-09-02 13:45:28 +01007323client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007324requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007325run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7326 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007327 "$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 +02007328 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007329 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007330 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007331 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7332 0 \
7333 -c "=> renegotiate" \
7334 -s "=> renegotiate" \
7335 -s "Extra-header:" \
7336 -c "HTTP/1.0 200 OK"
7337
Janos Follath74537a62016-09-02 13:45:28 +01007338client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007339requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007340run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007341 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007342 "$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 +02007343 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007344 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007345 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007346 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007347 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7348 0 \
7349 -c "=> renegotiate" \
7350 -s "=> renegotiate" \
7351 -s "Extra-header:" \
7352 -c "HTTP/1.0 200 OK"
7353
Janos Follath74537a62016-09-02 13:45:28 +01007354client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007355requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007356run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007357 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007358 "$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 +02007359 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007360 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007361 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007362 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007363 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7364 0 \
7365 -c "=> renegotiate" \
7366 -s "=> renegotiate" \
7367 -s "Extra-header:" \
7368 -c "HTTP/1.0 200 OK"
7369
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007370## Interop tests with OpenSSL might trigger a bug in recent versions (including
7371## all versions installed on the CI machines), reported here:
7372## Bug report: https://github.com/openssl/openssl/issues/6902
7373## They should be re-enabled once a fixed version of OpenSSL is available
7374## (this should happen in some 1.1.1_ release according to the ticket).
7375skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007376client_needs_more_time 6
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" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007379 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7380 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007381 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007382 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +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é-Gonnard9590e0a2014-09-26 16:27:59 +02007388run_test "DTLS proxy: 3d, openssl server, fragmentation" \
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 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007392 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007393 -c "HTTP/1.0 200 OK"
7394
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007395skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007396client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007397not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007398run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7399 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7400 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007401 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007402 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007403 -c "HTTP/1.0 200 OK"
7404
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007405requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007406client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007407not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007408run_test "DTLS proxy: 3d, gnutls server" \
7409 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7410 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007411 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007412 0 \
7413 -s "Extra-header:" \
7414 -c "Extra-header:"
7415
k-stachowiakabb843e2019-02-18 16:14:03 +01007416requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007417client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007418not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007419run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7420 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007421 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007422 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007423 0 \
7424 -s "Extra-header:" \
7425 -c "Extra-header:"
7426
k-stachowiakabb843e2019-02-18 16:14:03 +01007427requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007428client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007429not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007430run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7431 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007432 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007433 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007434 0 \
7435 -s "Extra-header:" \
7436 -c "Extra-header:"
7437
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007438# Final report
7439
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007440echo "------------------------------------------------------------------------"
7441
7442if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007443 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007444else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007445 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007446fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007447PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007448echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007449
7450exit $FAILS