blob: a038463534da923986d49471f5787b4b99cf3445 [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
629 if [ "X$PXY_CMD" = "X" -a "$DTLS" -eq 1 ]; then
630 PXY_CMD="$P_PXY"
631 fi
632
Manuel Pégourié-Gonnardbedcb3e2020-06-25 09:52:54 +0200633 # fix client port
634 if [ -n "$PXY_CMD" ]; then
635 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
636 else
637 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
638 fi
639
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100640 # prepend valgrind to our commands if active
641 if [ "$MEMCHECK" -gt 0 ]; then
642 if is_polar "$SRV_CMD"; then
643 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
644 fi
645 if is_polar "$CLI_CMD"; then
646 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
647 fi
648 fi
649
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200650 TIMES_LEFT=2
651 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200652 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200653
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200654 # run the commands
655 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200656 printf "# $NAME\n$PXY_CMD\n" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200657 $PXY_CMD >> $PXY_OUT 2>&1 &
658 PXY_PID=$!
Unknown43dc0d62019-09-02 10:42:57 -0400659 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200660 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200661
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200662 check_osrv_dtls
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200663 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200664 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
665 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100666 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200667
Manuel Pégourié-Gonnardcbd5c032020-06-08 12:06:21 +0200668 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200669 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
670 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100671
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100672 sleep 0.05
673
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200674 # terminate the server (and the proxy)
675 kill $SRV_PID
676 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100677
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200678 if [ -n "$PXY_CMD" ]; then
679 kill $PXY_PID >/dev/null 2>&1
680 wait $PXY_PID
681 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100682
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200683 # retry only on timeouts
684 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
685 printf "RETRY "
686 else
687 TIMES_LEFT=0
688 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200689 done
690
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100691 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200692 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100693 # expected client exit to incorrectly succeed in case of catastrophic
694 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100695 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200696 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100697 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100698 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100699 return
700 fi
701 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100702 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200703 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100704 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100705 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100706 return
707 fi
708 fi
709
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100710 # check server exit code
711 if [ $? != 0 ]; then
712 fail "server fail"
713 return
714 fi
715
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100716 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100717 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
718 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100719 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200720 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100721 return
722 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100723
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100724 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200725 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100726 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100727 while [ $# -gt 0 ]
728 do
729 case $1 in
730 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100731 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 +0100732 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100733 return
734 fi
735 ;;
736
737 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100738 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 +0100739 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100740 return
741 fi
742 ;;
743
744 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100745 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 +0100746 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100747 return
748 fi
749 ;;
750
751 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100752 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 +0100753 fail "pattern '$2' MUST NOT be present in the Client output"
754 return
755 fi
756 ;;
757
758 # The filtering in the following two options (-u and -U) do the following
759 # - ignore valgrind output
Antonin Décimod5f47592019-01-23 15:24:37 +0100760 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100761 # - keep one of each non-unique line
762 # - count how many lines remain
763 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
764 # if there were no duplicates.
765 "-U")
766 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
767 fail "lines following pattern '$2' must be unique in Server output"
768 return
769 fi
770 ;;
771
772 "-u")
773 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
774 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100775 return
776 fi
777 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100778 "-F")
779 if ! $2 "$SRV_OUT"; then
780 fail "function call to '$2' failed on Server output"
781 return
782 fi
783 ;;
784 "-f")
785 if ! $2 "$CLI_OUT"; then
786 fail "function call to '$2' failed on Client output"
787 return
788 fi
789 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100790
791 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200792 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100793 exit 1
794 esac
795 shift 2
796 done
797
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100798 # check valgrind's results
799 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200800 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100801 fail "Server has memory errors"
802 return
803 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200804 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100805 fail "Client has memory errors"
806 return
807 fi
808 fi
809
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100810 # if we're here, everything is ok
811 echo "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100812 if [ "$PRESERVE_LOGS" -gt 0 ]; then
813 mv $SRV_OUT o-srv-${TESTS}.log
814 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100815 if [ -n "$PXY_CMD" ]; then
816 mv $PXY_OUT o-pxy-${TESTS}.log
817 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100818 fi
819
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200820 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100821}
822
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100823cleanup() {
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200824 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200825 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
826 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
827 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
828 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100829 exit 1
830}
831
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +0100832#
833# MAIN
834#
835
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +0100836get_options "$@"
837
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100838# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +0100839P_SRV_BIN="${P_SRV%%[ ]*}"
840P_CLI_BIN="${P_CLI%%[ ]*}"
841P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +0100842if [ ! -x "$P_SRV_BIN" ]; then
843 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100844 exit 1
845fi
Hanno Becker17c04932017-10-10 14:44:53 +0100846if [ ! -x "$P_CLI_BIN" ]; then
847 echo "Command '$P_CLI_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_PXY_BIN" ]; then
851 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200852 exit 1
853fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +0100854if [ "$MEMCHECK" -gt 0 ]; then
855 if which valgrind >/dev/null 2>&1; then :; else
856 echo "Memcheck not possible. Valgrind not found"
857 exit 1
858 fi
859fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +0100860if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
861 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +0100862 exit 1
863fi
864
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +0200865# used by watchdog
866MAIN_PID="$$"
867
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100868# We use somewhat arbitrary delays for tests:
869# - how long do we wait for the server to start (when lsof not available)?
870# - how long do we allow for the client to finish?
871# (not to check performance, just to avoid waiting indefinitely)
872# Things are slower with valgrind, so give extra time here.
873#
874# Note: without lsof, there is a trade-off between the running time of this
875# script and the risk of spurious errors because we didn't wait long enough.
876# The watchdog delay on the other hand doesn't affect normal running time of
877# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200878if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100879 START_DELAY=6
880 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200881else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100882 START_DELAY=2
883 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200884fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +0100885
886# some particular tests need more time:
887# - for the client, we multiply the usual watchdog limit by a factor
888# - for the server, we sleep for a number of seconds after the client exits
889# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200890CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +0100891SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200892
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200893# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +0000894# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200895P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
896P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +0100897P_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 +0200898O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200899O_CLI="$O_CLI -connect localhost:+SRV_PORT"
900G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200901G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +0200902
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200903if [ -n "${OPENSSL_LEGACY:-}" ]; then
904 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
905 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
906fi
907
Hanno Becker58e9dc32018-08-17 15:53:21 +0100908if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200909 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
910fi
911
Hanno Becker58e9dc32018-08-17 15:53:21 +0100912if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +0200913 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200914fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100915
Gilles Peskine62469d92017-05-10 10:13:59 +0200916# Allow SHA-1, because many of our test certificates use it
917P_SRV="$P_SRV allow_sha1=1"
918P_CLI="$P_CLI allow_sha1=1"
919
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200920# Also pick a unique name for intermediate files
921SRV_OUT="srv_out.$$"
922CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200923PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200924SESSION="session.$$"
925
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200926SKIP_NEXT="NO"
927
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +0100928trap cleanup INT TERM HUP
929
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200930# Basic test
931
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200932# Checks that:
933# - things work with all ciphersuites active (used with config-full in all.sh)
934# - the expected (highest security) parameters are selected
935# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200936run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200937 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200938 "$P_CLI" \
939 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200940 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200941 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200942 -s "client hello v3, signature_algorithm ext: 6" \
943 -s "ECDHE curve: secp521r1" \
944 -S "error" \
945 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200946
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000947run_test "Default, DTLS" \
948 "$P_SRV dtls=1" \
949 "$P_CLI dtls=1" \
950 0 \
951 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200952 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +0000953
Manuel Pégourié-Gonnard95a17fb2020-01-02 11:58:00 +0100954requires_config_enabled MBEDTLS_ZLIB_SUPPORT
955run_test "Default (compression enabled)" \
956 "$P_SRV debug_level=3" \
957 "$P_CLI debug_level=3" \
958 0 \
959 -s "Allocating compression buffer" \
960 -c "Allocating compression buffer" \
961 -s "Record expansion is unknown (compression)" \
962 -c "Record expansion is unknown (compression)" \
963 -S "error" \
964 -C "error"
965
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100966# Test current time in ServerHello
967requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +0200968run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100969 "$P_SRV debug_level=3" \
970 "$P_CLI debug_level=3" \
971 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100972 -f "check_server_hello_time" \
973 -F "check_server_hello_time"
974
Simon Butcher8e004102016-10-14 00:48:33 +0100975# Test for uniqueness of IVs in AEAD ciphersuites
976run_test "Unique IV in GCM" \
977 "$P_SRV exchanges=20 debug_level=4" \
978 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
979 0 \
980 -u "IV used" \
981 -U "IV used"
982
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100983# Tests for rc4 option
984
Simon Butchera410af52016-05-19 22:12:18 +0100985requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100986run_test "RC4: server disabled, client enabled" \
987 "$P_SRV" \
988 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
989 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100990 -s "SSL - The server has no ciphersuites in common"
991
Simon Butchera410af52016-05-19 22:12:18 +0100992requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +0100993run_test "RC4: server half, client enabled" \
994 "$P_SRV arc4=1" \
995 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
996 1 \
997 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +0100998
999run_test "RC4: server enabled, client disabled" \
1000 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1001 "$P_CLI" \
1002 1 \
1003 -s "SSL - The server has no ciphersuites in common"
1004
1005run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001006 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001007 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1008 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001009 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001010 -S "SSL - The server has no ciphersuites in common"
1011
Hanno Beckerd26bb202018-08-17 09:54:10 +01001012# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1013
1014requires_gnutls
1015requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1016run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1017 "$G_SRV"\
1018 "$P_CLI force_version=tls1_1" \
1019 0
1020
1021requires_gnutls
1022requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1023run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1024 "$G_SRV"\
1025 "$P_CLI force_version=tls1" \
1026 0
1027
Gilles Peskinebc70a182017-05-09 15:59:24 +02001028# Tests for SHA-1 support
1029
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001030requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001031run_test "SHA-1 forbidden by default in server certificate" \
1032 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1033 "$P_CLI debug_level=2 allow_sha1=0" \
1034 1 \
1035 -c "The certificate is signed with an unacceptable hash"
1036
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001037requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1038run_test "SHA-1 forbidden by default in server certificate" \
1039 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1040 "$P_CLI debug_level=2 allow_sha1=0" \
1041 0
1042
Gilles Peskinebc70a182017-05-09 15:59:24 +02001043run_test "SHA-1 explicitly allowed in server certificate" \
1044 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1045 "$P_CLI allow_sha1=1" \
1046 0
1047
1048run_test "SHA-256 allowed by default in server certificate" \
1049 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1050 "$P_CLI allow_sha1=0" \
1051 0
1052
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001053requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001054run_test "SHA-1 forbidden by default in client certificate" \
1055 "$P_SRV auth_mode=required allow_sha1=0" \
1056 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1057 1 \
1058 -s "The certificate is signed with an unacceptable hash"
1059
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001060requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
1061run_test "SHA-1 forbidden by default in client certificate" \
1062 "$P_SRV auth_mode=required allow_sha1=0" \
1063 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1064 0
1065
Gilles Peskinebc70a182017-05-09 15:59:24 +02001066run_test "SHA-1 explicitly allowed in client certificate" \
1067 "$P_SRV auth_mode=required allow_sha1=1" \
1068 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1069 0
1070
1071run_test "SHA-256 allowed by default in client certificate" \
1072 "$P_SRV auth_mode=required allow_sha1=0" \
1073 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1074 0
1075
Hanno Becker7ae8a762018-08-14 15:43:35 +01001076# Tests for datagram packing
1077run_test "DTLS: multiple records in same datagram, client and server" \
1078 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1079 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1080 0 \
1081 -c "next record in same datagram" \
1082 -s "next record in same datagram"
1083
1084run_test "DTLS: multiple records in same datagram, client only" \
1085 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1086 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1087 0 \
1088 -s "next record in same datagram" \
1089 -C "next record in same datagram"
1090
1091run_test "DTLS: multiple records in same datagram, server only" \
1092 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1093 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1094 0 \
1095 -S "next record in same datagram" \
1096 -c "next record in same datagram"
1097
1098run_test "DTLS: multiple records in same datagram, neither client nor server" \
1099 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1100 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1101 0 \
1102 -S "next record in same datagram" \
1103 -C "next record in same datagram"
1104
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001105# Tests for Truncated HMAC extension
1106
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001107run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001108 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001109 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001110 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001111 -s "dumping 'expected mac' (20 bytes)" \
1112 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001113
Hanno Becker32c55012017-11-10 08:42:54 +00001114requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001115run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001116 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001117 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001118 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001119 -s "dumping 'expected mac' (20 bytes)" \
1120 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001121
Hanno Becker32c55012017-11-10 08:42:54 +00001122requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001123run_test "Truncated HMAC: client enabled, server default" \
1124 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001125 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001126 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001127 -s "dumping 'expected mac' (20 bytes)" \
1128 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001129
Hanno Becker32c55012017-11-10 08:42:54 +00001130requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001131run_test "Truncated HMAC: client enabled, server disabled" \
1132 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001133 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001134 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001135 -s "dumping 'expected mac' (20 bytes)" \
1136 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001137
Hanno Becker32c55012017-11-10 08:42:54 +00001138requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001139run_test "Truncated HMAC: client disabled, server enabled" \
1140 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001141 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001142 0 \
1143 -s "dumping 'expected mac' (20 bytes)" \
1144 -S "dumping 'expected mac' (10 bytes)"
1145
1146requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001147run_test "Truncated HMAC: client enabled, server enabled" \
1148 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001149 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001150 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001151 -S "dumping 'expected mac' (20 bytes)" \
1152 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001153
Hanno Becker4c4f4102017-11-10 09:16:05 +00001154run_test "Truncated HMAC, DTLS: client default, server default" \
1155 "$P_SRV dtls=1 debug_level=4" \
1156 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1157 0 \
1158 -s "dumping 'expected mac' (20 bytes)" \
1159 -S "dumping 'expected mac' (10 bytes)"
1160
1161requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1162run_test "Truncated HMAC, DTLS: client disabled, server default" \
1163 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001164 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001165 0 \
1166 -s "dumping 'expected mac' (20 bytes)" \
1167 -S "dumping 'expected mac' (10 bytes)"
1168
1169requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1170run_test "Truncated HMAC, DTLS: client enabled, server default" \
1171 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001172 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001173 0 \
1174 -s "dumping 'expected mac' (20 bytes)" \
1175 -S "dumping 'expected mac' (10 bytes)"
1176
1177requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1178run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1179 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001180 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001181 0 \
1182 -s "dumping 'expected mac' (20 bytes)" \
1183 -S "dumping 'expected mac' (10 bytes)"
1184
1185requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1186run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1187 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001188 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001189 0 \
1190 -s "dumping 'expected mac' (20 bytes)" \
1191 -S "dumping 'expected mac' (10 bytes)"
1192
1193requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1194run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1195 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001196 "$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 +01001197 0 \
1198 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001199 -s "dumping 'expected mac' (10 bytes)"
1200
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001201# Tests for Encrypt-then-MAC extension
1202
1203run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001204 "$P_SRV debug_level=3 \
1205 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001206 "$P_CLI debug_level=3" \
1207 0 \
1208 -c "client hello, adding encrypt_then_mac extension" \
1209 -s "found encrypt then mac extension" \
1210 -s "server hello, adding encrypt then mac extension" \
1211 -c "found encrypt_then_mac extension" \
1212 -c "using encrypt then mac" \
1213 -s "using encrypt then mac"
1214
1215run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001216 "$P_SRV debug_level=3 etm=0 \
1217 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001218 "$P_CLI debug_level=3 etm=1" \
1219 0 \
1220 -c "client hello, adding encrypt_then_mac extension" \
1221 -s "found encrypt then mac extension" \
1222 -S "server hello, adding encrypt then mac extension" \
1223 -C "found encrypt_then_mac extension" \
1224 -C "using encrypt then mac" \
1225 -S "using encrypt then mac"
1226
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01001227run_test "Encrypt then MAC: client enabled, aead cipher" \
1228 "$P_SRV debug_level=3 etm=1 \
1229 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
1230 "$P_CLI debug_level=3 etm=1" \
1231 0 \
1232 -c "client hello, adding encrypt_then_mac extension" \
1233 -s "found encrypt then mac extension" \
1234 -S "server hello, adding encrypt then mac extension" \
1235 -C "found encrypt_then_mac extension" \
1236 -C "using encrypt then mac" \
1237 -S "using encrypt then mac"
1238
1239run_test "Encrypt then MAC: client enabled, stream cipher" \
1240 "$P_SRV debug_level=3 etm=1 \
1241 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001242 "$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 +01001243 0 \
1244 -c "client hello, adding encrypt_then_mac extension" \
1245 -s "found encrypt then mac extension" \
1246 -S "server hello, adding encrypt then mac extension" \
1247 -C "found encrypt_then_mac extension" \
1248 -C "using encrypt then mac" \
1249 -S "using encrypt then mac"
1250
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001251run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001252 "$P_SRV debug_level=3 etm=1 \
1253 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001254 "$P_CLI debug_level=3 etm=0" \
1255 0 \
1256 -C "client hello, adding encrypt_then_mac extension" \
1257 -S "found encrypt then mac extension" \
1258 -S "server hello, adding encrypt then mac extension" \
1259 -C "found encrypt_then_mac extension" \
1260 -C "using encrypt then mac" \
1261 -S "using encrypt then mac"
1262
Janos Follathe2681a42016-03-07 15:57:05 +00001263requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001264run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001265 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001266 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001267 "$P_CLI debug_level=3 force_version=ssl3" \
1268 0 \
1269 -C "client hello, adding encrypt_then_mac extension" \
1270 -S "found encrypt then mac extension" \
1271 -S "server hello, adding encrypt then mac extension" \
1272 -C "found encrypt_then_mac extension" \
1273 -C "using encrypt then mac" \
1274 -S "using encrypt then mac"
1275
Janos Follathe2681a42016-03-07 15:57:05 +00001276requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001277run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01001278 "$P_SRV debug_level=3 force_version=ssl3 \
1279 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001280 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001281 0 \
1282 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001283 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01001284 -S "server hello, adding encrypt then mac extension" \
1285 -C "found encrypt_then_mac extension" \
1286 -C "using encrypt then mac" \
1287 -S "using encrypt then mac"
1288
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02001289# Tests for Extended Master Secret extension
1290
1291run_test "Extended Master Secret: default" \
1292 "$P_SRV debug_level=3" \
1293 "$P_CLI debug_level=3" \
1294 0 \
1295 -c "client hello, adding extended_master_secret extension" \
1296 -s "found extended master secret extension" \
1297 -s "server hello, adding extended master secret extension" \
1298 -c "found extended_master_secret extension" \
1299 -c "using extended master secret" \
1300 -s "using extended master secret"
1301
1302run_test "Extended Master Secret: client enabled, server disabled" \
1303 "$P_SRV debug_level=3 extended_ms=0" \
1304 "$P_CLI debug_level=3 extended_ms=1" \
1305 0 \
1306 -c "client hello, adding extended_master_secret extension" \
1307 -s "found extended master secret extension" \
1308 -S "server hello, adding extended master secret extension" \
1309 -C "found extended_master_secret extension" \
1310 -C "using extended master secret" \
1311 -S "using extended master secret"
1312
1313run_test "Extended Master Secret: client disabled, server enabled" \
1314 "$P_SRV debug_level=3 extended_ms=1" \
1315 "$P_CLI debug_level=3 extended_ms=0" \
1316 0 \
1317 -C "client hello, adding extended_master_secret extension" \
1318 -S "found extended master secret extension" \
1319 -S "server hello, adding extended master secret extension" \
1320 -C "found extended_master_secret extension" \
1321 -C "using extended master secret" \
1322 -S "using extended master secret"
1323
Janos Follathe2681a42016-03-07 15:57:05 +00001324requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001325run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001326 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001327 "$P_CLI debug_level=3 force_version=ssl3" \
1328 0 \
1329 -C "client hello, adding extended_master_secret extension" \
1330 -S "found extended master secret extension" \
1331 -S "server hello, adding extended master secret extension" \
1332 -C "found extended_master_secret extension" \
1333 -C "using extended master secret" \
1334 -S "using extended master secret"
1335
Janos Follathe2681a42016-03-07 15:57:05 +00001336requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001337run_test "Extended Master Secret: client enabled, server SSLv3" \
1338 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001339 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001340 0 \
1341 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01001342 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02001343 -S "server hello, adding extended master secret extension" \
1344 -C "found extended_master_secret extension" \
1345 -C "using extended master secret" \
1346 -S "using extended master secret"
1347
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001348# Tests for FALLBACK_SCSV
1349
1350run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001351 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001352 "$P_CLI debug_level=3 force_version=tls1_1" \
1353 0 \
1354 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001355 -S "received FALLBACK_SCSV" \
1356 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001357 -C "is a fatal alert message (msg 86)"
1358
1359run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001360 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001361 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1362 0 \
1363 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001364 -S "received FALLBACK_SCSV" \
1365 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001366 -C "is a fatal alert message (msg 86)"
1367
1368run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001369 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001370 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001371 1 \
1372 -c "adding FALLBACK_SCSV" \
1373 -s "received FALLBACK_SCSV" \
1374 -s "inapropriate fallback" \
1375 -c "is a fatal alert message (msg 86)"
1376
1377run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001378 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001379 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001380 0 \
1381 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001382 -s "received FALLBACK_SCSV" \
1383 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02001384 -C "is a fatal alert message (msg 86)"
1385
1386requires_openssl_with_fallback_scsv
1387run_test "Fallback SCSV: default, openssl server" \
1388 "$O_SRV" \
1389 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
1390 0 \
1391 -C "adding FALLBACK_SCSV" \
1392 -C "is a fatal alert message (msg 86)"
1393
1394requires_openssl_with_fallback_scsv
1395run_test "Fallback SCSV: enabled, openssl server" \
1396 "$O_SRV" \
1397 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
1398 1 \
1399 -c "adding FALLBACK_SCSV" \
1400 -c "is a fatal alert message (msg 86)"
1401
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001402requires_openssl_with_fallback_scsv
1403run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001404 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001405 "$O_CLI -tls1_1" \
1406 0 \
1407 -S "received FALLBACK_SCSV" \
1408 -S "inapropriate fallback"
1409
1410requires_openssl_with_fallback_scsv
1411run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001412 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001413 "$O_CLI -tls1_1 -fallback_scsv" \
1414 1 \
1415 -s "received FALLBACK_SCSV" \
1416 -s "inapropriate fallback"
1417
1418requires_openssl_with_fallback_scsv
1419run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02001420 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02001421 "$O_CLI -fallback_scsv" \
1422 0 \
1423 -s "received FALLBACK_SCSV" \
1424 -S "inapropriate fallback"
1425
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001426# Test sending and receiving empty application data records
1427
1428run_test "Encrypt then MAC: empty application data record" \
1429 "$P_SRV auth_mode=none debug_level=4 etm=1" \
1430 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
1431 0 \
1432 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1433 -s "dumping 'input payload after decrypt' (0 bytes)" \
1434 -c "0 bytes written in 1 fragments"
1435
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001436run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001437 "$P_SRV auth_mode=none debug_level=4 etm=0" \
1438 "$P_CLI auth_mode=none etm=0 request_size=0" \
1439 0 \
1440 -s "dumping 'input payload after decrypt' (0 bytes)" \
1441 -c "0 bytes written in 1 fragments"
1442
1443run_test "Encrypt then MAC, DTLS: empty application data record" \
1444 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
1445 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
1446 0 \
1447 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
1448 -s "dumping 'input payload after decrypt' (0 bytes)" \
1449 -c "0 bytes written in 1 fragments"
1450
Manuel Pégourié-Gonnard98a879a2020-03-24 10:53:39 +01001451run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01001452 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
1453 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
1454 0 \
1455 -s "dumping 'input payload after decrypt' (0 bytes)" \
1456 -c "0 bytes written in 1 fragments"
1457
Gilles Peskined50177f2017-05-16 17:53:03 +02001458## ClientHello generated with
1459## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
1460## then manually twiddling the ciphersuite list.
1461## The ClientHello content is spelled out below as a hex string as
1462## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
1463## The expected response is an inappropriate_fallback alert.
1464requires_openssl_with_fallback_scsv
1465run_test "Fallback SCSV: beginning of list" \
1466 "$P_SRV debug_level=2" \
1467 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
1468 0 \
1469 -s "received FALLBACK_SCSV" \
1470 -s "inapropriate fallback"
1471
1472requires_openssl_with_fallback_scsv
1473run_test "Fallback SCSV: end of list" \
1474 "$P_SRV debug_level=2" \
1475 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
1476 0 \
1477 -s "received FALLBACK_SCSV" \
1478 -s "inapropriate fallback"
1479
1480## Here the expected response is a valid ServerHello prefix, up to the random.
1481requires_openssl_with_fallback_scsv
1482run_test "Fallback SCSV: not in list" \
1483 "$P_SRV debug_level=2" \
1484 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
1485 0 \
1486 -S "received FALLBACK_SCSV" \
1487 -S "inapropriate fallback"
1488
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001489# Tests for CBC 1/n-1 record splitting
1490
1491run_test "CBC Record splitting: TLS 1.2, no splitting" \
1492 "$P_SRV" \
1493 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1494 request_size=123 force_version=tls1_2" \
1495 0 \
1496 -s "Read from client: 123 bytes read" \
1497 -S "Read from client: 1 bytes read" \
1498 -S "122 bytes read"
1499
1500run_test "CBC Record splitting: TLS 1.1, no splitting" \
1501 "$P_SRV" \
1502 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1503 request_size=123 force_version=tls1_1" \
1504 0 \
1505 -s "Read from client: 123 bytes read" \
1506 -S "Read from client: 1 bytes read" \
1507 -S "122 bytes read"
1508
1509run_test "CBC Record splitting: TLS 1.0, splitting" \
1510 "$P_SRV" \
1511 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1512 request_size=123 force_version=tls1" \
1513 0 \
1514 -S "Read from client: 123 bytes read" \
1515 -s "Read from client: 1 bytes read" \
1516 -s "122 bytes read"
1517
Janos Follathe2681a42016-03-07 15:57:05 +00001518requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001519run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001520 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001521 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1522 request_size=123 force_version=ssl3" \
1523 0 \
1524 -S "Read from client: 123 bytes read" \
1525 -s "Read from client: 1 bytes read" \
1526 -s "122 bytes read"
1527
1528run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001529 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01001530 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
1531 request_size=123 force_version=tls1" \
1532 0 \
1533 -s "Read from client: 123 bytes read" \
1534 -S "Read from client: 1 bytes read" \
1535 -S "122 bytes read"
1536
1537run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
1538 "$P_SRV" \
1539 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1540 request_size=123 force_version=tls1 recsplit=0" \
1541 0 \
1542 -s "Read from client: 123 bytes read" \
1543 -S "Read from client: 1 bytes read" \
1544 -S "122 bytes read"
1545
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01001546run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
1547 "$P_SRV nbio=2" \
1548 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
1549 request_size=123 force_version=tls1" \
1550 0 \
1551 -S "Read from client: 123 bytes read" \
1552 -s "Read from client: 1 bytes read" \
1553 -s "122 bytes read"
1554
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001555# Tests for Session Tickets
1556
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001557run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001558 "$P_SRV debug_level=3 tickets=1" \
1559 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001560 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001561 -c "client hello, adding session ticket extension" \
1562 -s "found session ticket extension" \
1563 -s "server hello, adding session ticket extension" \
1564 -c "found session_ticket extension" \
1565 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001566 -S "session successfully restored from cache" \
1567 -s "session successfully restored from ticket" \
1568 -s "a session has been resumed" \
1569 -c "a session has been resumed"
1570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001571run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001572 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
1573 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001574 0 \
1575 -c "client hello, adding session ticket extension" \
1576 -s "found session ticket extension" \
1577 -s "server hello, adding session ticket extension" \
1578 -c "found session_ticket extension" \
1579 -c "parse new session ticket" \
1580 -S "session successfully restored from cache" \
1581 -s "session successfully restored from ticket" \
1582 -s "a session has been resumed" \
1583 -c "a session has been resumed"
1584
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001585run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001586 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
1587 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01001588 0 \
1589 -c "client hello, adding session ticket extension" \
1590 -s "found session ticket extension" \
1591 -s "server hello, adding session ticket extension" \
1592 -c "found session_ticket extension" \
1593 -c "parse new session ticket" \
1594 -S "session successfully restored from cache" \
1595 -S "session successfully restored from ticket" \
1596 -S "a session has been resumed" \
1597 -C "a session has been resumed"
1598
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001599run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001600 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001601 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001602 0 \
1603 -c "client hello, adding session ticket extension" \
1604 -c "found session_ticket extension" \
1605 -c "parse new session ticket" \
1606 -c "a session has been resumed"
1607
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001608run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001609 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001610 "( $O_CLI -sess_out $SESSION; \
1611 $O_CLI -sess_in $SESSION; \
1612 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01001613 0 \
1614 -s "found session ticket extension" \
1615 -s "server hello, adding session ticket extension" \
1616 -S "session successfully restored from cache" \
1617 -s "session successfully restored from ticket" \
1618 -s "a session has been resumed"
1619
Hanno Becker1d739932018-08-21 13:55:22 +01001620# Tests for Session Tickets with DTLS
1621
1622run_test "Session resume using tickets, DTLS: basic" \
1623 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001624 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001625 0 \
1626 -c "client hello, adding session ticket extension" \
1627 -s "found session ticket extension" \
1628 -s "server hello, adding session ticket extension" \
1629 -c "found session_ticket extension" \
1630 -c "parse new session ticket" \
1631 -S "session successfully restored from cache" \
1632 -s "session successfully restored from ticket" \
1633 -s "a session has been resumed" \
1634 -c "a session has been resumed"
1635
1636run_test "Session resume using tickets, DTLS: cache disabled" \
1637 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001638 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001639 0 \
1640 -c "client hello, adding session ticket extension" \
1641 -s "found session ticket extension" \
1642 -s "server hello, adding session ticket extension" \
1643 -c "found session_ticket extension" \
1644 -c "parse new session ticket" \
1645 -S "session successfully restored from cache" \
1646 -s "session successfully restored from ticket" \
1647 -s "a session has been resumed" \
1648 -c "a session has been resumed"
1649
1650run_test "Session resume using tickets, DTLS: timeout" \
1651 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001652 "$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 +01001653 0 \
1654 -c "client hello, adding session ticket extension" \
1655 -s "found session ticket extension" \
1656 -s "server hello, adding session ticket extension" \
1657 -c "found session_ticket extension" \
1658 -c "parse new session ticket" \
1659 -S "session successfully restored from cache" \
1660 -S "session successfully restored from ticket" \
1661 -S "a session has been resumed" \
1662 -C "a session has been resumed"
1663
1664run_test "Session resume using tickets, DTLS: openssl server" \
1665 "$O_SRV -dtls1" \
1666 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
1667 0 \
1668 -c "client hello, adding session ticket extension" \
1669 -c "found session_ticket extension" \
1670 -c "parse new session ticket" \
1671 -c "a session has been resumed"
1672
1673run_test "Session resume using tickets, DTLS: openssl client" \
1674 "$P_SRV dtls=1 debug_level=3 tickets=1" \
1675 "( $O_CLI -dtls1 -sess_out $SESSION; \
1676 $O_CLI -dtls1 -sess_in $SESSION; \
1677 rm -f $SESSION )" \
1678 0 \
1679 -s "found session ticket extension" \
1680 -s "server hello, adding session ticket extension" \
1681 -S "session successfully restored from cache" \
1682 -s "session successfully restored from ticket" \
1683 -s "a session has been resumed"
1684
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001685# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001686
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001687run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001688 "$P_SRV debug_level=3 tickets=0" \
1689 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001690 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001691 -c "client hello, adding session ticket extension" \
1692 -s "found session ticket extension" \
1693 -S "server hello, adding session ticket extension" \
1694 -C "found session_ticket extension" \
1695 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001696 -s "session successfully restored from cache" \
1697 -S "session successfully restored from ticket" \
1698 -s "a session has been resumed" \
1699 -c "a session has been resumed"
1700
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001701run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001702 "$P_SRV debug_level=3 tickets=1" \
1703 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001704 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001705 -C "client hello, adding session ticket extension" \
1706 -S "found session ticket extension" \
1707 -S "server hello, adding session ticket extension" \
1708 -C "found session_ticket extension" \
1709 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001710 -s "session successfully restored from cache" \
1711 -S "session successfully restored from ticket" \
1712 -s "a session has been resumed" \
1713 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001714
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001715run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001716 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
1717 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001718 0 \
1719 -S "session successfully restored from cache" \
1720 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001721 -S "a session has been resumed" \
1722 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001723
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001724run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001725 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
1726 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001727 0 \
1728 -s "session successfully restored from cache" \
1729 -S "session successfully restored from ticket" \
1730 -s "a session has been resumed" \
1731 -c "a session has been resumed"
1732
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02001733run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001734 "$P_SRV debug_level=3 tickets=0" \
1735 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001736 0 \
1737 -s "session successfully restored from cache" \
1738 -S "session successfully restored from ticket" \
1739 -s "a session has been resumed" \
1740 -c "a session has been resumed"
1741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001742run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001743 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
1744 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01001745 0 \
1746 -S "session successfully restored from cache" \
1747 -S "session successfully restored from ticket" \
1748 -S "a session has been resumed" \
1749 -C "a session has been resumed"
1750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001751run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001752 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
1753 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01001754 0 \
1755 -s "session successfully restored from cache" \
1756 -S "session successfully restored from ticket" \
1757 -s "a session has been resumed" \
1758 -c "a session has been resumed"
1759
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001760run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001761 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001762 "( $O_CLI -sess_out $SESSION; \
1763 $O_CLI -sess_in $SESSION; \
1764 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001765 0 \
1766 -s "found session ticket extension" \
1767 -S "server hello, adding session ticket extension" \
1768 -s "session successfully restored from cache" \
1769 -S "session successfully restored from ticket" \
1770 -s "a session has been resumed"
1771
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001772run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001773 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001774 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01001775 0 \
1776 -C "found session_ticket extension" \
1777 -C "parse new session ticket" \
1778 -c "a session has been resumed"
1779
Hanno Becker1d739932018-08-21 13:55:22 +01001780# Tests for Session Resume based on session-ID and cache, DTLS
1781
1782run_test "Session resume using cache, DTLS: tickets enabled on client" \
1783 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001784 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001785 0 \
1786 -c "client hello, adding session ticket extension" \
1787 -s "found session ticket extension" \
1788 -S "server hello, adding session ticket extension" \
1789 -C "found session_ticket extension" \
1790 -C "parse new session ticket" \
1791 -s "session successfully restored from cache" \
1792 -S "session successfully restored from ticket" \
1793 -s "a session has been resumed" \
1794 -c "a session has been resumed"
1795
1796run_test "Session resume using cache, DTLS: tickets enabled on server" \
1797 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001798 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001799 0 \
1800 -C "client hello, adding session ticket extension" \
1801 -S "found session ticket extension" \
1802 -S "server hello, adding session ticket extension" \
1803 -C "found session_ticket extension" \
1804 -C "parse new session ticket" \
1805 -s "session successfully restored from cache" \
1806 -S "session successfully restored from ticket" \
1807 -s "a session has been resumed" \
1808 -c "a session has been resumed"
1809
1810run_test "Session resume using cache, DTLS: cache_max=0" \
1811 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001812 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001813 0 \
1814 -S "session successfully restored from cache" \
1815 -S "session successfully restored from ticket" \
1816 -S "a session has been resumed" \
1817 -C "a session has been resumed"
1818
1819run_test "Session resume using cache, DTLS: cache_max=1" \
1820 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001821 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01001822 0 \
1823 -s "session successfully restored from cache" \
1824 -S "session successfully restored from ticket" \
1825 -s "a session has been resumed" \
1826 -c "a session has been resumed"
1827
1828run_test "Session resume using cache, DTLS: timeout > delay" \
1829 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001830 "$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 +01001831 0 \
1832 -s "session successfully restored from cache" \
1833 -S "session successfully restored from ticket" \
1834 -s "a session has been resumed" \
1835 -c "a session has been resumed"
1836
1837run_test "Session resume using cache, DTLS: timeout < delay" \
1838 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001839 "$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 +01001840 0 \
1841 -S "session successfully restored from cache" \
1842 -S "session successfully restored from ticket" \
1843 -S "a session has been resumed" \
1844 -C "a session has been resumed"
1845
1846run_test "Session resume using cache, DTLS: no timeout" \
1847 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01001848 "$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 +01001849 0 \
1850 -s "session successfully restored from cache" \
1851 -S "session successfully restored from ticket" \
1852 -s "a session has been resumed" \
1853 -c "a session has been resumed"
1854
1855run_test "Session resume using cache, DTLS: openssl client" \
1856 "$P_SRV dtls=1 debug_level=3 tickets=0" \
1857 "( $O_CLI -dtls1 -sess_out $SESSION; \
1858 $O_CLI -dtls1 -sess_in $SESSION; \
1859 rm -f $SESSION )" \
1860 0 \
1861 -s "found session ticket extension" \
1862 -S "server hello, adding session ticket extension" \
1863 -s "session successfully restored from cache" \
1864 -S "session successfully restored from ticket" \
1865 -s "a session has been resumed"
1866
1867run_test "Session resume using cache, DTLS: openssl server" \
1868 "$O_SRV -dtls1" \
1869 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
1870 0 \
1871 -C "found session_ticket extension" \
1872 -C "parse new session ticket" \
1873 -c "a session has been resumed"
1874
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001875# Tests for Max Fragment Length extension
1876
Angus Grattonc4dd0732018-04-11 16:28:39 +10001877if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
1878 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 +01001879 exit 1
1880fi
1881
Angus Grattonc4dd0732018-04-11 16:28:39 +10001882if [ $MAX_CONTENT_LEN -ne 16384 ]; then
1883 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
1884fi
1885
Hanno Becker4aed27e2017-09-18 15:00:34 +01001886requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001887run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001888 "$P_SRV debug_level=3" \
1889 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001890 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001891 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1892 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001893 -C "client hello, adding max_fragment_length extension" \
1894 -S "found max fragment length extension" \
1895 -S "server hello, max_fragment_length extension" \
1896 -C "found max_fragment_length extension"
1897
Hanno Becker4aed27e2017-09-18 15:00:34 +01001898requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01001899run_test "Max fragment length: enabled, default, larger message" \
1900 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001901 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001902 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001903 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1904 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001905 -C "client hello, adding max_fragment_length extension" \
1906 -S "found max fragment length extension" \
1907 -S "server hello, max_fragment_length extension" \
1908 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001909 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1910 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001911 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001912
1913requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1914run_test "Max fragment length, DTLS: enabled, default, larger message" \
1915 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001916 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001917 1 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001918 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
1919 -s "Maximum fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001920 -C "client hello, adding max_fragment_length extension" \
1921 -S "found max fragment length extension" \
1922 -S "server hello, max_fragment_length extension" \
1923 -C "found max_fragment_length extension" \
1924 -c "fragment larger than.*maximum "
1925
Angus Grattonc4dd0732018-04-11 16:28:39 +10001926# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
1927# (session fragment length will be 16384 regardless of mbedtls
1928# content length configuration.)
1929
Hanno Beckerc5266962017-09-18 15:01:50 +01001930requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1931run_test "Max fragment length: disabled, larger message" \
1932 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001933 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001934 0 \
1935 -C "Maximum fragment length is 16384" \
1936 -S "Maximum fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001937 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
1938 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01001939 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01001940
1941requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
1942run_test "Max fragment length DTLS: disabled, larger message" \
1943 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001944 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01001945 1 \
1946 -C "Maximum fragment length is 16384" \
1947 -S "Maximum fragment length is 16384" \
1948 -c "fragment larger than.*maximum "
1949
1950requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001951run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001952 "$P_SRV debug_level=3" \
1953 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001954 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001955 -c "Maximum fragment length is 4096" \
1956 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001957 -c "client hello, adding max_fragment_length extension" \
1958 -s "found max fragment length extension" \
1959 -s "server hello, max_fragment_length extension" \
1960 -c "found max_fragment_length extension"
1961
Hanno Becker4aed27e2017-09-18 15:00:34 +01001962requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001963run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001964 "$P_SRV debug_level=3 max_frag_len=4096" \
1965 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001966 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10001967 -c "Maximum fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001968 -s "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01001969 -C "client hello, adding max_fragment_length extension" \
1970 -S "found max fragment length extension" \
1971 -S "server hello, max_fragment_length extension" \
1972 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001973
Hanno Becker4aed27e2017-09-18 15:00:34 +01001974requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02001975requires_gnutls
1976run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001977 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001978 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001979 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001980 -c "Maximum fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02001981 -c "client hello, adding max_fragment_length extension" \
1982 -c "found max_fragment_length extension"
1983
Hanno Becker4aed27e2017-09-18 15:00:34 +01001984requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001985run_test "Max fragment length: client, message just fits" \
1986 "$P_SRV debug_level=3" \
1987 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
1988 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02001989 -c "Maximum fragment length is 2048" \
1990 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001991 -c "client hello, adding max_fragment_length extension" \
1992 -s "found max fragment length extension" \
1993 -s "server hello, max_fragment_length extension" \
1994 -c "found max_fragment_length extension" \
1995 -c "2048 bytes written in 1 fragments" \
1996 -s "2048 bytes read"
1997
Hanno Becker4aed27e2017-09-18 15:00:34 +01001998requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02001999run_test "Max fragment length: client, larger message" \
2000 "$P_SRV debug_level=3" \
2001 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
2002 0 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002003 -c "Maximum fragment length is 2048" \
2004 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002005 -c "client hello, adding max_fragment_length extension" \
2006 -s "found max fragment length extension" \
2007 -s "server hello, max_fragment_length extension" \
2008 -c "found max_fragment_length extension" \
2009 -c "2345 bytes written in 2 fragments" \
2010 -s "2048 bytes read" \
2011 -s "297 bytes read"
2012
Hanno Becker4aed27e2017-09-18 15:00:34 +01002013requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00002014run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002015 "$P_SRV debug_level=3 dtls=1" \
2016 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
2017 1 \
Manuel Pégourié-Gonnarda2cda6b2015-08-31 18:30:52 +02002018 -c "Maximum fragment length is 2048" \
2019 -s "Maximum fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02002020 -c "client hello, adding max_fragment_length extension" \
2021 -s "found max fragment length extension" \
2022 -s "server hello, max_fragment_length extension" \
2023 -c "found max_fragment_length extension" \
2024 -c "fragment larger than.*maximum"
2025
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002026# Tests for renegotiation
2027
Hanno Becker6a243642017-10-12 15:18:45 +01002028# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002029run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002030 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002031 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002032 0 \
2033 -C "client hello, adding renegotiation extension" \
2034 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2035 -S "found renegotiation extension" \
2036 -s "server hello, secure renegotiation extension" \
2037 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002038 -C "=> renegotiate" \
2039 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002040 -S "write hello request"
2041
Hanno Becker6a243642017-10-12 15:18:45 +01002042requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002043run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002044 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002045 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002046 0 \
2047 -c "client hello, adding renegotiation extension" \
2048 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2049 -s "found renegotiation extension" \
2050 -s "server hello, secure renegotiation extension" \
2051 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002052 -c "=> renegotiate" \
2053 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002054 -S "write hello request"
2055
Hanno Becker6a243642017-10-12 15:18:45 +01002056requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002057run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002058 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002059 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002060 0 \
2061 -c "client hello, adding renegotiation extension" \
2062 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2063 -s "found renegotiation extension" \
2064 -s "server hello, secure renegotiation extension" \
2065 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002066 -c "=> renegotiate" \
2067 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002068 -s "write hello request"
2069
Janos Follathb0f148c2017-10-05 12:29:42 +01002070# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2071# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2072# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002073requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002074run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
2075 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
2076 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
2077 0 \
2078 -c "client hello, adding renegotiation extension" \
2079 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2080 -s "found renegotiation extension" \
2081 -s "server hello, secure renegotiation extension" \
2082 -c "found renegotiation extension" \
2083 -c "=> renegotiate" \
2084 -s "=> renegotiate" \
2085 -S "write hello request" \
2086 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2087
2088# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
2089# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
2090# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01002091requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01002092run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
2093 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
2094 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2095 0 \
2096 -c "client hello, adding renegotiation extension" \
2097 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2098 -s "found renegotiation extension" \
2099 -s "server hello, secure renegotiation extension" \
2100 -c "found renegotiation extension" \
2101 -c "=> renegotiate" \
2102 -s "=> renegotiate" \
2103 -s "write hello request" \
2104 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
2105
Hanno Becker6a243642017-10-12 15:18:45 +01002106requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002107run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002108 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002109 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002110 0 \
2111 -c "client hello, adding renegotiation extension" \
2112 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2113 -s "found renegotiation extension" \
2114 -s "server hello, secure renegotiation extension" \
2115 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002116 -c "=> renegotiate" \
2117 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002118 -s "write hello request"
2119
Hanno Becker6a243642017-10-12 15:18:45 +01002120requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002121run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002122 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002123 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002124 1 \
2125 -c "client hello, adding renegotiation extension" \
2126 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2127 -S "found renegotiation extension" \
2128 -s "server hello, secure renegotiation extension" \
2129 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002130 -c "=> renegotiate" \
2131 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002132 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02002133 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002134 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002135
Hanno Becker6a243642017-10-12 15:18:45 +01002136requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002137run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002138 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002139 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002140 0 \
2141 -C "client hello, adding renegotiation extension" \
2142 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2143 -S "found renegotiation extension" \
2144 -s "server hello, secure renegotiation extension" \
2145 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01002146 -C "=> renegotiate" \
2147 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002148 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02002149 -S "SSL - An unexpected message was received from our peer" \
2150 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01002151
Hanno Becker6a243642017-10-12 15:18:45 +01002152requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002153run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002154 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002155 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002156 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002157 0 \
2158 -C "client hello, adding renegotiation extension" \
2159 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2160 -S "found renegotiation extension" \
2161 -s "server hello, secure renegotiation extension" \
2162 -c "found renegotiation extension" \
2163 -C "=> renegotiate" \
2164 -S "=> renegotiate" \
2165 -s "write hello request" \
2166 -S "SSL - An unexpected message was received from our peer" \
2167 -S "failed"
2168
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002169# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01002170requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002171run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002172 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002173 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002174 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002175 0 \
2176 -C "client hello, adding renegotiation extension" \
2177 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2178 -S "found renegotiation extension" \
2179 -s "server hello, secure renegotiation extension" \
2180 -c "found renegotiation extension" \
2181 -C "=> renegotiate" \
2182 -S "=> renegotiate" \
2183 -s "write hello request" \
2184 -S "SSL - An unexpected message was received from our peer" \
2185 -S "failed"
2186
Hanno Becker6a243642017-10-12 15:18:45 +01002187requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002188run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002189 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002190 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002191 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002192 0 \
2193 -C "client hello, adding renegotiation extension" \
2194 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2195 -S "found renegotiation extension" \
2196 -s "server hello, secure renegotiation extension" \
2197 -c "found renegotiation extension" \
2198 -C "=> renegotiate" \
2199 -S "=> renegotiate" \
2200 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02002201 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002202
Hanno Becker6a243642017-10-12 15:18:45 +01002203requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002204run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002205 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002206 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002207 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02002208 0 \
2209 -c "client hello, adding renegotiation extension" \
2210 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2211 -s "found renegotiation extension" \
2212 -s "server hello, secure renegotiation extension" \
2213 -c "found renegotiation extension" \
2214 -c "=> renegotiate" \
2215 -s "=> renegotiate" \
2216 -s "write hello request" \
2217 -S "SSL - An unexpected message was received from our peer" \
2218 -S "failed"
2219
Hanno Becker6a243642017-10-12 15:18:45 +01002220requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002221run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002222 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002223 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
2224 0 \
2225 -C "client hello, adding renegotiation extension" \
2226 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2227 -S "found renegotiation extension" \
2228 -s "server hello, secure renegotiation extension" \
2229 -c "found renegotiation extension" \
2230 -S "record counter limit reached: renegotiate" \
2231 -C "=> renegotiate" \
2232 -S "=> renegotiate" \
2233 -S "write hello request" \
2234 -S "SSL - An unexpected message was received from our peer" \
2235 -S "failed"
2236
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002237# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01002238requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002239run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002240 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002241 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002242 0 \
2243 -c "client hello, adding renegotiation extension" \
2244 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2245 -s "found renegotiation extension" \
2246 -s "server hello, secure renegotiation extension" \
2247 -c "found renegotiation extension" \
2248 -s "record counter limit reached: renegotiate" \
2249 -c "=> renegotiate" \
2250 -s "=> renegotiate" \
2251 -s "write hello request" \
2252 -S "SSL - An unexpected message was received from our peer" \
2253 -S "failed"
2254
Hanno Becker6a243642017-10-12 15:18:45 +01002255requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002256run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002257 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01002258 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002259 0 \
2260 -c "client hello, adding renegotiation extension" \
2261 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2262 -s "found renegotiation extension" \
2263 -s "server hello, secure renegotiation extension" \
2264 -c "found renegotiation extension" \
2265 -s "record counter limit reached: renegotiate" \
2266 -c "=> renegotiate" \
2267 -s "=> renegotiate" \
2268 -s "write hello request" \
2269 -S "SSL - An unexpected message was received from our peer" \
2270 -S "failed"
2271
Hanno Becker6a243642017-10-12 15:18:45 +01002272requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002273run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002274 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01002275 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
2276 0 \
2277 -C "client hello, adding renegotiation extension" \
2278 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2279 -S "found renegotiation extension" \
2280 -s "server hello, secure renegotiation extension" \
2281 -c "found renegotiation extension" \
2282 -S "record counter limit reached: renegotiate" \
2283 -C "=> renegotiate" \
2284 -S "=> renegotiate" \
2285 -S "write hello request" \
2286 -S "SSL - An unexpected message was received from our peer" \
2287 -S "failed"
2288
Hanno Becker6a243642017-10-12 15:18:45 +01002289requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002290run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002291 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002292 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002293 0 \
2294 -c "client hello, adding renegotiation extension" \
2295 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2296 -s "found renegotiation extension" \
2297 -s "server hello, secure renegotiation extension" \
2298 -c "found renegotiation extension" \
2299 -c "=> renegotiate" \
2300 -s "=> renegotiate" \
2301 -S "write hello request"
2302
Hanno Becker6a243642017-10-12 15:18:45 +01002303requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002304run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01002305 "$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 +02002306 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02002307 0 \
2308 -c "client hello, adding renegotiation extension" \
2309 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2310 -s "found renegotiation extension" \
2311 -s "server hello, secure renegotiation extension" \
2312 -c "found renegotiation extension" \
2313 -c "=> renegotiate" \
2314 -s "=> renegotiate" \
2315 -s "write hello request"
2316
Hanno Becker6a243642017-10-12 15:18:45 +01002317requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002318run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02002319 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002320 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002321 0 \
2322 -c "client hello, adding renegotiation extension" \
2323 -c "found renegotiation extension" \
2324 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002325 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002326 -C "error" \
2327 -c "HTTP/1.0 200 [Oo][Kk]"
2328
Paul Bakker539d9722015-02-08 16:18:35 +01002329requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002330requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002331run_test "Renegotiation: gnutls server strict, client-initiated" \
2332 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002333 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002334 0 \
2335 -c "client hello, adding renegotiation extension" \
2336 -c "found renegotiation extension" \
2337 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002338 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02002339 -C "error" \
2340 -c "HTTP/1.0 200 [Oo][Kk]"
2341
Paul Bakker539d9722015-02-08 16:18:35 +01002342requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002343requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002344run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
2345 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2346 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
2347 1 \
2348 -c "client hello, adding renegotiation extension" \
2349 -C "found renegotiation extension" \
2350 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002351 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002352 -c "error" \
2353 -C "HTTP/1.0 200 [Oo][Kk]"
2354
Paul Bakker539d9722015-02-08 16:18:35 +01002355requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002356requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002357run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
2358 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2359 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2360 allow_legacy=0" \
2361 1 \
2362 -c "client hello, adding renegotiation extension" \
2363 -C "found renegotiation extension" \
2364 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002365 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002366 -c "error" \
2367 -C "HTTP/1.0 200 [Oo][Kk]"
2368
Paul Bakker539d9722015-02-08 16:18:35 +01002369requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002370requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002371run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
2372 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2373 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
2374 allow_legacy=1" \
2375 0 \
2376 -c "client hello, adding renegotiation extension" \
2377 -C "found renegotiation extension" \
2378 -c "=> renegotiate" \
2379 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002380 -C "error" \
2381 -c "HTTP/1.0 200 [Oo][Kk]"
2382
Hanno Becker6a243642017-10-12 15:18:45 +01002383requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02002384run_test "Renegotiation: DTLS, client-initiated" \
2385 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
2386 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
2387 0 \
2388 -c "client hello, adding renegotiation extension" \
2389 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2390 -s "found renegotiation extension" \
2391 -s "server hello, secure renegotiation extension" \
2392 -c "found renegotiation extension" \
2393 -c "=> renegotiate" \
2394 -s "=> renegotiate" \
2395 -S "write hello request"
2396
Hanno Becker6a243642017-10-12 15:18:45 +01002397requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002398run_test "Renegotiation: DTLS, server-initiated" \
2399 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02002400 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
2401 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02002402 0 \
2403 -c "client hello, adding renegotiation extension" \
2404 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2405 -s "found renegotiation extension" \
2406 -s "server hello, secure renegotiation extension" \
2407 -c "found renegotiation extension" \
2408 -c "=> renegotiate" \
2409 -s "=> renegotiate" \
2410 -s "write hello request"
2411
Hanno Becker6a243642017-10-12 15:18:45 +01002412requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00002413run_test "Renegotiation: DTLS, renego_period overflow" \
2414 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
2415 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
2416 0 \
2417 -c "client hello, adding renegotiation extension" \
2418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
2419 -s "found renegotiation extension" \
2420 -s "server hello, secure renegotiation extension" \
2421 -s "record counter limit reached: renegotiate" \
2422 -c "=> renegotiate" \
2423 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01002424 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00002425
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00002426requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01002427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002428run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
2429 "$G_SRV -u --mtu 4096" \
2430 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
2431 0 \
2432 -c "client hello, adding renegotiation extension" \
2433 -c "found renegotiation extension" \
2434 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002435 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02002436 -C "error" \
2437 -s "Extra-header:"
2438
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002439# Test for the "secure renegotation" extension only (no actual renegotiation)
2440
Paul Bakker539d9722015-02-08 16:18:35 +01002441requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002442run_test "Renego ext: gnutls server strict, client default" \
2443 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
2444 "$P_CLI debug_level=3" \
2445 0 \
2446 -c "found renegotiation extension" \
2447 -C "error" \
2448 -c "HTTP/1.0 200 [Oo][Kk]"
2449
Paul Bakker539d9722015-02-08 16:18:35 +01002450requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002451run_test "Renego ext: gnutls server unsafe, client default" \
2452 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2453 "$P_CLI debug_level=3" \
2454 0 \
2455 -C "found renegotiation extension" \
2456 -C "error" \
2457 -c "HTTP/1.0 200 [Oo][Kk]"
2458
Paul Bakker539d9722015-02-08 16:18:35 +01002459requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002460run_test "Renego ext: gnutls server unsafe, client break legacy" \
2461 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
2462 "$P_CLI debug_level=3 allow_legacy=-1" \
2463 1 \
2464 -C "found renegotiation extension" \
2465 -c "error" \
2466 -C "HTTP/1.0 200 [Oo][Kk]"
2467
Paul Bakker539d9722015-02-08 16:18:35 +01002468requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002469run_test "Renego ext: gnutls client strict, server default" \
2470 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002471 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002472 0 \
2473 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2474 -s "server hello, secure renegotiation extension"
2475
Paul Bakker539d9722015-02-08 16:18:35 +01002476requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002477run_test "Renego ext: gnutls client unsafe, server default" \
2478 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002479 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002480 0 \
2481 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2482 -S "server hello, secure renegotiation extension"
2483
Paul Bakker539d9722015-02-08 16:18:35 +01002484requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002485run_test "Renego ext: gnutls client unsafe, server break legacy" \
2486 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002487 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01002488 1 \
2489 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
2490 -S "server hello, secure renegotiation extension"
2491
Janos Follath0b242342016-02-17 10:11:21 +00002492# Tests for silently dropping trailing extra bytes in .der certificates
2493
2494requires_gnutls
2495run_test "DER format: no trailing bytes" \
2496 "$P_SRV crt_file=data_files/server5-der0.crt \
2497 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002498 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002499 0 \
2500 -c "Handshake was completed" \
2501
2502requires_gnutls
2503run_test "DER format: with a trailing zero byte" \
2504 "$P_SRV crt_file=data_files/server5-der1a.crt \
2505 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002506 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002507 0 \
2508 -c "Handshake was completed" \
2509
2510requires_gnutls
2511run_test "DER format: with a trailing random byte" \
2512 "$P_SRV crt_file=data_files/server5-der1b.crt \
2513 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002514 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002515 0 \
2516 -c "Handshake was completed" \
2517
2518requires_gnutls
2519run_test "DER format: with 2 trailing random bytes" \
2520 "$P_SRV crt_file=data_files/server5-der2.crt \
2521 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002522 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002523 0 \
2524 -c "Handshake was completed" \
2525
2526requires_gnutls
2527run_test "DER format: with 4 trailing random bytes" \
2528 "$P_SRV crt_file=data_files/server5-der4.crt \
2529 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002530 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002531 0 \
2532 -c "Handshake was completed" \
2533
2534requires_gnutls
2535run_test "DER format: with 8 trailing random bytes" \
2536 "$P_SRV crt_file=data_files/server5-der8.crt \
2537 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002538 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002539 0 \
2540 -c "Handshake was completed" \
2541
2542requires_gnutls
2543run_test "DER format: with 9 trailing random bytes" \
2544 "$P_SRV crt_file=data_files/server5-der9.crt \
2545 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02002546 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00002547 0 \
2548 -c "Handshake was completed" \
2549
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002550# Tests for auth_mode
2551
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002552run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002553 "$P_SRV crt_file=data_files/server5-badsign.crt \
2554 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002555 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002556 1 \
2557 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002558 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002559 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002560 -c "X509 - Certificate verification failed"
2561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002562run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002563 "$P_SRV crt_file=data_files/server5-badsign.crt \
2564 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002565 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002566 0 \
2567 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002568 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002569 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002570 -C "X509 - Certificate verification failed"
2571
Hanno Beckere6706e62017-05-15 16:05:15 +01002572run_test "Authentication: server goodcert, client optional, no trusted CA" \
2573 "$P_SRV" \
2574 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
2575 0 \
2576 -c "x509_verify_cert() returned" \
2577 -c "! The certificate is not correctly signed by the trusted CA" \
2578 -c "! Certificate verification flags"\
2579 -C "! mbedtls_ssl_handshake returned" \
2580 -C "X509 - Certificate verification failed" \
2581 -C "SSL - No CA Chain is set, but required to operate"
2582
2583run_test "Authentication: server goodcert, client required, no trusted CA" \
2584 "$P_SRV" \
2585 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
2586 1 \
2587 -c "x509_verify_cert() returned" \
2588 -c "! The certificate is not correctly signed by the trusted CA" \
2589 -c "! Certificate verification flags"\
2590 -c "! mbedtls_ssl_handshake returned" \
2591 -c "SSL - No CA Chain is set, but required to operate"
2592
2593# The purpose of the next two tests is to test the client's behaviour when receiving a server
2594# certificate with an unsupported elliptic curve. This should usually not happen because
2595# the client informs the server about the supported curves - it does, though, in the
2596# corner case of a static ECDH suite, because the server doesn't check the curve on that
2597# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
2598# different means to have the server ignoring the client's supported curve list.
2599
2600requires_config_enabled MBEDTLS_ECP_C
2601run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
2602 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2603 crt_file=data_files/server5.ku-ka.crt" \
2604 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
2605 1 \
2606 -c "bad certificate (EC key curve)"\
2607 -c "! Certificate verification flags"\
2608 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
2609
2610requires_config_enabled MBEDTLS_ECP_C
2611run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
2612 "$P_SRV debug_level=1 key_file=data_files/server5.key \
2613 crt_file=data_files/server5.ku-ka.crt" \
2614 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
2615 1 \
2616 -c "bad certificate (EC key curve)"\
2617 -c "! Certificate verification flags"\
2618 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
2619
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002620run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01002621 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002622 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002623 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002624 0 \
2625 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002626 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002627 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002628 -C "X509 - Certificate verification failed"
2629
Simon Butcher99000142016-10-13 17:21:01 +01002630run_test "Authentication: client SHA256, server required" \
2631 "$P_SRV auth_mode=required" \
2632 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2633 key_file=data_files/server6.key \
2634 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
2635 0 \
2636 -c "Supported Signature Algorithm found: 4," \
2637 -c "Supported Signature Algorithm found: 5,"
2638
2639run_test "Authentication: client SHA384, server required" \
2640 "$P_SRV auth_mode=required" \
2641 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
2642 key_file=data_files/server6.key \
2643 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
2644 0 \
2645 -c "Supported Signature Algorithm found: 4," \
2646 -c "Supported Signature Algorithm found: 5,"
2647
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002648requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
2649run_test "Authentication: client has no cert, server required (SSLv3)" \
2650 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
2651 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
2652 key_file=data_files/server5.key" \
2653 1 \
2654 -S "skip write certificate request" \
2655 -C "skip parse certificate request" \
2656 -c "got a certificate request" \
2657 -c "got no certificate to send" \
2658 -S "x509_verify_cert() returned" \
2659 -s "client has no certificate" \
2660 -s "! mbedtls_ssl_handshake returned" \
2661 -c "! mbedtls_ssl_handshake returned" \
2662 -s "No client certification received from the client, but required by the authentication mode"
2663
2664run_test "Authentication: client has no cert, server required (TLS)" \
2665 "$P_SRV debug_level=3 auth_mode=required" \
2666 "$P_CLI debug_level=3 crt_file=none \
2667 key_file=data_files/server5.key" \
2668 1 \
2669 -S "skip write certificate request" \
2670 -C "skip parse certificate request" \
2671 -c "got a certificate request" \
2672 -c "= write certificate$" \
2673 -C "skip write certificate$" \
2674 -S "x509_verify_cert() returned" \
2675 -s "client has no certificate" \
2676 -s "! mbedtls_ssl_handshake returned" \
2677 -c "! mbedtls_ssl_handshake returned" \
2678 -s "No client certification received from the client, but required by the authentication mode"
2679
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002680run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002681 "$P_SRV debug_level=3 auth_mode=required" \
2682 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002683 key_file=data_files/server5.key" \
2684 1 \
2685 -S "skip write certificate request" \
2686 -C "skip parse certificate request" \
2687 -c "got a certificate request" \
2688 -C "skip write certificate" \
2689 -C "skip write certificate verify" \
2690 -S "skip parse certificate verify" \
2691 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002692 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002693 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002694 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002695 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002696 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02002697# We don't check that the client receives the alert because it might
2698# detect that its write end of the connection is closed and abort
2699# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002700
Janos Follath89baba22017-04-10 14:34:35 +01002701run_test "Authentication: client cert not trusted, server required" \
2702 "$P_SRV debug_level=3 auth_mode=required" \
2703 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2704 key_file=data_files/server5.key" \
2705 1 \
2706 -S "skip write certificate request" \
2707 -C "skip parse certificate request" \
2708 -c "got a certificate request" \
2709 -C "skip write certificate" \
2710 -C "skip write certificate verify" \
2711 -S "skip parse certificate verify" \
2712 -s "x509_verify_cert() returned" \
2713 -s "! The certificate is not correctly signed by the trusted CA" \
2714 -s "! mbedtls_ssl_handshake returned" \
2715 -c "! mbedtls_ssl_handshake returned" \
2716 -s "X509 - Certificate verification failed"
2717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002718run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002719 "$P_SRV debug_level=3 auth_mode=optional" \
2720 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002721 key_file=data_files/server5.key" \
2722 0 \
2723 -S "skip write certificate request" \
2724 -C "skip parse certificate request" \
2725 -c "got a certificate request" \
2726 -C "skip write certificate" \
2727 -C "skip write certificate verify" \
2728 -S "skip parse certificate verify" \
2729 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002730 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002731 -S "! mbedtls_ssl_handshake returned" \
2732 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002733 -S "X509 - Certificate verification failed"
2734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002735run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002736 "$P_SRV debug_level=3 auth_mode=none" \
2737 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002738 key_file=data_files/server5.key" \
2739 0 \
2740 -s "skip write certificate request" \
2741 -C "skip parse certificate request" \
2742 -c "got no certificate request" \
2743 -c "skip write certificate" \
2744 -c "skip write certificate verify" \
2745 -s "skip parse certificate verify" \
2746 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002747 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002748 -S "! mbedtls_ssl_handshake returned" \
2749 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01002750 -S "X509 - Certificate verification failed"
2751
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002752run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002753 "$P_SRV debug_level=3 auth_mode=optional" \
2754 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002755 0 \
2756 -S "skip write certificate request" \
2757 -C "skip parse certificate request" \
2758 -c "got a certificate request" \
2759 -C "skip write certificate$" \
2760 -C "got no certificate to send" \
2761 -S "SSLv3 client has no certificate" \
2762 -c "skip write certificate verify" \
2763 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002764 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002765 -S "! mbedtls_ssl_handshake returned" \
2766 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002767 -S "X509 - Certificate verification failed"
2768
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002769run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002770 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002771 "$O_CLI" \
2772 0 \
2773 -S "skip write certificate request" \
2774 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002775 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002776 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002777 -S "X509 - Certificate verification failed"
2778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002779run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002780 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002781 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002782 0 \
2783 -C "skip parse certificate request" \
2784 -c "got a certificate request" \
2785 -C "skip write certificate$" \
2786 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002787 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002788
Gilles Peskinefd8332e2017-05-03 16:25:07 +02002789run_test "Authentication: client no cert, openssl server required" \
2790 "$O_SRV -Verify 10" \
2791 "$P_CLI debug_level=3 crt_file=none key_file=none" \
2792 1 \
2793 -C "skip parse certificate request" \
2794 -c "got a certificate request" \
2795 -C "skip write certificate$" \
2796 -c "skip write certificate verify" \
2797 -c "! mbedtls_ssl_handshake returned"
2798
Janos Follathe2681a42016-03-07 15:57:05 +00002799requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002800run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002801 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01002802 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002803 0 \
2804 -S "skip write certificate request" \
2805 -C "skip parse certificate request" \
2806 -c "got a certificate request" \
2807 -C "skip write certificate$" \
2808 -c "skip write certificate verify" \
2809 -c "got no certificate to send" \
2810 -s "SSLv3 client has no certificate" \
2811 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01002812 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02002813 -S "! mbedtls_ssl_handshake returned" \
2814 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01002815 -S "X509 - Certificate verification failed"
2816
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02002817# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
2818# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002819
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002820MAX_IM_CA='8'
Simon Butcher06b78632017-07-28 01:00:17 +01002821MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002822
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002823if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01002824 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002825 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002826 printf "test value of ${MAX_IM_CA}. \n"
2827 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01002828 printf "The tests assume this value and if it changes, the tests in this\n"
2829 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002830 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01002831
2832 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01002833fi
2834
Angus Grattonc4dd0732018-04-11 16:28:39 +10002835requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002836run_test "Authentication: server max_int chain, client default" \
2837 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
2838 key_file=data_files/dir-maxpath/09.key" \
2839 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
2840 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002841 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002842
Angus Grattonc4dd0732018-04-11 16:28:39 +10002843requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002844run_test "Authentication: server max_int+1 chain, client default" \
2845 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2846 key_file=data_files/dir-maxpath/10.key" \
2847 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
2848 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002849 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002850
Angus Grattonc4dd0732018-04-11 16:28:39 +10002851requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002852run_test "Authentication: server max_int+1 chain, client optional" \
2853 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2854 key_file=data_files/dir-maxpath/10.key" \
2855 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2856 auth_mode=optional" \
2857 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002858 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002859
Angus Grattonc4dd0732018-04-11 16:28:39 +10002860requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002861run_test "Authentication: server max_int+1 chain, client none" \
2862 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
2863 key_file=data_files/dir-maxpath/10.key" \
2864 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
2865 auth_mode=none" \
2866 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002867 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002868
Angus Grattonc4dd0732018-04-11 16:28:39 +10002869requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002870run_test "Authentication: client max_int+1 chain, server default" \
2871 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
2872 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2873 key_file=data_files/dir-maxpath/10.key" \
2874 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002875 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002876
Angus Grattonc4dd0732018-04-11 16:28:39 +10002877requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002878run_test "Authentication: client max_int+1 chain, server optional" \
2879 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
2880 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2881 key_file=data_files/dir-maxpath/10.key" \
2882 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002883 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002884
Angus Grattonc4dd0732018-04-11 16:28:39 +10002885requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002886run_test "Authentication: client max_int+1 chain, server required" \
2887 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2888 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
2889 key_file=data_files/dir-maxpath/10.key" \
2890 1 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002891 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002892
Angus Grattonc4dd0732018-04-11 16:28:39 +10002893requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002894run_test "Authentication: client max_int chain, server required" \
2895 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
2896 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
2897 key_file=data_files/dir-maxpath/09.key" \
2898 0 \
Antonin Décimod5f47592019-01-23 15:24:37 +01002899 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02002900
Janos Follath89baba22017-04-10 14:34:35 +01002901# Tests for CA list in CertificateRequest messages
2902
2903run_test "Authentication: send CA list in CertificateRequest (default)" \
2904 "$P_SRV debug_level=3 auth_mode=required" \
2905 "$P_CLI crt_file=data_files/server6.crt \
2906 key_file=data_files/server6.key" \
2907 0 \
2908 -s "requested DN"
2909
2910run_test "Authentication: do not send CA list in CertificateRequest" \
2911 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2912 "$P_CLI crt_file=data_files/server6.crt \
2913 key_file=data_files/server6.key" \
2914 0 \
2915 -S "requested DN"
2916
2917run_test "Authentication: send CA list in CertificateRequest, client self signed" \
2918 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
2919 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
2920 key_file=data_files/server5.key" \
2921 1 \
2922 -S "requested DN" \
2923 -s "x509_verify_cert() returned" \
2924 -s "! The certificate is not correctly signed by the trusted CA" \
2925 -s "! mbedtls_ssl_handshake returned" \
2926 -c "! mbedtls_ssl_handshake returned" \
2927 -s "X509 - Certificate verification failed"
2928
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01002929# Tests for certificate selection based on SHA verson
2930
2931run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
2932 "$P_SRV crt_file=data_files/server5.crt \
2933 key_file=data_files/server5.key \
2934 crt_file2=data_files/server5-sha1.crt \
2935 key_file2=data_files/server5.key" \
2936 "$P_CLI force_version=tls1_2" \
2937 0 \
2938 -c "signed using.*ECDSA with SHA256" \
2939 -C "signed using.*ECDSA with SHA1"
2940
2941run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
2942 "$P_SRV crt_file=data_files/server5.crt \
2943 key_file=data_files/server5.key \
2944 crt_file2=data_files/server5-sha1.crt \
2945 key_file2=data_files/server5.key" \
2946 "$P_CLI force_version=tls1_1" \
2947 0 \
2948 -C "signed using.*ECDSA with SHA256" \
2949 -c "signed using.*ECDSA with SHA1"
2950
2951run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
2952 "$P_SRV crt_file=data_files/server5.crt \
2953 key_file=data_files/server5.key \
2954 crt_file2=data_files/server5-sha1.crt \
2955 key_file2=data_files/server5.key" \
2956 "$P_CLI force_version=tls1" \
2957 0 \
2958 -C "signed using.*ECDSA with SHA256" \
2959 -c "signed using.*ECDSA with SHA1"
2960
2961run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
2962 "$P_SRV crt_file=data_files/server5.crt \
2963 key_file=data_files/server5.key \
2964 crt_file2=data_files/server6.crt \
2965 key_file2=data_files/server6.key" \
2966 "$P_CLI force_version=tls1_1" \
2967 0 \
2968 -c "serial number.*09" \
2969 -c "signed using.*ECDSA with SHA256" \
2970 -C "signed using.*ECDSA with SHA1"
2971
2972run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
2973 "$P_SRV crt_file=data_files/server6.crt \
2974 key_file=data_files/server6.key \
2975 crt_file2=data_files/server5.crt \
2976 key_file2=data_files/server5.key" \
2977 "$P_CLI force_version=tls1_1" \
2978 0 \
2979 -c "serial number.*0A" \
2980 -c "signed using.*ECDSA with SHA256" \
2981 -C "signed using.*ECDSA with SHA1"
2982
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002983# tests for SNI
2984
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002985run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002986 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002987 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002988 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002989 0 \
2990 -S "parse ServerName extension" \
2991 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
2992 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002993
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002994run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02002995 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01002996 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02002997 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 +02002998 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02002999 0 \
3000 -s "parse ServerName extension" \
3001 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3002 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003004run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003005 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003006 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003007 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 +02003008 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003009 0 \
3010 -s "parse ServerName extension" \
3011 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3012 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003013
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003014run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02003015 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003016 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02003017 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 +02003018 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003019 1 \
3020 -s "parse ServerName extension" \
3021 -s "ssl_sni_wrapper() returned" \
3022 -s "mbedtls_ssl_handshake returned" \
3023 -c "mbedtls_ssl_handshake returned" \
3024 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01003025
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003026run_test "SNI: client auth no override: optional" \
3027 "$P_SRV debug_level=3 auth_mode=optional \
3028 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3029 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3030 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003031 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003032 -S "skip write certificate request" \
3033 -C "skip parse certificate request" \
3034 -c "got a certificate request" \
3035 -C "skip write certificate" \
3036 -C "skip write certificate verify" \
3037 -S "skip parse certificate verify"
3038
3039run_test "SNI: client auth override: none -> optional" \
3040 "$P_SRV debug_level=3 auth_mode=none \
3041 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3042 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3043 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003044 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003045 -S "skip write certificate request" \
3046 -C "skip parse certificate request" \
3047 -c "got a certificate request" \
3048 -C "skip write certificate" \
3049 -C "skip write certificate verify" \
3050 -S "skip parse certificate verify"
3051
3052run_test "SNI: client auth override: optional -> none" \
3053 "$P_SRV debug_level=3 auth_mode=optional \
3054 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3055 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3056 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003057 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02003058 -s "skip write certificate request" \
3059 -C "skip parse certificate request" \
3060 -c "got no certificate request" \
3061 -c "skip write certificate" \
3062 -c "skip write certificate verify" \
3063 -s "skip parse certificate verify"
3064
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003065run_test "SNI: CA no override" \
3066 "$P_SRV debug_level=3 auth_mode=optional \
3067 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3068 ca_file=data_files/test-ca.crt \
3069 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3070 "$P_CLI debug_level=3 server_name=localhost \
3071 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3072 1 \
3073 -S "skip write certificate request" \
3074 -C "skip parse certificate request" \
3075 -c "got a certificate request" \
3076 -C "skip write certificate" \
3077 -C "skip write certificate verify" \
3078 -S "skip parse certificate verify" \
3079 -s "x509_verify_cert() returned" \
3080 -s "! The certificate is not correctly signed by the trusted CA" \
3081 -S "The certificate has been revoked (is on a CRL)"
3082
3083run_test "SNI: CA override" \
3084 "$P_SRV debug_level=3 auth_mode=optional \
3085 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3086 ca_file=data_files/test-ca.crt \
3087 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3088 "$P_CLI debug_level=3 server_name=localhost \
3089 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3090 0 \
3091 -S "skip write certificate request" \
3092 -C "skip parse certificate request" \
3093 -c "got a certificate request" \
3094 -C "skip write certificate" \
3095 -C "skip write certificate verify" \
3096 -S "skip parse certificate verify" \
3097 -S "x509_verify_cert() returned" \
3098 -S "! The certificate is not correctly signed by the trusted CA" \
3099 -S "The certificate has been revoked (is on a CRL)"
3100
3101run_test "SNI: CA override with CRL" \
3102 "$P_SRV debug_level=3 auth_mode=optional \
3103 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3104 ca_file=data_files/test-ca.crt \
3105 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3106 "$P_CLI debug_level=3 server_name=localhost \
3107 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3108 1 \
3109 -S "skip write certificate request" \
3110 -C "skip parse certificate request" \
3111 -c "got a certificate request" \
3112 -C "skip write certificate" \
3113 -C "skip write certificate verify" \
3114 -S "skip parse certificate verify" \
3115 -s "x509_verify_cert() returned" \
3116 -S "! The certificate is not correctly signed by the trusted CA" \
3117 -s "The certificate has been revoked (is on a CRL)"
3118
Andres AG1a834452016-12-07 10:01:30 +00003119# Tests for SNI and DTLS
3120
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003121run_test "SNI: DTLS, no SNI callback" \
3122 "$P_SRV debug_level=3 dtls=1 \
3123 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
3124 "$P_CLI server_name=localhost dtls=1" \
3125 0 \
3126 -S "parse ServerName extension" \
3127 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
3128 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3129
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003130run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00003131 "$P_SRV debug_level=3 dtls=1 \
3132 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3133 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3134 "$P_CLI server_name=localhost dtls=1" \
3135 0 \
3136 -s "parse ServerName extension" \
3137 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3138 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
3139
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01003140run_test "SNI: DTLS, matching cert 2" \
3141 "$P_SRV debug_level=3 dtls=1 \
3142 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3143 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3144 "$P_CLI server_name=polarssl.example dtls=1" \
3145 0 \
3146 -s "parse ServerName extension" \
3147 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
3148 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
3149
3150run_test "SNI: DTLS, no matching cert" \
3151 "$P_SRV debug_level=3 dtls=1 \
3152 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3153 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
3154 "$P_CLI server_name=nonesuch.example dtls=1" \
3155 1 \
3156 -s "parse ServerName extension" \
3157 -s "ssl_sni_wrapper() returned" \
3158 -s "mbedtls_ssl_handshake returned" \
3159 -c "mbedtls_ssl_handshake returned" \
3160 -c "SSL - A fatal alert message was received from our peer"
3161
3162run_test "SNI: DTLS, client auth no override: optional" \
3163 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3164 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3165 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
3166 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3167 0 \
3168 -S "skip write certificate request" \
3169 -C "skip parse certificate request" \
3170 -c "got a certificate request" \
3171 -C "skip write certificate" \
3172 -C "skip write certificate verify" \
3173 -S "skip parse certificate verify"
3174
3175run_test "SNI: DTLS, client auth override: none -> optional" \
3176 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
3177 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3178 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
3179 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3180 0 \
3181 -S "skip write certificate request" \
3182 -C "skip parse certificate request" \
3183 -c "got a certificate request" \
3184 -C "skip write certificate" \
3185 -C "skip write certificate verify" \
3186 -S "skip parse certificate verify"
3187
3188run_test "SNI: DTLS, client auth override: optional -> none" \
3189 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3190 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3191 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
3192 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
3193 0 \
3194 -s "skip write certificate request" \
3195 -C "skip parse certificate request" \
3196 -c "got no certificate request" \
3197 -c "skip write certificate" \
3198 -c "skip write certificate verify" \
3199 -s "skip parse certificate verify"
3200
3201run_test "SNI: DTLS, CA no override" \
3202 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3203 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3204 ca_file=data_files/test-ca.crt \
3205 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
3206 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3207 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3208 1 \
3209 -S "skip write certificate request" \
3210 -C "skip parse certificate request" \
3211 -c "got a certificate request" \
3212 -C "skip write certificate" \
3213 -C "skip write certificate verify" \
3214 -S "skip parse certificate verify" \
3215 -s "x509_verify_cert() returned" \
3216 -s "! The certificate is not correctly signed by the trusted CA" \
3217 -S "The certificate has been revoked (is on a CRL)"
3218
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003219run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00003220 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
3221 crt_file=data_files/server5.crt key_file=data_files/server5.key \
3222 ca_file=data_files/test-ca.crt \
3223 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
3224 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3225 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3226 0 \
3227 -S "skip write certificate request" \
3228 -C "skip parse certificate request" \
3229 -c "got a certificate request" \
3230 -C "skip write certificate" \
3231 -C "skip write certificate verify" \
3232 -S "skip parse certificate verify" \
3233 -S "x509_verify_cert() returned" \
3234 -S "! The certificate is not correctly signed by the trusted CA" \
3235 -S "The certificate has been revoked (is on a CRL)"
3236
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01003237run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00003238 "$P_SRV debug_level=3 auth_mode=optional \
3239 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
3240 ca_file=data_files/test-ca.crt \
3241 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
3242 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
3243 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
3244 1 \
3245 -S "skip write certificate request" \
3246 -C "skip parse certificate request" \
3247 -c "got a certificate request" \
3248 -C "skip write certificate" \
3249 -C "skip write certificate verify" \
3250 -S "skip parse certificate verify" \
3251 -s "x509_verify_cert() returned" \
3252 -S "! The certificate is not correctly signed by the trusted CA" \
3253 -s "The certificate has been revoked (is on a CRL)"
3254
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003255# Tests for non-blocking I/O: exercise a variety of handshake flows
3256
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003257run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003258 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3259 "$P_CLI nbio=2 tickets=0" \
3260 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003261 -S "mbedtls_ssl_handshake returned" \
3262 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003263 -c "Read from server: .* bytes read"
3264
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003265run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003266 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
3267 "$P_CLI nbio=2 tickets=0" \
3268 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003269 -S "mbedtls_ssl_handshake returned" \
3270 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003271 -c "Read from server: .* bytes read"
3272
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003273run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003274 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3275 "$P_CLI nbio=2 tickets=1" \
3276 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003277 -S "mbedtls_ssl_handshake returned" \
3278 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003279 -c "Read from server: .* bytes read"
3280
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003281run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003282 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3283 "$P_CLI nbio=2 tickets=1" \
3284 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003285 -S "mbedtls_ssl_handshake returned" \
3286 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003287 -c "Read from server: .* bytes read"
3288
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003289run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003290 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
3291 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3292 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003293 -S "mbedtls_ssl_handshake returned" \
3294 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003295 -c "Read from server: .* bytes read"
3296
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003297run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003298 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
3299 "$P_CLI nbio=2 tickets=1 reconnect=1" \
3300 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003301 -S "mbedtls_ssl_handshake returned" \
3302 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003303 -c "Read from server: .* bytes read"
3304
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003305run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003306 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
3307 "$P_CLI nbio=2 tickets=0 reconnect=1" \
3308 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003309 -S "mbedtls_ssl_handshake returned" \
3310 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01003311 -c "Read from server: .* bytes read"
3312
Hanno Becker00076712017-11-15 16:39:08 +00003313# Tests for event-driven I/O: exercise a variety of handshake flows
3314
3315run_test "Event-driven I/O: basic handshake" \
3316 "$P_SRV event=1 tickets=0 auth_mode=none" \
3317 "$P_CLI event=1 tickets=0" \
3318 0 \
3319 -S "mbedtls_ssl_handshake returned" \
3320 -C "mbedtls_ssl_handshake returned" \
3321 -c "Read from server: .* bytes read"
3322
3323run_test "Event-driven I/O: client auth" \
3324 "$P_SRV event=1 tickets=0 auth_mode=required" \
3325 "$P_CLI event=1 tickets=0" \
3326 0 \
3327 -S "mbedtls_ssl_handshake returned" \
3328 -C "mbedtls_ssl_handshake returned" \
3329 -c "Read from server: .* bytes read"
3330
3331run_test "Event-driven I/O: ticket" \
3332 "$P_SRV event=1 tickets=1 auth_mode=none" \
3333 "$P_CLI event=1 tickets=1" \
3334 0 \
3335 -S "mbedtls_ssl_handshake returned" \
3336 -C "mbedtls_ssl_handshake returned" \
3337 -c "Read from server: .* bytes read"
3338
3339run_test "Event-driven I/O: ticket + client auth" \
3340 "$P_SRV event=1 tickets=1 auth_mode=required" \
3341 "$P_CLI event=1 tickets=1" \
3342 0 \
3343 -S "mbedtls_ssl_handshake returned" \
3344 -C "mbedtls_ssl_handshake returned" \
3345 -c "Read from server: .* bytes read"
3346
3347run_test "Event-driven I/O: ticket + client auth + resume" \
3348 "$P_SRV event=1 tickets=1 auth_mode=required" \
3349 "$P_CLI event=1 tickets=1 reconnect=1" \
3350 0 \
3351 -S "mbedtls_ssl_handshake returned" \
3352 -C "mbedtls_ssl_handshake returned" \
3353 -c "Read from server: .* bytes read"
3354
3355run_test "Event-driven I/O: ticket + resume" \
3356 "$P_SRV event=1 tickets=1 auth_mode=none" \
3357 "$P_CLI event=1 tickets=1 reconnect=1" \
3358 0 \
3359 -S "mbedtls_ssl_handshake returned" \
3360 -C "mbedtls_ssl_handshake returned" \
3361 -c "Read from server: .* bytes read"
3362
3363run_test "Event-driven I/O: session-id resume" \
3364 "$P_SRV event=1 tickets=0 auth_mode=none" \
3365 "$P_CLI event=1 tickets=0 reconnect=1" \
3366 0 \
3367 -S "mbedtls_ssl_handshake returned" \
3368 -C "mbedtls_ssl_handshake returned" \
3369 -c "Read from server: .* bytes read"
3370
Hanno Becker6a33f592018-03-13 11:38:46 +00003371run_test "Event-driven I/O, DTLS: basic handshake" \
3372 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
3373 "$P_CLI dtls=1 event=1 tickets=0" \
3374 0 \
3375 -c "Read from server: .* bytes read"
3376
3377run_test "Event-driven I/O, DTLS: client auth" \
3378 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
3379 "$P_CLI dtls=1 event=1 tickets=0" \
3380 0 \
3381 -c "Read from server: .* bytes read"
3382
3383run_test "Event-driven I/O, DTLS: ticket" \
3384 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
3385 "$P_CLI dtls=1 event=1 tickets=1" \
3386 0 \
3387 -c "Read from server: .* bytes read"
3388
3389run_test "Event-driven I/O, DTLS: ticket + client auth" \
3390 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
3391 "$P_CLI dtls=1 event=1 tickets=1" \
3392 0 \
3393 -c "Read from server: .* bytes read"
3394
3395run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
3396 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003397 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003398 0 \
3399 -c "Read from server: .* bytes read"
3400
3401run_test "Event-driven I/O, DTLS: ticket + resume" \
3402 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003403 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003404 0 \
3405 -c "Read from server: .* bytes read"
3406
3407run_test "Event-driven I/O, DTLS: session-id resume" \
3408 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003409 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00003410 0 \
3411 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003412
3413# This test demonstrates the need for the mbedtls_ssl_check_pending function.
3414# During session resumption, the client will send its ApplicationData record
3415# within the same datagram as the Finished messages. In this situation, the
3416# server MUST NOT idle on the underlying transport after handshake completion,
3417# because the ApplicationData request has already been queued internally.
3418run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00003419 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003420 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01003421 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00003422 0 \
3423 -c "Read from server: .* bytes read"
3424
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003425# Tests for version negotiation
3426
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003427run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003428 "$P_SRV" \
3429 "$P_CLI" \
3430 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003431 -S "mbedtls_ssl_handshake returned" \
3432 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003433 -s "Protocol is TLSv1.2" \
3434 -c "Protocol is TLSv1.2"
3435
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003436run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003437 "$P_SRV" \
3438 "$P_CLI max_version=tls1_1" \
3439 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003440 -S "mbedtls_ssl_handshake returned" \
3441 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003442 -s "Protocol is TLSv1.1" \
3443 -c "Protocol is TLSv1.1"
3444
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003445run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003446 "$P_SRV max_version=tls1_1" \
3447 "$P_CLI" \
3448 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003449 -S "mbedtls_ssl_handshake returned" \
3450 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003451 -s "Protocol is TLSv1.1" \
3452 -c "Protocol is TLSv1.1"
3453
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003454run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003455 "$P_SRV max_version=tls1_1" \
3456 "$P_CLI max_version=tls1_1" \
3457 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003458 -S "mbedtls_ssl_handshake returned" \
3459 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003460 -s "Protocol is TLSv1.1" \
3461 -c "Protocol is TLSv1.1"
3462
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003463run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003464 "$P_SRV min_version=tls1_1" \
3465 "$P_CLI max_version=tls1_1" \
3466 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003467 -S "mbedtls_ssl_handshake returned" \
3468 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003469 -s "Protocol is TLSv1.1" \
3470 -c "Protocol is TLSv1.1"
3471
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003472run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003473 "$P_SRV max_version=tls1_1" \
3474 "$P_CLI min_version=tls1_1" \
3475 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003476 -S "mbedtls_ssl_handshake returned" \
3477 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003478 -s "Protocol is TLSv1.1" \
3479 -c "Protocol is TLSv1.1"
3480
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003481run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003482 "$P_SRV max_version=tls1_1" \
3483 "$P_CLI min_version=tls1_2" \
3484 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003485 -s "mbedtls_ssl_handshake returned" \
3486 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003487 -c "SSL - Handshake protocol not within min/max boundaries"
3488
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003489run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003490 "$P_SRV min_version=tls1_2" \
3491 "$P_CLI max_version=tls1_1" \
3492 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003493 -s "mbedtls_ssl_handshake returned" \
3494 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01003495 -s "SSL - Handshake protocol not within min/max boundaries"
3496
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003497# Tests for ALPN extension
3498
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003499run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003500 "$P_SRV debug_level=3" \
3501 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003502 0 \
3503 -C "client hello, adding alpn extension" \
3504 -S "found alpn extension" \
3505 -C "got an alert message, type: \\[2:120]" \
3506 -S "server hello, adding alpn extension" \
3507 -C "found alpn extension " \
3508 -C "Application Layer Protocol is" \
3509 -S "Application Layer Protocol is"
3510
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003511run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003512 "$P_SRV debug_level=3" \
3513 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003514 0 \
3515 -c "client hello, adding alpn extension" \
3516 -s "found alpn extension" \
3517 -C "got an alert message, type: \\[2:120]" \
3518 -S "server hello, adding alpn extension" \
3519 -C "found alpn extension " \
3520 -c "Application Layer Protocol is (none)" \
3521 -S "Application Layer Protocol is"
3522
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003523run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003524 "$P_SRV debug_level=3 alpn=abc,1234" \
3525 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003526 0 \
3527 -C "client hello, adding alpn extension" \
3528 -S "found alpn extension" \
3529 -C "got an alert message, type: \\[2:120]" \
3530 -S "server hello, adding alpn extension" \
3531 -C "found alpn extension " \
3532 -C "Application Layer Protocol is" \
3533 -s "Application Layer Protocol is (none)"
3534
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003535run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003536 "$P_SRV debug_level=3 alpn=abc,1234" \
3537 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003538 0 \
3539 -c "client hello, adding alpn extension" \
3540 -s "found alpn extension" \
3541 -C "got an alert message, type: \\[2:120]" \
3542 -s "server hello, adding alpn extension" \
3543 -c "found alpn extension" \
3544 -c "Application Layer Protocol is abc" \
3545 -s "Application Layer Protocol is abc"
3546
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003547run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003548 "$P_SRV debug_level=3 alpn=abc,1234" \
3549 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003550 0 \
3551 -c "client hello, adding alpn extension" \
3552 -s "found alpn extension" \
3553 -C "got an alert message, type: \\[2:120]" \
3554 -s "server hello, adding alpn extension" \
3555 -c "found alpn extension" \
3556 -c "Application Layer Protocol is abc" \
3557 -s "Application Layer Protocol is abc"
3558
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003559run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003560 "$P_SRV debug_level=3 alpn=abc,1234" \
3561 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003562 0 \
3563 -c "client hello, adding alpn extension" \
3564 -s "found alpn extension" \
3565 -C "got an alert message, type: \\[2:120]" \
3566 -s "server hello, adding alpn extension" \
3567 -c "found alpn extension" \
3568 -c "Application Layer Protocol is 1234" \
3569 -s "Application Layer Protocol is 1234"
3570
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003571run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003572 "$P_SRV debug_level=3 alpn=abc,123" \
3573 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02003574 1 \
3575 -c "client hello, adding alpn extension" \
3576 -s "found alpn extension" \
3577 -c "got an alert message, type: \\[2:120]" \
3578 -S "server hello, adding alpn extension" \
3579 -C "found alpn extension" \
3580 -C "Application Layer Protocol is 1234" \
3581 -S "Application Layer Protocol is 1234"
3582
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02003583
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003584# Tests for keyUsage in leaf certificates, part 1:
3585# server-side certificate/suite selection
3586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003587run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003588 "$P_SRV key_file=data_files/server2.key \
3589 crt_file=data_files/server2.ku-ds.crt" \
3590 "$P_CLI" \
3591 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02003592 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003593
3594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003595run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003596 "$P_SRV key_file=data_files/server2.key \
3597 crt_file=data_files/server2.ku-ke.crt" \
3598 "$P_CLI" \
3599 0 \
3600 -c "Ciphersuite is TLS-RSA-WITH-"
3601
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003602run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003603 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003604 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003605 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003606 1 \
3607 -C "Ciphersuite is "
3608
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003609run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003610 "$P_SRV key_file=data_files/server5.key \
3611 crt_file=data_files/server5.ku-ds.crt" \
3612 "$P_CLI" \
3613 0 \
3614 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
3615
3616
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003617run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003618 "$P_SRV key_file=data_files/server5.key \
3619 crt_file=data_files/server5.ku-ka.crt" \
3620 "$P_CLI" \
3621 0 \
3622 -c "Ciphersuite is TLS-ECDH-"
3623
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003624run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003625 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003626 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02003627 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003628 1 \
3629 -C "Ciphersuite is "
3630
3631# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003632# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003633
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003634run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003635 "$O_SRV -key data_files/server2.key \
3636 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003637 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003638 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3639 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003640 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003641 -C "Processing of the Certificate handshake message failed" \
3642 -c "Ciphersuite is TLS-"
3643
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003644run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003645 "$O_SRV -key data_files/server2.key \
3646 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003647 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003648 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3649 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003650 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003651 -C "Processing of the Certificate handshake message failed" \
3652 -c "Ciphersuite is TLS-"
3653
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003654run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003655 "$O_SRV -key data_files/server2.key \
3656 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003657 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003658 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3659 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003660 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003661 -C "Processing of the Certificate handshake message failed" \
3662 -c "Ciphersuite is TLS-"
3663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003664run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003665 "$O_SRV -key data_files/server2.key \
3666 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003667 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003668 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3669 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003670 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003671 -c "Processing of the Certificate handshake message failed" \
3672 -C "Ciphersuite is TLS-"
3673
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003674run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
3675 "$O_SRV -key data_files/server2.key \
3676 -cert data_files/server2.ku-ke.crt" \
3677 "$P_CLI debug_level=1 auth_mode=optional \
3678 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3679 0 \
3680 -c "bad certificate (usage extensions)" \
3681 -C "Processing of the Certificate handshake message failed" \
3682 -c "Ciphersuite is TLS-" \
3683 -c "! Usage does not match the keyUsage extension"
3684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003685run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003686 "$O_SRV -key data_files/server2.key \
3687 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003688 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003689 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
3690 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003691 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003692 -C "Processing of the Certificate handshake message failed" \
3693 -c "Ciphersuite is TLS-"
3694
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003695run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003696 "$O_SRV -key data_files/server2.key \
3697 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003698 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003699 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3700 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003701 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02003702 -c "Processing of the Certificate handshake message failed" \
3703 -C "Ciphersuite is TLS-"
3704
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01003705run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
3706 "$O_SRV -key data_files/server2.key \
3707 -cert data_files/server2.ku-ds.crt" \
3708 "$P_CLI debug_level=1 auth_mode=optional \
3709 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
3710 0 \
3711 -c "bad certificate (usage extensions)" \
3712 -C "Processing of the Certificate handshake message failed" \
3713 -c "Ciphersuite is TLS-" \
3714 -c "! Usage does not match the keyUsage extension"
3715
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003716# Tests for keyUsage in leaf certificates, part 3:
3717# server-side checking of client cert
3718
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003719run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003720 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003721 "$O_CLI -key data_files/server2.key \
3722 -cert data_files/server2.ku-ds.crt" \
3723 0 \
3724 -S "bad certificate (usage extensions)" \
3725 -S "Processing of the Certificate handshake message failed"
3726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003727run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003728 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003729 "$O_CLI -key data_files/server2.key \
3730 -cert data_files/server2.ku-ke.crt" \
3731 0 \
3732 -s "bad certificate (usage extensions)" \
3733 -S "Processing of the Certificate handshake message failed"
3734
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003735run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003736 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003737 "$O_CLI -key data_files/server2.key \
3738 -cert data_files/server2.ku-ke.crt" \
3739 1 \
3740 -s "bad certificate (usage extensions)" \
3741 -s "Processing of the Certificate handshake message failed"
3742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003743run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003744 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003745 "$O_CLI -key data_files/server5.key \
3746 -cert data_files/server5.ku-ds.crt" \
3747 0 \
3748 -S "bad certificate (usage extensions)" \
3749 -S "Processing of the Certificate handshake message failed"
3750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003751run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003752 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02003753 "$O_CLI -key data_files/server5.key \
3754 -cert data_files/server5.ku-ka.crt" \
3755 0 \
3756 -s "bad certificate (usage extensions)" \
3757 -S "Processing of the Certificate handshake message failed"
3758
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003759# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
3760
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003761run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003762 "$P_SRV key_file=data_files/server5.key \
3763 crt_file=data_files/server5.eku-srv.crt" \
3764 "$P_CLI" \
3765 0
3766
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003767run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003768 "$P_SRV key_file=data_files/server5.key \
3769 crt_file=data_files/server5.eku-srv.crt" \
3770 "$P_CLI" \
3771 0
3772
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003773run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003774 "$P_SRV key_file=data_files/server5.key \
3775 crt_file=data_files/server5.eku-cs_any.crt" \
3776 "$P_CLI" \
3777 0
3778
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003779run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003780 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003781 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02003782 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003783 1
3784
3785# Tests for extendedKeyUsage, part 2: client-side checking of server cert
3786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003787run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003788 "$O_SRV -key data_files/server5.key \
3789 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003790 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003791 0 \
3792 -C "bad certificate (usage extensions)" \
3793 -C "Processing of the Certificate handshake message failed" \
3794 -c "Ciphersuite is TLS-"
3795
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003796run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003797 "$O_SRV -key data_files/server5.key \
3798 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003799 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003800 0 \
3801 -C "bad certificate (usage extensions)" \
3802 -C "Processing of the Certificate handshake message failed" \
3803 -c "Ciphersuite is TLS-"
3804
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003805run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003806 "$O_SRV -key data_files/server5.key \
3807 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003808 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003809 0 \
3810 -C "bad certificate (usage extensions)" \
3811 -C "Processing of the Certificate handshake message failed" \
3812 -c "Ciphersuite is TLS-"
3813
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003814run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003815 "$O_SRV -key data_files/server5.key \
3816 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003817 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003818 1 \
3819 -c "bad certificate (usage extensions)" \
3820 -c "Processing of the Certificate handshake message failed" \
3821 -C "Ciphersuite is TLS-"
3822
3823# Tests for extendedKeyUsage, part 3: server-side checking of client cert
3824
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003825run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003826 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003827 "$O_CLI -key data_files/server5.key \
3828 -cert data_files/server5.eku-cli.crt" \
3829 0 \
3830 -S "bad certificate (usage extensions)" \
3831 -S "Processing of the Certificate handshake message failed"
3832
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003833run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003834 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003835 "$O_CLI -key data_files/server5.key \
3836 -cert data_files/server5.eku-srv_cli.crt" \
3837 0 \
3838 -S "bad certificate (usage extensions)" \
3839 -S "Processing of the Certificate handshake message failed"
3840
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003841run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003842 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003843 "$O_CLI -key data_files/server5.key \
3844 -cert data_files/server5.eku-cs_any.crt" \
3845 0 \
3846 -S "bad certificate (usage extensions)" \
3847 -S "Processing of the Certificate handshake message failed"
3848
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003849run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003850 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003851 "$O_CLI -key data_files/server5.key \
3852 -cert data_files/server5.eku-cs.crt" \
3853 0 \
3854 -s "bad certificate (usage extensions)" \
3855 -S "Processing of the Certificate handshake message failed"
3856
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003857run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003858 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02003859 "$O_CLI -key data_files/server5.key \
3860 -cert data_files/server5.eku-cs.crt" \
3861 1 \
3862 -s "bad certificate (usage extensions)" \
3863 -s "Processing of the Certificate handshake message failed"
3864
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003865# Tests for DHM parameters loading
3866
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003867run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003868 "$P_SRV" \
3869 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3870 debug_level=3" \
3871 0 \
3872 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01003873 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003875run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003876 "$P_SRV dhm_file=data_files/dhparams.pem" \
3877 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3878 debug_level=3" \
3879 0 \
3880 -c "value of 'DHM: P ' (1024 bits)" \
3881 -c "value of 'DHM: G ' (2 bits)"
3882
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02003883# Tests for DHM client-side size checking
3884
3885run_test "DHM size: server default, client default, OK" \
3886 "$P_SRV" \
3887 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3888 debug_level=1" \
3889 0 \
3890 -C "DHM prime too short:"
3891
3892run_test "DHM size: server default, client 2048, OK" \
3893 "$P_SRV" \
3894 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3895 debug_level=1 dhmlen=2048" \
3896 0 \
3897 -C "DHM prime too short:"
3898
3899run_test "DHM size: server 1024, client default, OK" \
3900 "$P_SRV dhm_file=data_files/dhparams.pem" \
3901 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3902 debug_level=1" \
3903 0 \
3904 -C "DHM prime too short:"
3905
3906run_test "DHM size: server 1000, client default, rejected" \
3907 "$P_SRV dhm_file=data_files/dh.1000.pem" \
3908 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3909 debug_level=1" \
3910 1 \
3911 -c "DHM prime too short:"
3912
3913run_test "DHM size: server default, client 2049, rejected" \
3914 "$P_SRV" \
3915 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
3916 debug_level=1 dhmlen=2049" \
3917 1 \
3918 -c "DHM prime too short:"
3919
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003920# Tests for PSK callback
3921
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003922run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003923 "$P_SRV psk=abc123 psk_identity=foo" \
3924 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3925 psk_identity=foo psk=abc123" \
3926 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003927 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003928 -S "SSL - Unknown identity received" \
3929 -S "SSL - Verification of the message MAC failed"
3930
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003931run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02003932 "$P_SRV" \
3933 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3934 psk_identity=foo psk=abc123" \
3935 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003936 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003937 -S "SSL - Unknown identity received" \
3938 -S "SSL - Verification of the message MAC failed"
3939
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003940run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003941 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
3942 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3943 psk_identity=foo psk=abc123" \
3944 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003945 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003946 -s "SSL - Unknown identity received" \
3947 -S "SSL - Verification of the message MAC failed"
3948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003949run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003950 "$P_SRV psk_list=abc,dead,def,beef" \
3951 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3952 psk_identity=abc psk=dead" \
3953 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003954 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003955 -S "SSL - Unknown identity received" \
3956 -S "SSL - Verification of the message MAC failed"
3957
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003958run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003959 "$P_SRV psk_list=abc,dead,def,beef" \
3960 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3961 psk_identity=def psk=beef" \
3962 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003963 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003964 -S "SSL - Unknown identity received" \
3965 -S "SSL - Verification of the message MAC failed"
3966
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003967run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003968 "$P_SRV psk_list=abc,dead,def,beef" \
3969 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3970 psk_identity=ghi psk=beef" \
3971 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003972 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003973 -s "SSL - Unknown identity received" \
3974 -S "SSL - Verification of the message MAC failed"
3975
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003976run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003977 "$P_SRV psk_list=abc,dead,def,beef" \
3978 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
3979 psk_identity=abc psk=beef" \
3980 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01003981 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02003982 -S "SSL - Unknown identity received" \
3983 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02003984
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003985# Tests for EC J-PAKE
3986
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02003987requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003988run_test "ECJPAKE: client not configured" \
3989 "$P_SRV debug_level=3" \
3990 "$P_CLI debug_level=3" \
3991 0 \
3992 -C "add ciphersuite: c0ff" \
3993 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02003994 -S "found ecjpake kkpp extension" \
3995 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003996 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02003997 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02003998 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02003999 -S "None of the common ciphersuites is usable"
4000
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004001requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004002run_test "ECJPAKE: server not configured" \
4003 "$P_SRV debug_level=3" \
4004 "$P_CLI debug_level=3 ecjpake_pw=bla \
4005 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4006 1 \
4007 -c "add ciphersuite: c0ff" \
4008 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004009 -s "found ecjpake kkpp extension" \
4010 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004011 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004012 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004013 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02004014 -s "None of the common ciphersuites is usable"
4015
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004016requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004017run_test "ECJPAKE: working, TLS" \
4018 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4019 "$P_CLI debug_level=3 ecjpake_pw=bla \
4020 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02004021 0 \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004022 -c "add ciphersuite: c0ff" \
4023 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004024 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004025 -s "found ecjpake kkpp extension" \
4026 -S "skip ecjpake kkpp extension" \
4027 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02004028 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02004029 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004030 -S "None of the common ciphersuites is usable" \
4031 -S "SSL - Verification of the message MAC failed"
4032
Janos Follath74537a62016-09-02 13:45:28 +01004033server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004034requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004035run_test "ECJPAKE: password mismatch, TLS" \
4036 "$P_SRV debug_level=3 ecjpake_pw=bla" \
4037 "$P_CLI debug_level=3 ecjpake_pw=bad \
4038 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4039 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004040 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004041 -s "SSL - Verification of the message MAC failed"
4042
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004043requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004044run_test "ECJPAKE: working, DTLS" \
4045 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4046 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4047 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4048 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004049 -c "re-using cached ecjpake parameters" \
4050 -S "SSL - Verification of the message MAC failed"
4051
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004052requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004053run_test "ECJPAKE: working, DTLS, no cookie" \
4054 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
4055 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
4056 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4057 0 \
4058 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004059 -S "SSL - Verification of the message MAC failed"
4060
Janos Follath74537a62016-09-02 13:45:28 +01004061server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004062requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004063run_test "ECJPAKE: password mismatch, DTLS" \
4064 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
4065 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
4066 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4067 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02004068 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02004069 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02004070
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004071# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02004072requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02004073run_test "ECJPAKE: working, DTLS, nolog" \
4074 "$P_SRV dtls=1 ecjpake_pw=bla" \
4075 "$P_CLI dtls=1 ecjpake_pw=bla \
4076 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
4077 0
4078
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004079# Tests for ciphersuites per version
4080
Janos Follathe2681a42016-03-07 15:57:05 +00004081requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004082requires_config_enabled MBEDTLS_CAMELLIA_C
4083requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004084run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004085 "$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 +02004086 "$P_CLI force_version=ssl3" \
4087 0 \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004088 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004089
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004090requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4091requires_config_enabled MBEDTLS_CAMELLIA_C
4092requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004093run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004094 "$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 +01004095 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004096 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004097 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004098
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004099requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4100requires_config_enabled MBEDTLS_CAMELLIA_C
4101requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004102run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004103 "$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 +02004104 "$P_CLI force_version=tls1_1" \
4105 0 \
4106 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
4107
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004108requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4109requires_config_enabled MBEDTLS_CAMELLIA_C
4110requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004111run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardf1e62e82019-03-01 10:14:58 +01004112 "$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 +02004113 "$P_CLI force_version=tls1_2" \
4114 0 \
4115 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
4116
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02004117# Test for ClientHello without extensions
4118
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02004119requires_gnutls
Manuel Pégourié-Gonnardd20ae892020-01-30 12:45:14 +01004120run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard7c9add22020-01-30 10:58:57 +01004121 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02004122 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02004123 0 \
4124 -s "dumping 'client hello extensions' (0 bytes)"
4125
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004126# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004127
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004128run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004129 "$P_SRV" \
4130 "$P_CLI request_size=100" \
4131 0 \
4132 -s "Read from client: 100 bytes read$"
4133
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004134run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02004135 "$P_SRV" \
4136 "$P_CLI request_size=500" \
4137 0 \
4138 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02004139
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004140# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004141
Janos Follathe2681a42016-03-07 15:57:05 +00004142requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004143run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004144 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004145 "$P_CLI request_size=1 force_version=ssl3 \
4146 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4147 0 \
4148 -s "Read from client: 1 bytes read"
4149
Janos Follathe2681a42016-03-07 15:57:05 +00004150requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004151run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004152 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004153 "$P_CLI request_size=1 force_version=ssl3 \
4154 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4155 0 \
4156 -s "Read from client: 1 bytes read"
4157
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004158run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004159 "$P_SRV" \
4160 "$P_CLI request_size=1 force_version=tls1 \
4161 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4162 0 \
4163 -s "Read from client: 1 bytes read"
4164
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004165run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004166 "$P_SRV" \
4167 "$P_CLI request_size=1 force_version=tls1 etm=0 \
4168 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4169 0 \
4170 -s "Read from client: 1 bytes read"
4171
Hanno Becker32c55012017-11-10 08:42:54 +00004172requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004173run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004174 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004175 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004176 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004177 0 \
4178 -s "Read from client: 1 bytes read"
4179
Hanno Becker32c55012017-11-10 08:42:54 +00004180requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004181run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004182 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004183 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004184 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004185 0 \
4186 -s "Read from client: 1 bytes read"
4187
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004188run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004189 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004190 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00004191 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4192 0 \
4193 -s "Read from client: 1 bytes read"
4194
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004195run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004196 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4197 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004198 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004199 0 \
4200 -s "Read from client: 1 bytes read"
4201
4202requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004203run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004204 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004205 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004206 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004207 0 \
4208 -s "Read from client: 1 bytes read"
4209
Hanno Becker8501f982017-11-10 08:59:04 +00004210requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004211run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004212 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4213 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4214 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004215 0 \
4216 -s "Read from client: 1 bytes read"
4217
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004218run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004219 "$P_SRV" \
4220 "$P_CLI request_size=1 force_version=tls1_1 \
4221 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4222 0 \
4223 -s "Read from client: 1 bytes read"
4224
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004225run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004226 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004227 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004228 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004229 0 \
4230 -s "Read from client: 1 bytes read"
4231
4232requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004233run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004234 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004235 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004236 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004237 0 \
4238 -s "Read from client: 1 bytes read"
4239
4240requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004241run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004242 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004243 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004244 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004245 0 \
4246 -s "Read from client: 1 bytes read"
4247
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004248run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004249 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004250 "$P_CLI request_size=1 force_version=tls1_1 \
4251 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4252 0 \
4253 -s "Read from client: 1 bytes read"
4254
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004255run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00004256 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004257 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004258 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004259 0 \
4260 -s "Read from client: 1 bytes read"
4261
Hanno Becker8501f982017-11-10 08:59:04 +00004262requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004263run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004264 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004265 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004266 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004267 0 \
4268 -s "Read from client: 1 bytes read"
4269
Hanno Becker32c55012017-11-10 08:42:54 +00004270requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004271run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004272 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004273 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004274 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004275 0 \
4276 -s "Read from client: 1 bytes read"
4277
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004278run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004279 "$P_SRV" \
4280 "$P_CLI request_size=1 force_version=tls1_2 \
4281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4282 0 \
4283 -s "Read from client: 1 bytes read"
4284
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004285run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004286 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00004287 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004288 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01004289 0 \
4290 -s "Read from client: 1 bytes read"
4291
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004292run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004293 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004294 "$P_CLI request_size=1 force_version=tls1_2 \
4295 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004296 0 \
4297 -s "Read from client: 1 bytes read"
4298
Hanno Becker32c55012017-11-10 08:42:54 +00004299requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004300run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004301 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004302 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004303 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004304 0 \
4305 -s "Read from client: 1 bytes read"
4306
Hanno Becker8501f982017-11-10 08:59:04 +00004307requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004308run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004309 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004310 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004311 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004312 0 \
4313 -s "Read from client: 1 bytes read"
4314
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004315run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004316 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004317 "$P_CLI request_size=1 force_version=tls1_2 \
4318 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4319 0 \
4320 -s "Read from client: 1 bytes read"
4321
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004322run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004323 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004324 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004325 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00004326 0 \
4327 -s "Read from client: 1 bytes read"
4328
Hanno Becker32c55012017-11-10 08:42:54 +00004329requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004330run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004331 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004332 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004333 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004334 0 \
4335 -s "Read from client: 1 bytes read"
4336
Hanno Becker8501f982017-11-10 08:59:04 +00004337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004338run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004339 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00004340 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004341 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004342 0 \
4343 -s "Read from client: 1 bytes read"
4344
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004345run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004346 "$P_SRV" \
4347 "$P_CLI request_size=1 force_version=tls1_2 \
4348 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4349 0 \
4350 -s "Read from client: 1 bytes read"
4351
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004352run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02004353 "$P_SRV" \
4354 "$P_CLI request_size=1 force_version=tls1_2 \
4355 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4356 0 \
4357 -s "Read from client: 1 bytes read"
4358
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004359# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00004360
4361requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004362run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004363 "$P_SRV dtls=1 force_version=dtls1" \
4364 "$P_CLI dtls=1 request_size=1 \
4365 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4366 0 \
4367 -s "Read from client: 1 bytes read"
4368
4369requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004370run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00004371 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
4372 "$P_CLI dtls=1 request_size=1 \
4373 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4374 0 \
4375 -s "Read from client: 1 bytes read"
4376
4377requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4378requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004379run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004380 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
4381 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00004382 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4383 0 \
4384 -s "Read from client: 1 bytes read"
4385
4386requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4387requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004388run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004389 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004390 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004391 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004392 0 \
4393 -s "Read from client: 1 bytes read"
4394
4395requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004396run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00004397 "$P_SRV dtls=1 force_version=dtls1_2" \
4398 "$P_CLI dtls=1 request_size=1 \
4399 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4400 0 \
4401 -s "Read from client: 1 bytes read"
4402
4403requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004404run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004405 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004406 "$P_CLI dtls=1 request_size=1 \
4407 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4408 0 \
4409 -s "Read from client: 1 bytes read"
4410
4411requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4412requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004413run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004414 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004415 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00004417 0 \
4418 -s "Read from client: 1 bytes read"
4419
4420requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4421requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004422run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004423 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00004424 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004425 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00004426 0 \
4427 -s "Read from client: 1 bytes read"
4428
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004429# Tests for small server packets
4430
4431requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4432run_test "Small server packet SSLv3 BlockCipher" \
4433 "$P_SRV response_size=1 min_version=ssl3" \
4434 "$P_CLI force_version=ssl3 \
4435 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4436 0 \
4437 -c "Read from server: 1 bytes read"
4438
4439requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4440run_test "Small server packet SSLv3 StreamCipher" \
4441 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4442 "$P_CLI force_version=ssl3 \
4443 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4444 0 \
4445 -c "Read from server: 1 bytes read"
4446
4447run_test "Small server packet TLS 1.0 BlockCipher" \
4448 "$P_SRV response_size=1" \
4449 "$P_CLI force_version=tls1 \
4450 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4451 0 \
4452 -c "Read from server: 1 bytes read"
4453
4454run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
4455 "$P_SRV response_size=1" \
4456 "$P_CLI force_version=tls1 etm=0 \
4457 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4458 0 \
4459 -c "Read from server: 1 bytes read"
4460
4461requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4462run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
4463 "$P_SRV response_size=1 trunc_hmac=1" \
4464 "$P_CLI force_version=tls1 \
4465 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4466 0 \
4467 -c "Read from server: 1 bytes read"
4468
4469requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4470run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
4471 "$P_SRV response_size=1 trunc_hmac=1" \
4472 "$P_CLI force_version=tls1 \
4473 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4474 0 \
4475 -c "Read from server: 1 bytes read"
4476
4477run_test "Small server packet TLS 1.0 StreamCipher" \
4478 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4479 "$P_CLI force_version=tls1 \
4480 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4481 0 \
4482 -c "Read from server: 1 bytes read"
4483
4484run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
4485 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4486 "$P_CLI force_version=tls1 \
4487 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4488 0 \
4489 -c "Read from server: 1 bytes read"
4490
4491requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4492run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
4493 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4494 "$P_CLI force_version=tls1 \
4495 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4496 0 \
4497 -c "Read from server: 1 bytes read"
4498
4499requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4500run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
4501 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4502 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
4503 trunc_hmac=1 etm=0" \
4504 0 \
4505 -c "Read from server: 1 bytes read"
4506
4507run_test "Small server packet TLS 1.1 BlockCipher" \
4508 "$P_SRV response_size=1" \
4509 "$P_CLI force_version=tls1_1 \
4510 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4511 0 \
4512 -c "Read from server: 1 bytes read"
4513
4514run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
4515 "$P_SRV response_size=1" \
4516 "$P_CLI force_version=tls1_1 \
4517 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4518 0 \
4519 -c "Read from server: 1 bytes read"
4520
4521requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4522run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
4523 "$P_SRV response_size=1 trunc_hmac=1" \
4524 "$P_CLI force_version=tls1_1 \
4525 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4526 0 \
4527 -c "Read from server: 1 bytes read"
4528
4529requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4530run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
4531 "$P_SRV response_size=1 trunc_hmac=1" \
4532 "$P_CLI force_version=tls1_1 \
4533 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4534 0 \
4535 -c "Read from server: 1 bytes read"
4536
4537run_test "Small server packet TLS 1.1 StreamCipher" \
4538 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4539 "$P_CLI force_version=tls1_1 \
4540 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4541 0 \
4542 -c "Read from server: 1 bytes read"
4543
4544run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
4545 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4546 "$P_CLI force_version=tls1_1 \
4547 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4548 0 \
4549 -c "Read from server: 1 bytes read"
4550
4551requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4552run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
4553 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4554 "$P_CLI force_version=tls1_1 \
4555 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4556 0 \
4557 -c "Read from server: 1 bytes read"
4558
4559requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4560run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
4561 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4562 "$P_CLI force_version=tls1_1 \
4563 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4564 0 \
4565 -c "Read from server: 1 bytes read"
4566
4567run_test "Small server packet TLS 1.2 BlockCipher" \
4568 "$P_SRV response_size=1" \
4569 "$P_CLI force_version=tls1_2 \
4570 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4571 0 \
4572 -c "Read from server: 1 bytes read"
4573
4574run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
4575 "$P_SRV response_size=1" \
4576 "$P_CLI force_version=tls1_2 \
4577 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
4578 0 \
4579 -c "Read from server: 1 bytes read"
4580
4581run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
4582 "$P_SRV response_size=1" \
4583 "$P_CLI force_version=tls1_2 \
4584 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
4585 0 \
4586 -c "Read from server: 1 bytes read"
4587
4588requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4589run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
4590 "$P_SRV response_size=1 trunc_hmac=1" \
4591 "$P_CLI force_version=tls1_2 \
4592 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4593 0 \
4594 -c "Read from server: 1 bytes read"
4595
4596requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4597run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
4598 "$P_SRV response_size=1 trunc_hmac=1" \
4599 "$P_CLI force_version=tls1_2 \
4600 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
4601 0 \
4602 -c "Read from server: 1 bytes read"
4603
4604run_test "Small server packet TLS 1.2 StreamCipher" \
4605 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4606 "$P_CLI force_version=tls1_2 \
4607 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4608 0 \
4609 -c "Read from server: 1 bytes read"
4610
4611run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
4612 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4613 "$P_CLI force_version=tls1_2 \
4614 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4615 0 \
4616 -c "Read from server: 1 bytes read"
4617
4618requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4619run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
4620 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4621 "$P_CLI force_version=tls1_2 \
4622 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4623 0 \
4624 -c "Read from server: 1 bytes read"
4625
4626requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4627run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
4628 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
4629 "$P_CLI force_version=tls1_2 \
4630 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
4631 0 \
4632 -c "Read from server: 1 bytes read"
4633
4634run_test "Small server packet TLS 1.2 AEAD" \
4635 "$P_SRV response_size=1" \
4636 "$P_CLI force_version=tls1_2 \
4637 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4638 0 \
4639 -c "Read from server: 1 bytes read"
4640
4641run_test "Small server packet TLS 1.2 AEAD shorter tag" \
4642 "$P_SRV response_size=1" \
4643 "$P_CLI force_version=tls1_2 \
4644 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4645 0 \
4646 -c "Read from server: 1 bytes read"
4647
4648# Tests for small server packets in DTLS
4649
4650requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4651run_test "Small server packet DTLS 1.0" \
4652 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
4653 "$P_CLI dtls=1 \
4654 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4655 0 \
4656 -c "Read from server: 1 bytes read"
4657
4658requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4659run_test "Small server packet DTLS 1.0, without EtM" \
4660 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
4661 "$P_CLI dtls=1 \
4662 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4663 0 \
4664 -c "Read from server: 1 bytes read"
4665
4666requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4667requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4668run_test "Small server packet DTLS 1.0, truncated hmac" \
4669 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
4670 "$P_CLI dtls=1 trunc_hmac=1 \
4671 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4672 0 \
4673 -c "Read from server: 1 bytes read"
4674
4675requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4676requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4677run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
4678 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
4679 "$P_CLI dtls=1 \
4680 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4681 0 \
4682 -c "Read from server: 1 bytes read"
4683
4684requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4685run_test "Small server packet DTLS 1.2" \
4686 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
4687 "$P_CLI dtls=1 \
4688 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4689 0 \
4690 -c "Read from server: 1 bytes read"
4691
4692requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4693run_test "Small server packet DTLS 1.2, without EtM" \
4694 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
4695 "$P_CLI dtls=1 \
4696 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4697 0 \
4698 -c "Read from server: 1 bytes read"
4699
4700requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4701requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4702run_test "Small server packet DTLS 1.2, truncated hmac" \
4703 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
4704 "$P_CLI dtls=1 \
4705 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
4706 0 \
4707 -c "Read from server: 1 bytes read"
4708
4709requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
4710requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
4711run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
4712 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
4713 "$P_CLI dtls=1 \
4714 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
4715 0 \
4716 -c "Read from server: 1 bytes read"
4717
Janos Follath00efff72016-05-06 13:48:23 +01004718# A test for extensions in SSLv3
4719
4720requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4721run_test "SSLv3 with extensions, server side" \
4722 "$P_SRV min_version=ssl3 debug_level=3" \
4723 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
4724 0 \
4725 -S "dumping 'client hello extensions'" \
4726 -S "server hello, total extension length:"
4727
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004728# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004729
Angus Grattonc4dd0732018-04-11 16:28:39 +10004730# How many fragments do we expect to write $1 bytes?
4731fragments_for_write() {
4732 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
4733}
4734
Janos Follathe2681a42016-03-07 15:57:05 +00004735requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004736run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004737 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004738 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004739 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4740 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004741 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4742 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004743
Janos Follathe2681a42016-03-07 15:57:05 +00004744requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004745run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004746 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004747 "$P_CLI request_size=16384 force_version=ssl3 \
4748 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4749 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004750 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4751 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004752
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004753run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004754 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004755 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004756 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4757 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004758 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4759 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004760
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004761run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004762 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004763 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
4764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4765 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004766 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004767
Hanno Becker32c55012017-11-10 08:42:54 +00004768requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004769run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004770 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004771 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004772 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004773 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004774 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4775 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004776
Hanno Becker32c55012017-11-10 08:42:54 +00004777requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004778run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004779 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004780 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004781 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004782 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004783 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004784
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004785run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004786 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004787 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004788 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4789 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004790 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004791
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004792run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004793 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4794 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004795 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004796 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004797 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004798
4799requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004800run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004801 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004802 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004803 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004804 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004805 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004806
Hanno Becker278fc7a2017-11-10 09:16:28 +00004807requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004808run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004809 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004810 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004811 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004812 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004813 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4814 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004815
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004816run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004817 "$P_SRV" \
4818 "$P_CLI request_size=16384 force_version=tls1_1 \
4819 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4820 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004821 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4822 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004823
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004824run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004825 "$P_SRV" \
4826 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
4827 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004828 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004829 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004830
Hanno Becker32c55012017-11-10 08:42:54 +00004831requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004832run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004833 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004834 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004835 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004836 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004837 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004838
Hanno Becker32c55012017-11-10 08:42:54 +00004839requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004840run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004841 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004842 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004843 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004844 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004845 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004846
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004847run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004848 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4849 "$P_CLI request_size=16384 force_version=tls1_1 \
4850 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4851 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004852 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4853 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004854
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004855run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004856 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004857 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004858 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004859 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004860 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4861 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004862
Hanno Becker278fc7a2017-11-10 09:16:28 +00004863requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004864run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004865 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004866 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004867 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004868 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004869 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004870
Hanno Becker278fc7a2017-11-10 09:16:28 +00004871requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004872run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004873 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004874 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004875 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004876 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004877 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4878 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004879
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004880run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004881 "$P_SRV" \
4882 "$P_CLI request_size=16384 force_version=tls1_2 \
4883 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4884 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004885 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4886 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004887
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004888run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004889 "$P_SRV" \
4890 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
4891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4892 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004893 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004894
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004895run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004896 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01004897 "$P_CLI request_size=16384 force_version=tls1_2 \
4898 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004899 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004900 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4901 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004902
Hanno Becker32c55012017-11-10 08:42:54 +00004903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004904run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004905 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004906 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004908 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004909 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004910
Hanno Becker278fc7a2017-11-10 09:16:28 +00004911requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004912run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004913 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004914 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004916 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004917 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4918 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004919
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004920run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004921 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004922 "$P_CLI request_size=16384 force_version=tls1_2 \
4923 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4924 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004925 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4926 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004927
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004928run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01004929 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004930 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004931 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
4932 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004933 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00004934
Hanno Becker32c55012017-11-10 08:42:54 +00004935requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004936run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004937 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004938 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004939 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004940 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004941 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004942
Hanno Becker278fc7a2017-11-10 09:16:28 +00004943requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004944run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00004945 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00004946 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00004947 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004948 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004949 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4950 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004951
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004952run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004953 "$P_SRV" \
4954 "$P_CLI request_size=16384 force_version=tls1_2 \
4955 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
4956 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004957 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4958 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004959
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004960run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004961 "$P_SRV" \
4962 "$P_CLI request_size=16384 force_version=tls1_2 \
4963 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
4964 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10004965 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
4966 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02004967
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004968# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004969requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4970run_test "Large server packet SSLv3 StreamCipher" \
4971 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4972 "$P_CLI force_version=ssl3 \
4973 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
4974 0 \
4975 -c "Read from server: 16384 bytes read"
4976
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04004977# Checking next 4 tests logs for 1n-1 split against BEAST too
4978requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4979run_test "Large server packet SSLv3 BlockCipher" \
4980 "$P_SRV response_size=16384 min_version=ssl3" \
4981 "$P_CLI force_version=ssl3 recsplit=0 \
4982 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4983 0 \
4984 -c "Read from server: 1 bytes read"\
4985 -c "16383 bytes read"\
4986 -C "Read from server: 16384 bytes read"
4987
Andrzej Kurek30e731d2017-10-12 13:50:29 +02004988run_test "Large server packet TLS 1.0 BlockCipher" \
4989 "$P_SRV response_size=16384" \
4990 "$P_CLI force_version=tls1 recsplit=0 \
4991 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
4992 0 \
4993 -c "Read from server: 1 bytes read"\
4994 -c "16383 bytes read"\
4995 -C "Read from server: 16384 bytes read"
4996
Andrzej Kurekc19fc552018-06-19 09:37:30 -04004997run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
4998 "$P_SRV response_size=16384" \
4999 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
5000 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5001 0 \
5002 -c "Read from server: 1 bytes read"\
5003 -c "16383 bytes read"\
5004 -C "Read from server: 16384 bytes read"
5005
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005006requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5007run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
5008 "$P_SRV response_size=16384" \
5009 "$P_CLI force_version=tls1 recsplit=0 \
5010 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5011 trunc_hmac=1" \
5012 0 \
5013 -c "Read from server: 1 bytes read"\
5014 -c "16383 bytes read"\
5015 -C "Read from server: 16384 bytes read"
5016
5017requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5018run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
5019 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5020 "$P_CLI force_version=tls1 \
5021 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5022 trunc_hmac=1" \
5023 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005024 -s "16384 bytes written in 1 fragments" \
5025 -c "Read from server: 16384 bytes read"
5026
5027run_test "Large server packet TLS 1.0 StreamCipher" \
5028 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5029 "$P_CLI force_version=tls1 \
5030 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5031 0 \
5032 -s "16384 bytes written in 1 fragments" \
5033 -c "Read from server: 16384 bytes read"
5034
5035run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
5036 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5037 "$P_CLI force_version=tls1 \
5038 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5039 0 \
5040 -s "16384 bytes written in 1 fragments" \
5041 -c "Read from server: 16384 bytes read"
5042
5043requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5044run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
5045 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5046 "$P_CLI force_version=tls1 \
5047 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5048 0 \
5049 -s "16384 bytes written in 1 fragments" \
5050 -c "Read from server: 16384 bytes read"
5051
5052requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5053run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
5054 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5055 "$P_CLI force_version=tls1 \
5056 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5057 0 \
5058 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005059 -c "Read from server: 16384 bytes read"
5060
5061run_test "Large server packet TLS 1.1 BlockCipher" \
5062 "$P_SRV response_size=16384" \
5063 "$P_CLI force_version=tls1_1 \
5064 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5065 0 \
5066 -c "Read from server: 16384 bytes read"
5067
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005068run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
5069 "$P_SRV response_size=16384" \
5070 "$P_CLI force_version=tls1_1 etm=0 \
5071 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005072 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005073 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005074 -c "Read from server: 16384 bytes read"
5075
5076requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5077run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
5078 "$P_SRV response_size=16384" \
5079 "$P_CLI force_version=tls1_1 \
5080 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5081 trunc_hmac=1" \
5082 0 \
5083 -c "Read from server: 16384 bytes read"
5084
5085requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005086run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
5087 "$P_SRV response_size=16384 trunc_hmac=1" \
5088 "$P_CLI force_version=tls1_1 \
5089 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5090 0 \
5091 -s "16384 bytes written in 1 fragments" \
5092 -c "Read from server: 16384 bytes read"
5093
5094run_test "Large server packet TLS 1.1 StreamCipher" \
5095 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5096 "$P_CLI force_version=tls1_1 \
5097 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5098 0 \
5099 -c "Read from server: 16384 bytes read"
5100
5101run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
5102 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5103 "$P_CLI force_version=tls1_1 \
5104 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5105 0 \
5106 -s "16384 bytes written in 1 fragments" \
5107 -c "Read from server: 16384 bytes read"
5108
5109requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005110run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
5111 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5112 "$P_CLI force_version=tls1_1 \
5113 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5114 trunc_hmac=1" \
5115 0 \
5116 -c "Read from server: 16384 bytes read"
5117
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005118run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
5119 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5120 "$P_CLI force_version=tls1_1 \
5121 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5122 0 \
5123 -s "16384 bytes written in 1 fragments" \
5124 -c "Read from server: 16384 bytes read"
5125
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005126run_test "Large server packet TLS 1.2 BlockCipher" \
5127 "$P_SRV response_size=16384" \
5128 "$P_CLI force_version=tls1_2 \
5129 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5130 0 \
5131 -c "Read from server: 16384 bytes read"
5132
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005133run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5134 "$P_SRV response_size=16384" \
5135 "$P_CLI force_version=tls1_2 etm=0 \
5136 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5137 0 \
5138 -s "16384 bytes written in 1 fragments" \
5139 -c "Read from server: 16384 bytes read"
5140
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005141run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5142 "$P_SRV response_size=16384" \
5143 "$P_CLI force_version=tls1_2 \
5144 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5145 0 \
5146 -c "Read from server: 16384 bytes read"
5147
5148requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5149run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5150 "$P_SRV response_size=16384" \
5151 "$P_CLI force_version=tls1_2 \
5152 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5153 trunc_hmac=1" \
5154 0 \
5155 -c "Read from server: 16384 bytes read"
5156
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005157run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5158 "$P_SRV response_size=16384 trunc_hmac=1" \
5159 "$P_CLI force_version=tls1_2 \
5160 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5161 0 \
5162 -s "16384 bytes written in 1 fragments" \
5163 -c "Read from server: 16384 bytes read"
5164
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005165run_test "Large server packet TLS 1.2 StreamCipher" \
5166 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5167 "$P_CLI force_version=tls1_2 \
5168 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5169 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005170 -s "16384 bytes written in 1 fragments" \
5171 -c "Read from server: 16384 bytes read"
5172
5173run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
5174 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5175 "$P_CLI force_version=tls1_2 \
5176 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
5177 0 \
5178 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005179 -c "Read from server: 16384 bytes read"
5180
5181requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5182run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
5183 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5184 "$P_CLI force_version=tls1_2 \
5185 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
5186 trunc_hmac=1" \
5187 0 \
5188 -c "Read from server: 16384 bytes read"
5189
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005190requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5191run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
5192 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
5193 "$P_CLI force_version=tls1_2 \
5194 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
5195 0 \
5196 -s "16384 bytes written in 1 fragments" \
5197 -c "Read from server: 16384 bytes read"
5198
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005199run_test "Large server packet TLS 1.2 AEAD" \
5200 "$P_SRV response_size=16384" \
5201 "$P_CLI force_version=tls1_2 \
5202 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5203 0 \
5204 -c "Read from server: 16384 bytes read"
5205
5206run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5207 "$P_SRV response_size=16384" \
5208 "$P_CLI force_version=tls1_2 \
5209 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5210 0 \
5211 -c "Read from server: 16384 bytes read"
5212
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005213# Tests for restartable ECC
5214
5215requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5216run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005217 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005218 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005219 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005220 debug_level=1" \
5221 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005222 -C "x509_verify_cert.*4b00" \
5223 -C "mbedtls_pk_verify.*4b00" \
5224 -C "mbedtls_ecdh_make_public.*4b00" \
5225 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005226
5227requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5228run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005229 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005230 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005231 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005232 debug_level=1 ec_max_ops=0" \
5233 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005234 -C "x509_verify_cert.*4b00" \
5235 -C "mbedtls_pk_verify.*4b00" \
5236 -C "mbedtls_ecdh_make_public.*4b00" \
5237 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005238
5239requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5240run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005241 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005242 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005243 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005244 debug_level=1 ec_max_ops=65535" \
5245 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005246 -C "x509_verify_cert.*4b00" \
5247 -C "mbedtls_pk_verify.*4b00" \
5248 -C "mbedtls_ecdh_make_public.*4b00" \
5249 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005250
5251requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5252run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005253 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005254 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005255 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005256 debug_level=1 ec_max_ops=1000" \
5257 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005258 -c "x509_verify_cert.*4b00" \
5259 -c "mbedtls_pk_verify.*4b00" \
5260 -c "mbedtls_ecdh_make_public.*4b00" \
5261 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005262
5263requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005264run_test "EC restart: TLS, max_ops=1000, badsign" \
5265 "$P_SRV auth_mode=required \
5266 crt_file=data_files/server5-badsign.crt \
5267 key_file=data_files/server5.key" \
5268 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5269 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5270 debug_level=1 ec_max_ops=1000" \
5271 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005272 -c "x509_verify_cert.*4b00" \
5273 -C "mbedtls_pk_verify.*4b00" \
5274 -C "mbedtls_ecdh_make_public.*4b00" \
5275 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005276 -c "! The certificate is not correctly signed by the trusted CA" \
5277 -c "! mbedtls_ssl_handshake returned" \
5278 -c "X509 - Certificate verification failed"
5279
5280requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5281run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5282 "$P_SRV auth_mode=required \
5283 crt_file=data_files/server5-badsign.crt \
5284 key_file=data_files/server5.key" \
5285 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5286 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5287 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5288 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005289 -c "x509_verify_cert.*4b00" \
5290 -c "mbedtls_pk_verify.*4b00" \
5291 -c "mbedtls_ecdh_make_public.*4b00" \
5292 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005293 -c "! The certificate is not correctly signed by the trusted CA" \
5294 -C "! mbedtls_ssl_handshake returned" \
5295 -C "X509 - Certificate verification failed"
5296
5297requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5298run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5299 "$P_SRV auth_mode=required \
5300 crt_file=data_files/server5-badsign.crt \
5301 key_file=data_files/server5.key" \
5302 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5303 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5304 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5305 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005306 -C "x509_verify_cert.*4b00" \
5307 -c "mbedtls_pk_verify.*4b00" \
5308 -c "mbedtls_ecdh_make_public.*4b00" \
5309 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005310 -C "! The certificate is not correctly signed by the trusted CA" \
5311 -C "! mbedtls_ssl_handshake returned" \
5312 -C "X509 - Certificate verification failed"
5313
5314requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005315run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005316 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005317 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005318 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005319 dtls=1 debug_level=1 ec_max_ops=1000" \
5320 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005321 -c "x509_verify_cert.*4b00" \
5322 -c "mbedtls_pk_verify.*4b00" \
5323 -c "mbedtls_ecdh_make_public.*4b00" \
5324 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005325
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005326requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5327run_test "EC restart: TLS, max_ops=1000 no client auth" \
5328 "$P_SRV" \
5329 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5330 debug_level=1 ec_max_ops=1000" \
5331 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005332 -c "x509_verify_cert.*4b00" \
5333 -c "mbedtls_pk_verify.*4b00" \
5334 -c "mbedtls_ecdh_make_public.*4b00" \
5335 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005336
5337requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5338run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
5339 "$P_SRV psk=abc123" \
5340 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
5341 psk=abc123 debug_level=1 ec_max_ops=1000" \
5342 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005343 -C "x509_verify_cert.*4b00" \
5344 -C "mbedtls_pk_verify.*4b00" \
5345 -C "mbedtls_ecdh_make_public.*4b00" \
5346 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02005347
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005348# Tests of asynchronous private key support in SSL
5349
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005350requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005351run_test "SSL async private: sign, delay=0" \
5352 "$P_SRV \
5353 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005354 "$P_CLI" \
5355 0 \
5356 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005357 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005358
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005359requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005360run_test "SSL async private: sign, delay=1" \
5361 "$P_SRV \
5362 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005363 "$P_CLI" \
5364 0 \
5365 -s "Async sign callback: using key slot " \
5366 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005367 -s "Async resume (slot [0-9]): sign done, status=0"
5368
Gilles Peskine12d0cc12018-04-26 15:06:56 +02005369requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5370run_test "SSL async private: sign, delay=2" \
5371 "$P_SRV \
5372 async_operations=s async_private_delay1=2 async_private_delay2=2" \
5373 "$P_CLI" \
5374 0 \
5375 -s "Async sign callback: using key slot " \
5376 -U "Async sign callback: using key slot " \
5377 -s "Async resume (slot [0-9]): call 1 more times." \
5378 -s "Async resume (slot [0-9]): call 0 more times." \
5379 -s "Async resume (slot [0-9]): sign done, status=0"
5380
Gilles Peskined3268832018-04-26 06:23:59 +02005381# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
5382# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
5383requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5384requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5385run_test "SSL async private: sign, RSA, TLS 1.1" \
5386 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
5387 async_operations=s async_private_delay1=0 async_private_delay2=0" \
5388 "$P_CLI force_version=tls1_1" \
5389 0 \
5390 -s "Async sign callback: using key slot " \
5391 -s "Async resume (slot [0-9]): sign done, status=0"
5392
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005393requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02005394run_test "SSL async private: sign, SNI" \
5395 "$P_SRV debug_level=3 \
5396 async_operations=s async_private_delay1=0 async_private_delay2=0 \
5397 crt_file=data_files/server5.crt key_file=data_files/server5.key \
5398 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
5399 "$P_CLI server_name=polarssl.example" \
5400 0 \
5401 -s "Async sign callback: using key slot " \
5402 -s "Async resume (slot [0-9]): sign done, status=0" \
5403 -s "parse ServerName extension" \
5404 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
5405 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
5406
5407requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005408run_test "SSL async private: decrypt, delay=0" \
5409 "$P_SRV \
5410 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5411 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5412 0 \
5413 -s "Async decrypt callback: using key slot " \
5414 -s "Async resume (slot [0-9]): decrypt done, status=0"
5415
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005416requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005417run_test "SSL async private: decrypt, delay=1" \
5418 "$P_SRV \
5419 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5420 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5421 0 \
5422 -s "Async decrypt callback: using key slot " \
5423 -s "Async resume (slot [0-9]): call 0 more times." \
5424 -s "Async resume (slot [0-9]): decrypt done, status=0"
5425
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005426requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005427run_test "SSL async private: decrypt RSA-PSK, delay=0" \
5428 "$P_SRV psk=abc123 \
5429 async_operations=d async_private_delay1=0 async_private_delay2=0" \
5430 "$P_CLI psk=abc123 \
5431 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5432 0 \
5433 -s "Async decrypt callback: using key slot " \
5434 -s "Async resume (slot [0-9]): decrypt done, status=0"
5435
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005436requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005437run_test "SSL async private: decrypt RSA-PSK, delay=1" \
5438 "$P_SRV psk=abc123 \
5439 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5440 "$P_CLI psk=abc123 \
5441 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
5442 0 \
5443 -s "Async decrypt callback: using key slot " \
5444 -s "Async resume (slot [0-9]): call 0 more times." \
5445 -s "Async resume (slot [0-9]): decrypt done, status=0"
5446
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005447requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005448run_test "SSL async private: sign callback not present" \
5449 "$P_SRV \
5450 async_operations=d async_private_delay1=1 async_private_delay2=1" \
5451 "$P_CLI; [ \$? -eq 1 ] &&
5452 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5453 0 \
5454 -S "Async sign callback" \
5455 -s "! mbedtls_ssl_handshake returned" \
5456 -s "The own private key or pre-shared key is not set, but needed" \
5457 -s "Async resume (slot [0-9]): decrypt done, status=0" \
5458 -s "Successful connection"
5459
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005460requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005461run_test "SSL async private: decrypt callback not present" \
5462 "$P_SRV debug_level=1 \
5463 async_operations=s async_private_delay1=1 async_private_delay2=1" \
5464 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
5465 [ \$? -eq 1 ] && $P_CLI" \
5466 0 \
5467 -S "Async decrypt callback" \
5468 -s "! mbedtls_ssl_handshake returned" \
5469 -s "got no RSA private key" \
5470 -s "Async resume (slot [0-9]): sign done, status=0" \
5471 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005472
5473# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005474requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005475run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005476 "$P_SRV \
5477 async_operations=s async_private_delay1=1 \
5478 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5479 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005480 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5481 0 \
5482 -s "Async sign callback: using key slot 0," \
5483 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005484 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005485
5486# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005487requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005488run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005489 "$P_SRV \
5490 async_operations=s async_private_delay2=1 \
5491 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5492 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005493 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5494 0 \
5495 -s "Async sign callback: using key slot 0," \
5496 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005497 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005498
5499# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005500requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02005501run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005502 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02005503 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005504 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5505 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005506 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5507 0 \
5508 -s "Async sign callback: using key slot 1," \
5509 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005510 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005511
5512# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005513requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005514run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005515 "$P_SRV \
5516 async_operations=s async_private_delay1=1 \
5517 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5518 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005519 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5520 0 \
5521 -s "Async sign callback: no key matches this certificate."
5522
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005523requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005524run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005525 "$P_SRV \
5526 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5527 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005528 "$P_CLI" \
5529 1 \
5530 -s "Async sign callback: injected error" \
5531 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005532 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005533 -s "! mbedtls_ssl_handshake returned"
5534
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005535requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005536run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005537 "$P_SRV \
5538 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5539 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005540 "$P_CLI" \
5541 1 \
5542 -s "Async sign callback: using key slot " \
5543 -S "Async resume" \
5544 -s "Async cancel"
5545
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005546requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005547run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005548 "$P_SRV \
5549 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5550 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005551 "$P_CLI" \
5552 1 \
5553 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005554 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02005555 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005556 -s "! mbedtls_ssl_handshake returned"
5557
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005558requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005559run_test "SSL async private: decrypt, error in start" \
5560 "$P_SRV \
5561 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5562 async_private_error=1" \
5563 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5564 1 \
5565 -s "Async decrypt callback: injected error" \
5566 -S "Async resume" \
5567 -S "Async cancel" \
5568 -s "! mbedtls_ssl_handshake returned"
5569
5570requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5571run_test "SSL async private: decrypt, cancel after start" \
5572 "$P_SRV \
5573 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5574 async_private_error=2" \
5575 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5576 1 \
5577 -s "Async decrypt callback: using key slot " \
5578 -S "Async resume" \
5579 -s "Async cancel"
5580
5581requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
5582run_test "SSL async private: decrypt, error in resume" \
5583 "$P_SRV \
5584 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5585 async_private_error=3" \
5586 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5587 1 \
5588 -s "Async decrypt callback: using key slot " \
5589 -s "Async resume callback: decrypt done but injected error" \
5590 -S "Async cancel" \
5591 -s "! mbedtls_ssl_handshake returned"
5592
5593requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005594run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005595 "$P_SRV \
5596 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5597 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005598 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5599 0 \
5600 -s "Async cancel" \
5601 -s "! mbedtls_ssl_handshake returned" \
5602 -s "Async resume" \
5603 -s "Successful connection"
5604
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005605requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005606run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005607 "$P_SRV \
5608 async_operations=s async_private_delay1=1 async_private_delay2=1 \
5609 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005610 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
5611 0 \
5612 -s "! mbedtls_ssl_handshake returned" \
5613 -s "Async resume" \
5614 -s "Successful connection"
5615
5616# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005617requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005618run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005619 "$P_SRV \
5620 async_operations=s async_private_delay1=1 async_private_error=-2 \
5621 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5622 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005623 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5624 [ \$? -eq 1 ] &&
5625 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5626 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02005627 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005628 -S "Async resume" \
5629 -s "Async cancel" \
5630 -s "! mbedtls_ssl_handshake returned" \
5631 -s "Async sign callback: no key matches this certificate." \
5632 -s "Successful connection"
5633
5634# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005635requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02005636run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005637 "$P_SRV \
5638 async_operations=s async_private_delay1=1 async_private_error=-3 \
5639 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5640 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01005641 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
5642 [ \$? -eq 1 ] &&
5643 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
5644 0 \
5645 -s "Async resume" \
5646 -s "! mbedtls_ssl_handshake returned" \
5647 -s "Async sign callback: no key matches this certificate." \
5648 -s "Successful connection"
5649
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005650requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005651requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005652run_test "SSL async private: renegotiation: client-initiated; sign" \
5653 "$P_SRV \
5654 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005655 exchanges=2 renegotiation=1" \
5656 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
5657 0 \
5658 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005659 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005660
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005661requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005662requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005663run_test "SSL async private: renegotiation: server-initiated; sign" \
5664 "$P_SRV \
5665 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005666 exchanges=2 renegotiation=1 renegotiate=1" \
5667 "$P_CLI exchanges=2 renegotiation=1" \
5668 0 \
5669 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005670 -s "Async resume (slot [0-9]): sign done, status=0"
5671
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005672requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005673requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5674run_test "SSL async private: renegotiation: client-initiated; decrypt" \
5675 "$P_SRV \
5676 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5677 exchanges=2 renegotiation=1" \
5678 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
5679 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5680 0 \
5681 -s "Async decrypt callback: using key slot " \
5682 -s "Async resume (slot [0-9]): decrypt done, status=0"
5683
Gilles Peskineb74a1c72018-04-24 13:09:22 +02005684requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01005685requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
5686run_test "SSL async private: renegotiation: server-initiated; decrypt" \
5687 "$P_SRV \
5688 async_operations=d async_private_delay1=1 async_private_delay2=1 \
5689 exchanges=2 renegotiation=1 renegotiate=1" \
5690 "$P_CLI exchanges=2 renegotiation=1 \
5691 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5692 0 \
5693 -s "Async decrypt callback: using key slot " \
5694 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01005695
Ron Eldor58093c82018-06-28 13:22:05 +03005696# Tests for ECC extensions (rfc 4492)
5697
Ron Eldor643df7c2018-06-28 16:17:00 +03005698requires_config_enabled MBEDTLS_AES_C
5699requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5700requires_config_enabled MBEDTLS_SHA256_C
5701requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005702run_test "Force a non ECC ciphersuite in the client side" \
5703 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005704 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005705 0 \
5706 -C "client hello, adding supported_elliptic_curves extension" \
5707 -C "client hello, adding supported_point_formats extension" \
5708 -S "found supported elliptic curves extension" \
5709 -S "found supported point formats extension"
5710
Ron Eldor643df7c2018-06-28 16:17:00 +03005711requires_config_enabled MBEDTLS_AES_C
5712requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5713requires_config_enabled MBEDTLS_SHA256_C
5714requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005715run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03005716 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03005717 "$P_CLI debug_level=3" \
5718 0 \
5719 -C "found supported_point_formats extension" \
5720 -S "server hello, supported_point_formats extension"
5721
Ron Eldor643df7c2018-06-28 16:17:00 +03005722requires_config_enabled MBEDTLS_AES_C
5723requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5724requires_config_enabled MBEDTLS_SHA256_C
5725requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005726run_test "Force an ECC ciphersuite in the client side" \
5727 "$P_SRV debug_level=3" \
5728 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5729 0 \
5730 -c "client hello, adding supported_elliptic_curves extension" \
5731 -c "client hello, adding supported_point_formats extension" \
5732 -s "found supported elliptic curves extension" \
5733 -s "found supported point formats extension"
5734
Ron Eldor643df7c2018-06-28 16:17:00 +03005735requires_config_enabled MBEDTLS_AES_C
5736requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
5737requires_config_enabled MBEDTLS_SHA256_C
5738requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03005739run_test "Force an ECC ciphersuite in the server side" \
5740 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
5741 "$P_CLI debug_level=3" \
5742 0 \
5743 -c "found supported_point_formats extension" \
5744 -s "server hello, supported_point_formats extension"
5745
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005746# Tests for DTLS HelloVerifyRequest
5747
5748run_test "DTLS cookie: enabled" \
5749 "$P_SRV dtls=1 debug_level=2" \
5750 "$P_CLI dtls=1 debug_level=2" \
5751 0 \
5752 -s "cookie verification failed" \
5753 -s "cookie verification passed" \
5754 -S "cookie verification skipped" \
5755 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005756 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005757 -S "SSL - The requested feature is not available"
5758
5759run_test "DTLS cookie: disabled" \
5760 "$P_SRV dtls=1 debug_level=2 cookies=0" \
5761 "$P_CLI dtls=1 debug_level=2" \
5762 0 \
5763 -S "cookie verification failed" \
5764 -S "cookie verification passed" \
5765 -s "cookie verification skipped" \
5766 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005767 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005768 -S "SSL - The requested feature is not available"
5769
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005770run_test "DTLS cookie: default (failing)" \
5771 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
5772 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
5773 1 \
5774 -s "cookie verification failed" \
5775 -S "cookie verification passed" \
5776 -S "cookie verification skipped" \
5777 -C "received hello verify request" \
5778 -S "hello verification requested" \
5779 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005780
5781requires_ipv6
5782run_test "DTLS cookie: enabled, IPv6" \
5783 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
5784 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
5785 0 \
5786 -s "cookie verification failed" \
5787 -s "cookie verification passed" \
5788 -S "cookie verification skipped" \
5789 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005790 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02005791 -S "SSL - The requested feature is not available"
5792
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005793run_test "DTLS cookie: enabled, nbio" \
5794 "$P_SRV dtls=1 nbio=2 debug_level=2" \
5795 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5796 0 \
5797 -s "cookie verification failed" \
5798 -s "cookie verification passed" \
5799 -S "cookie verification skipped" \
5800 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02005801 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02005802 -S "SSL - The requested feature is not available"
5803
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005804# Tests for client reconnecting from the same port with DTLS
5805
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005806not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005807run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005808 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5809 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005810 0 \
5811 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005812 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005813 -S "Client initiated reconnection from same port"
5814
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005815not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005816run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02005817 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
5818 "$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 +02005819 0 \
5820 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005821 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005822 -s "Client initiated reconnection from same port"
5823
Paul Bakker362689d2016-05-13 10:33:25 +01005824not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
5825run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005826 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
5827 "$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 +02005828 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005829 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02005830 -s "Client initiated reconnection from same port"
5831
Paul Bakker362689d2016-05-13 10:33:25 +01005832only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
5833run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
5834 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
5835 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
5836 0 \
5837 -S "The operation timed out" \
5838 -s "Client initiated reconnection from same port"
5839
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005840run_test "DTLS client reconnect from same port: no cookies" \
5841 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02005842 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
5843 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02005844 -s "The operation timed out" \
5845 -S "Client initiated reconnection from same port"
5846
Manuel Pégourié-Gonnardb85ce9e2020-03-13 11:11:02 +01005847run_test "DTLS client reconnect from same port: attacker-injected" \
5848 -p "$P_PXY inject_clihlo=1" \
5849 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
5850 "$P_CLI dtls=1 exchanges=2" \
5851 0 \
5852 -s "possible client reconnect from the same port" \
5853 -S "Client initiated reconnection from same port"
5854
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005855# Tests for various cases of client authentication with DTLS
5856# (focused on handshake flows and message parsing)
5857
5858run_test "DTLS client auth: required" \
5859 "$P_SRV dtls=1 auth_mode=required" \
5860 "$P_CLI dtls=1" \
5861 0 \
5862 -s "Verifying peer X.509 certificate... ok"
5863
5864run_test "DTLS client auth: optional, client has no cert" \
5865 "$P_SRV dtls=1 auth_mode=optional" \
5866 "$P_CLI dtls=1 crt_file=none key_file=none" \
5867 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005868 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005869
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005870run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005871 "$P_SRV dtls=1 auth_mode=none" \
5872 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
5873 0 \
5874 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01005875 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02005876
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02005877run_test "DTLS wrong PSK: badmac alert" \
5878 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
5879 "$P_CLI dtls=1 psk=abc124" \
5880 1 \
5881 -s "SSL - Verification of the message MAC failed" \
5882 -c "SSL - A fatal alert message was received from our peer"
5883
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02005884# Tests for receiving fragmented handshake messages with DTLS
5885
5886requires_gnutls
5887run_test "DTLS reassembly: no fragmentation (gnutls server)" \
5888 "$G_SRV -u --mtu 2048 -a" \
5889 "$P_CLI dtls=1 debug_level=2" \
5890 0 \
5891 -C "found fragmented DTLS handshake message" \
5892 -C "error"
5893
5894requires_gnutls
5895run_test "DTLS reassembly: some fragmentation (gnutls server)" \
5896 "$G_SRV -u --mtu 512" \
5897 "$P_CLI dtls=1 debug_level=2" \
5898 0 \
5899 -c "found fragmented DTLS handshake message" \
5900 -C "error"
5901
5902requires_gnutls
5903run_test "DTLS reassembly: more fragmentation (gnutls server)" \
5904 "$G_SRV -u --mtu 128" \
5905 "$P_CLI dtls=1 debug_level=2" \
5906 0 \
5907 -c "found fragmented DTLS handshake message" \
5908 -C "error"
5909
5910requires_gnutls
5911run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
5912 "$G_SRV -u --mtu 128" \
5913 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5914 0 \
5915 -c "found fragmented DTLS handshake message" \
5916 -C "error"
5917
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005918requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005919requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005920run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
5921 "$G_SRV -u --mtu 256" \
5922 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
5923 0 \
5924 -c "found fragmented DTLS handshake message" \
5925 -c "client hello, adding renegotiation extension" \
5926 -c "found renegotiation extension" \
5927 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005928 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005929 -C "error" \
5930 -s "Extra-header:"
5931
5932requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01005933requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005934run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
5935 "$G_SRV -u --mtu 256" \
5936 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
5937 0 \
5938 -c "found fragmented DTLS handshake message" \
5939 -c "client hello, adding renegotiation extension" \
5940 -c "found renegotiation extension" \
5941 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005942 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02005943 -C "error" \
5944 -s "Extra-header:"
5945
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005946run_test "DTLS reassembly: no fragmentation (openssl server)" \
5947 "$O_SRV -dtls1 -mtu 2048" \
5948 "$P_CLI dtls=1 debug_level=2" \
5949 0 \
5950 -C "found fragmented DTLS handshake message" \
5951 -C "error"
5952
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005953run_test "DTLS reassembly: some fragmentation (openssl server)" \
5954 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005955 "$P_CLI dtls=1 debug_level=2" \
5956 0 \
5957 -c "found fragmented DTLS handshake message" \
5958 -C "error"
5959
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02005960run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02005961 "$O_SRV -dtls1 -mtu 256" \
5962 "$P_CLI dtls=1 debug_level=2" \
5963 0 \
5964 -c "found fragmented DTLS handshake message" \
5965 -C "error"
5966
5967run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
5968 "$O_SRV -dtls1 -mtu 256" \
5969 "$P_CLI dtls=1 nbio=2 debug_level=2" \
5970 0 \
5971 -c "found fragmented DTLS handshake message" \
5972 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02005973
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005974# Tests for sending fragmented handshake messages with DTLS
5975#
5976# Use client auth when we need the client to send large messages,
5977# and use large cert chains on both sides too (the long chains we have all use
5978# both RSA and ECDSA, but ideally we should have long chains with either).
5979# Sizes reached (UDP payload):
5980# - 2037B for server certificate
5981# - 1542B for client certificate
5982# - 1013B for newsessionticket
5983# - all others below 512B
5984# All those tests assume MAX_CONTENT_LEN is at least 2048
5985
5986requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5987requires_config_enabled MBEDTLS_RSA_C
5988requires_config_enabled MBEDTLS_ECDSA_C
5989requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
5990run_test "DTLS fragmenting: none (for reference)" \
5991 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
5992 crt_file=data_files/server7_int-ca.crt \
5993 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005994 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01005995 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02005996 "$P_CLI dtls=1 debug_level=2 \
5997 crt_file=data_files/server8_int-ca2.crt \
5998 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04005999 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006000 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006001 0 \
6002 -S "found fragmented DTLS handshake message" \
6003 -C "found fragmented DTLS handshake message" \
6004 -C "error"
6005
6006requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6007requires_config_enabled MBEDTLS_RSA_C
6008requires_config_enabled MBEDTLS_ECDSA_C
6009requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006010run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006011 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6012 crt_file=data_files/server7_int-ca.crt \
6013 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006014 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006015 max_frag_len=1024" \
6016 "$P_CLI dtls=1 debug_level=2 \
6017 crt_file=data_files/server8_int-ca2.crt \
6018 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006019 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006020 max_frag_len=2048" \
6021 0 \
6022 -S "found fragmented DTLS handshake message" \
6023 -c "found fragmented DTLS handshake message" \
6024 -C "error"
6025
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006026# With the MFL extension, the server has no way of forcing
6027# the client to not exceed a certain MTU; hence, the following
6028# test can't be replicated with an MTU proxy such as the one
6029# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006030requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6031requires_config_enabled MBEDTLS_RSA_C
6032requires_config_enabled MBEDTLS_ECDSA_C
6033requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006034run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006035 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6036 crt_file=data_files/server7_int-ca.crt \
6037 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006038 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006039 max_frag_len=512" \
6040 "$P_CLI dtls=1 debug_level=2 \
6041 crt_file=data_files/server8_int-ca2.crt \
6042 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006043 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006044 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006045 0 \
6046 -S "found fragmented DTLS handshake message" \
6047 -c "found fragmented DTLS handshake message" \
6048 -C "error"
6049
6050requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6051requires_config_enabled MBEDTLS_RSA_C
6052requires_config_enabled MBEDTLS_ECDSA_C
6053requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006054run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006055 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6056 crt_file=data_files/server7_int-ca.crt \
6057 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006058 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006059 max_frag_len=2048" \
6060 "$P_CLI dtls=1 debug_level=2 \
6061 crt_file=data_files/server8_int-ca2.crt \
6062 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006063 hs_timeout=2500-60000 \
6064 max_frag_len=1024" \
6065 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006066 -S "found fragmented DTLS handshake message" \
6067 -c "found fragmented DTLS handshake message" \
6068 -C "error"
6069
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006070# While not required by the standard defining the MFL extension
6071# (according to which it only applies to records, not to datagrams),
6072# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6073# as otherwise there wouldn't be any means to communicate MTU restrictions
6074# to the peer.
6075# The next test checks that no datagrams significantly larger than the
6076# negotiated MFL are sent.
6077requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6078requires_config_enabled MBEDTLS_RSA_C
6079requires_config_enabled MBEDTLS_ECDSA_C
6080requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6081run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006082 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006083 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6084 crt_file=data_files/server7_int-ca.crt \
6085 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006086 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006087 max_frag_len=2048" \
6088 "$P_CLI dtls=1 debug_level=2 \
6089 crt_file=data_files/server8_int-ca2.crt \
6090 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006091 hs_timeout=2500-60000 \
6092 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006093 0 \
6094 -S "found fragmented DTLS handshake message" \
6095 -c "found fragmented DTLS handshake message" \
6096 -C "error"
6097
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006098requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6099requires_config_enabled MBEDTLS_RSA_C
6100requires_config_enabled MBEDTLS_ECDSA_C
6101requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006102run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006103 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6104 crt_file=data_files/server7_int-ca.crt \
6105 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006106 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006107 max_frag_len=2048" \
6108 "$P_CLI dtls=1 debug_level=2 \
6109 crt_file=data_files/server8_int-ca2.crt \
6110 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006111 hs_timeout=2500-60000 \
6112 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006113 0 \
6114 -s "found fragmented DTLS handshake message" \
6115 -c "found fragmented DTLS handshake message" \
6116 -C "error"
6117
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006118# While not required by the standard defining the MFL extension
6119# (according to which it only applies to records, not to datagrams),
6120# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6121# as otherwise there wouldn't be any means to communicate MTU restrictions
6122# to the peer.
6123# The next test checks that no datagrams significantly larger than the
6124# negotiated MFL are sent.
6125requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6126requires_config_enabled MBEDTLS_RSA_C
6127requires_config_enabled MBEDTLS_ECDSA_C
6128requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6129run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006130 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006131 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6132 crt_file=data_files/server7_int-ca.crt \
6133 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006134 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006135 max_frag_len=2048" \
6136 "$P_CLI dtls=1 debug_level=2 \
6137 crt_file=data_files/server8_int-ca2.crt \
6138 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006139 hs_timeout=2500-60000 \
6140 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006141 0 \
6142 -s "found fragmented DTLS handshake message" \
6143 -c "found fragmented DTLS handshake message" \
6144 -C "error"
6145
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006146requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6147requires_config_enabled MBEDTLS_RSA_C
6148requires_config_enabled MBEDTLS_ECDSA_C
6149run_test "DTLS fragmenting: none (for reference) (MTU)" \
6150 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6151 crt_file=data_files/server7_int-ca.crt \
6152 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006153 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006154 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006155 "$P_CLI dtls=1 debug_level=2 \
6156 crt_file=data_files/server8_int-ca2.crt \
6157 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006158 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006159 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006160 0 \
6161 -S "found fragmented DTLS handshake message" \
6162 -C "found fragmented DTLS handshake message" \
6163 -C "error"
6164
6165requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6166requires_config_enabled MBEDTLS_RSA_C
6167requires_config_enabled MBEDTLS_ECDSA_C
6168run_test "DTLS fragmenting: client (MTU)" \
6169 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6170 crt_file=data_files/server7_int-ca.crt \
6171 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006172 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006173 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006174 "$P_CLI dtls=1 debug_level=2 \
6175 crt_file=data_files/server8_int-ca2.crt \
6176 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006177 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006178 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006179 0 \
6180 -s "found fragmented DTLS handshake message" \
6181 -C "found fragmented DTLS handshake message" \
6182 -C "error"
6183
6184requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6185requires_config_enabled MBEDTLS_RSA_C
6186requires_config_enabled MBEDTLS_ECDSA_C
6187run_test "DTLS fragmenting: server (MTU)" \
6188 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6189 crt_file=data_files/server7_int-ca.crt \
6190 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006191 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006192 mtu=512" \
6193 "$P_CLI dtls=1 debug_level=2 \
6194 crt_file=data_files/server8_int-ca2.crt \
6195 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006196 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006197 mtu=2048" \
6198 0 \
6199 -S "found fragmented DTLS handshake message" \
6200 -c "found fragmented DTLS handshake message" \
6201 -C "error"
6202
6203requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6204requires_config_enabled MBEDTLS_RSA_C
6205requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006206run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006207 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006208 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6209 crt_file=data_files/server7_int-ca.crt \
6210 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006211 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006212 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006213 "$P_CLI dtls=1 debug_level=2 \
6214 crt_file=data_files/server8_int-ca2.crt \
6215 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006216 hs_timeout=2500-60000 \
6217 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006218 0 \
6219 -s "found fragmented DTLS handshake message" \
6220 -c "found fragmented DTLS handshake message" \
6221 -C "error"
6222
Andrzej Kurek77826052018-10-11 07:34:08 -04006223# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006224requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6225requires_config_enabled MBEDTLS_RSA_C
6226requires_config_enabled MBEDTLS_ECDSA_C
6227requires_config_enabled MBEDTLS_SHA256_C
6228requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6229requires_config_enabled MBEDTLS_AES_C
6230requires_config_enabled MBEDTLS_GCM_C
6231run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006232 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006233 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6234 crt_file=data_files/server7_int-ca.crt \
6235 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006236 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006237 mtu=512" \
6238 "$P_CLI dtls=1 debug_level=2 \
6239 crt_file=data_files/server8_int-ca2.crt \
6240 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006241 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6242 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006243 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006244 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006245 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006246 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006247 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006248
Andrzej Kurek7311c782018-10-11 06:49:41 -04006249# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006250# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006251# The ratio of max/min timeout should ideally equal 4 to accept two
6252# retransmissions, but in some cases (like both the server and client using
6253# fragmentation and auto-reduction) an extra retransmission might occur,
6254# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006255not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006256requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6257requires_config_enabled MBEDTLS_RSA_C
6258requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006259requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6260requires_config_enabled MBEDTLS_AES_C
6261requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006262run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6263 -p "$P_PXY mtu=508" \
6264 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6265 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006266 key_file=data_files/server7.key \
6267 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006268 "$P_CLI dtls=1 debug_level=2 \
6269 crt_file=data_files/server8_int-ca2.crt \
6270 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006271 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6272 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006273 0 \
6274 -s "found fragmented DTLS handshake message" \
6275 -c "found fragmented DTLS handshake message" \
6276 -C "error"
6277
Andrzej Kurek77826052018-10-11 07:34:08 -04006278# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006279only_with_valgrind
6280requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6281requires_config_enabled MBEDTLS_RSA_C
6282requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006283requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6284requires_config_enabled MBEDTLS_AES_C
6285requires_config_enabled MBEDTLS_GCM_C
Hanno Becker108992e2018-08-29 17:04:18 +01006286run_test "DTLS fragmenting: proxy MTU: auto-reduction" \
6287 -p "$P_PXY mtu=508" \
6288 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6289 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006290 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006291 hs_timeout=250-10000" \
6292 "$P_CLI dtls=1 debug_level=2 \
6293 crt_file=data_files/server8_int-ca2.crt \
6294 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006295 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006296 hs_timeout=250-10000" \
6297 0 \
6298 -s "found fragmented DTLS handshake message" \
6299 -c "found fragmented DTLS handshake message" \
6300 -C "error"
6301
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006302# 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 +02006303# OTOH the client might resend if the server is to slow to reset after sending
6304# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006305not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006306requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6307requires_config_enabled MBEDTLS_RSA_C
6308requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006309run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006310 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006311 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6312 crt_file=data_files/server7_int-ca.crt \
6313 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006314 hs_timeout=10000-60000 \
6315 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006316 "$P_CLI dtls=1 debug_level=2 \
6317 crt_file=data_files/server8_int-ca2.crt \
6318 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006319 hs_timeout=10000-60000 \
6320 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006321 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006322 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006323 -s "found fragmented DTLS handshake message" \
6324 -c "found fragmented DTLS handshake message" \
6325 -C "error"
6326
Andrzej Kurek77826052018-10-11 07:34:08 -04006327# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006328# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6329# OTOH the client might resend if the server is to slow to reset after sending
6330# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006331not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006332requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6333requires_config_enabled MBEDTLS_RSA_C
6334requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006335requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6336requires_config_enabled MBEDTLS_AES_C
6337requires_config_enabled MBEDTLS_GCM_C
6338run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006339 -p "$P_PXY mtu=512" \
6340 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6341 crt_file=data_files/server7_int-ca.crt \
6342 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006343 hs_timeout=10000-60000 \
6344 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006345 "$P_CLI dtls=1 debug_level=2 \
6346 crt_file=data_files/server8_int-ca2.crt \
6347 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006348 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6349 hs_timeout=10000-60000 \
6350 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006351 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006352 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006353 -s "found fragmented DTLS handshake message" \
6354 -c "found fragmented DTLS handshake message" \
6355 -C "error"
6356
Andrzej Kurek7311c782018-10-11 06:49:41 -04006357not_with_valgrind # spurious autoreduction due to timeout
6358requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6359requires_config_enabled MBEDTLS_RSA_C
6360requires_config_enabled MBEDTLS_ECDSA_C
6361run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006362 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006363 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6364 crt_file=data_files/server7_int-ca.crt \
6365 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006366 hs_timeout=10000-60000 \
6367 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006368 "$P_CLI dtls=1 debug_level=2 \
6369 crt_file=data_files/server8_int-ca2.crt \
6370 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006371 hs_timeout=10000-60000 \
6372 mtu=1024 nbio=2" \
6373 0 \
6374 -S "autoreduction" \
6375 -s "found fragmented DTLS handshake message" \
6376 -c "found fragmented DTLS handshake message" \
6377 -C "error"
6378
Andrzej Kurek77826052018-10-11 07:34:08 -04006379# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006380not_with_valgrind # spurious autoreduction due to timeout
6381requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6382requires_config_enabled MBEDTLS_RSA_C
6383requires_config_enabled MBEDTLS_ECDSA_C
6384requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6385requires_config_enabled MBEDTLS_AES_C
6386requires_config_enabled MBEDTLS_GCM_C
6387run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
6388 -p "$P_PXY mtu=512" \
6389 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6390 crt_file=data_files/server7_int-ca.crt \
6391 key_file=data_files/server7.key \
6392 hs_timeout=10000-60000 \
6393 mtu=512 nbio=2" \
6394 "$P_CLI dtls=1 debug_level=2 \
6395 crt_file=data_files/server8_int-ca2.crt \
6396 key_file=data_files/server8.key \
6397 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6398 hs_timeout=10000-60000 \
6399 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006400 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006401 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006402 -s "found fragmented DTLS handshake message" \
6403 -c "found fragmented DTLS handshake message" \
6404 -C "error"
6405
Andrzej Kurek77826052018-10-11 07:34:08 -04006406# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01006407# This ensures things still work after session_reset().
6408# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006409# Since we don't support reading fragmented ClientHello yet,
6410# up the MTU to 1450 (larger than ClientHello with session ticket,
6411# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006412# An autoreduction on the client-side might happen if the server is
6413# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02006414# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006415# resumed listening, which would result in a spurious autoreduction.
6416not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006417requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6418requires_config_enabled MBEDTLS_RSA_C
6419requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006420requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6421requires_config_enabled MBEDTLS_AES_C
6422requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006423run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
6424 -p "$P_PXY mtu=1450" \
6425 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6426 crt_file=data_files/server7_int-ca.crt \
6427 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006428 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006429 mtu=1450" \
6430 "$P_CLI dtls=1 debug_level=2 \
6431 crt_file=data_files/server8_int-ca2.crt \
6432 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006433 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006434 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01006435 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006436 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006437 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02006438 -s "found fragmented DTLS handshake message" \
6439 -c "found fragmented DTLS handshake message" \
6440 -C "error"
6441
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006442# An autoreduction on the client-side might happen if the server is
6443# slow to reset, therefore omitting '-C "autoreduction"' below.
6444not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006445requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6446requires_config_enabled MBEDTLS_RSA_C
6447requires_config_enabled MBEDTLS_ECDSA_C
6448requires_config_enabled MBEDTLS_SHA256_C
6449requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6450requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6451requires_config_enabled MBEDTLS_CHACHAPOLY_C
6452run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
6453 -p "$P_PXY mtu=512" \
6454 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6455 crt_file=data_files/server7_int-ca.crt \
6456 key_file=data_files/server7.key \
6457 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006458 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006459 mtu=512" \
6460 "$P_CLI dtls=1 debug_level=2 \
6461 crt_file=data_files/server8_int-ca2.crt \
6462 key_file=data_files/server8.key \
6463 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006464 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006465 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006466 mtu=512" \
6467 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006468 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006469 -s "found fragmented DTLS handshake message" \
6470 -c "found fragmented DTLS handshake message" \
6471 -C "error"
6472
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006473# An autoreduction on the client-side might happen if the server is
6474# slow to reset, therefore omitting '-C "autoreduction"' below.
6475not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006476requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6477requires_config_enabled MBEDTLS_RSA_C
6478requires_config_enabled MBEDTLS_ECDSA_C
6479requires_config_enabled MBEDTLS_SHA256_C
6480requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6481requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6482requires_config_enabled MBEDTLS_AES_C
6483requires_config_enabled MBEDTLS_GCM_C
6484run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
6485 -p "$P_PXY mtu=512" \
6486 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6487 crt_file=data_files/server7_int-ca.crt \
6488 key_file=data_files/server7.key \
6489 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006490 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006491 mtu=512" \
6492 "$P_CLI dtls=1 debug_level=2 \
6493 crt_file=data_files/server8_int-ca2.crt \
6494 key_file=data_files/server8.key \
6495 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006496 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006497 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006498 mtu=512" \
6499 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006500 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006501 -s "found fragmented DTLS handshake message" \
6502 -c "found fragmented DTLS handshake message" \
6503 -C "error"
6504
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006505# An autoreduction on the client-side might happen if the server is
6506# slow to reset, therefore omitting '-C "autoreduction"' below.
6507not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006508requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6509requires_config_enabled MBEDTLS_RSA_C
6510requires_config_enabled MBEDTLS_ECDSA_C
6511requires_config_enabled MBEDTLS_SHA256_C
6512requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6513requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6514requires_config_enabled MBEDTLS_AES_C
6515requires_config_enabled MBEDTLS_CCM_C
6516run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006517 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006518 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6519 crt_file=data_files/server7_int-ca.crt \
6520 key_file=data_files/server7.key \
6521 exchanges=2 renegotiation=1 \
6522 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006523 hs_timeout=10000-60000 \
6524 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006525 "$P_CLI dtls=1 debug_level=2 \
6526 crt_file=data_files/server8_int-ca2.crt \
6527 key_file=data_files/server8.key \
6528 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006529 hs_timeout=10000-60000 \
6530 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006531 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006532 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006533 -s "found fragmented DTLS handshake message" \
6534 -c "found fragmented DTLS handshake message" \
6535 -C "error"
6536
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006537# An autoreduction on the client-side might happen if the server is
6538# slow to reset, therefore omitting '-C "autoreduction"' below.
6539not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006540requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6541requires_config_enabled MBEDTLS_RSA_C
6542requires_config_enabled MBEDTLS_ECDSA_C
6543requires_config_enabled MBEDTLS_SHA256_C
6544requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6545requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6546requires_config_enabled MBEDTLS_AES_C
6547requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6548requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
6549run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006550 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006551 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6552 crt_file=data_files/server7_int-ca.crt \
6553 key_file=data_files/server7.key \
6554 exchanges=2 renegotiation=1 \
6555 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006556 hs_timeout=10000-60000 \
6557 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006558 "$P_CLI dtls=1 debug_level=2 \
6559 crt_file=data_files/server8_int-ca2.crt \
6560 key_file=data_files/server8.key \
6561 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006562 hs_timeout=10000-60000 \
6563 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006564 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006565 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006566 -s "found fragmented DTLS handshake message" \
6567 -c "found fragmented DTLS handshake message" \
6568 -C "error"
6569
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006570# An autoreduction on the client-side might happen if the server is
6571# slow to reset, therefore omitting '-C "autoreduction"' below.
6572not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006573requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6574requires_config_enabled MBEDTLS_RSA_C
6575requires_config_enabled MBEDTLS_ECDSA_C
6576requires_config_enabled MBEDTLS_SHA256_C
6577requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6578requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
6579requires_config_enabled MBEDTLS_AES_C
6580requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6581run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006582 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006583 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6584 crt_file=data_files/server7_int-ca.crt \
6585 key_file=data_files/server7.key \
6586 exchanges=2 renegotiation=1 \
6587 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006588 hs_timeout=10000-60000 \
6589 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006590 "$P_CLI dtls=1 debug_level=2 \
6591 crt_file=data_files/server8_int-ca2.crt \
6592 key_file=data_files/server8.key \
6593 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006594 hs_timeout=10000-60000 \
6595 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006596 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006597 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006598 -s "found fragmented DTLS handshake message" \
6599 -c "found fragmented DTLS handshake message" \
6600 -C "error"
6601
Andrzej Kurek77826052018-10-11 07:34:08 -04006602# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006603requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6604requires_config_enabled MBEDTLS_RSA_C
6605requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006606requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6607requires_config_enabled MBEDTLS_AES_C
6608requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006609client_needs_more_time 2
6610run_test "DTLS fragmenting: proxy MTU + 3d" \
6611 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006612 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006613 crt_file=data_files/server7_int-ca.crt \
6614 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006615 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006616 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006617 crt_file=data_files/server8_int-ca2.crt \
6618 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006619 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006620 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02006621 0 \
6622 -s "found fragmented DTLS handshake message" \
6623 -c "found fragmented DTLS handshake message" \
6624 -C "error"
6625
Andrzej Kurek77826052018-10-11 07:34:08 -04006626# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006627requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6628requires_config_enabled MBEDTLS_RSA_C
6629requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006630requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6631requires_config_enabled MBEDTLS_AES_C
6632requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006633client_needs_more_time 2
6634run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
6635 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
6636 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6637 crt_file=data_files/server7_int-ca.crt \
6638 key_file=data_files/server7.key \
6639 hs_timeout=250-10000 mtu=512 nbio=2" \
6640 "$P_CLI dtls=1 debug_level=2 \
6641 crt_file=data_files/server8_int-ca2.crt \
6642 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006643 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006644 hs_timeout=250-10000 mtu=512 nbio=2" \
6645 0 \
6646 -s "found fragmented DTLS handshake message" \
6647 -c "found fragmented DTLS handshake message" \
6648 -C "error"
6649
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006650# interop tests for DTLS fragmentating with reliable connection
6651#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006652# here and below we just want to test that the we fragment in a way that
6653# pleases other implementations, so we don't need the peer to fragment
6654requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6655requires_config_enabled MBEDTLS_RSA_C
6656requires_config_enabled MBEDTLS_ECDSA_C
6657requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006658requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006659run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
6660 "$G_SRV -u" \
6661 "$P_CLI dtls=1 debug_level=2 \
6662 crt_file=data_files/server8_int-ca2.crt \
6663 key_file=data_files/server8.key \
6664 mtu=512 force_version=dtls1_2" \
6665 0 \
6666 -c "fragmenting handshake message" \
6667 -C "error"
6668
6669requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6670requires_config_enabled MBEDTLS_RSA_C
6671requires_config_enabled MBEDTLS_ECDSA_C
6672requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006673requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006674run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
6675 "$G_SRV -u" \
6676 "$P_CLI dtls=1 debug_level=2 \
6677 crt_file=data_files/server8_int-ca2.crt \
6678 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006679 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006680 0 \
6681 -c "fragmenting handshake message" \
6682 -C "error"
6683
Hanno Beckerb9a00862018-08-28 10:20:22 +01006684# We use --insecure for the GnuTLS client because it expects
6685# the hostname / IP it connects to to be the name used in the
6686# certificate obtained from the server. Here, however, it
6687# connects to 127.0.0.1 while our test certificates use 'localhost'
6688# as the server name in the certificate. This will make the
6689# certifiate validation fail, but passing --insecure makes
6690# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006691requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6692requires_config_enabled MBEDTLS_RSA_C
6693requires_config_enabled MBEDTLS_ECDSA_C
6694requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006695requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006696requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006697run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006698 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006699 crt_file=data_files/server7_int-ca.crt \
6700 key_file=data_files/server7.key \
6701 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006702 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006703 0 \
6704 -s "fragmenting handshake message"
6705
Hanno Beckerb9a00862018-08-28 10:20:22 +01006706# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006707requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6708requires_config_enabled MBEDTLS_RSA_C
6709requires_config_enabled MBEDTLS_ECDSA_C
6710requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02006711requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04006712requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006713run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006714 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006715 crt_file=data_files/server7_int-ca.crt \
6716 key_file=data_files/server7.key \
6717 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02006718 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02006719 0 \
6720 -s "fragmenting handshake message"
6721
6722requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6723requires_config_enabled MBEDTLS_RSA_C
6724requires_config_enabled MBEDTLS_ECDSA_C
6725requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6726run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
6727 "$O_SRV -dtls1_2 -verify 10" \
6728 "$P_CLI dtls=1 debug_level=2 \
6729 crt_file=data_files/server8_int-ca2.crt \
6730 key_file=data_files/server8.key \
6731 mtu=512 force_version=dtls1_2" \
6732 0 \
6733 -c "fragmenting handshake message" \
6734 -C "error"
6735
6736requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6737requires_config_enabled MBEDTLS_RSA_C
6738requires_config_enabled MBEDTLS_ECDSA_C
6739requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6740run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
6741 "$O_SRV -dtls1 -verify 10" \
6742 "$P_CLI dtls=1 debug_level=2 \
6743 crt_file=data_files/server8_int-ca2.crt \
6744 key_file=data_files/server8.key \
6745 mtu=512 force_version=dtls1" \
6746 0 \
6747 -c "fragmenting handshake message" \
6748 -C "error"
6749
6750requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6751requires_config_enabled MBEDTLS_RSA_C
6752requires_config_enabled MBEDTLS_ECDSA_C
6753requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6754run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
6755 "$P_SRV dtls=1 debug_level=2 \
6756 crt_file=data_files/server7_int-ca.crt \
6757 key_file=data_files/server7.key \
6758 mtu=512 force_version=dtls1_2" \
6759 "$O_CLI -dtls1_2" \
6760 0 \
6761 -s "fragmenting handshake message"
6762
6763requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6764requires_config_enabled MBEDTLS_RSA_C
6765requires_config_enabled MBEDTLS_ECDSA_C
6766requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6767run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
6768 "$P_SRV dtls=1 debug_level=2 \
6769 crt_file=data_files/server7_int-ca.crt \
6770 key_file=data_files/server7.key \
6771 mtu=512 force_version=dtls1" \
6772 "$O_CLI -dtls1" \
6773 0 \
6774 -s "fragmenting handshake message"
6775
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006776# interop tests for DTLS fragmentating with unreliable connection
6777#
6778# again we just want to test that the we fragment in a way that
6779# pleases other implementations, so we don't need the peer to fragment
6780requires_gnutls_next
6781requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6782requires_config_enabled MBEDTLS_RSA_C
6783requires_config_enabled MBEDTLS_ECDSA_C
6784requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006785client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006786run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
6787 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6788 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006789 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006790 crt_file=data_files/server8_int-ca2.crt \
6791 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006792 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006793 0 \
6794 -c "fragmenting handshake message" \
6795 -C "error"
6796
6797requires_gnutls_next
6798requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6799requires_config_enabled MBEDTLS_RSA_C
6800requires_config_enabled MBEDTLS_ECDSA_C
6801requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006802client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006803run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
6804 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6805 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006806 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006807 crt_file=data_files/server8_int-ca2.crt \
6808 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006809 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006810 0 \
6811 -c "fragmenting handshake message" \
6812 -C "error"
6813
k-stachowiakabb843e2019-02-18 16:14:03 +01006814requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006815requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6816requires_config_enabled MBEDTLS_RSA_C
6817requires_config_enabled MBEDTLS_ECDSA_C
6818requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6819client_needs_more_time 4
6820run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
6821 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6822 "$P_SRV dtls=1 debug_level=2 \
6823 crt_file=data_files/server7_int-ca.crt \
6824 key_file=data_files/server7.key \
6825 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006826 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006827 0 \
6828 -s "fragmenting handshake message"
6829
k-stachowiakabb843e2019-02-18 16:14:03 +01006830requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006831requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6832requires_config_enabled MBEDTLS_RSA_C
6833requires_config_enabled MBEDTLS_ECDSA_C
6834requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
6835client_needs_more_time 4
6836run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
6837 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6838 "$P_SRV dtls=1 debug_level=2 \
6839 crt_file=data_files/server7_int-ca.crt \
6840 key_file=data_files/server7.key \
6841 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiakabb843e2019-02-18 16:14:03 +01006842 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006843 0 \
6844 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006845
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006846## Interop test with OpenSSL might trigger a bug in recent versions (including
6847## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006848## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006849## They should be re-enabled once a fixed version of OpenSSL is available
6850## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01006851skip_next_test
6852requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6853requires_config_enabled MBEDTLS_RSA_C
6854requires_config_enabled MBEDTLS_ECDSA_C
6855requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6856client_needs_more_time 4
6857run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
6858 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6859 "$O_SRV -dtls1_2 -verify 10" \
6860 "$P_CLI dtls=1 debug_level=2 \
6861 crt_file=data_files/server8_int-ca2.crt \
6862 key_file=data_files/server8.key \
6863 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6864 0 \
6865 -c "fragmenting handshake message" \
6866 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006867
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006868skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006869requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6870requires_config_enabled MBEDTLS_RSA_C
6871requires_config_enabled MBEDTLS_ECDSA_C
6872requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006873client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006874run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
6875 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006876 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006877 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006878 crt_file=data_files/server8_int-ca2.crt \
6879 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006880 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006881 0 \
6882 -c "fragmenting handshake message" \
6883 -C "error"
6884
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006885skip_next_test
6886requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6887requires_config_enabled MBEDTLS_RSA_C
6888requires_config_enabled MBEDTLS_ECDSA_C
6889requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
6890client_needs_more_time 4
6891run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
6892 -p "$P_PXY drop=8 delay=8 duplicate=8" \
6893 "$P_SRV dtls=1 debug_level=2 \
6894 crt_file=data_files/server7_int-ca.crt \
6895 key_file=data_files/server7.key \
6896 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
6897 "$O_CLI -dtls1_2" \
6898 0 \
6899 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006900
6901# -nbio is added to prevent s_client from blocking in case of duplicated
6902# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006903skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006904requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6905requires_config_enabled MBEDTLS_RSA_C
6906requires_config_enabled MBEDTLS_ECDSA_C
6907requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006908client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006909run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
6910 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006911 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006912 crt_file=data_files/server7_int-ca.crt \
6913 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02006914 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02006915 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02006916 0 \
6917 -s "fragmenting handshake message"
6918
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006919# Tests for specific things with "unreliable" UDP connection
6920
6921not_with_valgrind # spurious resend due to timeout
6922run_test "DTLS proxy: reference" \
6923 -p "$P_PXY" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006924 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
6925 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02006926 0 \
6927 -C "replayed record" \
6928 -S "replayed record" \
6929 -C "record from another epoch" \
6930 -S "record from another epoch" \
6931 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006932 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006933 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006934 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02006935 -c "HTTP/1.0 200 OK"
6936
6937not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006938run_test "DTLS proxy: duplicate every packet" \
6939 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnard34cbf102019-09-09 11:14:37 +02006940 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
6941 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02006942 0 \
6943 -c "replayed record" \
6944 -s "replayed record" \
6945 -c "record from another epoch" \
6946 -s "record from another epoch" \
6947 -S "resend" \
6948 -s "Extra-header:" \
6949 -c "HTTP/1.0 200 OK"
6950
6951run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
6952 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006953 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
6954 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006955 0 \
6956 -c "replayed record" \
6957 -S "replayed record" \
6958 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006959 -s "record from another epoch" \
6960 -c "resend" \
6961 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006962 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006963 -c "HTTP/1.0 200 OK"
6964
6965run_test "DTLS proxy: multiple records in same datagram" \
6966 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006967 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6968 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006969 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006970 -c "next record in same datagram" \
6971 -s "next record in same datagram"
6972
6973run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
6974 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006975 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
6976 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006977 0 \
6978 -c "next record in same datagram" \
6979 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006980
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006981run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
6982 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006983 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
6984 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006985 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006986 -c "discarding invalid record (mac)" \
6987 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006988 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006989 -c "HTTP/1.0 200 OK" \
6990 -S "too many records with bad MAC" \
6991 -S "Verification of the message MAC failed"
6992
6993run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
6994 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01006995 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
6996 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006997 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006998 -C "discarding invalid record (mac)" \
6999 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007000 -S "Extra-header:" \
7001 -C "HTTP/1.0 200 OK" \
7002 -s "too many records with bad MAC" \
7003 -s "Verification of the message MAC failed"
7004
7005run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7006 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007007 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7008 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007009 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007010 -c "discarding invalid record (mac)" \
7011 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007012 -s "Extra-header:" \
7013 -c "HTTP/1.0 200 OK" \
7014 -S "too many records with bad MAC" \
7015 -S "Verification of the message MAC failed"
7016
7017run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7018 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007019 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7020 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007021 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007022 -c "discarding invalid record (mac)" \
7023 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007024 -s "Extra-header:" \
7025 -c "HTTP/1.0 200 OK" \
7026 -s "too many records with bad MAC" \
7027 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007028
7029run_test "DTLS proxy: delay ChangeCipherSpec" \
7030 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007031 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7032 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007033 0 \
7034 -c "record from another epoch" \
7035 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007036 -s "Extra-header:" \
7037 -c "HTTP/1.0 200 OK"
7038
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007039# Tests for reordering support with DTLS
7040
Hanno Becker56cdfd12018-08-17 13:42:15 +01007041run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7042 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007043 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7044 hs_timeout=2500-60000" \
7045 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7046 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007047 0 \
7048 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007049 -c "Next handshake message has been buffered - load"\
7050 -S "Buffering HS message" \
7051 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007052 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007053 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007054 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007055 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007056
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007057run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7058 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007059 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7060 hs_timeout=2500-60000" \
7061 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7062 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007063 0 \
7064 -c "Buffering HS message" \
7065 -c "found fragmented DTLS handshake message"\
7066 -c "Next handshake message 1 not or only partially bufffered" \
7067 -c "Next handshake message has been buffered - load"\
7068 -S "Buffering HS message" \
7069 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007070 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007071 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007072 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007073 -S "Remember CCS message"
7074
Hanno Beckera1adcca2018-08-24 14:41:07 +01007075# The client buffers the ServerKeyExchange before receiving the fragmented
7076# Certificate message; at the time of writing, together these are aroudn 1200b
7077# in size, so that the bound below ensures that the certificate can be reassembled
7078# while keeping the ServerKeyExchange.
7079requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7080run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007081 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007082 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7083 hs_timeout=2500-60000" \
7084 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7085 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007086 0 \
7087 -c "Buffering HS message" \
7088 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007089 -C "attempt to make space by freeing buffered messages" \
7090 -S "Buffering HS message" \
7091 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007092 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007093 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007094 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007095 -S "Remember CCS message"
7096
7097# The size constraints ensure that the delayed certificate message can't
7098# be reassembled while keeping the ServerKeyExchange message, but it can
7099# when dropping it first.
7100requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7101requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7102run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7103 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007104 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7105 hs_timeout=2500-60000" \
7106 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7107 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007108 0 \
7109 -c "Buffering HS message" \
7110 -c "attempt to make space by freeing buffered future messages" \
7111 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007112 -S "Buffering HS message" \
7113 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007114 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007115 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007116 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007117 -S "Remember CCS message"
7118
Hanno Becker56cdfd12018-08-17 13:42:15 +01007119run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7120 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007121 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7122 hs_timeout=2500-60000" \
7123 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7124 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007125 0 \
7126 -C "Buffering HS message" \
7127 -C "Next handshake message has been buffered - load"\
7128 -s "Buffering HS message" \
7129 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007130 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007131 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007132 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007133 -S "Remember CCS message"
7134
7135run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
7136 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007137 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7138 hs_timeout=2500-60000" \
7139 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7140 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007141 0 \
7142 -C "Buffering HS message" \
7143 -C "Next handshake message has been buffered - load"\
7144 -S "Buffering HS message" \
7145 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007146 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007147 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007148 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007149 -S "Remember CCS message"
7150
7151run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
7152 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007153 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7154 hs_timeout=2500-60000" \
7155 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7156 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007157 0 \
7158 -C "Buffering HS message" \
7159 -C "Next handshake message has been buffered - load"\
7160 -S "Buffering HS message" \
7161 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007162 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007163 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007164 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007165 -s "Remember CCS message"
7166
Hanno Beckera1adcca2018-08-24 14:41:07 +01007167run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007168 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007169 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7170 hs_timeout=2500-60000" \
7171 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7172 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01007173 0 \
7174 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007175 -s "Found buffered record from current epoch - load" \
7176 -c "Buffer record from epoch 1" \
7177 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007178
Hanno Beckera1adcca2018-08-24 14:41:07 +01007179# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
7180# from the server are delayed, so that the encrypted Finished message
7181# is received and buffered. When the fragmented NewSessionTicket comes
7182# in afterwards, the encrypted Finished message must be freed in order
7183# to make space for the NewSessionTicket to be reassembled.
7184# This works only in very particular circumstances:
7185# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
7186# of the NewSessionTicket, but small enough to also allow buffering of
7187# the encrypted Finished message.
7188# - The MTU setting on the server must be so small that the NewSessionTicket
7189# needs to be fragmented.
7190# - All messages sent by the server must be small enough to be either sent
7191# without fragmentation or be reassembled within the bounds of
7192# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
7193# handshake, omitting CRTs.
7194requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240
7195requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280
7196run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
7197 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
7198 "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
7199 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
7200 0 \
7201 -s "Buffer record from epoch 1" \
7202 -s "Found buffered record from current epoch - load" \
7203 -c "Buffer record from epoch 1" \
7204 -C "Found buffered record from current epoch - load" \
7205 -c "Enough space available after freeing future epoch record"
7206
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02007207# Tests for "randomly unreliable connection": try a variety of flows and peers
7208
7209client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007210run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
7211 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007212 "$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 +02007213 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007214 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007215 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7216 0 \
7217 -s "Extra-header:" \
7218 -c "HTTP/1.0 200 OK"
7219
Janos Follath74537a62016-09-02 13:45:28 +01007220client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007221run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
7222 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007223 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7224 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007225 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7226 0 \
7227 -s "Extra-header:" \
7228 -c "HTTP/1.0 200 OK"
7229
Janos Follath74537a62016-09-02 13:45:28 +01007230client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007231run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
7232 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007233 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
7234 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007235 0 \
7236 -s "Extra-header:" \
7237 -c "HTTP/1.0 200 OK"
7238
Janos Follath74537a62016-09-02 13:45:28 +01007239client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007240run_test "DTLS proxy: 3d, FS, client auth" \
7241 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007242 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
7243 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007244 0 \
7245 -s "Extra-header:" \
7246 -c "HTTP/1.0 200 OK"
7247
Janos Follath74537a62016-09-02 13:45:28 +01007248client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007249run_test "DTLS proxy: 3d, FS, ticket" \
7250 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007251 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
7252 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007253 0 \
7254 -s "Extra-header:" \
7255 -c "HTTP/1.0 200 OK"
7256
Janos Follath74537a62016-09-02 13:45:28 +01007257client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02007258run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
7259 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007260 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
7261 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007262 0 \
7263 -s "Extra-header:" \
7264 -c "HTTP/1.0 200 OK"
7265
Janos Follath74537a62016-09-02 13:45:28 +01007266client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007267run_test "DTLS proxy: 3d, max handshake, nbio" \
7268 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007269 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007270 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007271 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007272 0 \
7273 -s "Extra-header:" \
7274 -c "HTTP/1.0 200 OK"
7275
Janos Follath74537a62016-09-02 13:45:28 +01007276client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007277run_test "DTLS proxy: 3d, min handshake, resumption" \
7278 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007279 "$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 +02007280 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007281 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007282 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02007283 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7284 0 \
7285 -s "a session has been resumed" \
7286 -c "a session has been resumed" \
7287 -s "Extra-header:" \
7288 -c "HTTP/1.0 200 OK"
7289
Janos Follath74537a62016-09-02 13:45:28 +01007290client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007291run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
7292 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007293 "$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 +02007294 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007295 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard498e6322020-02-17 11:04:33 +01007296 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02007297 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
7298 0 \
7299 -s "a session has been resumed" \
7300 -c "a session has been resumed" \
7301 -s "Extra-header:" \
7302 -c "HTTP/1.0 200 OK"
7303
Janos Follath74537a62016-09-02 13:45:28 +01007304client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007305requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007306run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007307 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007308 "$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 +02007309 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007310 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007311 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02007312 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7313 0 \
7314 -c "=> renegotiate" \
7315 -s "=> renegotiate" \
7316 -s "Extra-header:" \
7317 -c "HTTP/1.0 200 OK"
7318
Janos Follath74537a62016-09-02 13:45:28 +01007319client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007320requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007321run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
7322 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007323 "$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 +02007324 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007325 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02007326 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007327 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7328 0 \
7329 -c "=> renegotiate" \
7330 -s "=> renegotiate" \
7331 -s "Extra-header:" \
7332 -c "HTTP/1.0 200 OK"
7333
Janos Follath74537a62016-09-02 13:45:28 +01007334client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007335requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007336run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007337 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007338 "$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 +02007339 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007340 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007341 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007342 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007343 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7344 0 \
7345 -c "=> renegotiate" \
7346 -s "=> renegotiate" \
7347 -s "Extra-header:" \
7348 -c "HTTP/1.0 200 OK"
7349
Janos Follath74537a62016-09-02 13:45:28 +01007350client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01007351requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007352run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007353 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007354 "$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 +02007355 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007356 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007357 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02007358 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02007359 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
7360 0 \
7361 -c "=> renegotiate" \
7362 -s "=> renegotiate" \
7363 -s "Extra-header:" \
7364 -c "HTTP/1.0 200 OK"
7365
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007366## Interop tests with OpenSSL might trigger a bug in recent versions (including
7367## all versions installed on the CI machines), reported here:
7368## Bug report: https://github.com/openssl/openssl/issues/6902
7369## They should be re-enabled once a fixed version of OpenSSL is available
7370## (this should happen in some 1.1.1_ release according to the ticket).
7371skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01007372client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007373not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007374run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007375 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7376 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007377 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007378 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02007379 -c "HTTP/1.0 200 OK"
7380
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007381skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007382client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007383not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007384run_test "DTLS proxy: 3d, openssl server, fragmentation" \
7385 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7386 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007387 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007388 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007389 -c "HTTP/1.0 200 OK"
7390
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02007391skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01007392client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007393not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007394run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
7395 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
7396 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007397 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007398 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007399 -c "HTTP/1.0 200 OK"
7400
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00007401requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01007402client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007403not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007404run_test "DTLS proxy: 3d, gnutls server" \
7405 -p "$P_PXY drop=5 delay=5 duplicate=5" \
7406 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007407 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007408 0 \
7409 -s "Extra-header:" \
7410 -c "Extra-header:"
7411
k-stachowiakabb843e2019-02-18 16:14:03 +01007412requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007413client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007414not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007415run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
7416 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007417 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007418 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02007419 0 \
7420 -s "Extra-header:" \
7421 -c "Extra-header:"
7422
k-stachowiakabb843e2019-02-18 16:14:03 +01007423requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01007424client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02007425not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007426run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
7427 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiakabb843e2019-02-18 16:14:03 +01007428 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007429 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02007430 0 \
7431 -s "Extra-header:" \
7432 -c "Extra-header:"
7433
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01007434# Final report
7435
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007436echo "------------------------------------------------------------------------"
7437
7438if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007439 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007440else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01007441 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007442fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02007443PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02007444echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01007445
7446exit $FAILS