blob: a2ffcb4a41e56e7a220bb4983da29d01966dae7c [file] [log] [blame]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001#!/bin/sh
2
Simon Butcher58eddef2016-05-19 23:43:11 +01003# ssl-opt.sh
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01004#
Bence Szépkúti1e148272020-08-07 13:07:28 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02006# SPDX-License-Identifier: Apache-2.0
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19#
Simon Butcher58eddef2016-05-19 23:43:11 +010020# Purpose
21#
22# Executes tests to prove various TLS/SSL options and extensions.
23#
24# The goal is not to cover every ciphersuite/version, but instead to cover
25# specific options (max fragment length, truncated hmac, etc) or procedures
26# (session resumption from cache or ticket, renego, etc).
27#
28# The tests assume a build with default options, with exceptions expressed
29# with a dependency. The tests focus on functionality and do not consider
30# performance.
31#
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010032
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010033set -u
34
Jaeden Amero6e70eb22019-07-03 13:51:04 +010035# Limit the size of each log to 10 GiB, in case of failures with this script
36# where it may output seemingly unlimited length error logs.
37ulimit -f 20971520
38
Gilles Peskine560280b2019-09-16 15:17:38 +020039ORIGINAL_PWD=$PWD
40if ! cd "$(dirname "$0")"; then
41 exit 125
Angus Grattonc4dd0732018-04-11 16:28:39 +100042fi
43
Antonin Décimo36e89b52019-01-23 15:24:37 +010044# default values, can be overridden by the environment
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +010045: ${P_SRV:=../programs/ssl/ssl_server2}
46: ${P_CLI:=../programs/ssl/ssl_client2}
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +020047: ${P_PXY:=../programs/test/udp_proxy}
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +010048: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020049: ${GNUTLS_CLI:=gnutls-cli}
50: ${GNUTLS_SERV:=gnutls-serv}
Gilles Peskined50177f2017-05-16 17:53:03 +020051: ${PERL:=perl}
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +010052
Gilles Peskine560280b2019-09-16 15:17:38 +020053guess_config_name() {
54 if git diff --quiet ../include/mbedtls/config.h 2>/dev/null; then
55 echo "default"
56 else
57 echo "unknown"
58 fi
59}
60: ${MBEDTLS_TEST_OUTCOME_FILE=}
61: ${MBEDTLS_TEST_CONFIGURATION:="$(guess_config_name)"}
62: ${MBEDTLS_TEST_PLATFORM:="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
63
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +020064O_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 +010065O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +020066G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +010067G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
Gilles Peskined50177f2017-05-16 17:53:03 +020068TCP_CLIENT="$PERL scripts/tcp_client.pl"
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +010069
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020070# alternative versions of OpenSSL and GnuTLS (no default path)
71
72if [ -n "${OPENSSL_LEGACY:-}" ]; then
73 O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key"
74 O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client"
75else
76 O_LEGACY_SRV=false
77 O_LEGACY_CLI=false
78fi
79
Hanno Becker58e9dc32018-08-17 15:53:21 +010080if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020081 G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
82else
83 G_NEXT_SRV=false
84fi
85
Hanno Becker58e9dc32018-08-17 15:53:21 +010086if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +020087 G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt"
88else
89 G_NEXT_CLI=false
90fi
91
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010092TESTS=0
93FAILS=0
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +020094SKIPS=0
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +010095
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000096CONFIG_H='../include/mbedtls/config.h'
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +020097
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +010098MEMCHECK=0
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +010099FILTER='.*'
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200100EXCLUDE='^$'
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100101
Paul Bakkere20310a2016-05-10 11:18:17 +0100102SHOW_TEST_NUMBER=0
Paul Bakkerb7584a52016-05-10 10:50:43 +0100103RUN_TEST_NUMBER=''
104
Paul Bakkeracaac852016-05-10 11:47:13 +0100105PRESERVE_LOGS=0
106
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200107# Pick a "unique" server port in the range 10000-19999, and a proxy
108# port which is this plus 10000. Each port number may be independently
109# overridden by a command line option.
110SRV_PORT=$(($$ % 10000 + 10000))
111PXY_PORT=$((SRV_PORT + 10000))
112
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100113print_usage() {
114 echo "Usage: $0 [options]"
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100115 printf " -h|--help\tPrint this help.\n"
116 printf " -m|--memcheck\tCheck memory leaks and errors.\n"
Gilles Peskine880f7f22020-08-26 22:50:38 +0200117 printf " -f|--filter\tOnly matching tests are executed (BRE)\n"
118 printf " -e|--exclude\tMatching tests are excluded (BRE)\n"
Paul Bakkerb7584a52016-05-10 10:50:43 +0100119 printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
Paul Bakkere20310a2016-05-10 11:18:17 +0100120 printf " -s|--show-numbers\tShow test numbers in front of test names\n"
Paul Bakkeracaac852016-05-10 11:47:13 +0100121 printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
Gilles Peskine560280b2019-09-16 15:17:38 +0200122 printf " --outcome-file\tFile where test outcomes are written\n"
123 printf " \t(default: \$MBEDTLS_TEST_OUTCOME_FILE, none if empty)\n"
124 printf " --port \tTCP/UDP port (default: randomish 1xxxx)\n"
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200125 printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
Gilles Peskine560280b2019-09-16 15:17:38 +0200126 printf " --seed \tInteger seed value to use for this test run\n"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100127}
128
129get_options() {
130 while [ $# -gt 0 ]; do
131 case "$1" in
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100132 -f|--filter)
133 shift; FILTER=$1
134 ;;
135 -e|--exclude)
136 shift; EXCLUDE=$1
137 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100138 -m|--memcheck)
139 MEMCHECK=1
140 ;;
Paul Bakkerb7584a52016-05-10 10:50:43 +0100141 -n|--number)
142 shift; RUN_TEST_NUMBER=$1
143 ;;
Paul Bakkere20310a2016-05-10 11:18:17 +0100144 -s|--show-numbers)
145 SHOW_TEST_NUMBER=1
146 ;;
Paul Bakkeracaac852016-05-10 11:47:13 +0100147 -p|--preserve-logs)
148 PRESERVE_LOGS=1
149 ;;
Gilles Peskinef93c7d32017-04-14 17:55:28 +0200150 --port)
151 shift; SRV_PORT=$1
152 ;;
153 --proxy-port)
154 shift; PXY_PORT=$1
155 ;;
Andres AGf04f54d2016-10-10 15:46:20 +0100156 --seed)
157 shift; SEED="$1"
158 ;;
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100159 -h|--help)
160 print_usage
161 exit 0
162 ;;
163 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200164 echo "Unknown argument: '$1'"
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100165 print_usage
166 exit 1
167 ;;
168 esac
169 shift
170 done
171}
172
Gilles Peskine560280b2019-09-16 15:17:38 +0200173# Make the outcome file path relative to the original directory, not
174# to .../tests
175case "$MBEDTLS_TEST_OUTCOME_FILE" in
176 [!/]*)
177 MBEDTLS_TEST_OUTCOME_FILE="$ORIGINAL_PWD/$MBEDTLS_TEST_OUTCOME_FILE"
178 ;;
179esac
180
Gilles Peskine64457492020-08-26 21:53:33 +0200181# Read boolean configuration options from config.h for easy and quick
182# testing. Skip non-boolean options (with something other than spaces
183# and a comment after "#define SYMBOL"). The variable contains a
184# space-separated list of symbols.
185CONFIGS_ENABLED=" $(<"$CONFIG_H" \
186 sed -n 's!^ *#define *\([A-Za-z][0-9A-Z_a-z]*\) *\(/*\)*!\1!p' |
187 tr '\n' ' ')"
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() {
Gilles Peskine64457492020-08-26 21:53:33 +0200199 case $CONFIGS_ENABLED in
200 *" $1 "*) :;;
201 *) SKIP_NEXT="YES";;
202 esac
Manuel Pégourié-Gonnard988209f2015-03-24 10:43:55 +0100203}
204
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200205# skip next test if the flag is enabled in config.h
206requires_config_disabled() {
Gilles Peskine64457492020-08-26 21:53:33 +0200207 case $CONFIGS_ENABLED in
208 *" $1 "*) SKIP_NEXT="YES";;
209 esac
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +0200210}
211
Hanno Becker7c48dd12018-08-28 16:09:22 +0100212get_config_value_or_default() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100213 # This function uses the query_config command line option to query the
214 # required Mbed TLS compile time configuration from the ssl_server2
215 # program. The command will always return a success value if the
216 # configuration is defined and the value will be printed to stdout.
217 #
218 # Note that if the configuration is not defined or is defined to nothing,
219 # the output of this function will be an empty string.
220 ${P_SRV} "query_config=${1}"
Hanno Becker7c48dd12018-08-28 16:09:22 +0100221}
222
223requires_config_value_at_least() {
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100224 VAL="$( get_config_value_or_default "$1" )"
225 if [ -z "$VAL" ]; then
226 # Should never happen
227 echo "Mbed TLS configuration $1 is not defined"
228 exit 1
229 elif [ "$VAL" -lt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100230 SKIP_NEXT="YES"
231 fi
232}
233
234requires_config_value_at_most() {
Hanno Becker7c48dd12018-08-28 16:09:22 +0100235 VAL=$( get_config_value_or_default "$1" )
Andres Amaya Garcia3169dc02018-10-16 21:29:07 +0100236 if [ -z "$VAL" ]; then
237 # Should never happen
238 echo "Mbed TLS configuration $1 is not defined"
239 exit 1
240 elif [ "$VAL" -gt "$2" ]; then
Hanno Becker5cd017f2018-08-24 14:40:12 +0100241 SKIP_NEXT="YES"
242 fi
243}
244
Gilles Peskine64457492020-08-26 21:53:33 +0200245# Space-separated list of ciphersuites supported by this build of
246# Mbed TLS.
247P_CIPHERSUITES=" $($P_CLI --help 2>/dev/null |
248 grep TLS- |
249 tr -s ' \n' ' ')"
Hanno Becker9d76d562018-11-16 17:27:29 +0000250requires_ciphersuite_enabled() {
Gilles Peskine64457492020-08-26 21:53:33 +0200251 case $P_CIPHERSUITES in
252 *" $1 "*) :;;
253 *) SKIP_NEXT="YES";;
254 esac
Hanno Becker9d76d562018-11-16 17:27:29 +0000255}
256
Gilles Peskine0d721652020-06-26 23:35:53 +0200257# maybe_requires_ciphersuite_enabled CMD [RUN_TEST_OPTION...]
258# If CMD (call to a TLS client or server program) requires a specific
259# ciphersuite, arrange to only run the test case if this ciphersuite is
260# enabled. As an exception, do run the test case if it expects a ciphersuite
261# mismatch.
262maybe_requires_ciphersuite_enabled() {
263 case "$1" in
264 *\ force_ciphersuite=*) :;;
265 *) return;; # No specific required ciphersuite
266 esac
267 ciphersuite="${1##*\ force_ciphersuite=}"
268 ciphersuite="${ciphersuite%%[!-0-9A-Z_a-z]*}"
269 shift
270
271 case "$*" in
272 *"-s SSL - The server has no ciphersuites in common"*)
273 # This test case expects a ciphersuite mismatch, so it doesn't
274 # require the ciphersuite to be enabled.
275 ;;
276 *)
277 requires_ciphersuite_enabled "$ciphersuite"
278 ;;
279 esac
280
281 unset ciphersuite
282}
283
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +0200284# skip next test if OpenSSL doesn't support FALLBACK_SCSV
285requires_openssl_with_fallback_scsv() {
286 if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
287 if $OPENSSL_CMD s_client -help 2>&1 | grep fallback_scsv >/dev/null
288 then
289 OPENSSL_HAS_FBSCSV="YES"
290 else
291 OPENSSL_HAS_FBSCSV="NO"
292 fi
293 fi
294 if [ "$OPENSSL_HAS_FBSCSV" = "NO" ]; then
295 SKIP_NEXT="YES"
296 fi
297}
298
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200299# skip next test if GnuTLS isn't available
300requires_gnutls() {
301 if [ -z "${GNUTLS_AVAILABLE:-}" ]; then
Manuel Pégourié-Gonnard03db6b02015-06-26 15:45:30 +0200302 if ( which "$GNUTLS_CLI" && which "$GNUTLS_SERV" ) >/dev/null 2>&1; then
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +0200303 GNUTLS_AVAILABLE="YES"
304 else
305 GNUTLS_AVAILABLE="NO"
306 fi
307 fi
308 if [ "$GNUTLS_AVAILABLE" = "NO" ]; then
309 SKIP_NEXT="YES"
310 fi
311}
312
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +0200313# skip next test if GnuTLS-next isn't available
314requires_gnutls_next() {
315 if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then
316 if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then
317 GNUTLS_NEXT_AVAILABLE="YES"
318 else
319 GNUTLS_NEXT_AVAILABLE="NO"
320 fi
321 fi
322 if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then
323 SKIP_NEXT="YES"
324 fi
325}
326
327# skip next test if OpenSSL-legacy isn't available
328requires_openssl_legacy() {
329 if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then
330 if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then
331 OPENSSL_LEGACY_AVAILABLE="YES"
332 else
333 OPENSSL_LEGACY_AVAILABLE="NO"
334 fi
335 fi
336 if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then
337 SKIP_NEXT="YES"
338 fi
339}
340
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200341# skip next test if IPv6 isn't available on this host
342requires_ipv6() {
343 if [ -z "${HAS_IPV6:-}" ]; then
344 $P_SRV server_addr='::1' > $SRV_OUT 2>&1 &
345 SRV_PID=$!
346 sleep 1
347 kill $SRV_PID >/dev/null 2>&1
348 if grep "NET - Binding of the socket failed" $SRV_OUT >/dev/null; then
349 HAS_IPV6="NO"
350 else
351 HAS_IPV6="YES"
352 fi
353 rm -r $SRV_OUT
354 fi
355
356 if [ "$HAS_IPV6" = "NO" ]; then
357 SKIP_NEXT="YES"
358 fi
359}
360
Andrzej Kurekb4593462018-10-11 08:43:30 -0400361# skip next test if it's i686 or uname is not available
362requires_not_i686() {
363 if [ -z "${IS_I686:-}" ]; then
364 IS_I686="YES"
365 if which "uname" >/dev/null 2>&1; then
366 if [ -z "$(uname -a | grep i686)" ]; then
367 IS_I686="NO"
368 fi
369 fi
370 fi
371 if [ "$IS_I686" = "YES" ]; then
372 SKIP_NEXT="YES"
373 fi
374}
375
Angus Grattonc4dd0732018-04-11 16:28:39 +1000376# Calculate the input & output maximum content lengths set in the config
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200377MAX_CONTENT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384")
378MAX_IN_LEN=$( ../scripts/config.py get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
379MAX_OUT_LEN=$( ../scripts/config.py get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN")
Angus Grattonc4dd0732018-04-11 16:28:39 +1000380
381if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then
382 MAX_CONTENT_LEN="$MAX_IN_LEN"
383fi
384if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then
385 MAX_CONTENT_LEN="$MAX_OUT_LEN"
386fi
387
388# skip the next test if the SSL output buffer is less than 16KB
389requires_full_size_output_buffer() {
390 if [ "$MAX_OUT_LEN" -ne 16384 ]; then
391 SKIP_NEXT="YES"
392 fi
393}
394
Manuel Pégourié-Gonnard76fe9e42014-09-24 15:17:31 +0200395# skip the next test if valgrind is in use
396not_with_valgrind() {
397 if [ "$MEMCHECK" -gt 0 ]; then
398 SKIP_NEXT="YES"
399 fi
400}
401
Paul Bakker362689d2016-05-13 10:33:25 +0100402# skip the next test if valgrind is NOT in use
403only_with_valgrind() {
404 if [ "$MEMCHECK" -eq 0 ]; then
405 SKIP_NEXT="YES"
406 fi
407}
408
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200409# multiply the client timeout delay by the given factor for the next test
Janos Follath74537a62016-09-02 13:45:28 +0100410client_needs_more_time() {
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200411 CLI_DELAY_FACTOR=$1
412}
413
Janos Follath74537a62016-09-02 13:45:28 +0100414# wait for the given seconds after the client finished in the next test
415server_needs_more_time() {
416 SRV_DELAY_SECONDS=$1
417}
418
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100419# print_name <name>
420print_name() {
Paul Bakkere20310a2016-05-10 11:18:17 +0100421 TESTS=$(( $TESTS + 1 ))
422 LINE=""
423
424 if [ "$SHOW_TEST_NUMBER" -gt 0 ]; then
425 LINE="$TESTS "
426 fi
427
428 LINE="$LINE$1"
429 printf "$LINE "
430 LEN=$(( 72 - `echo "$LINE" | wc -c` ))
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +0100431 for i in `seq 1 $LEN`; do printf '.'; done
432 printf ' '
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100433
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100434}
435
Gilles Peskine560280b2019-09-16 15:17:38 +0200436# record_outcome <outcome> [<failure-reason>]
437# The test name must be in $NAME.
438record_outcome() {
439 echo "$1"
440 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
441 printf '%s;%s;%s;%s;%s;%s\n' \
442 "$MBEDTLS_TEST_PLATFORM" "$MBEDTLS_TEST_CONFIGURATION" \
443 "ssl-opt" "$NAME" \
444 "$1" "${2-}" \
445 >>"$MBEDTLS_TEST_OUTCOME_FILE"
446 fi
447}
448
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100449# fail <message>
450fail() {
Gilles Peskine560280b2019-09-16 15:17:38 +0200451 record_outcome "FAIL" "$1"
Manuel Pégourié-Gonnard3eec6042014-02-27 15:37:24 +0100452 echo " ! $1"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100453
Manuel Pégourié-Gonnardc2b00922014-08-31 16:46:04 +0200454 mv $SRV_OUT o-srv-${TESTS}.log
455 mv $CLI_OUT o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200456 if [ -n "$PXY_CMD" ]; then
457 mv $PXY_OUT o-pxy-${TESTS}.log
458 fi
459 echo " ! outputs saved to o-XXX-${TESTS}.log"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +0100460
Manuel Pégourié-Gonnard3f3302f2020-06-08 11:49:05 +0200461 if [ "${LOG_FAILURE_ON_STDOUT:-0}" != 0 ]; then
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200462 echo " ! server output:"
463 cat o-srv-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200464 echo " ! ========================================================"
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200465 echo " ! client output:"
466 cat o-cli-${TESTS}.log
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200467 if [ -n "$PXY_CMD" ]; then
468 echo " ! ========================================================"
469 echo " ! proxy output:"
470 cat o-pxy-${TESTS}.log
471 fi
472 echo ""
Manuel Pégourié-Gonnard7fa67722014-08-31 17:42:53 +0200473 fi
474
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200475 FAILS=$(( $FAILS + 1 ))
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100476}
477
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100478# is_polar <cmd_line>
479is_polar() {
Gilles Peskine64457492020-08-26 21:53:33 +0200480 case "$1" in
481 *ssl_client2*) true;;
482 *ssl_server2*) true;;
483 *) false;;
484 esac
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100485}
486
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200487# openssl s_server doesn't have -www with DTLS
488check_osrv_dtls() {
Gilles Peskine64457492020-08-26 21:53:33 +0200489 case "$SRV_CMD" in
490 *s_server*-dtls*)
491 NEEDS_INPUT=1
492 SRV_CMD="$( echo $SRV_CMD | sed s/-www// )";;
493 *) NEEDS_INPUT=0;;
494 esac
Manuel Pégourié-Gonnardfa60f122014-09-26 16:07:29 +0200495}
496
497# provide input to commands that need it
498provide_input() {
499 if [ $NEEDS_INPUT -eq 0 ]; then
500 return
501 fi
502
503 while true; do
504 echo "HTTP/1.0 200 OK"
505 sleep 1
506 done
507}
508
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100509# has_mem_err <log_file_name>
510has_mem_err() {
511 if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" &&
512 grep -F 'ERROR SUMMARY: 0 errors from 0 contexts' "$1" ) > /dev/null
513 then
514 return 1 # false: does not have errors
515 else
516 return 0 # true: has errors
517 fi
518}
519
Unknownd364f4c2019-09-02 10:42:57 -0400520# Wait for process $2 named $3 to be listening on port $1. Print error to $4.
Gilles Peskine418b5362017-12-14 18:58:42 +0100521if type lsof >/dev/null 2>/dev/null; then
Unknownd364f4c2019-09-02 10:42:57 -0400522 wait_app_start() {
Gilles Peskine418b5362017-12-14 18:58:42 +0100523 START_TIME=$(date +%s)
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200524 if [ "$DTLS" -eq 1 ]; then
Gilles Peskine418b5362017-12-14 18:58:42 +0100525 proto=UDP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200526 else
Gilles Peskine418b5362017-12-14 18:58:42 +0100527 proto=TCP
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200528 fi
Gilles Peskine418b5362017-12-14 18:58:42 +0100529 # Make a tight loop, server normally takes less than 1s to start.
530 while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
531 if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
Unknownd364f4c2019-09-02 10:42:57 -0400532 echo "$3 START TIMEOUT"
533 echo "$3 START TIMEOUT" >> $4
Gilles Peskine418b5362017-12-14 18:58:42 +0100534 break
535 fi
536 # Linux and *BSD support decimal arguments to sleep. On other
537 # OSes this may be a tight loop.
538 sleep 0.1 2>/dev/null || true
539 done
540 }
541else
Unknownd364f4c2019-09-02 10:42:57 -0400542 echo "Warning: lsof not available, wait_app_start = sleep"
543 wait_app_start() {
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200544 sleep "$START_DELAY"
Gilles Peskine418b5362017-12-14 18:58:42 +0100545 }
546fi
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +0200547
Unknownd364f4c2019-09-02 10:42:57 -0400548# Wait for server process $2 to be listening on port $1.
549wait_server_start() {
550 wait_app_start $1 $2 "SERVER" $SRV_OUT
551}
552
553# Wait for proxy process $2 to be listening on port $1.
554wait_proxy_start() {
555 wait_app_start $1 $2 "PROXY" $PXY_OUT
556}
557
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100558# Given the client or server debug output, parse the unix timestamp that is
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100559# included in the first 4 bytes of the random bytes and check that it's within
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100560# acceptable bounds
561check_server_hello_time() {
562 # Extract the time from the debug (lvl 3) output of the client
Andres Amaya Garcia67d8da52017-09-15 15:49:24 +0100563 SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100564 # Get the Unix timestamp for now
565 CUR_TIME=$(date +'%s')
566 THRESHOLD_IN_SECS=300
567
568 # Check if the ServerHello time was printed
569 if [ -z "$SERVER_HELLO_TIME" ]; then
570 return 1
571 fi
572
573 # Check the time in ServerHello is within acceptable bounds
574 if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
575 # The time in ServerHello is at least 5 minutes before now
576 return 1
577 elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
Andres Amaya Garcia3b1bdff2017-09-14 12:41:29 +0100578 # The time in ServerHello is at least 5 minutes later than now
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +0100579 return 1
580 else
581 return 0
582 fi
583}
584
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100585# Get handshake memory usage from server or client output and put it into the variable specified by the first argument
586handshake_memory_get() {
587 OUTPUT_VARIABLE="$1"
588 OUTPUT_FILE="$2"
589
590 # Get memory usage from a pattern like "Heap memory usage after handshake: 23112 bytes. Peak memory usage was 33112"
591 MEM_USAGE=$(sed -n 's/.*Heap memory usage after handshake: //p' < "$OUTPUT_FILE" | grep -o "[0-9]*" | head -1)
592
593 # Check if memory usage was read
594 if [ -z "$MEM_USAGE" ]; then
595 echo "Error: Can not read the value of handshake memory usage"
596 return 1
597 else
598 eval "$OUTPUT_VARIABLE=$MEM_USAGE"
599 return 0
600 fi
601}
602
603# Get handshake memory usage from server or client output and check if this value
604# is not higher than the maximum given by the first argument
605handshake_memory_check() {
606 MAX_MEMORY="$1"
607 OUTPUT_FILE="$2"
608
609 # Get memory usage
610 if ! handshake_memory_get "MEMORY_USAGE" "$OUTPUT_FILE"; then
611 return 1
612 fi
613
614 # Check if memory usage is below max value
615 if [ "$MEMORY_USAGE" -gt "$MAX_MEMORY" ]; then
616 echo "\nFailed: Handshake memory usage was $MEMORY_USAGE bytes," \
617 "but should be below $MAX_MEMORY bytes"
618 return 1
619 else
620 return 0
621 fi
622}
623
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200624# wait for client to terminate and set CLI_EXIT
625# must be called right after starting the client
626wait_client_done() {
627 CLI_PID=$!
628
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +0200629 CLI_DELAY=$(( $DOG_DELAY * $CLI_DELAY_FACTOR ))
630 CLI_DELAY_FACTOR=1
631
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200632 ( sleep $CLI_DELAY; echo "===CLIENT_TIMEOUT===" >> $CLI_OUT; kill $CLI_PID ) &
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200633 DOG_PID=$!
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200634
635 wait $CLI_PID
636 CLI_EXIT=$?
637
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200638 kill $DOG_PID >/dev/null 2>&1
639 wait $DOG_PID
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200640
641 echo "EXIT: $CLI_EXIT" >> $CLI_OUT
Janos Follath74537a62016-09-02 13:45:28 +0100642
643 sleep $SRV_DELAY_SECONDS
644 SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200645}
646
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200647# check if the given command uses dtls and sets global variable DTLS
648detect_dtls() {
Gilles Peskine64457492020-08-26 21:53:33 +0200649 case "$1" in
650 *dtls=1*|-dtls|-u) DTLS=1;;
651 *) DTLS=0;;
652 esac
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200653}
654
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200655# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100656# Options: -s pattern pattern that must be present in server output
657# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100658# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100659# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100660# -S pattern pattern that must be absent in server output
661# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100662# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100663# -F call shell function on server output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100664run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100665 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200666 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100667
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100668 if echo "$NAME" | grep "$FILTER" | grep -v "$EXCLUDE" >/dev/null; then :
669 else
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200670 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200671 # There was no request to run the test, so don't record its outcome.
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100672 return
673 fi
674
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100675 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100676
Paul Bakkerb7584a52016-05-10 10:50:43 +0100677 # Do we only run numbered tests?
Gilles Peskine64457492020-08-26 21:53:33 +0200678 if [ -n "$RUN_TEST_NUMBER" ]; then
679 case ",$RUN_TEST_NUMBER," in
680 *",$TESTS,"*) :;;
681 *) SKIP_NEXT="YES";;
682 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100683 fi
684
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200685 # does this test use a proxy?
686 if [ "X$1" = "X-p" ]; then
687 PXY_CMD="$2"
688 shift 2
689 else
690 PXY_CMD=""
691 fi
692
693 # get commands and client output
694 SRV_CMD="$1"
695 CLI_CMD="$2"
696 CLI_EXPECT="$3"
697 shift 3
698
Hanno Becker91e72c32019-05-10 14:38:42 +0100699 # Check if test uses files
Gilles Peskine64457492020-08-26 21:53:33 +0200700 case "$SRV_CMD $CLI_CMD" in
701 *data_files/*)
702 requires_config_enabled MBEDTLS_FS_IO;;
703 esac
Hanno Becker91e72c32019-05-10 14:38:42 +0100704
Gilles Peskine0d721652020-06-26 23:35:53 +0200705 # If the client or serve requires a ciphersuite, check that it's enabled.
706 maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
707 maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
Hanno Becker9d76d562018-11-16 17:27:29 +0000708
709 # should we skip?
710 if [ "X$SKIP_NEXT" = "XYES" ]; then
711 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200712 record_outcome "SKIP"
Hanno Becker9d76d562018-11-16 17:27:29 +0000713 SKIPS=$(( $SKIPS + 1 ))
714 return
715 fi
716
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200717 # update DTLS variable
718 detect_dtls "$SRV_CMD"
719
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200720 # if the test uses DTLS but no custom proxy, add a simple proxy
721 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard70fce982020-06-25 09:54:46 +0200722 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200723 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard8779e9a2020-07-16 10:19:32 +0200724 case " $SRV_CMD " in
725 *' server_addr=::1 '*)
726 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
727 esac
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200728 fi
729
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100730 # fix client port
731 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200732 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
733 else
734 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
735 fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200736
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100737 # prepend valgrind to our commands if active
738 if [ "$MEMCHECK" -gt 0 ]; then
739 if is_polar "$SRV_CMD"; then
740 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
741 fi
742 if is_polar "$CLI_CMD"; then
743 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
744 fi
745 fi
746
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200747 TIMES_LEFT=2
748 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200749 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200750
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200751 # run the commands
752 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda3b994f2020-07-27 09:45:32 +0200753 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200754 $PXY_CMD >> $PXY_OUT 2>&1 &
755 PXY_PID=$!
Unknownd364f4c2019-09-02 10:42:57 -0400756 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200757 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200758
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200759 check_osrv_dtls
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200760 printf "# $NAME\n$SRV_CMD\n" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200761 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
762 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100763 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200764
Manuel Pégourié-Gonnardd06125c2020-06-08 12:06:21 +0200765 printf "# $NAME\n$CLI_CMD\n" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200766 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
767 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100768
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100769 sleep 0.05
770
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200771 # terminate the server (and the proxy)
772 kill $SRV_PID
773 wait $SRV_PID
Hanno Beckerd82d8462017-05-29 21:37:46 +0100774
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200775 if [ -n "$PXY_CMD" ]; then
776 kill $PXY_PID >/dev/null 2>&1
777 wait $PXY_PID
778 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100779
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200780 # retry only on timeouts
781 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
782 printf "RETRY "
783 else
784 TIMES_LEFT=0
785 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200786 done
787
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100788 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200789 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100790 # expected client exit to incorrectly succeed in case of catastrophic
791 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100792 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200793 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100794 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100795 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100796 return
797 fi
798 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100799 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200800 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100801 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100802 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100803 return
804 fi
805 fi
806
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100807 # check server exit code
808 if [ $? != 0 ]; then
809 fail "server fail"
810 return
811 fi
812
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100813 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100814 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
815 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100816 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200817 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100818 return
819 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100820
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100821 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200822 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100823 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100824 while [ $# -gt 0 ]
825 do
826 case $1 in
827 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100828 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 +0100829 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100830 return
831 fi
832 ;;
833
834 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100835 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 +0100836 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100837 return
838 fi
839 ;;
840
841 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100842 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 +0100843 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100844 return
845 fi
846 ;;
847
848 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100849 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 +0100850 fail "pattern '$2' MUST NOT be present in the Client output"
851 return
852 fi
853 ;;
854
855 # The filtering in the following two options (-u and -U) do the following
856 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100857 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100858 # - keep one of each non-unique line
859 # - count how many lines remain
860 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
861 # if there were no duplicates.
862 "-U")
863 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
864 fail "lines following pattern '$2' must be unique in Server output"
865 return
866 fi
867 ;;
868
869 "-u")
870 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
871 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100872 return
873 fi
874 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100875 "-F")
876 if ! $2 "$SRV_OUT"; then
877 fail "function call to '$2' failed on Server output"
878 return
879 fi
880 ;;
881 "-f")
882 if ! $2 "$CLI_OUT"; then
883 fail "function call to '$2' failed on Client output"
884 return
885 fi
886 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100887
888 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200889 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100890 exit 1
891 esac
892 shift 2
893 done
894
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100895 # check valgrind's results
896 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200897 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100898 fail "Server has memory errors"
899 return
900 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200901 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100902 fail "Client has memory errors"
903 return
904 fi
905 fi
906
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100907 # if we're here, everything is ok
Gilles Peskine560280b2019-09-16 15:17:38 +0200908 record_outcome "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100909 if [ "$PRESERVE_LOGS" -gt 0 ]; then
910 mv $SRV_OUT o-srv-${TESTS}.log
911 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100912 if [ -n "$PXY_CMD" ]; then
913 mv $PXY_OUT o-pxy-${TESTS}.log
914 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100915 fi
916
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200917 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100918}
919
Hanno Becker9b5853c2018-11-16 17:28:40 +0000920run_test_psa() {
921 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000922 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100923 "$P_SRV debug_level=3 force_version=tls1_2" \
924 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000925 0 \
926 -c "Successfully setup PSA-based decryption cipher context" \
927 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500928 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500929 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000930 -s "Successfully setup PSA-based decryption cipher context" \
931 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500932 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500933 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000934 -C "Failed to setup PSA-based cipher context"\
935 -S "Failed to setup PSA-based cipher context"\
936 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000937 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -0500938 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000939 -S "error" \
940 -C "error"
941}
942
Hanno Becker354e2482019-01-08 11:40:25 +0000943run_test_psa_force_curve() {
944 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
945 run_test "PSA - ECDH with $1" \
946 "$P_SRV debug_level=4 force_version=tls1_2" \
947 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
948 0 \
Hanno Becker28f78442019-02-18 16:47:50 +0000949 -c "Successfully setup PSA-based decryption cipher context" \
950 -c "Successfully setup PSA-based encryption cipher context" \
951 -c "PSA calc verify" \
952 -c "calc PSA finished" \
953 -s "Successfully setup PSA-based decryption cipher context" \
954 -s "Successfully setup PSA-based encryption cipher context" \
955 -s "PSA calc verify" \
956 -s "calc PSA finished" \
957 -C "Failed to setup PSA-based cipher context"\
958 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +0000959 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +0000960 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +0100961 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200962 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +0200963 -C "error"
964}
965
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100966# Test that the server's memory usage after a handshake is reduced when a client specifies
967# a maximum fragment length.
968# first argument ($1) is MFL for SSL client
969# second argument ($2) is memory usage for SSL client with default MFL (16k)
970run_test_memory_after_hanshake_with_mfl()
971{
972 # The test passes if the difference is around 2*(16k-MFL)
Gilles Peskine5b428d72020-08-26 21:52:23 +0200973 MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
Piotr Nowicki0937ed22019-11-26 16:32:40 +0100974
975 # Leave some margin for robustness
976 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
977
978 run_test "Handshake memory usage (MFL $1)" \
979 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
980 "$P_CLI debug_level=3 force_version=tls1_2 \
981 crt_file=data_files/server5.crt key_file=data_files/server5.key \
982 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
983 0 \
984 -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
985}
986
987
988# Test that the server's memory usage after a handshake is reduced when a client specifies
989# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
990run_tests_memory_after_hanshake()
991{
992 # all tests in this sequence requires the same configuration (see requires_config_enabled())
993 SKIP_THIS_TESTS="$SKIP_NEXT"
994
995 # first test with default MFU is to get reference memory usage
996 MEMORY_USAGE_MFL_16K=0
997 run_test "Handshake memory usage initial (MFL 16384 - default)" \
998 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
999 "$P_CLI debug_level=3 force_version=tls1_2 \
1000 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1001 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
1002 0 \
1003 -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
1004
1005 SKIP_NEXT="$SKIP_THIS_TESTS"
1006 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
1007
1008 SKIP_NEXT="$SKIP_THIS_TESTS"
1009 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
1010
1011 SKIP_NEXT="$SKIP_THIS_TESTS"
1012 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
1013
1014 SKIP_NEXT="$SKIP_THIS_TESTS"
1015 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
1016}
1017
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001018cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001019 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001020 rm -f context_srv.txt
1021 rm -f context_cli.txt
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001022 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1023 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1024 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1025 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001026 exit 1
1027}
1028
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001029#
1030# MAIN
1031#
1032
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001033get_options "$@"
1034
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001035# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001036P_SRV_BIN="${P_SRV%%[ ]*}"
1037P_CLI_BIN="${P_CLI%%[ ]*}"
1038P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001039if [ ! -x "$P_SRV_BIN" ]; then
1040 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001041 exit 1
1042fi
Hanno Becker17c04932017-10-10 14:44:53 +01001043if [ ! -x "$P_CLI_BIN" ]; then
1044 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001045 exit 1
1046fi
Hanno Becker17c04932017-10-10 14:44:53 +01001047if [ ! -x "$P_PXY_BIN" ]; then
1048 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001049 exit 1
1050fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001051if [ "$MEMCHECK" -gt 0 ]; then
1052 if which valgrind >/dev/null 2>&1; then :; else
1053 echo "Memcheck not possible. Valgrind not found"
1054 exit 1
1055 fi
1056fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001057if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1058 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001059 exit 1
1060fi
1061
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001062# used by watchdog
1063MAIN_PID="$$"
1064
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001065# We use somewhat arbitrary delays for tests:
1066# - how long do we wait for the server to start (when lsof not available)?
1067# - how long do we allow for the client to finish?
1068# (not to check performance, just to avoid waiting indefinitely)
1069# Things are slower with valgrind, so give extra time here.
1070#
1071# Note: without lsof, there is a trade-off between the running time of this
1072# script and the risk of spurious errors because we didn't wait long enough.
1073# The watchdog delay on the other hand doesn't affect normal running time of
1074# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001075if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001076 START_DELAY=6
1077 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001078else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001079 START_DELAY=2
1080 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001081fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001082
1083# some particular tests need more time:
1084# - for the client, we multiply the usual watchdog limit by a factor
1085# - for the server, we sleep for a number of seconds after the client exits
1086# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001087CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001088SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001089
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001090# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001091# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001092P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1093P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001094P_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 +02001095O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001096O_CLI="$O_CLI -connect localhost:+SRV_PORT"
1097G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001098G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001099
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001100if [ -n "${OPENSSL_LEGACY:-}" ]; then
1101 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1102 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1103fi
1104
Hanno Becker58e9dc32018-08-17 15:53:21 +01001105if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001106 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1107fi
1108
Hanno Becker58e9dc32018-08-17 15:53:21 +01001109if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001110 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001111fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001112
Gilles Peskine62469d92017-05-10 10:13:59 +02001113# Allow SHA-1, because many of our test certificates use it
1114P_SRV="$P_SRV allow_sha1=1"
1115P_CLI="$P_CLI allow_sha1=1"
1116
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001117# Also pick a unique name for intermediate files
1118SRV_OUT="srv_out.$$"
1119CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001120PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001121SESSION="session.$$"
1122
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001123SKIP_NEXT="NO"
1124
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001125trap cleanup INT TERM HUP
1126
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001127# Basic test
1128
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001129# Checks that:
1130# - things work with all ciphersuites active (used with config-full in all.sh)
1131# - the expected (highest security) parameters are selected
1132# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001133run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001134 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001135 "$P_CLI" \
1136 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001137 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001138 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001139 -s "client hello v3, signature_algorithm ext: 6" \
1140 -s "ECDHE curve: secp521r1" \
1141 -S "error" \
1142 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001143
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001144run_test "Default, DTLS" \
1145 "$P_SRV dtls=1" \
1146 "$P_CLI dtls=1" \
1147 0 \
1148 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001149 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001150
Hanno Becker721f7c12020-08-17 12:17:32 +01001151run_test "TLS client auth: required" \
1152 "$P_SRV auth_mode=required" \
1153 "$P_CLI" \
1154 0 \
1155 -s "Verifying peer X.509 certificate... ok"
1156
Hanno Becker2f54a3c2020-08-17 12:14:06 +01001157requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1158requires_config_enabled MBEDTLS_ECDSA_C
1159requires_config_enabled MBEDTLS_SHA256_C
1160run_test "TLS: password protected client key" \
1161 "$P_SRV auth_mode=required" \
1162 "$P_CLI crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
1163 0
1164
1165requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1166requires_config_enabled MBEDTLS_ECDSA_C
1167requires_config_enabled MBEDTLS_SHA256_C
1168run_test "TLS: password protected server key" \
1169 "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
1170 "$P_CLI" \
1171 0
1172
1173requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1174requires_config_enabled MBEDTLS_ECDSA_C
1175requires_config_enabled MBEDTLS_RSA_C
1176requires_config_enabled MBEDTLS_SHA256_C
1177run_test "TLS: password protected server key, two certificates" \
1178 "$P_SRV \
1179 key_file=data_files/server5.key.enc key_pwd=PolarSSLTest crt_file=data_files/server5.crt \
1180 key_file2=data_files/server2.key.enc key_pwd2=PolarSSLTest crt_file2=data_files/server2.crt" \
1181 "$P_CLI" \
1182 0
1183
Manuel Pégourié-Gonnard342d2ca2020-01-02 11:58:00 +01001184requires_config_enabled MBEDTLS_ZLIB_SUPPORT
1185run_test "Default (compression enabled)" \
1186 "$P_SRV debug_level=3" \
1187 "$P_CLI debug_level=3" \
1188 0 \
1189 -s "Allocating compression buffer" \
1190 -c "Allocating compression buffer" \
1191 -s "Record expansion is unknown (compression)" \
1192 -c "Record expansion is unknown (compression)" \
1193 -S "error" \
1194 -C "error"
1195
Hanno Becker746aaf32019-03-28 15:25:23 +00001196requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1197run_test "CA callback on client" \
1198 "$P_SRV debug_level=3" \
1199 "$P_CLI ca_callback=1 debug_level=3 " \
1200 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001201 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001202 -S "error" \
1203 -C "error"
1204
1205requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1206requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1207requires_config_enabled MBEDTLS_ECDSA_C
1208requires_config_enabled MBEDTLS_SHA256_C
1209run_test "CA callback on server" \
1210 "$P_SRV auth_mode=required" \
1211 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
1212 key_file=data_files/server5.key" \
1213 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001214 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001215 -s "Verifying peer X.509 certificate... ok" \
1216 -S "error" \
1217 -C "error"
1218
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +01001219# Test using an opaque private key for client authentication
1220requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1221requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1222requires_config_enabled MBEDTLS_ECDSA_C
1223requires_config_enabled MBEDTLS_SHA256_C
1224run_test "Opaque key for client authentication" \
1225 "$P_SRV auth_mode=required" \
1226 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
1227 key_file=data_files/server5.key" \
1228 0 \
1229 -c "key type: Opaque" \
1230 -s "Verifying peer X.509 certificate... ok" \
1231 -S "error" \
1232 -C "error"
1233
Hanno Becker9b5853c2018-11-16 17:28:40 +00001234# Test ciphersuites which we expect to be fully supported by PSA Crypto
1235# and check that we don't fall back to Mbed TLS' internal crypto primitives.
1236run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
1237run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
1238run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
1239run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
1240run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
1241run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
1242run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
1243run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
1244run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
1245
Hanno Becker354e2482019-01-08 11:40:25 +00001246requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1247run_test_psa_force_curve "secp521r1"
1248requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
1249run_test_psa_force_curve "brainpoolP512r1"
1250requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
1251run_test_psa_force_curve "secp384r1"
1252requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1253run_test_psa_force_curve "brainpoolP384r1"
1254requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1255run_test_psa_force_curve "secp256r1"
1256requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1257run_test_psa_force_curve "secp256k1"
1258requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1259run_test_psa_force_curve "brainpoolP256r1"
1260requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1261run_test_psa_force_curve "secp224r1"
1262requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1263run_test_psa_force_curve "secp224k1"
1264requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1265run_test_psa_force_curve "secp192r1"
1266requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1267run_test_psa_force_curve "secp192k1"
1268
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001269# Test current time in ServerHello
1270requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001271run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001272 "$P_SRV debug_level=3" \
1273 "$P_CLI debug_level=3" \
1274 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001275 -f "check_server_hello_time" \
1276 -F "check_server_hello_time"
1277
Simon Butcher8e004102016-10-14 00:48:33 +01001278# Test for uniqueness of IVs in AEAD ciphersuites
1279run_test "Unique IV in GCM" \
1280 "$P_SRV exchanges=20 debug_level=4" \
1281 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1282 0 \
1283 -u "IV used" \
1284 -U "IV used"
1285
Janos Follathee11be62019-04-04 12:03:30 +01001286# Tests for certificate verification callback
1287run_test "Configuration-specific CRT verification callback" \
1288 "$P_SRV debug_level=3" \
1289 "$P_CLI context_crt_cb=0 debug_level=3" \
1290 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001291 -S "error" \
1292 -c "Verify requested for " \
1293 -c "Use configuration-specific verification callback" \
1294 -C "Use context-specific verification callback" \
1295 -C "error"
1296
Hanno Beckerefb440a2019-04-03 13:04:33 +01001297run_test "Context-specific CRT verification callback" \
1298 "$P_SRV debug_level=3" \
1299 "$P_CLI context_crt_cb=1 debug_level=3" \
1300 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001301 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001302 -c "Verify requested for " \
1303 -c "Use context-specific verification callback" \
1304 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001305 -C "error"
1306
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001307# Tests for rc4 option
1308
Simon Butchera410af52016-05-19 22:12:18 +01001309requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001310run_test "RC4: server disabled, client enabled" \
1311 "$P_SRV" \
1312 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1313 1 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001314 -s "SSL - The server has no ciphersuites in common"
1315
Simon Butchera410af52016-05-19 22:12:18 +01001316requires_config_enabled MBEDTLS_REMOVE_ARC4_CIPHERSUITES
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001317run_test "RC4: server half, client enabled" \
1318 "$P_SRV arc4=1" \
1319 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1320 1 \
1321 -s "SSL - The server has no ciphersuites in common"
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001322
1323run_test "RC4: server enabled, client disabled" \
1324 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1325 "$P_CLI" \
1326 1 \
1327 -s "SSL - The server has no ciphersuites in common"
1328
1329run_test "RC4: both enabled" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01001330 "$P_SRV force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001331 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
1332 0 \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01001333 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnardbd47a582015-01-12 13:43:29 +01001334 -S "SSL - The server has no ciphersuites in common"
1335
Hanno Beckerd26bb202018-08-17 09:54:10 +01001336# Test empty CA list in CertificateRequest in TLS 1.1 and earlier
1337
1338requires_gnutls
1339requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
1340run_test "CertificateRequest with empty CA list, TLS 1.1 (GnuTLS server)" \
1341 "$G_SRV"\
1342 "$P_CLI force_version=tls1_1" \
1343 0
1344
1345requires_gnutls
1346requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
1347run_test "CertificateRequest with empty CA list, TLS 1.0 (GnuTLS server)" \
1348 "$G_SRV"\
1349 "$P_CLI force_version=tls1" \
1350 0
1351
Gilles Peskinebc70a182017-05-09 15:59:24 +02001352# Tests for SHA-1 support
1353
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001354requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001355run_test "SHA-1 forbidden by default in server certificate" \
1356 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1357 "$P_CLI debug_level=2 allow_sha1=0" \
1358 1 \
1359 -c "The certificate is signed with an unacceptable hash"
1360
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001361requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001362run_test "SHA-1 allowed by default in server certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001363 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1364 "$P_CLI debug_level=2 allow_sha1=0" \
1365 0
1366
Gilles Peskinebc70a182017-05-09 15:59:24 +02001367run_test "SHA-1 explicitly allowed in server certificate" \
1368 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1369 "$P_CLI allow_sha1=1" \
1370 0
1371
1372run_test "SHA-256 allowed by default in server certificate" \
1373 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1374 "$P_CLI allow_sha1=0" \
1375 0
1376
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001377requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskinebc70a182017-05-09 15:59:24 +02001378run_test "SHA-1 forbidden by default in client certificate" \
1379 "$P_SRV auth_mode=required allow_sha1=0" \
1380 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1381 1 \
1382 -s "The certificate is signed with an unacceptable hash"
1383
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001384requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02001385run_test "SHA-1 allowed by default in client certificate" \
Manuel Pégourié-Gonnardaf63c212017-06-08 17:51:08 +02001386 "$P_SRV auth_mode=required allow_sha1=0" \
1387 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1388 0
1389
Gilles Peskinebc70a182017-05-09 15:59:24 +02001390run_test "SHA-1 explicitly allowed in client certificate" \
1391 "$P_SRV auth_mode=required allow_sha1=1" \
1392 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1393 0
1394
1395run_test "SHA-256 allowed by default in client certificate" \
1396 "$P_SRV auth_mode=required allow_sha1=0" \
1397 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1398 0
1399
Hanno Becker7ae8a762018-08-14 15:43:35 +01001400# Tests for datagram packing
1401run_test "DTLS: multiple records in same datagram, client and server" \
1402 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1403 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1404 0 \
1405 -c "next record in same datagram" \
1406 -s "next record in same datagram"
1407
1408run_test "DTLS: multiple records in same datagram, client only" \
1409 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1410 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1411 0 \
1412 -s "next record in same datagram" \
1413 -C "next record in same datagram"
1414
1415run_test "DTLS: multiple records in same datagram, server only" \
1416 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1417 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1418 0 \
1419 -S "next record in same datagram" \
1420 -c "next record in same datagram"
1421
1422run_test "DTLS: multiple records in same datagram, neither client nor server" \
1423 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1424 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1425 0 \
1426 -S "next record in same datagram" \
1427 -C "next record in same datagram"
1428
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001429# Tests for Truncated HMAC extension
1430
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001431run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001432 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001433 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001434 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001435 -s "dumping 'expected mac' (20 bytes)" \
1436 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001437
Hanno Becker32c55012017-11-10 08:42:54 +00001438requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001439run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001440 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001441 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001442 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001443 -s "dumping 'expected mac' (20 bytes)" \
1444 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001445
Hanno Becker32c55012017-11-10 08:42:54 +00001446requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001447run_test "Truncated HMAC: client enabled, server default" \
1448 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001449 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001450 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001451 -s "dumping 'expected mac' (20 bytes)" \
1452 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001453
Hanno Becker32c55012017-11-10 08:42:54 +00001454requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001455run_test "Truncated HMAC: client enabled, server disabled" \
1456 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001457 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001458 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001459 -s "dumping 'expected mac' (20 bytes)" \
1460 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001461
Hanno Becker32c55012017-11-10 08:42:54 +00001462requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001463run_test "Truncated HMAC: client disabled, server enabled" \
1464 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001465 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001466 0 \
1467 -s "dumping 'expected mac' (20 bytes)" \
1468 -S "dumping 'expected mac' (10 bytes)"
1469
1470requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001471run_test "Truncated HMAC: client enabled, server enabled" \
1472 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001473 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001474 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001475 -S "dumping 'expected mac' (20 bytes)" \
1476 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001477
Hanno Becker4c4f4102017-11-10 09:16:05 +00001478run_test "Truncated HMAC, DTLS: client default, server default" \
1479 "$P_SRV dtls=1 debug_level=4" \
1480 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1481 0 \
1482 -s "dumping 'expected mac' (20 bytes)" \
1483 -S "dumping 'expected mac' (10 bytes)"
1484
1485requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1486run_test "Truncated HMAC, DTLS: client disabled, server default" \
1487 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001488 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001489 0 \
1490 -s "dumping 'expected mac' (20 bytes)" \
1491 -S "dumping 'expected mac' (10 bytes)"
1492
1493requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1494run_test "Truncated HMAC, DTLS: client enabled, server default" \
1495 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001496 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001497 0 \
1498 -s "dumping 'expected mac' (20 bytes)" \
1499 -S "dumping 'expected mac' (10 bytes)"
1500
1501requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1502run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1503 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001504 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001505 0 \
1506 -s "dumping 'expected mac' (20 bytes)" \
1507 -S "dumping 'expected mac' (10 bytes)"
1508
1509requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1510run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1511 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001512 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001513 0 \
1514 -s "dumping 'expected mac' (20 bytes)" \
1515 -S "dumping 'expected mac' (10 bytes)"
1516
1517requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1518run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1519 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001520 "$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 +01001521 0 \
1522 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001523 -s "dumping 'expected mac' (10 bytes)"
1524
Jarno Lamsa2937d812019-06-04 11:33:23 +03001525# Tests for Context serialization
1526
1527requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001528run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001529 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001530 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1531 0 \
1532 -c "Deserializing connection..." \
1533 -S "Deserializing connection..."
1534
1535requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1536run_test "Context serialization, client serializes, ChaChaPoly" \
1537 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1538 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1539 0 \
1540 -c "Deserializing connection..." \
1541 -S "Deserializing connection..."
1542
1543requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1544run_test "Context serialization, client serializes, GCM" \
1545 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1546 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001547 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001548 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001549 -S "Deserializing connection..."
1550
1551requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001552requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1553run_test "Context serialization, client serializes, with CID" \
1554 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1555 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1556 0 \
1557 -c "Deserializing connection..." \
1558 -S "Deserializing connection..."
1559
1560requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001561run_test "Context serialization, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001562 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001563 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1564 0 \
1565 -C "Deserializing connection..." \
1566 -s "Deserializing connection..."
1567
1568requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1569run_test "Context serialization, server serializes, ChaChaPoly" \
1570 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1571 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1572 0 \
1573 -C "Deserializing connection..." \
1574 -s "Deserializing connection..."
1575
1576requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1577run_test "Context serialization, server serializes, GCM" \
1578 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1579 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001580 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001581 -C "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001582 -s "Deserializing connection..."
1583
1584requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001585requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1586run_test "Context serialization, server serializes, with CID" \
1587 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1588 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1589 0 \
1590 -C "Deserializing connection..." \
1591 -s "Deserializing connection..."
1592
1593requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001594run_test "Context serialization, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001595 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001596 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1597 0 \
1598 -c "Deserializing connection..." \
1599 -s "Deserializing connection..."
1600
1601requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1602run_test "Context serialization, both serialize, ChaChaPoly" \
1603 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1604 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1605 0 \
1606 -c "Deserializing connection..." \
1607 -s "Deserializing connection..."
1608
1609requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1610run_test "Context serialization, both serialize, GCM" \
1611 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1612 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001613 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001614 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001615 -s "Deserializing connection..."
1616
Jarno Lamsac2376f02019-06-06 10:44:14 +03001617requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001618requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1619run_test "Context serialization, both serialize, with CID" \
1620 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1621 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1622 0 \
1623 -c "Deserializing connection..." \
1624 -s "Deserializing connection..."
1625
1626requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001627run_test "Context serialization, re-init, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001628 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001629 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1630 0 \
1631 -c "Deserializing connection..." \
1632 -S "Deserializing connection..."
1633
1634requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1635run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1636 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1637 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1638 0 \
1639 -c "Deserializing connection..." \
1640 -S "Deserializing connection..."
1641
1642requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1643run_test "Context serialization, re-init, client serializes, GCM" \
1644 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1645 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001646 0 \
1647 -c "Deserializing connection..." \
1648 -S "Deserializing connection..."
1649
Jarno Lamsac2376f02019-06-06 10:44:14 +03001650requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001651requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1652run_test "Context serialization, re-init, client serializes, with CID" \
1653 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1654 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1655 0 \
1656 -c "Deserializing connection..." \
1657 -S "Deserializing connection..."
1658
1659requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001660run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001661 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001662 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1663 0 \
1664 -C "Deserializing connection..." \
1665 -s "Deserializing connection..."
1666
1667requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1668run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1669 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1670 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1671 0 \
1672 -C "Deserializing connection..." \
1673 -s "Deserializing connection..."
1674
1675requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1676run_test "Context serialization, re-init, server serializes, GCM" \
1677 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1678 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001679 0 \
1680 -C "Deserializing connection..." \
1681 -s "Deserializing connection..."
1682
Jarno Lamsac2376f02019-06-06 10:44:14 +03001683requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001684requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1685run_test "Context serialization, re-init, server serializes, with CID" \
1686 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1687 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1688 0 \
1689 -C "Deserializing connection..." \
1690 -s "Deserializing connection..."
1691
1692requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001693run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001694 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001695 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1696 0 \
1697 -c "Deserializing connection..." \
1698 -s "Deserializing connection..."
1699
1700requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1701run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1702 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1703 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1704 0 \
1705 -c "Deserializing connection..." \
1706 -s "Deserializing connection..."
1707
1708requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1709run_test "Context serialization, re-init, both serialize, GCM" \
1710 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1711 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001712 0 \
1713 -c "Deserializing connection..." \
1714 -s "Deserializing connection..."
1715
Hanno Becker1b18fd32019-08-30 11:18:59 +01001716requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1717requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1718run_test "Context serialization, re-init, both serialize, with CID" \
1719 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1720 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1721 0 \
1722 -c "Deserializing connection..." \
1723 -s "Deserializing connection..."
1724
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001725requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1726run_test "Saving the serialized context to a file" \
1727 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
1728 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
1729 0 \
1730 -s "Save serialized context to a file... ok" \
1731 -c "Save serialized context to a file... ok"
1732rm -f context_srv.txt
1733rm -f context_cli.txt
1734
Hanno Becker7cf463e2019-04-09 18:08:47 +01001735# Tests for DTLS Connection ID extension
1736
Hanno Becker7cf463e2019-04-09 18:08:47 +01001737# So far, the CID API isn't implemented, so we can't
1738# grep for output witnessing its use. This needs to be
1739# changed once the CID extension is implemented.
1740
Hanno Beckera0e20d02019-05-15 14:03:01 +01001741requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001742run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001743 "$P_SRV debug_level=3 dtls=1 cid=0" \
1744 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1745 0 \
1746 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001747 -s "found CID extension" \
1748 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001749 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001750 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001751 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001752 -C "found CID extension" \
1753 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001754 -C "Copy CIDs into SSL transform" \
1755 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001756
Hanno Beckera0e20d02019-05-15 14:03:01 +01001757requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001758run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001759 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1760 "$P_CLI debug_level=3 dtls=1 cid=0" \
1761 0 \
1762 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001763 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001764 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001765 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001766 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001767 -C "found CID extension" \
1768 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001769 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001770 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001771
Hanno Beckera0e20d02019-05-15 14:03:01 +01001772requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001773run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001774 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1775 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1776 0 \
1777 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001778 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001779 -c "client hello, adding CID extension" \
1780 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001781 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001782 -s "server hello, adding CID extension" \
1783 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001784 -c "Use of CID extension negotiated" \
1785 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001786 -c "Copy CIDs into SSL transform" \
1787 -c "Peer CID (length 2 Bytes): de ad" \
1788 -s "Peer CID (length 2 Bytes): be ef" \
1789 -s "Use of Connection ID has been negotiated" \
1790 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001791
Hanno Beckera0e20d02019-05-15 14:03:01 +01001792requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001793run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001794 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001795 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1796 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1797 0 \
1798 -c "Enable use of CID extension." \
1799 -s "Enable use of CID extension." \
1800 -c "client hello, adding CID extension" \
1801 -s "found CID extension" \
1802 -s "Use of CID extension negotiated" \
1803 -s "server hello, adding CID extension" \
1804 -c "found CID extension" \
1805 -c "Use of CID extension negotiated" \
1806 -s "Copy CIDs into SSL transform" \
1807 -c "Copy CIDs into SSL transform" \
1808 -c "Peer CID (length 2 Bytes): de ad" \
1809 -s "Peer CID (length 2 Bytes): be ef" \
1810 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001811 -c "Use of Connection ID has been negotiated" \
1812 -c "ignoring unexpected CID" \
1813 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001814
Hanno Beckera0e20d02019-05-15 14:03:01 +01001815requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001816run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1817 -p "$P_PXY mtu=800" \
1818 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1819 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1820 0 \
1821 -c "Enable use of CID extension." \
1822 -s "Enable use of CID extension." \
1823 -c "client hello, adding CID extension" \
1824 -s "found CID extension" \
1825 -s "Use of CID extension negotiated" \
1826 -s "server hello, adding CID extension" \
1827 -c "found CID extension" \
1828 -c "Use of CID extension negotiated" \
1829 -s "Copy CIDs into SSL transform" \
1830 -c "Copy CIDs into SSL transform" \
1831 -c "Peer CID (length 2 Bytes): de ad" \
1832 -s "Peer CID (length 2 Bytes): be ef" \
1833 -s "Use of Connection ID has been negotiated" \
1834 -c "Use of Connection ID has been negotiated"
1835
Hanno Beckera0e20d02019-05-15 14:03:01 +01001836requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001837run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001838 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001839 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1840 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1841 0 \
1842 -c "Enable use of CID extension." \
1843 -s "Enable use of CID extension." \
1844 -c "client hello, adding CID extension" \
1845 -s "found CID extension" \
1846 -s "Use of CID extension negotiated" \
1847 -s "server hello, adding CID extension" \
1848 -c "found CID extension" \
1849 -c "Use of CID extension negotiated" \
1850 -s "Copy CIDs into SSL transform" \
1851 -c "Copy CIDs into SSL transform" \
1852 -c "Peer CID (length 2 Bytes): de ad" \
1853 -s "Peer CID (length 2 Bytes): be ef" \
1854 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001855 -c "Use of Connection ID has been negotiated" \
1856 -c "ignoring unexpected CID" \
1857 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001858
Hanno Beckera0e20d02019-05-15 14:03:01 +01001859requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001860run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001861 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1862 "$P_CLI debug_level=3 dtls=1 cid=1" \
1863 0 \
1864 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001865 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001866 -c "client hello, adding CID extension" \
1867 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001868 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001869 -s "server hello, adding CID extension" \
1870 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001871 -c "Use of CID extension negotiated" \
1872 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001873 -c "Copy CIDs into SSL transform" \
1874 -c "Peer CID (length 4 Bytes): de ad be ef" \
1875 -s "Peer CID (length 0 Bytes):" \
1876 -s "Use of Connection ID has been negotiated" \
1877 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001878
Hanno Beckera0e20d02019-05-15 14:03:01 +01001879requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001880run_test "Connection ID: Cli+Srv enabled, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001881 "$P_SRV debug_level=3 dtls=1 cid=1" \
1882 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1883 0 \
1884 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001885 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001886 -c "client hello, adding CID extension" \
1887 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001888 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001889 -s "server hello, adding CID extension" \
1890 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001891 -c "Use of CID extension negotiated" \
1892 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001893 -c "Copy CIDs into SSL transform" \
1894 -s "Peer CID (length 4 Bytes): de ad be ef" \
1895 -c "Peer CID (length 0 Bytes):" \
1896 -s "Use of Connection ID has been negotiated" \
1897 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001898
Hanno Beckera0e20d02019-05-15 14:03:01 +01001899requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001900run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001901 "$P_SRV debug_level=3 dtls=1 cid=1" \
1902 "$P_CLI debug_level=3 dtls=1 cid=1" \
1903 0 \
1904 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001905 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001906 -c "client hello, adding CID extension" \
1907 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001908 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001909 -s "server hello, adding CID extension" \
1910 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001911 -c "Use of CID extension negotiated" \
1912 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001913 -c "Copy CIDs into SSL transform" \
1914 -S "Use of Connection ID has been negotiated" \
1915 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001916
Hanno Beckera0e20d02019-05-15 14:03:01 +01001917requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001918run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001919 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1920 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1921 0 \
1922 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001923 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001924 -c "client hello, adding CID extension" \
1925 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001926 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001927 -s "server hello, adding CID extension" \
1928 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001929 -c "Use of CID extension negotiated" \
1930 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001931 -c "Copy CIDs into SSL transform" \
1932 -c "Peer CID (length 2 Bytes): de ad" \
1933 -s "Peer CID (length 2 Bytes): be ef" \
1934 -s "Use of Connection ID has been negotiated" \
1935 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001936
Hanno Beckera0e20d02019-05-15 14:03:01 +01001937requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001938run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001939 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1940 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1941 0 \
1942 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001943 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001944 -c "client hello, adding CID extension" \
1945 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001946 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001947 -s "server hello, adding CID extension" \
1948 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001949 -c "Use of CID extension negotiated" \
1950 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001951 -c "Copy CIDs into SSL transform" \
1952 -c "Peer CID (length 4 Bytes): de ad be ef" \
1953 -s "Peer CID (length 0 Bytes):" \
1954 -s "Use of Connection ID has been negotiated" \
1955 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001956
Hanno Beckera0e20d02019-05-15 14:03:01 +01001957requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001958run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001959 "$P_SRV debug_level=3 dtls=1 cid=1" \
1960 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1961 0 \
1962 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001963 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001964 -c "client hello, adding CID extension" \
1965 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001966 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001967 -s "server hello, adding CID extension" \
1968 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001969 -c "Use of CID extension negotiated" \
1970 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001971 -c "Copy CIDs into SSL transform" \
1972 -s "Peer CID (length 4 Bytes): de ad be ef" \
1973 -c "Peer CID (length 0 Bytes):" \
1974 -s "Use of Connection ID has been negotiated" \
1975 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001976
Hanno Beckera0e20d02019-05-15 14:03:01 +01001977requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001978run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001979 "$P_SRV debug_level=3 dtls=1 cid=1" \
1980 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1981 0 \
1982 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001983 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001984 -c "client hello, adding CID extension" \
1985 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001986 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001987 -s "server hello, adding CID extension" \
1988 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001989 -c "Use of CID extension negotiated" \
1990 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001991 -c "Copy CIDs into SSL transform" \
1992 -S "Use of Connection ID has been negotiated" \
1993 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001994
Hanno Beckera0e20d02019-05-15 14:03:01 +01001995requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001996run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001997 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1998 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
1999 0 \
2000 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002001 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002002 -c "client hello, adding CID extension" \
2003 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002004 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002005 -s "server hello, adding CID extension" \
2006 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002007 -c "Use of CID extension negotiated" \
2008 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002009 -c "Copy CIDs into SSL transform" \
2010 -c "Peer CID (length 2 Bytes): de ad" \
2011 -s "Peer CID (length 2 Bytes): be ef" \
2012 -s "Use of Connection ID has been negotiated" \
2013 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002014
Hanno Beckera0e20d02019-05-15 14:03:01 +01002015requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002016run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002017 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
2018 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2019 0 \
2020 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002021 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002022 -c "client hello, adding CID extension" \
2023 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002024 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002025 -s "server hello, adding CID extension" \
2026 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002027 -c "Use of CID extension negotiated" \
2028 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002029 -c "Copy CIDs into SSL transform" \
2030 -c "Peer CID (length 4 Bytes): de ad be ef" \
2031 -s "Peer CID (length 0 Bytes):" \
2032 -s "Use of Connection ID has been negotiated" \
2033 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002034
Hanno Beckera0e20d02019-05-15 14:03:01 +01002035requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002036run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002037 "$P_SRV debug_level=3 dtls=1 cid=1" \
2038 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2039 0 \
2040 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002041 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002042 -c "client hello, adding CID extension" \
2043 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002044 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002045 -s "server hello, adding CID extension" \
2046 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002047 -c "Use of CID extension negotiated" \
2048 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002049 -c "Copy CIDs into SSL transform" \
2050 -s "Peer CID (length 4 Bytes): de ad be ef" \
2051 -c "Peer CID (length 0 Bytes):" \
2052 -s "Use of Connection ID has been negotiated" \
2053 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002054
Hanno Beckera0e20d02019-05-15 14:03:01 +01002055requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002056run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002057 "$P_SRV debug_level=3 dtls=1 cid=1" \
2058 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2059 0 \
2060 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002061 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002062 -c "client hello, adding CID extension" \
2063 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002064 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002065 -s "server hello, adding CID extension" \
2066 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002067 -c "Use of CID extension negotiated" \
2068 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01002069 -c "Copy CIDs into SSL transform" \
2070 -S "Use of Connection ID has been negotiated" \
2071 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002072
Hanno Beckera0e20d02019-05-15 14:03:01 +01002073requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker9bae30d2019-04-23 11:52:44 +01002074requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002075run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002076 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2077 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2078 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002079 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2080 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2081 -s "(initial handshake) Use of Connection ID has been negotiated" \
2082 -c "(initial handshake) Use of Connection ID has been negotiated" \
2083 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2084 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2085 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2086 -c "(after renegotiation) Use of Connection ID has been negotiated"
2087
Hanno Beckera0e20d02019-05-15 14:03:01 +01002088requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002089requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002090run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002091 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2092 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2093 0 \
2094 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2095 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2096 -s "(initial handshake) Use of Connection ID has been negotiated" \
2097 -c "(initial handshake) Use of Connection ID has been negotiated" \
2098 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2099 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2100 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2101 -c "(after renegotiation) Use of Connection ID has been negotiated"
2102
Hanno Beckera0e20d02019-05-15 14:03:01 +01002103requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002104requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002105run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2106 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2107 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2108 0 \
2109 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2110 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2111 -s "(initial handshake) Use of Connection ID has been negotiated" \
2112 -c "(initial handshake) Use of Connection ID has been negotiated" \
2113 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2114 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2115 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2116 -c "(after renegotiation) Use of Connection ID has been negotiated"
2117
Hanno Beckera0e20d02019-05-15 14:03:01 +01002118requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002119requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002120run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002121 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002122 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2123 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2124 0 \
2125 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2126 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2127 -s "(initial handshake) Use of Connection ID has been negotiated" \
2128 -c "(initial handshake) Use of Connection ID has been negotiated" \
2129 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2130 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2131 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002132 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2133 -c "ignoring unexpected CID" \
2134 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002135
Hanno Beckera0e20d02019-05-15 14:03:01 +01002136requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002137requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2138run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002139 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2140 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2141 0 \
2142 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2143 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2144 -s "(initial handshake) Use of Connection ID has been negotiated" \
2145 -c "(initial handshake) Use of Connection ID has been negotiated" \
2146 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2147 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2148 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2149 -S "(after renegotiation) Use of Connection ID has been negotiated"
2150
Hanno Beckera0e20d02019-05-15 14:03:01 +01002151requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002152requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002153run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2154 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2155 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2156 0 \
2157 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2158 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2159 -s "(initial handshake) Use of Connection ID has been negotiated" \
2160 -c "(initial handshake) Use of Connection ID has been negotiated" \
2161 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2162 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2163 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2164 -S "(after renegotiation) Use of Connection ID has been negotiated"
2165
Hanno Beckera0e20d02019-05-15 14:03:01 +01002166requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002167requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002168run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002169 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002170 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2171 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2172 0 \
2173 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2174 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2175 -s "(initial handshake) Use of Connection ID has been negotiated" \
2176 -c "(initial handshake) Use of Connection ID has been negotiated" \
2177 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2178 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2179 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002180 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2181 -c "ignoring unexpected CID" \
2182 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002183
Hanno Beckera0e20d02019-05-15 14:03:01 +01002184requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002185requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2186run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002187 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2188 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2189 0 \
2190 -S "(initial handshake) Use of Connection ID has been negotiated" \
2191 -C "(initial handshake) Use of Connection ID has been negotiated" \
2192 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2193 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2194 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2195 -s "(after renegotiation) Use of Connection ID has been negotiated"
2196
Hanno Beckera0e20d02019-05-15 14:03:01 +01002197requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002198requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002199run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2200 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2201 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2202 0 \
2203 -S "(initial handshake) Use of Connection ID has been negotiated" \
2204 -C "(initial handshake) Use of Connection ID has been negotiated" \
2205 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2206 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2207 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2208 -s "(after renegotiation) Use of Connection ID has been negotiated"
2209
Hanno Beckera0e20d02019-05-15 14:03:01 +01002210requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002211requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002212run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002213 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002214 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2215 "$P_CLI debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2216 0 \
2217 -S "(initial handshake) Use of Connection ID has been negotiated" \
2218 -C "(initial handshake) Use of Connection ID has been negotiated" \
2219 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2220 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2221 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002222 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2223 -c "ignoring unexpected CID" \
2224 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002225
Hanno Beckera0e20d02019-05-15 14:03:01 +01002226requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002227requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2228run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002229 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2230 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2231 0 \
2232 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2233 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2234 -s "(initial handshake) Use of Connection ID has been negotiated" \
2235 -c "(initial handshake) Use of Connection ID has been negotiated" \
2236 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2237 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2238 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2239 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2240 -s "(after renegotiation) Use of Connection ID was not offered by client"
2241
Hanno Beckera0e20d02019-05-15 14:03:01 +01002242requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002243requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002244run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002245 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002246 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2247 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2248 0 \
2249 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2250 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2251 -s "(initial handshake) Use of Connection ID has been negotiated" \
2252 -c "(initial handshake) Use of Connection ID has been negotiated" \
2253 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2254 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2255 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2256 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002257 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2258 -c "ignoring unexpected CID" \
2259 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002260
Hanno Beckera0e20d02019-05-15 14:03:01 +01002261requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002262requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2263run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2264 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2265 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2266 0 \
2267 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2268 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2269 -s "(initial handshake) Use of Connection ID has been negotiated" \
2270 -c "(initial handshake) Use of Connection ID has been negotiated" \
2271 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2272 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2273 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2274 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2275 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2276
Hanno Beckera0e20d02019-05-15 14:03:01 +01002277requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002278requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2279run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002280 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002281 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2282 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2283 0 \
2284 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2285 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2286 -s "(initial handshake) Use of Connection ID has been negotiated" \
2287 -c "(initial handshake) Use of Connection ID has been negotiated" \
2288 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2289 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2290 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2291 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002292 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2293 -c "ignoring unexpected CID" \
2294 -s "ignoring unexpected CID"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002295
Andrzej Kurekb6577832020-06-08 07:08:03 -04002296requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2297requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2298run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
2299 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2300 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
2301 0 \
2302 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2303 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2304 -s "(initial handshake) Use of Connection ID has been negotiated" \
2305 -c "(initial handshake) Use of Connection ID has been negotiated" \
2306 -s "Reallocating in_buf" \
2307 -s "Reallocating out_buf"
2308
2309requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2310requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2311run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
2312 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2313 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
2314 0 \
2315 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2316 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2317 -s "(initial handshake) Use of Connection ID has been negotiated" \
2318 -c "(initial handshake) Use of Connection ID has been negotiated" \
2319 -s "Reallocating in_buf" \
2320 -s "Reallocating out_buf"
2321
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002322# Tests for Encrypt-then-MAC extension
2323
2324run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002325 "$P_SRV debug_level=3 \
2326 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002327 "$P_CLI debug_level=3" \
2328 0 \
2329 -c "client hello, adding encrypt_then_mac extension" \
2330 -s "found encrypt then mac extension" \
2331 -s "server hello, adding encrypt then mac extension" \
2332 -c "found encrypt_then_mac extension" \
2333 -c "using encrypt then mac" \
2334 -s "using encrypt then mac"
2335
2336run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002337 "$P_SRV debug_level=3 etm=0 \
2338 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002339 "$P_CLI debug_level=3 etm=1" \
2340 0 \
2341 -c "client hello, adding encrypt_then_mac extension" \
2342 -s "found encrypt then mac extension" \
2343 -S "server hello, adding encrypt then mac extension" \
2344 -C "found encrypt_then_mac extension" \
2345 -C "using encrypt then mac" \
2346 -S "using encrypt then mac"
2347
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002348run_test "Encrypt then MAC: client enabled, aead cipher" \
2349 "$P_SRV debug_level=3 etm=1 \
2350 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2351 "$P_CLI debug_level=3 etm=1" \
2352 0 \
2353 -c "client hello, adding encrypt_then_mac extension" \
2354 -s "found encrypt then mac extension" \
2355 -S "server hello, adding encrypt then mac extension" \
2356 -C "found encrypt_then_mac extension" \
2357 -C "using encrypt then mac" \
2358 -S "using encrypt then mac"
2359
2360run_test "Encrypt then MAC: client enabled, stream cipher" \
2361 "$P_SRV debug_level=3 etm=1 \
2362 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002363 "$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 +01002364 0 \
2365 -c "client hello, adding encrypt_then_mac extension" \
2366 -s "found encrypt then mac extension" \
2367 -S "server hello, adding encrypt then mac extension" \
2368 -C "found encrypt_then_mac extension" \
2369 -C "using encrypt then mac" \
2370 -S "using encrypt then mac"
2371
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002372run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002373 "$P_SRV debug_level=3 etm=1 \
2374 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002375 "$P_CLI debug_level=3 etm=0" \
2376 0 \
2377 -C "client hello, adding encrypt_then_mac extension" \
2378 -S "found encrypt then mac extension" \
2379 -S "server hello, adding encrypt then mac extension" \
2380 -C "found encrypt_then_mac extension" \
2381 -C "using encrypt then mac" \
2382 -S "using encrypt then mac"
2383
Janos Follathe2681a42016-03-07 15:57:05 +00002384requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002385run_test "Encrypt then MAC: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002386 "$P_SRV debug_level=3 min_version=ssl3 \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002387 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002388 "$P_CLI debug_level=3 force_version=ssl3" \
2389 0 \
2390 -C "client hello, adding encrypt_then_mac extension" \
2391 -S "found encrypt then mac extension" \
2392 -S "server hello, adding encrypt then mac extension" \
2393 -C "found encrypt_then_mac extension" \
2394 -C "using encrypt then mac" \
2395 -S "using encrypt then mac"
2396
Janos Follathe2681a42016-03-07 15:57:05 +00002397requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002398run_test "Encrypt then MAC: client enabled, server SSLv3" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002399 "$P_SRV debug_level=3 force_version=ssl3 \
2400 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002401 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002402 0 \
2403 -c "client hello, adding encrypt_then_mac extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002404 -S "found encrypt then mac extension" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002405 -S "server hello, adding encrypt then mac extension" \
2406 -C "found encrypt_then_mac extension" \
2407 -C "using encrypt then mac" \
2408 -S "using encrypt then mac"
2409
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002410# Tests for Extended Master Secret extension
2411
2412run_test "Extended Master Secret: default" \
2413 "$P_SRV debug_level=3" \
2414 "$P_CLI debug_level=3" \
2415 0 \
2416 -c "client hello, adding extended_master_secret extension" \
2417 -s "found extended master secret extension" \
2418 -s "server hello, adding extended master secret extension" \
2419 -c "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002420 -c "session hash for extended master secret" \
2421 -s "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002422
2423run_test "Extended Master Secret: client enabled, server disabled" \
2424 "$P_SRV debug_level=3 extended_ms=0" \
2425 "$P_CLI debug_level=3 extended_ms=1" \
2426 0 \
2427 -c "client hello, adding extended_master_secret extension" \
2428 -s "found extended master secret extension" \
2429 -S "server hello, adding extended master secret extension" \
2430 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002431 -C "session hash for extended master secret" \
2432 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002433
2434run_test "Extended Master Secret: client disabled, server enabled" \
2435 "$P_SRV debug_level=3 extended_ms=1" \
2436 "$P_CLI debug_level=3 extended_ms=0" \
2437 0 \
2438 -C "client hello, adding extended_master_secret extension" \
2439 -S "found extended master secret extension" \
2440 -S "server hello, adding extended master secret extension" \
2441 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002442 -C "session hash for extended master secret" \
2443 -S "session hash for extended master secret"
Manuel Pégourié-Gonnard367381f2014-10-20 18:40:56 +02002444
Janos Follathe2681a42016-03-07 15:57:05 +00002445requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002446run_test "Extended Master Secret: client SSLv3, server enabled" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002447 "$P_SRV debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002448 "$P_CLI debug_level=3 force_version=ssl3" \
2449 0 \
2450 -C "client hello, adding extended_master_secret extension" \
2451 -S "found extended master secret extension" \
2452 -S "server hello, adding extended master secret extension" \
2453 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002454 -C "session hash for extended master secret" \
2455 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002456
Janos Follathe2681a42016-03-07 15:57:05 +00002457requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002458run_test "Extended Master Secret: client enabled, server SSLv3" \
2459 "$P_SRV debug_level=3 force_version=ssl3" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002460 "$P_CLI debug_level=3 min_version=ssl3" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002461 0 \
2462 -c "client hello, adding extended_master_secret extension" \
Janos Follath00efff72016-05-06 13:48:23 +01002463 -S "found extended master secret extension" \
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002464 -S "server hello, adding extended master secret extension" \
2465 -C "found extended_master_secret extension" \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02002466 -C "session hash for extended master secret" \
2467 -S "session hash for extended master secret"
Manuel Pégourié-Gonnardb575b542014-10-24 15:12:31 +02002468
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002469# Tests for FALLBACK_SCSV
2470
2471run_test "Fallback SCSV: default" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002472 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002473 "$P_CLI debug_level=3 force_version=tls1_1" \
2474 0 \
2475 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002476 -S "received FALLBACK_SCSV" \
2477 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002478 -C "is a fatal alert message (msg 86)"
2479
2480run_test "Fallback SCSV: explicitly disabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002481 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002482 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2483 0 \
2484 -C "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002485 -S "received FALLBACK_SCSV" \
2486 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002487 -C "is a fatal alert message (msg 86)"
2488
2489run_test "Fallback SCSV: enabled" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002490 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002491 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002492 1 \
2493 -c "adding FALLBACK_SCSV" \
2494 -s "received FALLBACK_SCSV" \
2495 -s "inapropriate fallback" \
2496 -c "is a fatal alert message (msg 86)"
2497
2498run_test "Fallback SCSV: enabled, max version" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002499 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002500 "$P_CLI debug_level=3 fallback=1" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002501 0 \
2502 -c "adding FALLBACK_SCSV" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002503 -s "received FALLBACK_SCSV" \
2504 -S "inapropriate fallback" \
Manuel Pégourié-Gonnard1cbd39d2014-10-20 13:34:59 +02002505 -C "is a fatal alert message (msg 86)"
2506
2507requires_openssl_with_fallback_scsv
2508run_test "Fallback SCSV: default, openssl server" \
2509 "$O_SRV" \
2510 "$P_CLI debug_level=3 force_version=tls1_1 fallback=0" \
2511 0 \
2512 -C "adding FALLBACK_SCSV" \
2513 -C "is a fatal alert message (msg 86)"
2514
2515requires_openssl_with_fallback_scsv
2516run_test "Fallback SCSV: enabled, openssl server" \
2517 "$O_SRV" \
2518 "$P_CLI debug_level=3 force_version=tls1_1 fallback=1" \
2519 1 \
2520 -c "adding FALLBACK_SCSV" \
2521 -c "is a fatal alert message (msg 86)"
2522
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002523requires_openssl_with_fallback_scsv
2524run_test "Fallback SCSV: disabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002525 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002526 "$O_CLI -tls1_1" \
2527 0 \
2528 -S "received FALLBACK_SCSV" \
2529 -S "inapropriate fallback"
2530
2531requires_openssl_with_fallback_scsv
2532run_test "Fallback SCSV: enabled, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002533 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002534 "$O_CLI -tls1_1 -fallback_scsv" \
2535 1 \
2536 -s "received FALLBACK_SCSV" \
2537 -s "inapropriate fallback"
2538
2539requires_openssl_with_fallback_scsv
2540run_test "Fallback SCSV: enabled, max version, openssl client" \
Manuel Pégourié-Gonnard4268ae02015-08-04 12:44:10 +02002541 "$P_SRV debug_level=2" \
Manuel Pégourié-Gonnard01b26992014-10-20 14:05:28 +02002542 "$O_CLI -fallback_scsv" \
2543 0 \
2544 -s "received FALLBACK_SCSV" \
2545 -S "inapropriate fallback"
2546
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002547# Test sending and receiving empty application data records
2548
2549run_test "Encrypt then MAC: empty application data record" \
2550 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2551 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2552 0 \
2553 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2554 -s "dumping 'input payload after decrypt' (0 bytes)" \
2555 -c "0 bytes written in 1 fragments"
2556
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002557run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002558 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2559 "$P_CLI auth_mode=none etm=0 request_size=0" \
2560 0 \
2561 -s "dumping 'input payload after decrypt' (0 bytes)" \
2562 -c "0 bytes written in 1 fragments"
2563
2564run_test "Encrypt then MAC, DTLS: empty application data record" \
2565 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2566 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2567 0 \
2568 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2569 -s "dumping 'input payload after decrypt' (0 bytes)" \
2570 -c "0 bytes written in 1 fragments"
2571
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002572run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002573 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2574 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2575 0 \
2576 -s "dumping 'input payload after decrypt' (0 bytes)" \
2577 -c "0 bytes written in 1 fragments"
2578
Gilles Peskined50177f2017-05-16 17:53:03 +02002579## ClientHello generated with
2580## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
2581## then manually twiddling the ciphersuite list.
2582## The ClientHello content is spelled out below as a hex string as
2583## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
2584## The expected response is an inappropriate_fallback alert.
2585requires_openssl_with_fallback_scsv
2586run_test "Fallback SCSV: beginning of list" \
2587 "$P_SRV debug_level=2" \
2588 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
2589 0 \
2590 -s "received FALLBACK_SCSV" \
2591 -s "inapropriate fallback"
2592
2593requires_openssl_with_fallback_scsv
2594run_test "Fallback SCSV: end of list" \
2595 "$P_SRV debug_level=2" \
2596 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
2597 0 \
2598 -s "received FALLBACK_SCSV" \
2599 -s "inapropriate fallback"
2600
2601## Here the expected response is a valid ServerHello prefix, up to the random.
2602requires_openssl_with_fallback_scsv
2603run_test "Fallback SCSV: not in list" \
2604 "$P_SRV debug_level=2" \
2605 "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
2606 0 \
2607 -S "received FALLBACK_SCSV" \
2608 -S "inapropriate fallback"
2609
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002610# Tests for CBC 1/n-1 record splitting
2611
2612run_test "CBC Record splitting: TLS 1.2, no splitting" \
2613 "$P_SRV" \
2614 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2615 request_size=123 force_version=tls1_2" \
2616 0 \
2617 -s "Read from client: 123 bytes read" \
2618 -S "Read from client: 1 bytes read" \
2619 -S "122 bytes read"
2620
2621run_test "CBC Record splitting: TLS 1.1, no splitting" \
2622 "$P_SRV" \
2623 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2624 request_size=123 force_version=tls1_1" \
2625 0 \
2626 -s "Read from client: 123 bytes read" \
2627 -S "Read from client: 1 bytes read" \
2628 -S "122 bytes read"
2629
2630run_test "CBC Record splitting: TLS 1.0, splitting" \
2631 "$P_SRV" \
2632 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2633 request_size=123 force_version=tls1" \
2634 0 \
2635 -S "Read from client: 123 bytes read" \
2636 -s "Read from client: 1 bytes read" \
2637 -s "122 bytes read"
2638
Janos Follathe2681a42016-03-07 15:57:05 +00002639requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002640run_test "CBC Record splitting: SSLv3, splitting" \
Manuel Pégourié-Gonnard51d81662015-01-14 17:20:46 +01002641 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002642 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2643 request_size=123 force_version=ssl3" \
2644 0 \
2645 -S "Read from client: 123 bytes read" \
2646 -s "Read from client: 1 bytes read" \
2647 -s "122 bytes read"
2648
2649run_test "CBC Record splitting: TLS 1.0 RC4, no splitting" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01002650 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002651 "$P_CLI force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
2652 request_size=123 force_version=tls1" \
2653 0 \
2654 -s "Read from client: 123 bytes read" \
2655 -S "Read from client: 1 bytes read" \
2656 -S "122 bytes read"
2657
2658run_test "CBC Record splitting: TLS 1.0, splitting disabled" \
2659 "$P_SRV" \
2660 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2661 request_size=123 force_version=tls1 recsplit=0" \
2662 0 \
2663 -s "Read from client: 123 bytes read" \
2664 -S "Read from client: 1 bytes read" \
2665 -S "122 bytes read"
2666
Manuel Pégourié-Gonnarda852cf42015-01-13 20:56:15 +01002667run_test "CBC Record splitting: TLS 1.0, splitting, nbio" \
2668 "$P_SRV nbio=2" \
2669 "$P_CLI nbio=2 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2670 request_size=123 force_version=tls1" \
2671 0 \
2672 -S "Read from client: 123 bytes read" \
2673 -s "Read from client: 1 bytes read" \
2674 -s "122 bytes read"
2675
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002676# Tests for Session Tickets
2677
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002678run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002679 "$P_SRV debug_level=3 tickets=1" \
2680 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002681 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002682 -c "client hello, adding session ticket extension" \
2683 -s "found session ticket extension" \
2684 -s "server hello, adding session ticket extension" \
2685 -c "found session_ticket extension" \
2686 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002687 -S "session successfully restored from cache" \
2688 -s "session successfully restored from ticket" \
2689 -s "a session has been resumed" \
2690 -c "a session has been resumed"
2691
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002692run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002693 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2694 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002695 0 \
2696 -c "client hello, adding session ticket extension" \
2697 -s "found session ticket extension" \
2698 -s "server hello, adding session ticket extension" \
2699 -c "found session_ticket extension" \
2700 -c "parse new session ticket" \
2701 -S "session successfully restored from cache" \
2702 -s "session successfully restored from ticket" \
2703 -s "a session has been resumed" \
2704 -c "a session has been resumed"
2705
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002706run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002707 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2708 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002709 0 \
2710 -c "client hello, adding session ticket extension" \
2711 -s "found session ticket extension" \
2712 -s "server hello, adding session ticket extension" \
2713 -c "found session_ticket extension" \
2714 -c "parse new session ticket" \
2715 -S "session successfully restored from cache" \
2716 -S "session successfully restored from ticket" \
2717 -S "a session has been resumed" \
2718 -C "a session has been resumed"
2719
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002720run_test "Session resume using tickets: session copy" \
2721 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2722 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2723 0 \
2724 -c "client hello, adding session ticket extension" \
2725 -s "found session ticket extension" \
2726 -s "server hello, adding session ticket extension" \
2727 -c "found session_ticket extension" \
2728 -c "parse new session ticket" \
2729 -S "session successfully restored from cache" \
2730 -s "session successfully restored from ticket" \
2731 -s "a session has been resumed" \
2732 -c "a session has been resumed"
2733
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002734run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002735 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002736 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002737 0 \
2738 -c "client hello, adding session ticket extension" \
2739 -c "found session_ticket extension" \
2740 -c "parse new session ticket" \
2741 -c "a session has been resumed"
2742
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002743run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002744 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002745 "( $O_CLI -sess_out $SESSION; \
2746 $O_CLI -sess_in $SESSION; \
2747 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002748 0 \
2749 -s "found session ticket extension" \
2750 -s "server hello, adding session ticket extension" \
2751 -S "session successfully restored from cache" \
2752 -s "session successfully restored from ticket" \
2753 -s "a session has been resumed"
2754
Hanno Becker1d739932018-08-21 13:55:22 +01002755# Tests for Session Tickets with DTLS
2756
2757run_test "Session resume using tickets, DTLS: basic" \
2758 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002759 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002760 0 \
2761 -c "client hello, adding session ticket extension" \
2762 -s "found session ticket extension" \
2763 -s "server hello, adding session ticket extension" \
2764 -c "found session_ticket extension" \
2765 -c "parse new session ticket" \
2766 -S "session successfully restored from cache" \
2767 -s "session successfully restored from ticket" \
2768 -s "a session has been resumed" \
2769 -c "a session has been resumed"
2770
2771run_test "Session resume using tickets, DTLS: cache disabled" \
2772 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002773 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002774 0 \
2775 -c "client hello, adding session ticket extension" \
2776 -s "found session ticket extension" \
2777 -s "server hello, adding session ticket extension" \
2778 -c "found session_ticket extension" \
2779 -c "parse new session ticket" \
2780 -S "session successfully restored from cache" \
2781 -s "session successfully restored from ticket" \
2782 -s "a session has been resumed" \
2783 -c "a session has been resumed"
2784
2785run_test "Session resume using tickets, DTLS: timeout" \
2786 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002787 "$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 +01002788 0 \
2789 -c "client hello, adding session ticket extension" \
2790 -s "found session ticket extension" \
2791 -s "server hello, adding session ticket extension" \
2792 -c "found session_ticket extension" \
2793 -c "parse new session ticket" \
2794 -S "session successfully restored from cache" \
2795 -S "session successfully restored from ticket" \
2796 -S "a session has been resumed" \
2797 -C "a session has been resumed"
2798
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002799run_test "Session resume using tickets, DTLS: session copy" \
2800 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002801 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1 reco_mode=0" \
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002802 0 \
2803 -c "client hello, adding session ticket extension" \
2804 -s "found session ticket extension" \
2805 -s "server hello, adding session ticket extension" \
2806 -c "found session_ticket extension" \
2807 -c "parse new session ticket" \
2808 -S "session successfully restored from cache" \
2809 -s "session successfully restored from ticket" \
2810 -s "a session has been resumed" \
2811 -c "a session has been resumed"
2812
Hanno Becker1d739932018-08-21 13:55:22 +01002813run_test "Session resume using tickets, DTLS: openssl server" \
2814 "$O_SRV -dtls1" \
2815 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2816 0 \
2817 -c "client hello, adding session ticket extension" \
2818 -c "found session_ticket extension" \
2819 -c "parse new session ticket" \
2820 -c "a session has been resumed"
2821
2822run_test "Session resume using tickets, DTLS: openssl client" \
2823 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2824 "( $O_CLI -dtls1 -sess_out $SESSION; \
2825 $O_CLI -dtls1 -sess_in $SESSION; \
2826 rm -f $SESSION )" \
2827 0 \
2828 -s "found session ticket extension" \
2829 -s "server hello, adding session ticket extension" \
2830 -S "session successfully restored from cache" \
2831 -s "session successfully restored from ticket" \
2832 -s "a session has been resumed"
2833
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002834# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002835
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002836run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002837 "$P_SRV debug_level=3 tickets=0" \
2838 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002839 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002840 -c "client hello, adding session ticket extension" \
2841 -s "found session ticket extension" \
2842 -S "server hello, adding session ticket extension" \
2843 -C "found session_ticket extension" \
2844 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002845 -s "session successfully restored from cache" \
2846 -S "session successfully restored from ticket" \
2847 -s "a session has been resumed" \
2848 -c "a session has been resumed"
2849
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002850run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002851 "$P_SRV debug_level=3 tickets=1" \
2852 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002853 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002854 -C "client hello, adding session ticket extension" \
2855 -S "found session ticket extension" \
2856 -S "server hello, adding session ticket extension" \
2857 -C "found session_ticket extension" \
2858 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002859 -s "session successfully restored from cache" \
2860 -S "session successfully restored from ticket" \
2861 -s "a session has been resumed" \
2862 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002864run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002865 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2866 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002867 0 \
2868 -S "session successfully restored from cache" \
2869 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002870 -S "a session has been resumed" \
2871 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002872
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002873run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002874 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2875 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002876 0 \
2877 -s "session successfully restored from cache" \
2878 -S "session successfully restored from ticket" \
2879 -s "a session has been resumed" \
2880 -c "a session has been resumed"
2881
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002882run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002883 "$P_SRV debug_level=3 tickets=0" \
2884 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002885 0 \
2886 -s "session successfully restored from cache" \
2887 -S "session successfully restored from ticket" \
2888 -s "a session has been resumed" \
2889 -c "a session has been resumed"
2890
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002891run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002892 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2893 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002894 0 \
2895 -S "session successfully restored from cache" \
2896 -S "session successfully restored from ticket" \
2897 -S "a session has been resumed" \
2898 -C "a session has been resumed"
2899
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002900run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002901 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2902 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002903 0 \
2904 -s "session successfully restored from cache" \
2905 -S "session successfully restored from ticket" \
2906 -s "a session has been resumed" \
2907 -c "a session has been resumed"
2908
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002909run_test "Session resume using cache: session copy" \
2910 "$P_SRV debug_level=3 tickets=0" \
2911 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2912 0 \
2913 -s "session successfully restored from cache" \
2914 -S "session successfully restored from ticket" \
2915 -s "a session has been resumed" \
2916 -c "a session has been resumed"
2917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002918run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002919 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002920 "( $O_CLI -sess_out $SESSION; \
2921 $O_CLI -sess_in $SESSION; \
2922 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002923 0 \
2924 -s "found session ticket extension" \
2925 -S "server hello, adding session ticket extension" \
2926 -s "session successfully restored from cache" \
2927 -S "session successfully restored from ticket" \
2928 -s "a session has been resumed"
2929
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002930run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002931 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002932 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002933 0 \
2934 -C "found session_ticket extension" \
2935 -C "parse new session ticket" \
2936 -c "a session has been resumed"
2937
Hanno Becker1d739932018-08-21 13:55:22 +01002938# Tests for Session Resume based on session-ID and cache, DTLS
2939
2940run_test "Session resume using cache, DTLS: tickets enabled on client" \
2941 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002942 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002943 0 \
2944 -c "client hello, adding session ticket extension" \
2945 -s "found session ticket extension" \
2946 -S "server hello, adding session ticket extension" \
2947 -C "found session_ticket extension" \
2948 -C "parse new session ticket" \
2949 -s "session successfully restored from cache" \
2950 -S "session successfully restored from ticket" \
2951 -s "a session has been resumed" \
2952 -c "a session has been resumed"
2953
2954run_test "Session resume using cache, DTLS: tickets enabled on server" \
2955 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002956 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002957 0 \
2958 -C "client hello, adding session ticket extension" \
2959 -S "found session ticket extension" \
2960 -S "server hello, adding session ticket extension" \
2961 -C "found session_ticket extension" \
2962 -C "parse new session ticket" \
2963 -s "session successfully restored from cache" \
2964 -S "session successfully restored from ticket" \
2965 -s "a session has been resumed" \
2966 -c "a session has been resumed"
2967
2968run_test "Session resume using cache, DTLS: cache_max=0" \
2969 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002970 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002971 0 \
2972 -S "session successfully restored from cache" \
2973 -S "session successfully restored from ticket" \
2974 -S "a session has been resumed" \
2975 -C "a session has been resumed"
2976
2977run_test "Session resume using cache, DTLS: cache_max=1" \
2978 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002979 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002980 0 \
2981 -s "session successfully restored from cache" \
2982 -S "session successfully restored from ticket" \
2983 -s "a session has been resumed" \
2984 -c "a session has been resumed"
2985
2986run_test "Session resume using cache, DTLS: timeout > delay" \
2987 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002988 "$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 +01002989 0 \
2990 -s "session successfully restored from cache" \
2991 -S "session successfully restored from ticket" \
2992 -s "a session has been resumed" \
2993 -c "a session has been resumed"
2994
2995run_test "Session resume using cache, DTLS: timeout < delay" \
2996 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002997 "$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 +01002998 0 \
2999 -S "session successfully restored from cache" \
3000 -S "session successfully restored from ticket" \
3001 -S "a session has been resumed" \
3002 -C "a session has been resumed"
3003
3004run_test "Session resume using cache, DTLS: no timeout" \
3005 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003006 "$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 +01003007 0 \
3008 -s "session successfully restored from cache" \
3009 -S "session successfully restored from ticket" \
3010 -s "a session has been resumed" \
3011 -c "a session has been resumed"
3012
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02003013run_test "Session resume using cache, DTLS: session copy" \
3014 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01003015 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1 reco_mode=0" \
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02003016 0 \
3017 -s "session successfully restored from cache" \
3018 -S "session successfully restored from ticket" \
3019 -s "a session has been resumed" \
3020 -c "a session has been resumed"
3021
Hanno Becker1d739932018-08-21 13:55:22 +01003022run_test "Session resume using cache, DTLS: openssl client" \
3023 "$P_SRV dtls=1 debug_level=3 tickets=0" \
3024 "( $O_CLI -dtls1 -sess_out $SESSION; \
3025 $O_CLI -dtls1 -sess_in $SESSION; \
3026 rm -f $SESSION )" \
3027 0 \
3028 -s "found session ticket extension" \
3029 -S "server hello, adding session ticket extension" \
3030 -s "session successfully restored from cache" \
3031 -S "session successfully restored from ticket" \
3032 -s "a session has been resumed"
3033
3034run_test "Session resume using cache, DTLS: openssl server" \
3035 "$O_SRV -dtls1" \
3036 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
3037 0 \
3038 -C "found session_ticket extension" \
3039 -C "parse new session ticket" \
3040 -c "a session has been resumed"
3041
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003042# Tests for Max Fragment Length extension
3043
Angus Grattonc4dd0732018-04-11 16:28:39 +10003044if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then
3045 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 +01003046 exit 1
3047fi
3048
Angus Grattonc4dd0732018-04-11 16:28:39 +10003049if [ $MAX_CONTENT_LEN -ne 16384 ]; then
3050 printf "Using non-default maximum content length $MAX_CONTENT_LEN\n"
3051fi
3052
Hanno Becker4aed27e2017-09-18 15:00:34 +01003053requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003054run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003055 "$P_SRV debug_level=3" \
3056 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003057 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003058 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3059 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3060 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3061 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003062 -C "client hello, adding max_fragment_length extension" \
3063 -S "found max fragment length extension" \
3064 -S "server hello, max_fragment_length extension" \
3065 -C "found max_fragment_length extension"
3066
Hanno Becker4aed27e2017-09-18 15:00:34 +01003067requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01003068run_test "Max fragment length: enabled, default, larger message" \
3069 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003070 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003071 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003072 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3073 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3074 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3075 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003076 -C "client hello, adding max_fragment_length extension" \
3077 -S "found max fragment length extension" \
3078 -S "server hello, max_fragment_length extension" \
3079 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003080 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3081 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003082 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003083
3084requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3085run_test "Max fragment length, DTLS: enabled, default, larger message" \
3086 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003087 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003088 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003089 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3090 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3091 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3092 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003093 -C "client hello, adding max_fragment_length extension" \
3094 -S "found max fragment length extension" \
3095 -S "server hello, max_fragment_length extension" \
3096 -C "found max_fragment_length extension" \
3097 -c "fragment larger than.*maximum "
3098
Angus Grattonc4dd0732018-04-11 16:28:39 +10003099# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
3100# (session fragment length will be 16384 regardless of mbedtls
3101# content length configuration.)
3102
Hanno Beckerc5266962017-09-18 15:01:50 +01003103requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3104run_test "Max fragment length: disabled, larger message" \
3105 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003106 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003107 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003108 -C "Maximum input fragment length is 16384" \
3109 -C "Maximum output fragment length is 16384" \
3110 -S "Maximum input fragment length is 16384" \
3111 -S "Maximum output fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003112 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
3113 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01003114 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01003115
3116requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3117run_test "Max fragment length DTLS: disabled, larger message" \
3118 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10003119 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003120 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003121 -C "Maximum input fragment length is 16384" \
3122 -C "Maximum output fragment length is 16384" \
3123 -S "Maximum input fragment length is 16384" \
3124 -S "Maximum output fragment length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01003125 -c "fragment larger than.*maximum "
3126
3127requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003128run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003129 "$P_SRV debug_level=3" \
3130 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003131 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003132 -c "Maximum input fragment length is 4096" \
3133 -c "Maximum output fragment length is 4096" \
3134 -s "Maximum input fragment length is 4096" \
3135 -s "Maximum output fragment length is 4096" \
3136 -c "client hello, adding max_fragment_length extension" \
3137 -s "found max fragment length extension" \
3138 -s "server hello, max_fragment_length extension" \
3139 -c "found max_fragment_length extension"
3140
3141requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3142run_test "Max fragment length: client 512, server 1024" \
3143 "$P_SRV debug_level=3 max_frag_len=1024" \
3144 "$P_CLI debug_level=3 max_frag_len=512" \
3145 0 \
3146 -c "Maximum input fragment length is 512" \
3147 -c "Maximum output fragment length is 512" \
3148 -s "Maximum input fragment length is 512" \
3149 -s "Maximum output fragment length is 512" \
3150 -c "client hello, adding max_fragment_length extension" \
3151 -s "found max fragment length extension" \
3152 -s "server hello, max_fragment_length extension" \
3153 -c "found max_fragment_length extension"
3154
3155requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3156run_test "Max fragment length: client 512, server 2048" \
3157 "$P_SRV debug_level=3 max_frag_len=2048" \
3158 "$P_CLI debug_level=3 max_frag_len=512" \
3159 0 \
3160 -c "Maximum input fragment length is 512" \
3161 -c "Maximum output fragment length is 512" \
3162 -s "Maximum input fragment length is 512" \
3163 -s "Maximum output fragment length is 512" \
3164 -c "client hello, adding max_fragment_length extension" \
3165 -s "found max fragment length extension" \
3166 -s "server hello, max_fragment_length extension" \
3167 -c "found max_fragment_length extension"
3168
3169requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3170run_test "Max fragment length: client 512, server 4096" \
3171 "$P_SRV debug_level=3 max_frag_len=4096" \
3172 "$P_CLI debug_level=3 max_frag_len=512" \
3173 0 \
3174 -c "Maximum input fragment length is 512" \
3175 -c "Maximum output fragment length is 512" \
3176 -s "Maximum input fragment length is 512" \
3177 -s "Maximum output fragment length is 512" \
3178 -c "client hello, adding max_fragment_length extension" \
3179 -s "found max fragment length extension" \
3180 -s "server hello, max_fragment_length extension" \
3181 -c "found max_fragment_length extension"
3182
3183requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3184run_test "Max fragment length: client 1024, server 512" \
3185 "$P_SRV debug_level=3 max_frag_len=512" \
3186 "$P_CLI debug_level=3 max_frag_len=1024" \
3187 0 \
3188 -c "Maximum input fragment length is 1024" \
3189 -c "Maximum output fragment length is 1024" \
3190 -s "Maximum input fragment length is 1024" \
3191 -s "Maximum output fragment length is 512" \
3192 -c "client hello, adding max_fragment_length extension" \
3193 -s "found max fragment length extension" \
3194 -s "server hello, max_fragment_length extension" \
3195 -c "found max_fragment_length extension"
3196
3197requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3198run_test "Max fragment length: client 1024, server 2048" \
3199 "$P_SRV debug_level=3 max_frag_len=2048" \
3200 "$P_CLI debug_level=3 max_frag_len=1024" \
3201 0 \
3202 -c "Maximum input fragment length is 1024" \
3203 -c "Maximum output fragment length is 1024" \
3204 -s "Maximum input fragment length is 1024" \
3205 -s "Maximum output fragment length is 1024" \
3206 -c "client hello, adding max_fragment_length extension" \
3207 -s "found max fragment length extension" \
3208 -s "server hello, max_fragment_length extension" \
3209 -c "found max_fragment_length extension"
3210
3211requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3212run_test "Max fragment length: client 1024, server 4096" \
3213 "$P_SRV debug_level=3 max_frag_len=4096" \
3214 "$P_CLI debug_level=3 max_frag_len=1024" \
3215 0 \
3216 -c "Maximum input fragment length is 1024" \
3217 -c "Maximum output fragment length is 1024" \
3218 -s "Maximum input fragment length is 1024" \
3219 -s "Maximum output fragment length is 1024" \
3220 -c "client hello, adding max_fragment_length extension" \
3221 -s "found max fragment length extension" \
3222 -s "server hello, max_fragment_length extension" \
3223 -c "found max_fragment_length extension"
3224
3225requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3226run_test "Max fragment length: client 2048, server 512" \
3227 "$P_SRV debug_level=3 max_frag_len=512" \
3228 "$P_CLI debug_level=3 max_frag_len=2048" \
3229 0 \
3230 -c "Maximum input fragment length is 2048" \
3231 -c "Maximum output fragment length is 2048" \
3232 -s "Maximum input fragment length is 2048" \
3233 -s "Maximum output fragment length is 512" \
3234 -c "client hello, adding max_fragment_length extension" \
3235 -s "found max fragment length extension" \
3236 -s "server hello, max_fragment_length extension" \
3237 -c "found max_fragment_length extension"
3238
3239requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3240run_test "Max fragment length: client 2048, server 1024" \
3241 "$P_SRV debug_level=3 max_frag_len=1024" \
3242 "$P_CLI debug_level=3 max_frag_len=2048" \
3243 0 \
3244 -c "Maximum input fragment length is 2048" \
3245 -c "Maximum output fragment length is 2048" \
3246 -s "Maximum input fragment length is 2048" \
3247 -s "Maximum output fragment length is 1024" \
3248 -c "client hello, adding max_fragment_length extension" \
3249 -s "found max fragment length extension" \
3250 -s "server hello, max_fragment_length extension" \
3251 -c "found max_fragment_length extension"
3252
3253requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3254run_test "Max fragment length: client 2048, server 4096" \
3255 "$P_SRV debug_level=3 max_frag_len=4096" \
3256 "$P_CLI debug_level=3 max_frag_len=2048" \
3257 0 \
3258 -c "Maximum input fragment length is 2048" \
3259 -c "Maximum output fragment length is 2048" \
3260 -s "Maximum input fragment length is 2048" \
3261 -s "Maximum output fragment length is 2048" \
3262 -c "client hello, adding max_fragment_length extension" \
3263 -s "found max fragment length extension" \
3264 -s "server hello, max_fragment_length extension" \
3265 -c "found max_fragment_length extension"
3266
3267requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3268run_test "Max fragment length: client 4096, server 512" \
3269 "$P_SRV debug_level=3 max_frag_len=512" \
3270 "$P_CLI debug_level=3 max_frag_len=4096" \
3271 0 \
3272 -c "Maximum input fragment length is 4096" \
3273 -c "Maximum output fragment length is 4096" \
3274 -s "Maximum input fragment length is 4096" \
3275 -s "Maximum output fragment length is 512" \
3276 -c "client hello, adding max_fragment_length extension" \
3277 -s "found max fragment length extension" \
3278 -s "server hello, max_fragment_length extension" \
3279 -c "found max_fragment_length extension"
3280
3281requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3282run_test "Max fragment length: client 4096, server 1024" \
3283 "$P_SRV debug_level=3 max_frag_len=1024" \
3284 "$P_CLI debug_level=3 max_frag_len=4096" \
3285 0 \
3286 -c "Maximum input fragment length is 4096" \
3287 -c "Maximum output fragment length is 4096" \
3288 -s "Maximum input fragment length is 4096" \
3289 -s "Maximum output fragment length is 1024" \
3290 -c "client hello, adding max_fragment_length extension" \
3291 -s "found max fragment length extension" \
3292 -s "server hello, max_fragment_length extension" \
3293 -c "found max_fragment_length extension"
3294
3295requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3296run_test "Max fragment length: client 4096, server 2048" \
3297 "$P_SRV debug_level=3 max_frag_len=2048" \
3298 "$P_CLI debug_level=3 max_frag_len=4096" \
3299 0 \
3300 -c "Maximum input fragment length is 4096" \
3301 -c "Maximum output fragment length is 4096" \
3302 -s "Maximum input fragment length is 4096" \
3303 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003304 -c "client hello, adding max_fragment_length extension" \
3305 -s "found max fragment length extension" \
3306 -s "server hello, max_fragment_length extension" \
3307 -c "found max_fragment_length extension"
3308
Hanno Becker4aed27e2017-09-18 15:00:34 +01003309requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003310run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003311 "$P_SRV debug_level=3 max_frag_len=4096" \
3312 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003313 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003314 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3315 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3316 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3317 -s "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003318 -C "client hello, adding max_fragment_length extension" \
3319 -S "found max fragment length extension" \
3320 -S "server hello, max_fragment_length extension" \
3321 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003322
Hanno Becker4aed27e2017-09-18 15:00:34 +01003323requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003324requires_gnutls
3325run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003326 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003327 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003328 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003329 -c "Maximum input fragment length is 4096" \
3330 -c "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003331 -c "client hello, adding max_fragment_length extension" \
3332 -c "found max_fragment_length extension"
3333
Hanno Becker4aed27e2017-09-18 15:00:34 +01003334requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003335run_test "Max fragment length: client, message just fits" \
3336 "$P_SRV debug_level=3" \
3337 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3338 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003339 -c "Maximum input fragment length is 2048" \
3340 -c "Maximum output fragment length is 2048" \
3341 -s "Maximum input fragment length is 2048" \
3342 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003343 -c "client hello, adding max_fragment_length extension" \
3344 -s "found max fragment length extension" \
3345 -s "server hello, max_fragment_length extension" \
3346 -c "found max_fragment_length extension" \
3347 -c "2048 bytes written in 1 fragments" \
3348 -s "2048 bytes read"
3349
Hanno Becker4aed27e2017-09-18 15:00:34 +01003350requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003351run_test "Max fragment length: client, larger message" \
3352 "$P_SRV debug_level=3" \
3353 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3354 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003355 -c "Maximum input fragment length is 2048" \
3356 -c "Maximum output fragment length is 2048" \
3357 -s "Maximum input fragment length is 2048" \
3358 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003359 -c "client hello, adding max_fragment_length extension" \
3360 -s "found max fragment length extension" \
3361 -s "server hello, max_fragment_length extension" \
3362 -c "found max_fragment_length extension" \
3363 -c "2345 bytes written in 2 fragments" \
3364 -s "2048 bytes read" \
3365 -s "297 bytes read"
3366
Hanno Becker4aed27e2017-09-18 15:00:34 +01003367requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003368run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003369 "$P_SRV debug_level=3 dtls=1" \
3370 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3371 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003372 -c "Maximum input fragment length is 2048" \
3373 -c "Maximum output fragment length is 2048" \
3374 -s "Maximum input fragment length is 2048" \
3375 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003376 -c "client hello, adding max_fragment_length extension" \
3377 -s "found max fragment length extension" \
3378 -s "server hello, max_fragment_length extension" \
3379 -c "found max_fragment_length extension" \
3380 -c "fragment larger than.*maximum"
3381
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003382# Tests for renegotiation
3383
Hanno Becker6a243642017-10-12 15:18:45 +01003384# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003385run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003386 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003387 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003388 0 \
3389 -C "client hello, adding renegotiation extension" \
3390 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3391 -S "found renegotiation extension" \
3392 -s "server hello, secure renegotiation extension" \
3393 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003394 -C "=> renegotiate" \
3395 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003396 -S "write hello request"
3397
Hanno Becker6a243642017-10-12 15:18:45 +01003398requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003399run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003400 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003401 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003402 0 \
3403 -c "client hello, adding renegotiation extension" \
3404 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3405 -s "found renegotiation extension" \
3406 -s "server hello, secure renegotiation extension" \
3407 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003408 -c "=> renegotiate" \
3409 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003410 -S "write hello request"
3411
Hanno Becker6a243642017-10-12 15:18:45 +01003412requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003413run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003414 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003415 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003416 0 \
3417 -c "client hello, adding renegotiation extension" \
3418 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3419 -s "found renegotiation extension" \
3420 -s "server hello, secure renegotiation extension" \
3421 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003422 -c "=> renegotiate" \
3423 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003424 -s "write hello request"
3425
Janos Follathb0f148c2017-10-05 12:29:42 +01003426# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3427# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3428# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003429requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003430run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3431 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3432 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3433 0 \
3434 -c "client hello, adding renegotiation extension" \
3435 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3436 -s "found renegotiation extension" \
3437 -s "server hello, secure renegotiation extension" \
3438 -c "found renegotiation extension" \
3439 -c "=> renegotiate" \
3440 -s "=> renegotiate" \
3441 -S "write hello request" \
3442 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3443
3444# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3445# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3446# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003447requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003448run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3449 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3450 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3451 0 \
3452 -c "client hello, adding renegotiation extension" \
3453 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3454 -s "found renegotiation extension" \
3455 -s "server hello, secure renegotiation extension" \
3456 -c "found renegotiation extension" \
3457 -c "=> renegotiate" \
3458 -s "=> renegotiate" \
3459 -s "write hello request" \
3460 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3461
Hanno Becker6a243642017-10-12 15:18:45 +01003462requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003463run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003464 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003465 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003466 0 \
3467 -c "client hello, adding renegotiation extension" \
3468 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3469 -s "found renegotiation extension" \
3470 -s "server hello, secure renegotiation extension" \
3471 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003472 -c "=> renegotiate" \
3473 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003474 -s "write hello request"
3475
Hanno Becker6a243642017-10-12 15:18:45 +01003476requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003477requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3478run_test "Renegotiation with max fragment length: client 2048, server 512" \
3479 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3480 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 max_frag_len=2048 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
3481 0 \
3482 -c "Maximum input fragment length is 2048" \
3483 -c "Maximum output fragment length is 2048" \
3484 -s "Maximum input fragment length is 2048" \
3485 -s "Maximum output fragment length is 512" \
3486 -c "client hello, adding max_fragment_length extension" \
3487 -s "found max fragment length extension" \
3488 -s "server hello, max_fragment_length extension" \
3489 -c "found max_fragment_length extension" \
3490 -c "client hello, adding renegotiation extension" \
3491 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3492 -s "found renegotiation extension" \
3493 -s "server hello, secure renegotiation extension" \
3494 -c "found renegotiation extension" \
3495 -c "=> renegotiate" \
3496 -s "=> renegotiate" \
3497 -s "write hello request"
3498
3499requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003500run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003501 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003502 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003503 1 \
3504 -c "client hello, adding renegotiation extension" \
3505 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3506 -S "found renegotiation extension" \
3507 -s "server hello, secure renegotiation extension" \
3508 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003509 -c "=> renegotiate" \
3510 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003511 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003512 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003513 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003514
Hanno Becker6a243642017-10-12 15:18:45 +01003515requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003516run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003517 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003518 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003519 0 \
3520 -C "client hello, adding renegotiation extension" \
3521 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3522 -S "found renegotiation extension" \
3523 -s "server hello, secure renegotiation extension" \
3524 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003525 -C "=> renegotiate" \
3526 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003527 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003528 -S "SSL - An unexpected message was received from our peer" \
3529 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003530
Hanno Becker6a243642017-10-12 15:18:45 +01003531requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003532run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003533 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003534 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003535 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003536 0 \
3537 -C "client hello, adding renegotiation extension" \
3538 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3539 -S "found renegotiation extension" \
3540 -s "server hello, secure renegotiation extension" \
3541 -c "found renegotiation extension" \
3542 -C "=> renegotiate" \
3543 -S "=> renegotiate" \
3544 -s "write hello request" \
3545 -S "SSL - An unexpected message was received from our peer" \
3546 -S "failed"
3547
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003548# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003549requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003550run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003551 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003552 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003553 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003554 0 \
3555 -C "client hello, adding renegotiation extension" \
3556 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3557 -S "found renegotiation extension" \
3558 -s "server hello, secure renegotiation extension" \
3559 -c "found renegotiation extension" \
3560 -C "=> renegotiate" \
3561 -S "=> renegotiate" \
3562 -s "write hello request" \
3563 -S "SSL - An unexpected message was received from our peer" \
3564 -S "failed"
3565
Hanno Becker6a243642017-10-12 15:18:45 +01003566requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003567run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003568 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003569 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003570 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003571 0 \
3572 -C "client hello, adding renegotiation extension" \
3573 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3574 -S "found renegotiation extension" \
3575 -s "server hello, secure renegotiation extension" \
3576 -c "found renegotiation extension" \
3577 -C "=> renegotiate" \
3578 -S "=> renegotiate" \
3579 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003580 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003581
Hanno Becker6a243642017-10-12 15:18:45 +01003582requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003583run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003584 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003585 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003586 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003587 0 \
3588 -c "client hello, adding renegotiation extension" \
3589 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3590 -s "found renegotiation extension" \
3591 -s "server hello, secure renegotiation extension" \
3592 -c "found renegotiation extension" \
3593 -c "=> renegotiate" \
3594 -s "=> renegotiate" \
3595 -s "write hello request" \
3596 -S "SSL - An unexpected message was received from our peer" \
3597 -S "failed"
3598
Hanno Becker6a243642017-10-12 15:18:45 +01003599requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003600run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003601 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003602 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3603 0 \
3604 -C "client hello, adding renegotiation extension" \
3605 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3606 -S "found renegotiation extension" \
3607 -s "server hello, secure renegotiation extension" \
3608 -c "found renegotiation extension" \
3609 -S "record counter limit reached: renegotiate" \
3610 -C "=> renegotiate" \
3611 -S "=> renegotiate" \
3612 -S "write hello request" \
3613 -S "SSL - An unexpected message was received from our peer" \
3614 -S "failed"
3615
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003616# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003617requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003618run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003619 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003620 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003621 0 \
3622 -c "client hello, adding renegotiation extension" \
3623 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3624 -s "found renegotiation extension" \
3625 -s "server hello, secure renegotiation extension" \
3626 -c "found renegotiation extension" \
3627 -s "record counter limit reached: renegotiate" \
3628 -c "=> renegotiate" \
3629 -s "=> renegotiate" \
3630 -s "write hello request" \
3631 -S "SSL - An unexpected message was received from our peer" \
3632 -S "failed"
3633
Hanno Becker6a243642017-10-12 15:18:45 +01003634requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003635run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003636 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003637 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003638 0 \
3639 -c "client hello, adding renegotiation extension" \
3640 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3641 -s "found renegotiation extension" \
3642 -s "server hello, secure renegotiation extension" \
3643 -c "found renegotiation extension" \
3644 -s "record counter limit reached: renegotiate" \
3645 -c "=> renegotiate" \
3646 -s "=> renegotiate" \
3647 -s "write hello request" \
3648 -S "SSL - An unexpected message was received from our peer" \
3649 -S "failed"
3650
Hanno Becker6a243642017-10-12 15:18:45 +01003651requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003652run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003653 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003654 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3655 0 \
3656 -C "client hello, adding renegotiation extension" \
3657 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3658 -S "found renegotiation extension" \
3659 -s "server hello, secure renegotiation extension" \
3660 -c "found renegotiation extension" \
3661 -S "record counter limit reached: renegotiate" \
3662 -C "=> renegotiate" \
3663 -S "=> renegotiate" \
3664 -S "write hello request" \
3665 -S "SSL - An unexpected message was received from our peer" \
3666 -S "failed"
3667
Hanno Becker6a243642017-10-12 15:18:45 +01003668requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003669run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003670 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003671 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003672 0 \
3673 -c "client hello, adding renegotiation extension" \
3674 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3675 -s "found renegotiation extension" \
3676 -s "server hello, secure renegotiation extension" \
3677 -c "found renegotiation extension" \
3678 -c "=> renegotiate" \
3679 -s "=> renegotiate" \
3680 -S "write hello request"
3681
Hanno Becker6a243642017-10-12 15:18:45 +01003682requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003683run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003684 "$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 +02003685 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003686 0 \
3687 -c "client hello, adding renegotiation extension" \
3688 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3689 -s "found renegotiation extension" \
3690 -s "server hello, secure renegotiation extension" \
3691 -c "found renegotiation extension" \
3692 -c "=> renegotiate" \
3693 -s "=> renegotiate" \
3694 -s "write hello request"
3695
Hanno Becker6a243642017-10-12 15:18:45 +01003696requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003697run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003698 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003699 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003700 0 \
3701 -c "client hello, adding renegotiation extension" \
3702 -c "found renegotiation extension" \
3703 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003704 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003705 -C "error" \
3706 -c "HTTP/1.0 200 [Oo][Kk]"
3707
Paul Bakker539d9722015-02-08 16:18:35 +01003708requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003709requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003710run_test "Renegotiation: gnutls server strict, client-initiated" \
3711 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003712 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003713 0 \
3714 -c "client hello, adding renegotiation extension" \
3715 -c "found renegotiation extension" \
3716 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003717 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003718 -C "error" \
3719 -c "HTTP/1.0 200 [Oo][Kk]"
3720
Paul Bakker539d9722015-02-08 16:18:35 +01003721requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003722requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003723run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3724 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3725 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3726 1 \
3727 -c "client hello, adding renegotiation extension" \
3728 -C "found renegotiation extension" \
3729 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003730 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003731 -c "error" \
3732 -C "HTTP/1.0 200 [Oo][Kk]"
3733
Paul Bakker539d9722015-02-08 16:18:35 +01003734requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003735requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003736run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3737 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3738 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3739 allow_legacy=0" \
3740 1 \
3741 -c "client hello, adding renegotiation extension" \
3742 -C "found renegotiation extension" \
3743 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003744 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003745 -c "error" \
3746 -C "HTTP/1.0 200 [Oo][Kk]"
3747
Paul Bakker539d9722015-02-08 16:18:35 +01003748requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003749requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003750run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3751 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3752 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3753 allow_legacy=1" \
3754 0 \
3755 -c "client hello, adding renegotiation extension" \
3756 -C "found renegotiation extension" \
3757 -c "=> renegotiate" \
3758 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003759 -C "error" \
3760 -c "HTTP/1.0 200 [Oo][Kk]"
3761
Hanno Becker6a243642017-10-12 15:18:45 +01003762requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003763run_test "Renegotiation: DTLS, client-initiated" \
3764 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3765 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3766 0 \
3767 -c "client hello, adding renegotiation extension" \
3768 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3769 -s "found renegotiation extension" \
3770 -s "server hello, secure renegotiation extension" \
3771 -c "found renegotiation extension" \
3772 -c "=> renegotiate" \
3773 -s "=> renegotiate" \
3774 -S "write hello request"
3775
Hanno Becker6a243642017-10-12 15:18:45 +01003776requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003777run_test "Renegotiation: DTLS, server-initiated" \
3778 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003779 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3780 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003781 0 \
3782 -c "client hello, adding renegotiation extension" \
3783 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3784 -s "found renegotiation extension" \
3785 -s "server hello, secure renegotiation extension" \
3786 -c "found renegotiation extension" \
3787 -c "=> renegotiate" \
3788 -s "=> renegotiate" \
3789 -s "write hello request"
3790
Hanno Becker6a243642017-10-12 15:18:45 +01003791requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003792run_test "Renegotiation: DTLS, renego_period overflow" \
3793 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3794 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3795 0 \
3796 -c "client hello, adding renegotiation extension" \
3797 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3798 -s "found renegotiation extension" \
3799 -s "server hello, secure renegotiation extension" \
3800 -s "record counter limit reached: renegotiate" \
3801 -c "=> renegotiate" \
3802 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003803 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003804
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003805requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003806requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003807run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3808 "$G_SRV -u --mtu 4096" \
3809 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3810 0 \
3811 -c "client hello, adding renegotiation extension" \
3812 -c "found renegotiation extension" \
3813 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003814 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003815 -C "error" \
3816 -s "Extra-header:"
3817
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003818# Test for the "secure renegotation" extension only (no actual renegotiation)
3819
Paul Bakker539d9722015-02-08 16:18:35 +01003820requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003821run_test "Renego ext: gnutls server strict, client default" \
3822 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3823 "$P_CLI debug_level=3" \
3824 0 \
3825 -c "found renegotiation extension" \
3826 -C "error" \
3827 -c "HTTP/1.0 200 [Oo][Kk]"
3828
Paul Bakker539d9722015-02-08 16:18:35 +01003829requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003830run_test "Renego ext: gnutls server unsafe, client default" \
3831 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3832 "$P_CLI debug_level=3" \
3833 0 \
3834 -C "found renegotiation extension" \
3835 -C "error" \
3836 -c "HTTP/1.0 200 [Oo][Kk]"
3837
Paul Bakker539d9722015-02-08 16:18:35 +01003838requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003839run_test "Renego ext: gnutls server unsafe, client break legacy" \
3840 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3841 "$P_CLI debug_level=3 allow_legacy=-1" \
3842 1 \
3843 -C "found renegotiation extension" \
3844 -c "error" \
3845 -C "HTTP/1.0 200 [Oo][Kk]"
3846
Paul Bakker539d9722015-02-08 16:18:35 +01003847requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003848run_test "Renego ext: gnutls client strict, server default" \
3849 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003850 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003851 0 \
3852 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3853 -s "server hello, secure renegotiation extension"
3854
Paul Bakker539d9722015-02-08 16:18:35 +01003855requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003856run_test "Renego ext: gnutls client unsafe, server default" \
3857 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003858 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003859 0 \
3860 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3861 -S "server hello, secure renegotiation extension"
3862
Paul Bakker539d9722015-02-08 16:18:35 +01003863requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003864run_test "Renego ext: gnutls client unsafe, server break legacy" \
3865 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003866 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003867 1 \
3868 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3869 -S "server hello, secure renegotiation extension"
3870
Janos Follath0b242342016-02-17 10:11:21 +00003871# Tests for silently dropping trailing extra bytes in .der certificates
3872
3873requires_gnutls
3874run_test "DER format: no trailing bytes" \
3875 "$P_SRV crt_file=data_files/server5-der0.crt \
3876 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003877 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003878 0 \
3879 -c "Handshake was completed" \
3880
3881requires_gnutls
3882run_test "DER format: with a trailing zero byte" \
3883 "$P_SRV crt_file=data_files/server5-der1a.crt \
3884 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003885 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003886 0 \
3887 -c "Handshake was completed" \
3888
3889requires_gnutls
3890run_test "DER format: with a trailing random byte" \
3891 "$P_SRV crt_file=data_files/server5-der1b.crt \
3892 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003893 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003894 0 \
3895 -c "Handshake was completed" \
3896
3897requires_gnutls
3898run_test "DER format: with 2 trailing random bytes" \
3899 "$P_SRV crt_file=data_files/server5-der2.crt \
3900 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003901 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003902 0 \
3903 -c "Handshake was completed" \
3904
3905requires_gnutls
3906run_test "DER format: with 4 trailing random bytes" \
3907 "$P_SRV crt_file=data_files/server5-der4.crt \
3908 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003909 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003910 0 \
3911 -c "Handshake was completed" \
3912
3913requires_gnutls
3914run_test "DER format: with 8 trailing random bytes" \
3915 "$P_SRV crt_file=data_files/server5-der8.crt \
3916 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003917 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003918 0 \
3919 -c "Handshake was completed" \
3920
3921requires_gnutls
3922run_test "DER format: with 9 trailing random bytes" \
3923 "$P_SRV crt_file=data_files/server5-der9.crt \
3924 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003925 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003926 0 \
3927 -c "Handshake was completed" \
3928
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003929# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3930# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003931
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003932run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003933 "$P_SRV crt_file=data_files/server5-badsign.crt \
3934 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003935 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003936 1 \
3937 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003938 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003939 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003940 -c "X509 - Certificate verification failed"
3941
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003942run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003943 "$P_SRV crt_file=data_files/server5-badsign.crt \
3944 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003945 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003946 0 \
3947 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003948 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003949 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003950 -C "X509 - Certificate verification failed"
3951
Hanno Beckere6706e62017-05-15 16:05:15 +01003952run_test "Authentication: server goodcert, client optional, no trusted CA" \
3953 "$P_SRV" \
3954 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3955 0 \
3956 -c "x509_verify_cert() returned" \
3957 -c "! The certificate is not correctly signed by the trusted CA" \
3958 -c "! Certificate verification flags"\
3959 -C "! mbedtls_ssl_handshake returned" \
3960 -C "X509 - Certificate verification failed" \
3961 -C "SSL - No CA Chain is set, but required to operate"
3962
3963run_test "Authentication: server goodcert, client required, no trusted CA" \
3964 "$P_SRV" \
3965 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3966 1 \
3967 -c "x509_verify_cert() returned" \
3968 -c "! The certificate is not correctly signed by the trusted CA" \
3969 -c "! Certificate verification flags"\
3970 -c "! mbedtls_ssl_handshake returned" \
3971 -c "SSL - No CA Chain is set, but required to operate"
3972
3973# The purpose of the next two tests is to test the client's behaviour when receiving a server
3974# certificate with an unsupported elliptic curve. This should usually not happen because
3975# the client informs the server about the supported curves - it does, though, in the
3976# corner case of a static ECDH suite, because the server doesn't check the curve on that
3977# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3978# different means to have the server ignoring the client's supported curve list.
3979
3980requires_config_enabled MBEDTLS_ECP_C
3981run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3982 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3983 crt_file=data_files/server5.ku-ka.crt" \
3984 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3985 1 \
3986 -c "bad certificate (EC key curve)"\
3987 -c "! Certificate verification flags"\
3988 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3989
3990requires_config_enabled MBEDTLS_ECP_C
3991run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3992 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3993 crt_file=data_files/server5.ku-ka.crt" \
3994 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3995 1 \
3996 -c "bad certificate (EC key curve)"\
3997 -c "! Certificate verification flags"\
3998 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3999
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004000run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01004001 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004002 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004003 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004004 0 \
4005 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004006 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004007 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004008 -C "X509 - Certificate verification failed"
4009
Simon Butcher99000142016-10-13 17:21:01 +01004010run_test "Authentication: client SHA256, server required" \
4011 "$P_SRV auth_mode=required" \
4012 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4013 key_file=data_files/server6.key \
4014 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4015 0 \
4016 -c "Supported Signature Algorithm found: 4," \
4017 -c "Supported Signature Algorithm found: 5,"
4018
4019run_test "Authentication: client SHA384, server required" \
4020 "$P_SRV auth_mode=required" \
4021 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4022 key_file=data_files/server6.key \
4023 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4024 0 \
4025 -c "Supported Signature Algorithm found: 4," \
4026 -c "Supported Signature Algorithm found: 5,"
4027
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004028requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4029run_test "Authentication: client has no cert, server required (SSLv3)" \
4030 "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
4031 "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
4032 key_file=data_files/server5.key" \
4033 1 \
4034 -S "skip write certificate request" \
4035 -C "skip parse certificate request" \
4036 -c "got a certificate request" \
4037 -c "got no certificate to send" \
4038 -S "x509_verify_cert() returned" \
4039 -s "client has no certificate" \
4040 -s "! mbedtls_ssl_handshake returned" \
4041 -c "! mbedtls_ssl_handshake returned" \
4042 -s "No client certification received from the client, but required by the authentication mode"
4043
4044run_test "Authentication: client has no cert, server required (TLS)" \
4045 "$P_SRV debug_level=3 auth_mode=required" \
4046 "$P_CLI debug_level=3 crt_file=none \
4047 key_file=data_files/server5.key" \
4048 1 \
4049 -S "skip write certificate request" \
4050 -C "skip parse certificate request" \
4051 -c "got a certificate request" \
4052 -c "= write certificate$" \
4053 -C "skip write certificate$" \
4054 -S "x509_verify_cert() returned" \
4055 -s "client has no certificate" \
4056 -s "! mbedtls_ssl_handshake returned" \
4057 -c "! mbedtls_ssl_handshake returned" \
4058 -s "No client certification received from the client, but required by the authentication mode"
4059
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004060run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004061 "$P_SRV debug_level=3 auth_mode=required" \
4062 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004063 key_file=data_files/server5.key" \
4064 1 \
4065 -S "skip write certificate request" \
4066 -C "skip parse certificate request" \
4067 -c "got a certificate request" \
4068 -C "skip write certificate" \
4069 -C "skip write certificate verify" \
4070 -S "skip parse certificate verify" \
4071 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004072 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004073 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004074 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004075 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004076 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02004077# We don't check that the client receives the alert because it might
4078# detect that its write end of the connection is closed and abort
4079# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004080
Janos Follath89baba22017-04-10 14:34:35 +01004081run_test "Authentication: client cert not trusted, server required" \
4082 "$P_SRV debug_level=3 auth_mode=required" \
4083 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4084 key_file=data_files/server5.key" \
4085 1 \
4086 -S "skip write certificate request" \
4087 -C "skip parse certificate request" \
4088 -c "got a certificate request" \
4089 -C "skip write certificate" \
4090 -C "skip write certificate verify" \
4091 -S "skip parse certificate verify" \
4092 -s "x509_verify_cert() returned" \
4093 -s "! The certificate is not correctly signed by the trusted CA" \
4094 -s "! mbedtls_ssl_handshake returned" \
4095 -c "! mbedtls_ssl_handshake returned" \
4096 -s "X509 - Certificate verification failed"
4097
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004098run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004099 "$P_SRV debug_level=3 auth_mode=optional" \
4100 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004101 key_file=data_files/server5.key" \
4102 0 \
4103 -S "skip write certificate request" \
4104 -C "skip parse certificate request" \
4105 -c "got a certificate request" \
4106 -C "skip write certificate" \
4107 -C "skip write certificate verify" \
4108 -S "skip parse certificate verify" \
4109 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004110 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004111 -S "! mbedtls_ssl_handshake returned" \
4112 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004113 -S "X509 - Certificate verification failed"
4114
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004115run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004116 "$P_SRV debug_level=3 auth_mode=none" \
4117 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004118 key_file=data_files/server5.key" \
4119 0 \
4120 -s "skip write certificate request" \
4121 -C "skip parse certificate request" \
4122 -c "got no certificate request" \
4123 -c "skip write certificate" \
4124 -c "skip write certificate verify" \
4125 -s "skip parse certificate verify" \
4126 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004127 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004128 -S "! mbedtls_ssl_handshake returned" \
4129 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01004130 -S "X509 - Certificate verification failed"
4131
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004132run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004133 "$P_SRV debug_level=3 auth_mode=optional" \
4134 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004135 0 \
4136 -S "skip write certificate request" \
4137 -C "skip parse certificate request" \
4138 -c "got a certificate request" \
4139 -C "skip write certificate$" \
4140 -C "got no certificate to send" \
4141 -S "SSLv3 client has no certificate" \
4142 -c "skip write certificate verify" \
4143 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004144 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004145 -S "! mbedtls_ssl_handshake returned" \
4146 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004147 -S "X509 - Certificate verification failed"
4148
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004149run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004150 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004151 "$O_CLI" \
4152 0 \
4153 -S "skip write certificate request" \
4154 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004155 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004156 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004157 -S "X509 - Certificate verification failed"
4158
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004159run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004160 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004161 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004162 0 \
4163 -C "skip parse certificate request" \
4164 -c "got a certificate request" \
4165 -C "skip write certificate$" \
4166 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004167 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004168
Gilles Peskinefd8332e2017-05-03 16:25:07 +02004169run_test "Authentication: client no cert, openssl server required" \
4170 "$O_SRV -Verify 10" \
4171 "$P_CLI debug_level=3 crt_file=none key_file=none" \
4172 1 \
4173 -C "skip parse certificate request" \
4174 -c "got a certificate request" \
4175 -C "skip write certificate$" \
4176 -c "skip write certificate verify" \
4177 -c "! mbedtls_ssl_handshake returned"
4178
Janos Follathe2681a42016-03-07 15:57:05 +00004179requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004180run_test "Authentication: client no cert, ssl3" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004181 "$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01004182 "$P_CLI debug_level=3 crt_file=none key_file=none min_version=ssl3" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004183 0 \
4184 -S "skip write certificate request" \
4185 -C "skip parse certificate request" \
4186 -c "got a certificate request" \
4187 -C "skip write certificate$" \
4188 -c "skip write certificate verify" \
4189 -c "got no certificate to send" \
4190 -s "SSLv3 client has no certificate" \
4191 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01004192 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004193 -S "! mbedtls_ssl_handshake returned" \
4194 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01004195 -S "X509 - Certificate verification failed"
4196
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02004197# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
4198# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004199
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004200MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02004201MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004202
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004203if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Simon Butcher06b78632017-07-28 01:00:17 +01004204 printf "The ${CONFIG_H} file contains a value for the configuration of\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004205 printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004206 printf "test value of ${MAX_IM_CA}. \n"
4207 printf "\n"
Simon Butcherbcfa6f42017-07-28 15:59:35 +01004208 printf "The tests assume this value and if it changes, the tests in this\n"
4209 printf "script should also be adjusted.\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004210 printf "\n"
Simon Butcher06b78632017-07-28 01:00:17 +01004211
4212 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01004213fi
4214
Angus Grattonc4dd0732018-04-11 16:28:39 +10004215requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004216run_test "Authentication: server max_int chain, client default" \
4217 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4218 key_file=data_files/dir-maxpath/09.key" \
4219 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4220 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004221 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004222
Angus Grattonc4dd0732018-04-11 16:28:39 +10004223requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004224run_test "Authentication: server max_int+1 chain, client default" \
4225 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4226 key_file=data_files/dir-maxpath/10.key" \
4227 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4228 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004229 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004230
Angus Grattonc4dd0732018-04-11 16:28:39 +10004231requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004232run_test "Authentication: server max_int+1 chain, client optional" \
4233 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4234 key_file=data_files/dir-maxpath/10.key" \
4235 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4236 auth_mode=optional" \
4237 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004238 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004239
Angus Grattonc4dd0732018-04-11 16:28:39 +10004240requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004241run_test "Authentication: server max_int+1 chain, client none" \
4242 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4243 key_file=data_files/dir-maxpath/10.key" \
4244 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4245 auth_mode=none" \
4246 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004247 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004248
Angus Grattonc4dd0732018-04-11 16:28:39 +10004249requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004250run_test "Authentication: client max_int+1 chain, server default" \
4251 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4252 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4253 key_file=data_files/dir-maxpath/10.key" \
4254 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004255 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004256
Angus Grattonc4dd0732018-04-11 16:28:39 +10004257requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004258run_test "Authentication: client max_int+1 chain, server optional" \
4259 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4260 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4261 key_file=data_files/dir-maxpath/10.key" \
4262 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004263 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004264
Angus Grattonc4dd0732018-04-11 16:28:39 +10004265requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004266run_test "Authentication: client max_int+1 chain, server required" \
4267 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4268 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4269 key_file=data_files/dir-maxpath/10.key" \
4270 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004271 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004272
Angus Grattonc4dd0732018-04-11 16:28:39 +10004273requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004274run_test "Authentication: client max_int chain, server required" \
4275 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4276 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4277 key_file=data_files/dir-maxpath/09.key" \
4278 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004279 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004280
Janos Follath89baba22017-04-10 14:34:35 +01004281# Tests for CA list in CertificateRequest messages
4282
4283run_test "Authentication: send CA list in CertificateRequest (default)" \
4284 "$P_SRV debug_level=3 auth_mode=required" \
4285 "$P_CLI crt_file=data_files/server6.crt \
4286 key_file=data_files/server6.key" \
4287 0 \
4288 -s "requested DN"
4289
4290run_test "Authentication: do not send CA list in CertificateRequest" \
4291 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4292 "$P_CLI crt_file=data_files/server6.crt \
4293 key_file=data_files/server6.key" \
4294 0 \
4295 -S "requested DN"
4296
4297run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4298 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4299 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4300 key_file=data_files/server5.key" \
4301 1 \
4302 -S "requested DN" \
4303 -s "x509_verify_cert() returned" \
4304 -s "! The certificate is not correctly signed by the trusted CA" \
4305 -s "! mbedtls_ssl_handshake returned" \
4306 -c "! mbedtls_ssl_handshake returned" \
4307 -s "X509 - Certificate verification failed"
4308
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004309# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4310# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004311
4312requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4313run_test "Authentication, CA callback: server badcert, client required" \
4314 "$P_SRV crt_file=data_files/server5-badsign.crt \
4315 key_file=data_files/server5.key" \
4316 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4317 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004318 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004319 -c "x509_verify_cert() returned" \
4320 -c "! The certificate is not correctly signed by the trusted CA" \
4321 -c "! mbedtls_ssl_handshake returned" \
4322 -c "X509 - Certificate verification failed"
4323
4324requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4325run_test "Authentication, CA callback: server badcert, client optional" \
4326 "$P_SRV crt_file=data_files/server5-badsign.crt \
4327 key_file=data_files/server5.key" \
4328 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4329 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004330 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004331 -c "x509_verify_cert() returned" \
4332 -c "! The certificate is not correctly signed by the trusted CA" \
4333 -C "! mbedtls_ssl_handshake returned" \
4334 -C "X509 - Certificate verification failed"
4335
4336# The purpose of the next two tests is to test the client's behaviour when receiving a server
4337# certificate with an unsupported elliptic curve. This should usually not happen because
4338# the client informs the server about the supported curves - it does, though, in the
4339# corner case of a static ECDH suite, because the server doesn't check the curve on that
4340# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4341# different means to have the server ignoring the client's supported curve list.
4342
4343requires_config_enabled MBEDTLS_ECP_C
4344requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4345run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4346 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4347 crt_file=data_files/server5.ku-ka.crt" \
4348 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4349 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004350 -c "use CA callback for X.509 CRT verification" \
4351 -c "bad certificate (EC key curve)" \
4352 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004353 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4354
4355requires_config_enabled MBEDTLS_ECP_C
4356requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4357run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4358 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4359 crt_file=data_files/server5.ku-ka.crt" \
4360 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4361 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004362 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004363 -c "bad certificate (EC key curve)"\
4364 -c "! Certificate verification flags"\
4365 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4366
4367requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4368run_test "Authentication, CA callback: client SHA256, server required" \
4369 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4370 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4371 key_file=data_files/server6.key \
4372 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4373 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004374 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004375 -c "Supported Signature Algorithm found: 4," \
4376 -c "Supported Signature Algorithm found: 5,"
4377
4378requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4379run_test "Authentication, CA callback: client SHA384, server required" \
4380 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4381 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4382 key_file=data_files/server6.key \
4383 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4384 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004385 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004386 -c "Supported Signature Algorithm found: 4," \
4387 -c "Supported Signature Algorithm found: 5,"
4388
4389requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4390run_test "Authentication, CA callback: client badcert, server required" \
4391 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4392 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4393 key_file=data_files/server5.key" \
4394 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004395 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004396 -S "skip write certificate request" \
4397 -C "skip parse certificate request" \
4398 -c "got a certificate request" \
4399 -C "skip write certificate" \
4400 -C "skip write certificate verify" \
4401 -S "skip parse certificate verify" \
4402 -s "x509_verify_cert() returned" \
4403 -s "! The certificate is not correctly signed by the trusted CA" \
4404 -s "! mbedtls_ssl_handshake returned" \
4405 -s "send alert level=2 message=48" \
4406 -c "! mbedtls_ssl_handshake returned" \
4407 -s "X509 - Certificate verification failed"
4408# We don't check that the client receives the alert because it might
4409# detect that its write end of the connection is closed and abort
4410# before reading the alert message.
4411
4412requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4413run_test "Authentication, CA callback: client cert not trusted, server required" \
4414 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4415 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4416 key_file=data_files/server5.key" \
4417 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004418 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004419 -S "skip write certificate request" \
4420 -C "skip parse certificate request" \
4421 -c "got a certificate request" \
4422 -C "skip write certificate" \
4423 -C "skip write certificate verify" \
4424 -S "skip parse certificate verify" \
4425 -s "x509_verify_cert() returned" \
4426 -s "! The certificate is not correctly signed by the trusted CA" \
4427 -s "! mbedtls_ssl_handshake returned" \
4428 -c "! mbedtls_ssl_handshake returned" \
4429 -s "X509 - Certificate verification failed"
4430
4431requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4432run_test "Authentication, CA callback: client badcert, server optional" \
4433 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4434 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4435 key_file=data_files/server5.key" \
4436 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004437 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004438 -S "skip write certificate request" \
4439 -C "skip parse certificate request" \
4440 -c "got a certificate request" \
4441 -C "skip write certificate" \
4442 -C "skip write certificate verify" \
4443 -S "skip parse certificate verify" \
4444 -s "x509_verify_cert() returned" \
4445 -s "! The certificate is not correctly signed by the trusted CA" \
4446 -S "! mbedtls_ssl_handshake returned" \
4447 -C "! mbedtls_ssl_handshake returned" \
4448 -S "X509 - Certificate verification failed"
4449
4450requires_full_size_output_buffer
4451requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4452run_test "Authentication, CA callback: server max_int chain, client default" \
4453 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4454 key_file=data_files/dir-maxpath/09.key" \
4455 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4456 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004457 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004458 -C "X509 - A fatal error occurred"
4459
4460requires_full_size_output_buffer
4461requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4462run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4463 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4464 key_file=data_files/dir-maxpath/10.key" \
4465 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4466 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004467 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004468 -c "X509 - A fatal error occurred"
4469
4470requires_full_size_output_buffer
4471requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4472run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4473 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4474 key_file=data_files/dir-maxpath/10.key" \
4475 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4476 debug_level=3 auth_mode=optional" \
4477 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004478 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004479 -c "X509 - A fatal error occurred"
4480
4481requires_full_size_output_buffer
4482requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4483run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4484 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4485 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4486 key_file=data_files/dir-maxpath/10.key" \
4487 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004488 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004489 -s "X509 - A fatal error occurred"
4490
4491requires_full_size_output_buffer
4492requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4493run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4494 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4495 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4496 key_file=data_files/dir-maxpath/10.key" \
4497 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004498 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004499 -s "X509 - A fatal error occurred"
4500
4501requires_full_size_output_buffer
4502requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4503run_test "Authentication, CA callback: client max_int chain, server required" \
4504 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4505 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4506 key_file=data_files/dir-maxpath/09.key" \
4507 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004508 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004509 -S "X509 - A fatal error occurred"
4510
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004511# Tests for certificate selection based on SHA verson
4512
4513run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4514 "$P_SRV crt_file=data_files/server5.crt \
4515 key_file=data_files/server5.key \
4516 crt_file2=data_files/server5-sha1.crt \
4517 key_file2=data_files/server5.key" \
4518 "$P_CLI force_version=tls1_2" \
4519 0 \
4520 -c "signed using.*ECDSA with SHA256" \
4521 -C "signed using.*ECDSA with SHA1"
4522
4523run_test "Certificate hash: client TLS 1.1 -> SHA-1" \
4524 "$P_SRV crt_file=data_files/server5.crt \
4525 key_file=data_files/server5.key \
4526 crt_file2=data_files/server5-sha1.crt \
4527 key_file2=data_files/server5.key" \
4528 "$P_CLI force_version=tls1_1" \
4529 0 \
4530 -C "signed using.*ECDSA with SHA256" \
4531 -c "signed using.*ECDSA with SHA1"
4532
4533run_test "Certificate hash: client TLS 1.0 -> SHA-1" \
4534 "$P_SRV crt_file=data_files/server5.crt \
4535 key_file=data_files/server5.key \
4536 crt_file2=data_files/server5-sha1.crt \
4537 key_file2=data_files/server5.key" \
4538 "$P_CLI force_version=tls1" \
4539 0 \
4540 -C "signed using.*ECDSA with SHA256" \
4541 -c "signed using.*ECDSA with SHA1"
4542
4543run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 1)" \
4544 "$P_SRV crt_file=data_files/server5.crt \
4545 key_file=data_files/server5.key \
4546 crt_file2=data_files/server6.crt \
4547 key_file2=data_files/server6.key" \
4548 "$P_CLI force_version=tls1_1" \
4549 0 \
4550 -c "serial number.*09" \
4551 -c "signed using.*ECDSA with SHA256" \
4552 -C "signed using.*ECDSA with SHA1"
4553
4554run_test "Certificate hash: client TLS 1.1, no SHA-1 -> SHA-2 (order 2)" \
4555 "$P_SRV crt_file=data_files/server6.crt \
4556 key_file=data_files/server6.key \
4557 crt_file2=data_files/server5.crt \
4558 key_file2=data_files/server5.key" \
4559 "$P_CLI force_version=tls1_1" \
4560 0 \
4561 -c "serial number.*0A" \
4562 -c "signed using.*ECDSA with SHA256" \
4563 -C "signed using.*ECDSA with SHA1"
4564
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004565# tests for SNI
4566
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004567run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004568 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004569 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004570 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004571 0 \
4572 -S "parse ServerName extension" \
4573 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4574 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004575
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004576run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004577 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004578 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004579 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 +02004580 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004581 0 \
4582 -s "parse ServerName extension" \
4583 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4584 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004586run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004587 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004588 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004589 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 +02004590 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004591 0 \
4592 -s "parse ServerName extension" \
4593 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4594 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004595
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004596run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004597 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004598 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004599 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 +02004600 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004601 1 \
4602 -s "parse ServerName extension" \
4603 -s "ssl_sni_wrapper() returned" \
4604 -s "mbedtls_ssl_handshake returned" \
4605 -c "mbedtls_ssl_handshake returned" \
4606 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004607
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004608run_test "SNI: client auth no override: optional" \
4609 "$P_SRV debug_level=3 auth_mode=optional \
4610 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4611 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4612 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004613 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004614 -S "skip write certificate request" \
4615 -C "skip parse certificate request" \
4616 -c "got a certificate request" \
4617 -C "skip write certificate" \
4618 -C "skip write certificate verify" \
4619 -S "skip parse certificate verify"
4620
4621run_test "SNI: client auth override: none -> optional" \
4622 "$P_SRV debug_level=3 auth_mode=none \
4623 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4624 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4625 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004626 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004627 -S "skip write certificate request" \
4628 -C "skip parse certificate request" \
4629 -c "got a certificate request" \
4630 -C "skip write certificate" \
4631 -C "skip write certificate verify" \
4632 -S "skip parse certificate verify"
4633
4634run_test "SNI: client auth override: optional -> none" \
4635 "$P_SRV debug_level=3 auth_mode=optional \
4636 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4637 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4638 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004639 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004640 -s "skip write certificate request" \
4641 -C "skip parse certificate request" \
4642 -c "got no certificate request" \
4643 -c "skip write certificate" \
4644 -c "skip write certificate verify" \
4645 -s "skip parse certificate verify"
4646
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004647run_test "SNI: CA no override" \
4648 "$P_SRV debug_level=3 auth_mode=optional \
4649 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4650 ca_file=data_files/test-ca.crt \
4651 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4652 "$P_CLI debug_level=3 server_name=localhost \
4653 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4654 1 \
4655 -S "skip write certificate request" \
4656 -C "skip parse certificate request" \
4657 -c "got a certificate request" \
4658 -C "skip write certificate" \
4659 -C "skip write certificate verify" \
4660 -S "skip parse certificate verify" \
4661 -s "x509_verify_cert() returned" \
4662 -s "! The certificate is not correctly signed by the trusted CA" \
4663 -S "The certificate has been revoked (is on a CRL)"
4664
4665run_test "SNI: CA override" \
4666 "$P_SRV debug_level=3 auth_mode=optional \
4667 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4668 ca_file=data_files/test-ca.crt \
4669 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4670 "$P_CLI debug_level=3 server_name=localhost \
4671 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4672 0 \
4673 -S "skip write certificate request" \
4674 -C "skip parse certificate request" \
4675 -c "got a certificate request" \
4676 -C "skip write certificate" \
4677 -C "skip write certificate verify" \
4678 -S "skip parse certificate verify" \
4679 -S "x509_verify_cert() returned" \
4680 -S "! The certificate is not correctly signed by the trusted CA" \
4681 -S "The certificate has been revoked (is on a CRL)"
4682
4683run_test "SNI: CA override with CRL" \
4684 "$P_SRV debug_level=3 auth_mode=optional \
4685 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4686 ca_file=data_files/test-ca.crt \
4687 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4688 "$P_CLI debug_level=3 server_name=localhost \
4689 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4690 1 \
4691 -S "skip write certificate request" \
4692 -C "skip parse certificate request" \
4693 -c "got a certificate request" \
4694 -C "skip write certificate" \
4695 -C "skip write certificate verify" \
4696 -S "skip parse certificate verify" \
4697 -s "x509_verify_cert() returned" \
4698 -S "! The certificate is not correctly signed by the trusted CA" \
4699 -s "The certificate has been revoked (is on a CRL)"
4700
Andres AG1a834452016-12-07 10:01:30 +00004701# Tests for SNI and DTLS
4702
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004703run_test "SNI: DTLS, no SNI callback" \
4704 "$P_SRV debug_level=3 dtls=1 \
4705 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4706 "$P_CLI server_name=localhost dtls=1" \
4707 0 \
4708 -S "parse ServerName extension" \
4709 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4710 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4711
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004712run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004713 "$P_SRV debug_level=3 dtls=1 \
4714 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4715 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4716 "$P_CLI server_name=localhost dtls=1" \
4717 0 \
4718 -s "parse ServerName extension" \
4719 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4720 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4721
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004722run_test "SNI: DTLS, matching cert 2" \
4723 "$P_SRV debug_level=3 dtls=1 \
4724 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4725 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4726 "$P_CLI server_name=polarssl.example dtls=1" \
4727 0 \
4728 -s "parse ServerName extension" \
4729 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4730 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4731
4732run_test "SNI: DTLS, no matching cert" \
4733 "$P_SRV debug_level=3 dtls=1 \
4734 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4735 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4736 "$P_CLI server_name=nonesuch.example dtls=1" \
4737 1 \
4738 -s "parse ServerName extension" \
4739 -s "ssl_sni_wrapper() returned" \
4740 -s "mbedtls_ssl_handshake returned" \
4741 -c "mbedtls_ssl_handshake returned" \
4742 -c "SSL - A fatal alert message was received from our peer"
4743
4744run_test "SNI: DTLS, client auth no override: optional" \
4745 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4746 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4747 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4748 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4749 0 \
4750 -S "skip write certificate request" \
4751 -C "skip parse certificate request" \
4752 -c "got a certificate request" \
4753 -C "skip write certificate" \
4754 -C "skip write certificate verify" \
4755 -S "skip parse certificate verify"
4756
4757run_test "SNI: DTLS, client auth override: none -> optional" \
4758 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4759 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4760 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4761 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4762 0 \
4763 -S "skip write certificate request" \
4764 -C "skip parse certificate request" \
4765 -c "got a certificate request" \
4766 -C "skip write certificate" \
4767 -C "skip write certificate verify" \
4768 -S "skip parse certificate verify"
4769
4770run_test "SNI: DTLS, client auth override: optional -> none" \
4771 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4772 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4773 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4774 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4775 0 \
4776 -s "skip write certificate request" \
4777 -C "skip parse certificate request" \
4778 -c "got no certificate request" \
4779 -c "skip write certificate" \
4780 -c "skip write certificate verify" \
4781 -s "skip parse certificate verify"
4782
4783run_test "SNI: DTLS, CA no override" \
4784 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4785 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4786 ca_file=data_files/test-ca.crt \
4787 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4788 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4789 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4790 1 \
4791 -S "skip write certificate request" \
4792 -C "skip parse certificate request" \
4793 -c "got a certificate request" \
4794 -C "skip write certificate" \
4795 -C "skip write certificate verify" \
4796 -S "skip parse certificate verify" \
4797 -s "x509_verify_cert() returned" \
4798 -s "! The certificate is not correctly signed by the trusted CA" \
4799 -S "The certificate has been revoked (is on a CRL)"
4800
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004801run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004802 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4803 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4804 ca_file=data_files/test-ca.crt \
4805 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4806 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4807 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4808 0 \
4809 -S "skip write certificate request" \
4810 -C "skip parse certificate request" \
4811 -c "got a certificate request" \
4812 -C "skip write certificate" \
4813 -C "skip write certificate verify" \
4814 -S "skip parse certificate verify" \
4815 -S "x509_verify_cert() returned" \
4816 -S "! The certificate is not correctly signed by the trusted CA" \
4817 -S "The certificate has been revoked (is on a CRL)"
4818
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004819run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004820 "$P_SRV debug_level=3 auth_mode=optional \
4821 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4822 ca_file=data_files/test-ca.crt \
4823 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4824 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4825 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4826 1 \
4827 -S "skip write certificate request" \
4828 -C "skip parse certificate request" \
4829 -c "got a certificate request" \
4830 -C "skip write certificate" \
4831 -C "skip write certificate verify" \
4832 -S "skip parse certificate verify" \
4833 -s "x509_verify_cert() returned" \
4834 -S "! The certificate is not correctly signed by the trusted CA" \
4835 -s "The certificate has been revoked (is on a CRL)"
4836
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004837# Tests for non-blocking I/O: exercise a variety of handshake flows
4838
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004839run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004840 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4841 "$P_CLI nbio=2 tickets=0" \
4842 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004843 -S "mbedtls_ssl_handshake returned" \
4844 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004845 -c "Read from server: .* bytes read"
4846
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004847run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004848 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4849 "$P_CLI nbio=2 tickets=0" \
4850 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004851 -S "mbedtls_ssl_handshake returned" \
4852 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004853 -c "Read from server: .* bytes read"
4854
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004855run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004856 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4857 "$P_CLI nbio=2 tickets=1" \
4858 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004859 -S "mbedtls_ssl_handshake returned" \
4860 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004861 -c "Read from server: .* bytes read"
4862
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004863run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004864 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4865 "$P_CLI nbio=2 tickets=1" \
4866 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004867 -S "mbedtls_ssl_handshake returned" \
4868 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004869 -c "Read from server: .* bytes read"
4870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004871run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004872 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4873 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4874 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004875 -S "mbedtls_ssl_handshake returned" \
4876 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004877 -c "Read from server: .* bytes read"
4878
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004879run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004880 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4881 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4882 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004883 -S "mbedtls_ssl_handshake returned" \
4884 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004885 -c "Read from server: .* bytes read"
4886
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004887run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004888 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4889 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4890 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004891 -S "mbedtls_ssl_handshake returned" \
4892 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004893 -c "Read from server: .* bytes read"
4894
Hanno Becker00076712017-11-15 16:39:08 +00004895# Tests for event-driven I/O: exercise a variety of handshake flows
4896
4897run_test "Event-driven I/O: basic handshake" \
4898 "$P_SRV event=1 tickets=0 auth_mode=none" \
4899 "$P_CLI event=1 tickets=0" \
4900 0 \
4901 -S "mbedtls_ssl_handshake returned" \
4902 -C "mbedtls_ssl_handshake returned" \
4903 -c "Read from server: .* bytes read"
4904
4905run_test "Event-driven I/O: client auth" \
4906 "$P_SRV event=1 tickets=0 auth_mode=required" \
4907 "$P_CLI event=1 tickets=0" \
4908 0 \
4909 -S "mbedtls_ssl_handshake returned" \
4910 -C "mbedtls_ssl_handshake returned" \
4911 -c "Read from server: .* bytes read"
4912
4913run_test "Event-driven I/O: ticket" \
4914 "$P_SRV event=1 tickets=1 auth_mode=none" \
4915 "$P_CLI event=1 tickets=1" \
4916 0 \
4917 -S "mbedtls_ssl_handshake returned" \
4918 -C "mbedtls_ssl_handshake returned" \
4919 -c "Read from server: .* bytes read"
4920
4921run_test "Event-driven I/O: ticket + client auth" \
4922 "$P_SRV event=1 tickets=1 auth_mode=required" \
4923 "$P_CLI event=1 tickets=1" \
4924 0 \
4925 -S "mbedtls_ssl_handshake returned" \
4926 -C "mbedtls_ssl_handshake returned" \
4927 -c "Read from server: .* bytes read"
4928
4929run_test "Event-driven I/O: ticket + client auth + resume" \
4930 "$P_SRV event=1 tickets=1 auth_mode=required" \
4931 "$P_CLI event=1 tickets=1 reconnect=1" \
4932 0 \
4933 -S "mbedtls_ssl_handshake returned" \
4934 -C "mbedtls_ssl_handshake returned" \
4935 -c "Read from server: .* bytes read"
4936
4937run_test "Event-driven I/O: ticket + resume" \
4938 "$P_SRV event=1 tickets=1 auth_mode=none" \
4939 "$P_CLI event=1 tickets=1 reconnect=1" \
4940 0 \
4941 -S "mbedtls_ssl_handshake returned" \
4942 -C "mbedtls_ssl_handshake returned" \
4943 -c "Read from server: .* bytes read"
4944
4945run_test "Event-driven I/O: session-id resume" \
4946 "$P_SRV event=1 tickets=0 auth_mode=none" \
4947 "$P_CLI event=1 tickets=0 reconnect=1" \
4948 0 \
4949 -S "mbedtls_ssl_handshake returned" \
4950 -C "mbedtls_ssl_handshake returned" \
4951 -c "Read from server: .* bytes read"
4952
Hanno Becker6a33f592018-03-13 11:38:46 +00004953run_test "Event-driven I/O, DTLS: basic handshake" \
4954 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4955 "$P_CLI dtls=1 event=1 tickets=0" \
4956 0 \
4957 -c "Read from server: .* bytes read"
4958
4959run_test "Event-driven I/O, DTLS: client auth" \
4960 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4961 "$P_CLI dtls=1 event=1 tickets=0" \
4962 0 \
4963 -c "Read from server: .* bytes read"
4964
4965run_test "Event-driven I/O, DTLS: ticket" \
4966 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4967 "$P_CLI dtls=1 event=1 tickets=1" \
4968 0 \
4969 -c "Read from server: .* bytes read"
4970
4971run_test "Event-driven I/O, DTLS: ticket + client auth" \
4972 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4973 "$P_CLI dtls=1 event=1 tickets=1" \
4974 0 \
4975 -c "Read from server: .* bytes read"
4976
4977run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4978 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004979 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004980 0 \
4981 -c "Read from server: .* bytes read"
4982
4983run_test "Event-driven I/O, DTLS: ticket + resume" \
4984 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004985 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004986 0 \
4987 -c "Read from server: .* bytes read"
4988
4989run_test "Event-driven I/O, DTLS: session-id resume" \
4990 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004991 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004992 0 \
4993 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004994
4995# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4996# During session resumption, the client will send its ApplicationData record
4997# within the same datagram as the Finished messages. In this situation, the
4998# server MUST NOT idle on the underlying transport after handshake completion,
4999# because the ApplicationData request has already been queued internally.
5000run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00005001 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00005002 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01005003 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00005004 0 \
5005 -c "Read from server: .* bytes read"
5006
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005007# Tests for version negotiation
5008
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005009run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005010 "$P_SRV" \
5011 "$P_CLI" \
5012 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005013 -S "mbedtls_ssl_handshake returned" \
5014 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005015 -s "Protocol is TLSv1.2" \
5016 -c "Protocol is TLSv1.2"
5017
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005018run_test "Version check: cli max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005019 "$P_SRV" \
5020 "$P_CLI max_version=tls1_1" \
5021 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005022 -S "mbedtls_ssl_handshake returned" \
5023 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005024 -s "Protocol is TLSv1.1" \
5025 -c "Protocol is TLSv1.1"
5026
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005027run_test "Version check: srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005028 "$P_SRV max_version=tls1_1" \
5029 "$P_CLI" \
5030 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005031 -S "mbedtls_ssl_handshake returned" \
5032 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005033 -s "Protocol is TLSv1.1" \
5034 -c "Protocol is TLSv1.1"
5035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005036run_test "Version check: cli+srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005037 "$P_SRV max_version=tls1_1" \
5038 "$P_CLI max_version=tls1_1" \
5039 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005040 -S "mbedtls_ssl_handshake returned" \
5041 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005042 -s "Protocol is TLSv1.1" \
5043 -c "Protocol is TLSv1.1"
5044
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005045run_test "Version check: cli max 1.1, srv min 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005046 "$P_SRV min_version=tls1_1" \
5047 "$P_CLI max_version=tls1_1" \
5048 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005049 -S "mbedtls_ssl_handshake returned" \
5050 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005051 -s "Protocol is TLSv1.1" \
5052 -c "Protocol is TLSv1.1"
5053
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005054run_test "Version check: cli min 1.1, srv max 1.1 -> 1.1" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005055 "$P_SRV max_version=tls1_1" \
5056 "$P_CLI min_version=tls1_1" \
5057 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005058 -S "mbedtls_ssl_handshake returned" \
5059 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005060 -s "Protocol is TLSv1.1" \
5061 -c "Protocol is TLSv1.1"
5062
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005063run_test "Version check: cli min 1.2, srv max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005064 "$P_SRV max_version=tls1_1" \
5065 "$P_CLI min_version=tls1_2" \
5066 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005067 -s "mbedtls_ssl_handshake returned" \
5068 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005069 -c "SSL - Handshake protocol not within min/max boundaries"
5070
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005071run_test "Version check: srv min 1.2, cli max 1.1 -> fail" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005072 "$P_SRV min_version=tls1_2" \
5073 "$P_CLI max_version=tls1_1" \
5074 1 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005075 -s "mbedtls_ssl_handshake returned" \
5076 -c "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01005077 -s "SSL - Handshake protocol not within min/max boundaries"
5078
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005079# Tests for ALPN extension
5080
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005081run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005082 "$P_SRV debug_level=3" \
5083 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005084 0 \
5085 -C "client hello, adding alpn extension" \
5086 -S "found alpn extension" \
5087 -C "got an alert message, type: \\[2:120]" \
5088 -S "server hello, adding alpn extension" \
5089 -C "found alpn extension " \
5090 -C "Application Layer Protocol is" \
5091 -S "Application Layer Protocol is"
5092
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005093run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005094 "$P_SRV debug_level=3" \
5095 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005096 0 \
5097 -c "client hello, adding alpn extension" \
5098 -s "found alpn extension" \
5099 -C "got an alert message, type: \\[2:120]" \
5100 -S "server hello, adding alpn extension" \
5101 -C "found alpn extension " \
5102 -c "Application Layer Protocol is (none)" \
5103 -S "Application Layer Protocol is"
5104
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005105run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005106 "$P_SRV debug_level=3 alpn=abc,1234" \
5107 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005108 0 \
5109 -C "client hello, adding alpn extension" \
5110 -S "found alpn extension" \
5111 -C "got an alert message, type: \\[2:120]" \
5112 -S "server hello, adding alpn extension" \
5113 -C "found alpn extension " \
5114 -C "Application Layer Protocol is" \
5115 -s "Application Layer Protocol is (none)"
5116
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005117run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005118 "$P_SRV debug_level=3 alpn=abc,1234" \
5119 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005120 0 \
5121 -c "client hello, adding alpn extension" \
5122 -s "found alpn extension" \
5123 -C "got an alert message, type: \\[2:120]" \
5124 -s "server hello, adding alpn extension" \
5125 -c "found alpn extension" \
5126 -c "Application Layer Protocol is abc" \
5127 -s "Application Layer Protocol is abc"
5128
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005129run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005130 "$P_SRV debug_level=3 alpn=abc,1234" \
5131 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005132 0 \
5133 -c "client hello, adding alpn extension" \
5134 -s "found alpn extension" \
5135 -C "got an alert message, type: \\[2:120]" \
5136 -s "server hello, adding alpn extension" \
5137 -c "found alpn extension" \
5138 -c "Application Layer Protocol is abc" \
5139 -s "Application Layer Protocol is abc"
5140
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005141run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005142 "$P_SRV debug_level=3 alpn=abc,1234" \
5143 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005144 0 \
5145 -c "client hello, adding alpn extension" \
5146 -s "found alpn extension" \
5147 -C "got an alert message, type: \\[2:120]" \
5148 -s "server hello, adding alpn extension" \
5149 -c "found alpn extension" \
5150 -c "Application Layer Protocol is 1234" \
5151 -s "Application Layer Protocol is 1234"
5152
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005153run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005154 "$P_SRV debug_level=3 alpn=abc,123" \
5155 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02005156 1 \
5157 -c "client hello, adding alpn extension" \
5158 -s "found alpn extension" \
5159 -c "got an alert message, type: \\[2:120]" \
5160 -S "server hello, adding alpn extension" \
5161 -C "found alpn extension" \
5162 -C "Application Layer Protocol is 1234" \
5163 -S "Application Layer Protocol is 1234"
5164
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02005165
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005166# Tests for keyUsage in leaf certificates, part 1:
5167# server-side certificate/suite selection
5168
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005169run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005170 "$P_SRV key_file=data_files/server2.key \
5171 crt_file=data_files/server2.ku-ds.crt" \
5172 "$P_CLI" \
5173 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02005174 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005175
5176
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005177run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005178 "$P_SRV key_file=data_files/server2.key \
5179 crt_file=data_files/server2.ku-ke.crt" \
5180 "$P_CLI" \
5181 0 \
5182 -c "Ciphersuite is TLS-RSA-WITH-"
5183
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005184run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005185 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005186 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005187 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005188 1 \
5189 -C "Ciphersuite is "
5190
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005191run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005192 "$P_SRV key_file=data_files/server5.key \
5193 crt_file=data_files/server5.ku-ds.crt" \
5194 "$P_CLI" \
5195 0 \
5196 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
5197
5198
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005199run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005200 "$P_SRV key_file=data_files/server5.key \
5201 crt_file=data_files/server5.ku-ka.crt" \
5202 "$P_CLI" \
5203 0 \
5204 -c "Ciphersuite is TLS-ECDH-"
5205
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005206run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005207 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005208 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02005209 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005210 1 \
5211 -C "Ciphersuite is "
5212
5213# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005214# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005215
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005216run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005217 "$O_SRV -key data_files/server2.key \
5218 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005219 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005220 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5221 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005222 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005223 -C "Processing of the Certificate handshake message failed" \
5224 -c "Ciphersuite is TLS-"
5225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005226run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005227 "$O_SRV -key data_files/server2.key \
5228 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005229 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005230 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5231 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005232 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005233 -C "Processing of the Certificate handshake message failed" \
5234 -c "Ciphersuite is TLS-"
5235
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005236run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005237 "$O_SRV -key data_files/server2.key \
5238 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005239 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005240 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5241 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005242 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005243 -C "Processing of the Certificate handshake message failed" \
5244 -c "Ciphersuite is TLS-"
5245
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005246run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005247 "$O_SRV -key data_files/server2.key \
5248 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005249 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005250 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5251 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005252 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005253 -c "Processing of the Certificate handshake message failed" \
5254 -C "Ciphersuite is TLS-"
5255
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005256run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
5257 "$O_SRV -key data_files/server2.key \
5258 -cert data_files/server2.ku-ke.crt" \
5259 "$P_CLI debug_level=1 auth_mode=optional \
5260 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5261 0 \
5262 -c "bad certificate (usage extensions)" \
5263 -C "Processing of the Certificate handshake message failed" \
5264 -c "Ciphersuite is TLS-" \
5265 -c "! Usage does not match the keyUsage extension"
5266
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005267run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005268 "$O_SRV -key data_files/server2.key \
5269 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005270 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005271 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
5272 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005273 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005274 -C "Processing of the Certificate handshake message failed" \
5275 -c "Ciphersuite is TLS-"
5276
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005277run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005278 "$O_SRV -key data_files/server2.key \
5279 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005280 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005281 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5282 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005283 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02005284 -c "Processing of the Certificate handshake message failed" \
5285 -C "Ciphersuite is TLS-"
5286
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01005287run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
5288 "$O_SRV -key data_files/server2.key \
5289 -cert data_files/server2.ku-ds.crt" \
5290 "$P_CLI debug_level=1 auth_mode=optional \
5291 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
5292 0 \
5293 -c "bad certificate (usage extensions)" \
5294 -C "Processing of the Certificate handshake message failed" \
5295 -c "Ciphersuite is TLS-" \
5296 -c "! Usage does not match the keyUsage extension"
5297
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005298# Tests for keyUsage in leaf certificates, part 3:
5299# server-side checking of client cert
5300
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005301run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005302 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005303 "$O_CLI -key data_files/server2.key \
5304 -cert data_files/server2.ku-ds.crt" \
5305 0 \
5306 -S "bad certificate (usage extensions)" \
5307 -S "Processing of the Certificate handshake message failed"
5308
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005309run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005310 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005311 "$O_CLI -key data_files/server2.key \
5312 -cert data_files/server2.ku-ke.crt" \
5313 0 \
5314 -s "bad certificate (usage extensions)" \
5315 -S "Processing of the Certificate handshake message failed"
5316
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005317run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005318 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005319 "$O_CLI -key data_files/server2.key \
5320 -cert data_files/server2.ku-ke.crt" \
5321 1 \
5322 -s "bad certificate (usage extensions)" \
5323 -s "Processing of the Certificate handshake message failed"
5324
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005325run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005326 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005327 "$O_CLI -key data_files/server5.key \
5328 -cert data_files/server5.ku-ds.crt" \
5329 0 \
5330 -S "bad certificate (usage extensions)" \
5331 -S "Processing of the Certificate handshake message failed"
5332
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005333run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005334 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005335 "$O_CLI -key data_files/server5.key \
5336 -cert data_files/server5.ku-ka.crt" \
5337 0 \
5338 -s "bad certificate (usage extensions)" \
5339 -S "Processing of the Certificate handshake message failed"
5340
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005341# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5342
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005343run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005344 "$P_SRV key_file=data_files/server5.key \
5345 crt_file=data_files/server5.eku-srv.crt" \
5346 "$P_CLI" \
5347 0
5348
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005349run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005350 "$P_SRV key_file=data_files/server5.key \
5351 crt_file=data_files/server5.eku-srv.crt" \
5352 "$P_CLI" \
5353 0
5354
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005355run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005356 "$P_SRV key_file=data_files/server5.key \
5357 crt_file=data_files/server5.eku-cs_any.crt" \
5358 "$P_CLI" \
5359 0
5360
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005361run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005362 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005363 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005364 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005365 1
5366
5367# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5368
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005369run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005370 "$O_SRV -key data_files/server5.key \
5371 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005372 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005373 0 \
5374 -C "bad certificate (usage extensions)" \
5375 -C "Processing of the Certificate handshake message failed" \
5376 -c "Ciphersuite is TLS-"
5377
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005378run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005379 "$O_SRV -key data_files/server5.key \
5380 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005381 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005382 0 \
5383 -C "bad certificate (usage extensions)" \
5384 -C "Processing of the Certificate handshake message failed" \
5385 -c "Ciphersuite is TLS-"
5386
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005387run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005388 "$O_SRV -key data_files/server5.key \
5389 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005390 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005391 0 \
5392 -C "bad certificate (usage extensions)" \
5393 -C "Processing of the Certificate handshake message failed" \
5394 -c "Ciphersuite is TLS-"
5395
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005396run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005397 "$O_SRV -key data_files/server5.key \
5398 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005399 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005400 1 \
5401 -c "bad certificate (usage extensions)" \
5402 -c "Processing of the Certificate handshake message failed" \
5403 -C "Ciphersuite is TLS-"
5404
5405# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5406
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005407run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005408 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005409 "$O_CLI -key data_files/server5.key \
5410 -cert data_files/server5.eku-cli.crt" \
5411 0 \
5412 -S "bad certificate (usage extensions)" \
5413 -S "Processing of the Certificate handshake message failed"
5414
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005415run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005416 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005417 "$O_CLI -key data_files/server5.key \
5418 -cert data_files/server5.eku-srv_cli.crt" \
5419 0 \
5420 -S "bad certificate (usage extensions)" \
5421 -S "Processing of the Certificate handshake message failed"
5422
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005423run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005424 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005425 "$O_CLI -key data_files/server5.key \
5426 -cert data_files/server5.eku-cs_any.crt" \
5427 0 \
5428 -S "bad certificate (usage extensions)" \
5429 -S "Processing of the Certificate handshake message failed"
5430
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005431run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005432 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005433 "$O_CLI -key data_files/server5.key \
5434 -cert data_files/server5.eku-cs.crt" \
5435 0 \
5436 -s "bad certificate (usage extensions)" \
5437 -S "Processing of the Certificate handshake message failed"
5438
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005439run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005440 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005441 "$O_CLI -key data_files/server5.key \
5442 -cert data_files/server5.eku-cs.crt" \
5443 1 \
5444 -s "bad certificate (usage extensions)" \
5445 -s "Processing of the Certificate handshake message failed"
5446
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005447# Tests for DHM parameters loading
5448
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005449run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005450 "$P_SRV" \
5451 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5452 debug_level=3" \
5453 0 \
5454 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005455 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005456
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005457run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005458 "$P_SRV dhm_file=data_files/dhparams.pem" \
5459 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5460 debug_level=3" \
5461 0 \
5462 -c "value of 'DHM: P ' (1024 bits)" \
5463 -c "value of 'DHM: G ' (2 bits)"
5464
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005465# Tests for DHM client-side size checking
5466
5467run_test "DHM size: server default, client default, OK" \
5468 "$P_SRV" \
5469 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5470 debug_level=1" \
5471 0 \
5472 -C "DHM prime too short:"
5473
5474run_test "DHM size: server default, client 2048, OK" \
5475 "$P_SRV" \
5476 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5477 debug_level=1 dhmlen=2048" \
5478 0 \
5479 -C "DHM prime too short:"
5480
5481run_test "DHM size: server 1024, client default, OK" \
5482 "$P_SRV dhm_file=data_files/dhparams.pem" \
5483 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5484 debug_level=1" \
5485 0 \
5486 -C "DHM prime too short:"
5487
5488run_test "DHM size: server 1000, client default, rejected" \
5489 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5490 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5491 debug_level=1" \
5492 1 \
5493 -c "DHM prime too short:"
5494
5495run_test "DHM size: server default, client 2049, rejected" \
5496 "$P_SRV" \
5497 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5498 debug_level=1 dhmlen=2049" \
5499 1 \
5500 -c "DHM prime too short:"
5501
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005502# Tests for PSK callback
5503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005504run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005505 "$P_SRV psk=abc123 psk_identity=foo" \
5506 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5507 psk_identity=foo psk=abc123" \
5508 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005509 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005510 -S "SSL - Unknown identity received" \
5511 -S "SSL - Verification of the message MAC failed"
5512
Hanno Beckerf7027512018-10-23 15:27:39 +01005513requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5514run_test "PSK callback: opaque psk on client, no callback" \
5515 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5516 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005517 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005518 0 \
5519 -c "skip PMS generation for opaque PSK"\
5520 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005521 -C "session hash for extended master secret"\
5522 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005523 -S "SSL - None of the common ciphersuites is usable" \
5524 -S "SSL - Unknown identity received" \
5525 -S "SSL - Verification of the message MAC failed"
5526
5527requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5528run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5529 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5530 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005531 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005532 0 \
5533 -c "skip PMS generation for opaque PSK"\
5534 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005535 -C "session hash for extended master secret"\
5536 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005537 -S "SSL - None of the common ciphersuites is usable" \
5538 -S "SSL - Unknown identity received" \
5539 -S "SSL - Verification of the message MAC failed"
5540
5541requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5542run_test "PSK callback: opaque psk on client, no callback, EMS" \
5543 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5544 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005545 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005546 0 \
5547 -c "skip PMS generation for opaque PSK"\
5548 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005549 -c "session hash for extended master secret"\
5550 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005551 -S "SSL - None of the common ciphersuites is usable" \
5552 -S "SSL - Unknown identity received" \
5553 -S "SSL - Verification of the message MAC failed"
5554
5555requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5556run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5557 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5558 "$P_CLI extended_ms=1 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005559 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005560 0 \
5561 -c "skip PMS generation for opaque PSK"\
5562 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005563 -c "session hash for extended master secret"\
5564 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005565 -S "SSL - None of the common ciphersuites is usable" \
5566 -S "SSL - Unknown identity received" \
5567 -S "SSL - Verification of the message MAC failed"
5568
Hanno Becker28c79dc2018-10-26 13:15:08 +01005569requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5570run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005571 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005572 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5573 psk_identity=foo psk=abc123" \
5574 0 \
5575 -C "skip PMS generation for opaque PSK"\
5576 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005577 -C "session hash for extended master secret"\
5578 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005579 -S "SSL - None of the common ciphersuites is usable" \
5580 -S "SSL - Unknown identity received" \
5581 -S "SSL - Verification of the message MAC failed"
5582
5583requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5584run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005585 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005586 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5587 psk_identity=foo psk=abc123" \
5588 0 \
5589 -C "skip PMS generation for opaque PSK"\
5590 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005591 -C "session hash for extended master secret"\
5592 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005593 -S "SSL - None of the common ciphersuites is usable" \
5594 -S "SSL - Unknown identity received" \
5595 -S "SSL - Verification of the message MAC failed"
5596
5597requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5598run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005599 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005600 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5601 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5602 psk_identity=foo psk=abc123 extended_ms=1" \
5603 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005604 -c "session hash for extended master secret"\
5605 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005606 -C "skip PMS generation for opaque PSK"\
5607 -s "skip PMS generation for opaque PSK"\
5608 -S "SSL - None of the common ciphersuites is usable" \
5609 -S "SSL - Unknown identity received" \
5610 -S "SSL - Verification of the message MAC failed"
5611
5612requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5613run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005614 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005615 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5616 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5617 psk_identity=foo psk=abc123 extended_ms=1" \
5618 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005619 -c "session hash for extended master secret"\
5620 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005621 -C "skip PMS generation for opaque PSK"\
5622 -s "skip PMS generation for opaque PSK"\
5623 -S "SSL - None of the common ciphersuites is usable" \
5624 -S "SSL - Unknown identity received" \
5625 -S "SSL - Verification of the message MAC failed"
5626
5627requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5628run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005629 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005630 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5631 psk_identity=def psk=beef" \
5632 0 \
5633 -C "skip PMS generation for opaque PSK"\
5634 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005635 -C "session hash for extended master secret"\
5636 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005637 -S "SSL - None of the common ciphersuites is usable" \
5638 -S "SSL - Unknown identity received" \
5639 -S "SSL - Verification of the message MAC failed"
5640
5641requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5642run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005643 "$P_SRV extended_ms=0 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005644 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5645 psk_identity=def psk=beef" \
5646 0 \
5647 -C "skip PMS generation for opaque PSK"\
5648 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005649 -C "session hash for extended master secret"\
5650 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005651 -S "SSL - None of the common ciphersuites is usable" \
5652 -S "SSL - Unknown identity received" \
5653 -S "SSL - Verification of the message MAC failed"
5654
5655requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5656run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005657 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005658 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5659 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5660 psk_identity=abc psk=dead extended_ms=1" \
5661 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005662 -c "session hash for extended master secret"\
5663 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005664 -C "skip PMS generation for opaque PSK"\
5665 -s "skip PMS generation for opaque PSK"\
5666 -S "SSL - None of the common ciphersuites is usable" \
5667 -S "SSL - Unknown identity received" \
5668 -S "SSL - Verification of the message MAC failed"
5669
5670requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5671run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005672 "$P_SRV debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005673 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5674 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5675 psk_identity=abc psk=dead extended_ms=1" \
5676 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005677 -c "session hash for extended master secret"\
5678 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005679 -C "skip PMS generation for opaque PSK"\
5680 -s "skip PMS generation for opaque PSK"\
5681 -S "SSL - None of the common ciphersuites is usable" \
5682 -S "SSL - Unknown identity received" \
5683 -S "SSL - Verification of the message MAC failed"
5684
5685requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5686run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005687 "$P_SRV extended_ms=0 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005688 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5689 psk_identity=def psk=beef" \
5690 0 \
5691 -C "skip PMS generation for opaque PSK"\
5692 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005693 -C "session hash for extended master secret"\
5694 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005695 -S "SSL - None of the common ciphersuites is usable" \
5696 -S "SSL - Unknown identity received" \
5697 -S "SSL - Verification of the message MAC failed"
5698
5699requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5700run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005701 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef psk_list_opaque=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005702 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5703 psk_identity=def psk=beef" \
5704 0 \
5705 -C "skip PMS generation for opaque PSK"\
5706 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005707 -C "session hash for extended master secret"\
5708 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005709 -S "SSL - None of the common ciphersuites is usable" \
5710 -S "SSL - Unknown identity received" \
5711 -S "SSL - Verification of the message MAC failed"
5712
5713requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5714run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005715 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=foo psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005716 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5717 psk_identity=def psk=beef" \
5718 0 \
5719 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005720 -C "session hash for extended master secret"\
5721 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005722 -S "SSL - None of the common ciphersuites is usable" \
5723 -S "SSL - Unknown identity received" \
5724 -S "SSL - Verification of the message MAC failed"
5725
5726requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5727run_test "PSK callback: raw psk on client, id-matching but wrong raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005728 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=abc123 debug_level=3 psk_list=abc,dead,def,beef min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005729 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5730 psk_identity=def psk=beef" \
5731 0 \
5732 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005733 -C "session hash for extended master secret"\
5734 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005735 -S "SSL - None of the common ciphersuites is usable" \
5736 -S "SSL - Unknown identity received" \
5737 -S "SSL - Verification of the message MAC failed"
5738
5739requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5740run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005741 "$P_SRV extended_ms=0 psk_opaque=1 psk_identity=def psk=beef debug_level=3 psk_list=abc,dead,def,abc123 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA" \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005742 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5743 psk_identity=def psk=beef" \
5744 1 \
5745 -s "SSL - Verification of the message MAC failed"
5746
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005747run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005748 "$P_SRV" \
5749 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5750 psk_identity=foo psk=abc123" \
5751 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005752 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005753 -S "SSL - Unknown identity received" \
5754 -S "SSL - Verification of the message MAC failed"
5755
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005756run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005757 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5758 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5759 psk_identity=foo psk=abc123" \
5760 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005761 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005762 -s "SSL - Unknown identity received" \
5763 -S "SSL - Verification of the message MAC failed"
5764
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005765run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005766 "$P_SRV psk_list=abc,dead,def,beef" \
5767 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5768 psk_identity=abc psk=dead" \
5769 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005770 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005771 -S "SSL - Unknown identity received" \
5772 -S "SSL - Verification of the message MAC failed"
5773
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005774run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005775 "$P_SRV psk_list=abc,dead,def,beef" \
5776 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5777 psk_identity=def psk=beef" \
5778 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005779 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005780 -S "SSL - Unknown identity received" \
5781 -S "SSL - Verification of the message MAC failed"
5782
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005783run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005784 "$P_SRV psk_list=abc,dead,def,beef" \
5785 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5786 psk_identity=ghi psk=beef" \
5787 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005788 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005789 -s "SSL - Unknown identity received" \
5790 -S "SSL - Verification of the message MAC failed"
5791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005792run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005793 "$P_SRV psk_list=abc,dead,def,beef" \
5794 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5795 psk_identity=abc psk=beef" \
5796 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005797 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005798 -S "SSL - Unknown identity received" \
5799 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005800
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005801# Tests for EC J-PAKE
5802
Hanno Beckerfa452c42020-08-14 15:42:49 +01005803requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005804run_test "ECJPAKE: client not configured" \
5805 "$P_SRV debug_level=3" \
5806 "$P_CLI debug_level=3" \
5807 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005808 -C "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005809 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005810 -S "found ecjpake kkpp extension" \
5811 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005812 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005813 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005814 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005815 -S "None of the common ciphersuites is usable"
5816
Hanno Beckerfa452c42020-08-14 15:42:49 +01005817requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005818run_test "ECJPAKE: server not configured" \
5819 "$P_SRV debug_level=3" \
5820 "$P_CLI debug_level=3 ecjpake_pw=bla \
5821 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5822 1 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005823 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005824 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005825 -s "found ecjpake kkpp extension" \
5826 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005827 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005828 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005829 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005830 -s "None of the common ciphersuites is usable"
5831
Hanno Beckerfa452c42020-08-14 15:42:49 +01005832requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005833run_test "ECJPAKE: working, TLS" \
5834 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5835 "$P_CLI debug_level=3 ecjpake_pw=bla \
5836 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005837 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005838 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005839 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005840 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005841 -s "found ecjpake kkpp extension" \
5842 -S "skip ecjpake kkpp extension" \
5843 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005844 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005845 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005846 -S "None of the common ciphersuites is usable" \
5847 -S "SSL - Verification of the message MAC failed"
5848
Janos Follath74537a62016-09-02 13:45:28 +01005849server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005850requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005851run_test "ECJPAKE: password mismatch, TLS" \
5852 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5853 "$P_CLI debug_level=3 ecjpake_pw=bad \
5854 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5855 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005856 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005857 -s "SSL - Verification of the message MAC failed"
5858
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005859requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005860run_test "ECJPAKE: working, DTLS" \
5861 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5862 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5863 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5864 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005865 -c "re-using cached ecjpake parameters" \
5866 -S "SSL - Verification of the message MAC failed"
5867
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005868requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005869run_test "ECJPAKE: working, DTLS, no cookie" \
5870 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5871 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5872 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5873 0 \
5874 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005875 -S "SSL - Verification of the message MAC failed"
5876
Janos Follath74537a62016-09-02 13:45:28 +01005877server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005878requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005879run_test "ECJPAKE: password mismatch, DTLS" \
5880 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5881 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5882 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5883 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005884 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005885 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005886
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005887# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005888requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005889run_test "ECJPAKE: working, DTLS, nolog" \
5890 "$P_SRV dtls=1 ecjpake_pw=bla" \
5891 "$P_CLI dtls=1 ecjpake_pw=bla \
5892 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5893 0
5894
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005895# Tests for ciphersuites per version
5896
Janos Follathe2681a42016-03-07 15:57:05 +00005897requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005898requires_config_enabled MBEDTLS_CAMELLIA_C
5899requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005900run_test "Per-version suites: SSL3" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005901 "$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 +02005902 "$P_CLI force_version=ssl3" \
5903 0 \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005904 -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005905
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005906requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
5907requires_config_enabled MBEDTLS_CAMELLIA_C
5908requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005909run_test "Per-version suites: TLS 1.0" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005910 "$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 +01005911 "$P_CLI force_version=tls1 arc4=1" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005912 0 \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005913 -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005914
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005915requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
5916requires_config_enabled MBEDTLS_CAMELLIA_C
5917requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005918run_test "Per-version suites: TLS 1.1" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005919 "$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 +02005920 "$P_CLI force_version=tls1_1" \
5921 0 \
5922 -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
5923
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005924requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5925requires_config_enabled MBEDTLS_CAMELLIA_C
5926requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005927run_test "Per-version suites: TLS 1.2" \
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005928 "$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 +02005929 "$P_CLI force_version=tls1_2" \
5930 0 \
5931 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5932
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005933# Test for ClientHello without extensions
5934
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005935requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005936run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005937 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005938 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005939 0 \
5940 -s "dumping 'client hello extensions' (0 bytes)"
5941
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005942# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005943
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005944run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005945 "$P_SRV" \
5946 "$P_CLI request_size=100" \
5947 0 \
5948 -s "Read from client: 100 bytes read$"
5949
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005950run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005951 "$P_SRV" \
5952 "$P_CLI request_size=500" \
5953 0 \
5954 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005955
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005956# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005957
Janos Follathe2681a42016-03-07 15:57:05 +00005958requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005959run_test "Small client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01005960 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005961 "$P_CLI request_size=1 force_version=ssl3 \
5962 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5963 0 \
5964 -s "Read from client: 1 bytes read"
5965
Janos Follathe2681a42016-03-07 15:57:05 +00005966requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005967run_test "Small client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01005968 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005969 "$P_CLI request_size=1 force_version=ssl3 \
5970 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
5971 0 \
5972 -s "Read from client: 1 bytes read"
5973
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005974run_test "Small client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005975 "$P_SRV" \
5976 "$P_CLI request_size=1 force_version=tls1 \
5977 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5978 0 \
5979 -s "Read from client: 1 bytes read"
5980
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005981run_test "Small client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005982 "$P_SRV" \
5983 "$P_CLI request_size=1 force_version=tls1 etm=0 \
5984 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5985 0 \
5986 -s "Read from client: 1 bytes read"
5987
Hanno Becker32c55012017-11-10 08:42:54 +00005988requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005989run_test "Small client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005990 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005991 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005992 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005993 0 \
5994 -s "Read from client: 1 bytes read"
5995
Hanno Becker32c55012017-11-10 08:42:54 +00005996requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005997run_test "Small client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005998 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005999 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006000 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006001 0 \
6002 -s "Read from client: 1 bytes read"
6003
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006004run_test "Small client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006005 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006006 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker8501f982017-11-10 08:59:04 +00006007 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6008 0 \
6009 -s "Read from client: 1 bytes read"
6010
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006011run_test "Small client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00006012 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6013 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006014 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006015 0 \
6016 -s "Read from client: 1 bytes read"
6017
6018requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006019run_test "Small client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006020 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006021 "$P_CLI request_size=1 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006022 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006023 0 \
6024 -s "Read from client: 1 bytes read"
6025
Hanno Becker8501f982017-11-10 08:59:04 +00006026requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006027run_test "Small client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006028 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6029 "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6030 trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006031 0 \
6032 -s "Read from client: 1 bytes read"
6033
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006034run_test "Small client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006035 "$P_SRV" \
6036 "$P_CLI request_size=1 force_version=tls1_1 \
6037 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6038 0 \
6039 -s "Read from client: 1 bytes read"
6040
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006041run_test "Small client packet TLS 1.1 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006042 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00006043 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006044 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006045 0 \
6046 -s "Read from client: 1 bytes read"
6047
6048requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006049run_test "Small client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006050 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006051 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006052 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006053 0 \
6054 -s "Read from client: 1 bytes read"
6055
6056requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006057run_test "Small client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006058 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006059 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006060 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006061 0 \
6062 -s "Read from client: 1 bytes read"
6063
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006064run_test "Small client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006065 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006066 "$P_CLI request_size=1 force_version=tls1_1 \
6067 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6068 0 \
6069 -s "Read from client: 1 bytes read"
6070
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006071run_test "Small client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker8501f982017-11-10 08:59:04 +00006072 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006073 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006074 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006075 0 \
6076 -s "Read from client: 1 bytes read"
6077
Hanno Becker8501f982017-11-10 08:59:04 +00006078requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006079run_test "Small client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006080 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006081 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006082 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006083 0 \
6084 -s "Read from client: 1 bytes read"
6085
Hanno Becker32c55012017-11-10 08:42:54 +00006086requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006087run_test "Small client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006088 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006089 "$P_CLI request_size=1 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006090 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006091 0 \
6092 -s "Read from client: 1 bytes read"
6093
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006094run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006095 "$P_SRV" \
6096 "$P_CLI request_size=1 force_version=tls1_2 \
6097 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6098 0 \
6099 -s "Read from client: 1 bytes read"
6100
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006101run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006102 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00006103 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006104 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01006105 0 \
6106 -s "Read from client: 1 bytes read"
6107
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006108run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006109 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006110 "$P_CLI request_size=1 force_version=tls1_2 \
6111 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006112 0 \
6113 -s "Read from client: 1 bytes read"
6114
Hanno Becker32c55012017-11-10 08:42:54 +00006115requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006116run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006117 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006118 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006119 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006120 0 \
6121 -s "Read from client: 1 bytes read"
6122
Hanno Becker8501f982017-11-10 08:59:04 +00006123requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006124run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006125 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006126 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006127 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006128 0 \
6129 -s "Read from client: 1 bytes read"
6130
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006131run_test "Small client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006132 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006133 "$P_CLI request_size=1 force_version=tls1_2 \
6134 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6135 0 \
6136 -s "Read from client: 1 bytes read"
6137
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006138run_test "Small client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006139 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006140 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006141 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker8501f982017-11-10 08:59:04 +00006142 0 \
6143 -s "Read from client: 1 bytes read"
6144
Hanno Becker32c55012017-11-10 08:42:54 +00006145requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006146run_test "Small client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006147 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006148 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006149 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006150 0 \
6151 -s "Read from client: 1 bytes read"
6152
Hanno Becker8501f982017-11-10 08:59:04 +00006153requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006154run_test "Small client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006155 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00006156 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006157 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006158 0 \
6159 -s "Read from client: 1 bytes read"
6160
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006161run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006162 "$P_SRV" \
6163 "$P_CLI request_size=1 force_version=tls1_2 \
6164 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6165 0 \
6166 -s "Read from client: 1 bytes read"
6167
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006168run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02006169 "$P_SRV" \
6170 "$P_CLI request_size=1 force_version=tls1_2 \
6171 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6172 0 \
6173 -s "Read from client: 1 bytes read"
6174
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006175# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00006176
6177requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006178run_test "Small client packet DTLS 1.0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006179 "$P_SRV dtls=1 force_version=dtls1" \
6180 "$P_CLI dtls=1 request_size=1 \
6181 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6182 0 \
6183 -s "Read from client: 1 bytes read"
6184
6185requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006186run_test "Small client packet DTLS 1.0, without EtM" \
Hanno Beckere2148042017-11-10 08:59:18 +00006187 "$P_SRV dtls=1 force_version=dtls1 etm=0" \
6188 "$P_CLI dtls=1 request_size=1 \
6189 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6190 0 \
6191 -s "Read from client: 1 bytes read"
6192
6193requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6194requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006195run_test "Small client packet DTLS 1.0, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006196 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
6197 "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
Hanno Beckere2148042017-11-10 08:59:18 +00006198 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6199 0 \
6200 -s "Read from client: 1 bytes read"
6201
6202requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6203requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006204run_test "Small client packet DTLS 1.0, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006205 "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006206 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006207 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006208 0 \
6209 -s "Read from client: 1 bytes read"
6210
6211requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006212run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00006213 "$P_SRV dtls=1 force_version=dtls1_2" \
6214 "$P_CLI dtls=1 request_size=1 \
6215 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6216 0 \
6217 -s "Read from client: 1 bytes read"
6218
6219requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006220run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006221 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006222 "$P_CLI dtls=1 request_size=1 \
6223 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6224 0 \
6225 -s "Read from client: 1 bytes read"
6226
6227requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6228requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006229run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006230 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006231 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006232 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00006233 0 \
6234 -s "Read from client: 1 bytes read"
6235
6236requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6237requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006238run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006239 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00006240 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006241 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00006242 0 \
6243 -s "Read from client: 1 bytes read"
6244
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006245# Tests for small server packets
6246
6247requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6248run_test "Small server packet SSLv3 BlockCipher" \
6249 "$P_SRV response_size=1 min_version=ssl3" \
6250 "$P_CLI force_version=ssl3 \
6251 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6252 0 \
6253 -c "Read from server: 1 bytes read"
6254
6255requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6256run_test "Small server packet SSLv3 StreamCipher" \
6257 "$P_SRV response_size=1 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6258 "$P_CLI force_version=ssl3 \
6259 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6260 0 \
6261 -c "Read from server: 1 bytes read"
6262
6263run_test "Small server packet TLS 1.0 BlockCipher" \
6264 "$P_SRV response_size=1" \
6265 "$P_CLI force_version=tls1 \
6266 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6267 0 \
6268 -c "Read from server: 1 bytes read"
6269
6270run_test "Small server packet TLS 1.0 BlockCipher, without EtM" \
6271 "$P_SRV response_size=1" \
6272 "$P_CLI force_version=tls1 etm=0 \
6273 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6274 0 \
6275 -c "Read from server: 1 bytes read"
6276
6277requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6278run_test "Small server packet TLS 1.0 BlockCipher, truncated MAC" \
6279 "$P_SRV response_size=1 trunc_hmac=1" \
6280 "$P_CLI force_version=tls1 \
6281 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6282 0 \
6283 -c "Read from server: 1 bytes read"
6284
6285requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6286run_test "Small server packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
6287 "$P_SRV response_size=1 trunc_hmac=1" \
6288 "$P_CLI force_version=tls1 \
6289 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6290 0 \
6291 -c "Read from server: 1 bytes read"
6292
6293run_test "Small server packet TLS 1.0 StreamCipher" \
6294 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6295 "$P_CLI force_version=tls1 \
6296 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6297 0 \
6298 -c "Read from server: 1 bytes read"
6299
6300run_test "Small server packet TLS 1.0 StreamCipher, without EtM" \
6301 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6302 "$P_CLI force_version=tls1 \
6303 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6304 0 \
6305 -c "Read from server: 1 bytes read"
6306
6307requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6308run_test "Small server packet TLS 1.0 StreamCipher, truncated MAC" \
6309 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6310 "$P_CLI force_version=tls1 \
6311 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6312 0 \
6313 -c "Read from server: 1 bytes read"
6314
6315requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6316run_test "Small server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6317 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6318 "$P_CLI force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6319 trunc_hmac=1 etm=0" \
6320 0 \
6321 -c "Read from server: 1 bytes read"
6322
6323run_test "Small server packet TLS 1.1 BlockCipher" \
6324 "$P_SRV response_size=1" \
6325 "$P_CLI force_version=tls1_1 \
6326 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6327 0 \
6328 -c "Read from server: 1 bytes read"
6329
6330run_test "Small server packet TLS 1.1 BlockCipher, without EtM" \
6331 "$P_SRV response_size=1" \
6332 "$P_CLI force_version=tls1_1 \
6333 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6334 0 \
6335 -c "Read from server: 1 bytes read"
6336
6337requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6338run_test "Small server packet TLS 1.1 BlockCipher, truncated MAC" \
6339 "$P_SRV response_size=1 trunc_hmac=1" \
6340 "$P_CLI force_version=tls1_1 \
6341 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6342 0 \
6343 -c "Read from server: 1 bytes read"
6344
6345requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6346run_test "Small server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6347 "$P_SRV response_size=1 trunc_hmac=1" \
6348 "$P_CLI force_version=tls1_1 \
6349 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6350 0 \
6351 -c "Read from server: 1 bytes read"
6352
6353run_test "Small server packet TLS 1.1 StreamCipher" \
6354 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6355 "$P_CLI force_version=tls1_1 \
6356 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6357 0 \
6358 -c "Read from server: 1 bytes read"
6359
6360run_test "Small server packet TLS 1.1 StreamCipher, without EtM" \
6361 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6362 "$P_CLI force_version=tls1_1 \
6363 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6364 0 \
6365 -c "Read from server: 1 bytes read"
6366
6367requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6368run_test "Small server packet TLS 1.1 StreamCipher, truncated MAC" \
6369 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6370 "$P_CLI force_version=tls1_1 \
6371 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6372 0 \
6373 -c "Read from server: 1 bytes read"
6374
6375requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6376run_test "Small server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6377 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6378 "$P_CLI force_version=tls1_1 \
6379 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6380 0 \
6381 -c "Read from server: 1 bytes read"
6382
6383run_test "Small server packet TLS 1.2 BlockCipher" \
6384 "$P_SRV response_size=1" \
6385 "$P_CLI force_version=tls1_2 \
6386 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6387 0 \
6388 -c "Read from server: 1 bytes read"
6389
6390run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
6391 "$P_SRV response_size=1" \
6392 "$P_CLI force_version=tls1_2 \
6393 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
6394 0 \
6395 -c "Read from server: 1 bytes read"
6396
6397run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
6398 "$P_SRV response_size=1" \
6399 "$P_CLI force_version=tls1_2 \
6400 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6401 0 \
6402 -c "Read from server: 1 bytes read"
6403
6404requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6405run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
6406 "$P_SRV response_size=1 trunc_hmac=1" \
6407 "$P_CLI force_version=tls1_2 \
6408 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6409 0 \
6410 -c "Read from server: 1 bytes read"
6411
6412requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6413run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6414 "$P_SRV response_size=1 trunc_hmac=1" \
6415 "$P_CLI force_version=tls1_2 \
6416 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6417 0 \
6418 -c "Read from server: 1 bytes read"
6419
6420run_test "Small server packet TLS 1.2 StreamCipher" \
6421 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6422 "$P_CLI force_version=tls1_2 \
6423 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6424 0 \
6425 -c "Read from server: 1 bytes read"
6426
6427run_test "Small server packet TLS 1.2 StreamCipher, without EtM" \
6428 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6429 "$P_CLI force_version=tls1_2 \
6430 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6431 0 \
6432 -c "Read from server: 1 bytes read"
6433
6434requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6435run_test "Small server packet TLS 1.2 StreamCipher, truncated MAC" \
6436 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6437 "$P_CLI force_version=tls1_2 \
6438 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6439 0 \
6440 -c "Read from server: 1 bytes read"
6441
6442requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6443run_test "Small server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
6444 "$P_SRV response_size=1 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6445 "$P_CLI force_version=tls1_2 \
6446 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6447 0 \
6448 -c "Read from server: 1 bytes read"
6449
6450run_test "Small server packet TLS 1.2 AEAD" \
6451 "$P_SRV response_size=1" \
6452 "$P_CLI force_version=tls1_2 \
6453 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6454 0 \
6455 -c "Read from server: 1 bytes read"
6456
6457run_test "Small server packet TLS 1.2 AEAD shorter tag" \
6458 "$P_SRV response_size=1" \
6459 "$P_CLI force_version=tls1_2 \
6460 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6461 0 \
6462 -c "Read from server: 1 bytes read"
6463
6464# Tests for small server packets in DTLS
6465
6466requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6467run_test "Small server packet DTLS 1.0" \
6468 "$P_SRV dtls=1 response_size=1 force_version=dtls1" \
6469 "$P_CLI dtls=1 \
6470 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6471 0 \
6472 -c "Read from server: 1 bytes read"
6473
6474requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6475run_test "Small server packet DTLS 1.0, without EtM" \
6476 "$P_SRV dtls=1 response_size=1 force_version=dtls1 etm=0" \
6477 "$P_CLI dtls=1 \
6478 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6479 0 \
6480 -c "Read from server: 1 bytes read"
6481
6482requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6483requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6484run_test "Small server packet DTLS 1.0, truncated hmac" \
6485 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1" \
6486 "$P_CLI dtls=1 trunc_hmac=1 \
6487 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6488 0 \
6489 -c "Read from server: 1 bytes read"
6490
6491requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6492requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6493run_test "Small server packet DTLS 1.0, without EtM, truncated MAC" \
6494 "$P_SRV dtls=1 response_size=1 force_version=dtls1 trunc_hmac=1 etm=0" \
6495 "$P_CLI dtls=1 \
6496 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6497 0 \
6498 -c "Read from server: 1 bytes read"
6499
6500requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6501run_test "Small server packet DTLS 1.2" \
6502 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
6503 "$P_CLI dtls=1 \
6504 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6505 0 \
6506 -c "Read from server: 1 bytes read"
6507
6508requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6509run_test "Small server packet DTLS 1.2, without EtM" \
6510 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
6511 "$P_CLI dtls=1 \
6512 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6513 0 \
6514 -c "Read from server: 1 bytes read"
6515
6516requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6517requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6518run_test "Small server packet DTLS 1.2, truncated hmac" \
6519 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
6520 "$P_CLI dtls=1 \
6521 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
6522 0 \
6523 -c "Read from server: 1 bytes read"
6524
6525requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6526requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6527run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
6528 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
6529 "$P_CLI dtls=1 \
6530 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
6531 0 \
6532 -c "Read from server: 1 bytes read"
6533
Janos Follath00efff72016-05-06 13:48:23 +01006534# A test for extensions in SSLv3
6535
6536requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6537run_test "SSLv3 with extensions, server side" \
6538 "$P_SRV min_version=ssl3 debug_level=3" \
6539 "$P_CLI force_version=ssl3 tickets=1 max_frag_len=4096 alpn=abc,1234" \
6540 0 \
6541 -S "dumping 'client hello extensions'" \
6542 -S "server hello, total extension length:"
6543
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006544# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006545
Angus Grattonc4dd0732018-04-11 16:28:39 +10006546# How many fragments do we expect to write $1 bytes?
6547fragments_for_write() {
6548 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
6549}
6550
Janos Follathe2681a42016-03-07 15:57:05 +00006551requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006552run_test "Large client packet SSLv3 BlockCipher" \
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +01006553 "$P_SRV min_version=ssl3" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006554 "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006555 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6556 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006557 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6558 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006559
Janos Follathe2681a42016-03-07 15:57:05 +00006560requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006561run_test "Large client packet SSLv3 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006562 "$P_SRV min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006563 "$P_CLI request_size=16384 force_version=ssl3 \
6564 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6565 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006566 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6567 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006568
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006569run_test "Large client packet TLS 1.0 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006570 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006571 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006572 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6573 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006574 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6575 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006576
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006577run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006578 "$P_SRV" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006579 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
6580 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6581 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006582 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006583
Hanno Becker32c55012017-11-10 08:42:54 +00006584requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006585run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006586 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006587 "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006588 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006589 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006590 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6591 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006592
Hanno Becker32c55012017-11-10 08:42:54 +00006593requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006594run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006595 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006596 "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006597 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006598 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006599 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006600
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006601run_test "Large client packet TLS 1.0 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006602 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006603 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006604 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6605 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006606 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006607
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006608run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006609 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6610 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006611 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006612 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006613 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006614
6615requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006616run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006617 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006618 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006619 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006620 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006621 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006622
Hanno Becker278fc7a2017-11-10 09:16:28 +00006623requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006624run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006625 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006626 "$P_CLI request_size=16384 force_version=tls1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006627 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006628 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006629 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6630 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006631
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006632run_test "Large client packet TLS 1.1 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006633 "$P_SRV" \
6634 "$P_CLI request_size=16384 force_version=tls1_1 \
6635 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6636 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006637 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6638 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006639
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006640run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006641 "$P_SRV" \
6642 "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
6643 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006644 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006645 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006646
Hanno Becker32c55012017-11-10 08:42:54 +00006647requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006648run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006649 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006650 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006651 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006652 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006653 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006654
Hanno Becker32c55012017-11-10 08:42:54 +00006655requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006656run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006657 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006658 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006659 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006660 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006661 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006662
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006663run_test "Large client packet TLS 1.1 StreamCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006664 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6665 "$P_CLI request_size=16384 force_version=tls1_1 \
6666 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6667 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006668 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6669 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006670
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006671run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006672 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006673 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006674 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006675 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006676 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6677 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006678
Hanno Becker278fc7a2017-11-10 09:16:28 +00006679requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006680run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006681 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006682 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006683 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006684 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006685 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006686
Hanno Becker278fc7a2017-11-10 09:16:28 +00006687requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006688run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006689 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006690 "$P_CLI request_size=16384 force_version=tls1_1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006691 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006692 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006693 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6694 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006695
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006696run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006697 "$P_SRV" \
6698 "$P_CLI request_size=16384 force_version=tls1_2 \
6699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6700 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006701 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6702 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006703
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006704run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006705 "$P_SRV" \
6706 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
6707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6708 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006709 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006710
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006711run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006712 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01006713 "$P_CLI request_size=16384 force_version=tls1_2 \
6714 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006715 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006716 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6717 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006718
Hanno Becker32c55012017-11-10 08:42:54 +00006719requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006720run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006721 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006722 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006723 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006724 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006725 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006726
Hanno Becker278fc7a2017-11-10 09:16:28 +00006727requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006728run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006729 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006730 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006731 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006732 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006733 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6734 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006735
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006736run_test "Large client packet TLS 1.2 StreamCipher" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006737 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006738 "$P_CLI request_size=16384 force_version=tls1_2 \
6739 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6740 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006741 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6742 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006743
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006744run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \
Manuel Pégourié-Gonnardea0920f2015-03-24 09:50:15 +01006745 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006746 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006747 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6748 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006749 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00006750
Hanno Becker32c55012017-11-10 08:42:54 +00006751requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006752run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006753 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006754 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006755 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006756 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006757 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006758
Hanno Becker278fc7a2017-11-10 09:16:28 +00006759requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006760run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00006761 "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00006762 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00006763 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006764 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006765 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6766 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006767
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006768run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006769 "$P_SRV" \
6770 "$P_CLI request_size=16384 force_version=tls1_2 \
6771 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
6772 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006773 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6774 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006775
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006776run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006777 "$P_SRV" \
6778 "$P_CLI request_size=16384 force_version=tls1_2 \
6779 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
6780 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10006781 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
6782 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02006783
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006784# Test for large server packets
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006785requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6786run_test "Large server packet SSLv3 StreamCipher" \
6787 "$P_SRV response_size=16384 min_version=ssl3 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6788 "$P_CLI force_version=ssl3 \
6789 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6790 0 \
6791 -c "Read from server: 16384 bytes read"
6792
Andrzej Kurek6a4f2242018-08-27 08:00:13 -04006793# Checking next 4 tests logs for 1n-1 split against BEAST too
6794requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
6795run_test "Large server packet SSLv3 BlockCipher" \
6796 "$P_SRV response_size=16384 min_version=ssl3" \
6797 "$P_CLI force_version=ssl3 recsplit=0 \
6798 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6799 0 \
6800 -c "Read from server: 1 bytes read"\
6801 -c "16383 bytes read"\
6802 -C "Read from server: 16384 bytes read"
6803
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006804run_test "Large server packet TLS 1.0 BlockCipher" \
6805 "$P_SRV response_size=16384" \
6806 "$P_CLI force_version=tls1 recsplit=0 \
6807 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6808 0 \
6809 -c "Read from server: 1 bytes read"\
6810 -c "16383 bytes read"\
6811 -C "Read from server: 16384 bytes read"
6812
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006813run_test "Large server packet TLS 1.0 BlockCipher, without EtM" \
6814 "$P_SRV response_size=16384" \
6815 "$P_CLI force_version=tls1 etm=0 recsplit=0 \
6816 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6817 0 \
6818 -c "Read from server: 1 bytes read"\
6819 -c "16383 bytes read"\
6820 -C "Read from server: 16384 bytes read"
6821
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006822requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6823run_test "Large server packet TLS 1.0 BlockCipher truncated MAC" \
6824 "$P_SRV response_size=16384" \
6825 "$P_CLI force_version=tls1 recsplit=0 \
6826 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6827 trunc_hmac=1" \
6828 0 \
6829 -c "Read from server: 1 bytes read"\
6830 -c "16383 bytes read"\
6831 -C "Read from server: 16384 bytes read"
6832
6833requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6834run_test "Large server packet TLS 1.0 StreamCipher truncated MAC" \
6835 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6836 "$P_CLI force_version=tls1 \
6837 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6838 trunc_hmac=1" \
6839 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006840 -s "16384 bytes written in 1 fragments" \
6841 -c "Read from server: 16384 bytes read"
6842
6843run_test "Large server packet TLS 1.0 StreamCipher" \
6844 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6845 "$P_CLI force_version=tls1 \
6846 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6847 0 \
6848 -s "16384 bytes written in 1 fragments" \
6849 -c "Read from server: 16384 bytes read"
6850
6851run_test "Large server packet TLS 1.0 StreamCipher, without EtM" \
6852 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6853 "$P_CLI force_version=tls1 \
6854 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6855 0 \
6856 -s "16384 bytes written in 1 fragments" \
6857 -c "Read from server: 16384 bytes read"
6858
6859requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6860run_test "Large server packet TLS 1.0 StreamCipher, truncated MAC" \
6861 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6862 "$P_CLI force_version=tls1 \
6863 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6864 0 \
6865 -s "16384 bytes written in 1 fragments" \
6866 -c "Read from server: 16384 bytes read"
6867
6868requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6869run_test "Large server packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
6870 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6871 "$P_CLI force_version=tls1 \
6872 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6873 0 \
6874 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006875 -c "Read from server: 16384 bytes read"
6876
6877run_test "Large server packet TLS 1.1 BlockCipher" \
6878 "$P_SRV response_size=16384" \
6879 "$P_CLI force_version=tls1_1 \
6880 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6881 0 \
6882 -c "Read from server: 16384 bytes read"
6883
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006884run_test "Large server packet TLS 1.1 BlockCipher, without EtM" \
6885 "$P_SRV response_size=16384" \
6886 "$P_CLI force_version=tls1_1 etm=0 \
6887 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006888 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006889 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006890 -c "Read from server: 16384 bytes read"
6891
6892requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6893run_test "Large server packet TLS 1.1 BlockCipher truncated MAC" \
6894 "$P_SRV response_size=16384" \
6895 "$P_CLI force_version=tls1_1 \
6896 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6897 trunc_hmac=1" \
6898 0 \
6899 -c "Read from server: 16384 bytes read"
6900
6901requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006902run_test "Large server packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
6903 "$P_SRV response_size=16384 trunc_hmac=1" \
6904 "$P_CLI force_version=tls1_1 \
6905 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6906 0 \
6907 -s "16384 bytes written in 1 fragments" \
6908 -c "Read from server: 16384 bytes read"
6909
6910run_test "Large server packet TLS 1.1 StreamCipher" \
6911 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6912 "$P_CLI force_version=tls1_1 \
6913 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6914 0 \
6915 -c "Read from server: 16384 bytes read"
6916
6917run_test "Large server packet TLS 1.1 StreamCipher, without EtM" \
6918 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6919 "$P_CLI force_version=tls1_1 \
6920 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6921 0 \
6922 -s "16384 bytes written in 1 fragments" \
6923 -c "Read from server: 16384 bytes read"
6924
6925requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006926run_test "Large server packet TLS 1.1 StreamCipher truncated MAC" \
6927 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6928 "$P_CLI force_version=tls1_1 \
6929 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
6930 trunc_hmac=1" \
6931 0 \
6932 -c "Read from server: 16384 bytes read"
6933
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006934run_test "Large server packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
6935 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
6936 "$P_CLI force_version=tls1_1 \
6937 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
6938 0 \
6939 -s "16384 bytes written in 1 fragments" \
6940 -c "Read from server: 16384 bytes read"
6941
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006942run_test "Large server packet TLS 1.2 BlockCipher" \
6943 "$P_SRV response_size=16384" \
6944 "$P_CLI force_version=tls1_2 \
6945 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6946 0 \
6947 -c "Read from server: 16384 bytes read"
6948
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006949run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
6950 "$P_SRV response_size=16384" \
6951 "$P_CLI force_version=tls1_2 etm=0 \
6952 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
6953 0 \
6954 -s "16384 bytes written in 1 fragments" \
6955 -c "Read from server: 16384 bytes read"
6956
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006957run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
6958 "$P_SRV response_size=16384" \
6959 "$P_CLI force_version=tls1_2 \
6960 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
6961 0 \
6962 -c "Read from server: 16384 bytes read"
6963
6964requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6965run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
6966 "$P_SRV response_size=16384" \
6967 "$P_CLI force_version=tls1_2 \
6968 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
6969 trunc_hmac=1" \
6970 0 \
6971 -c "Read from server: 16384 bytes read"
6972
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006973run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
6974 "$P_SRV response_size=16384 trunc_hmac=1" \
6975 "$P_CLI force_version=tls1_2 \
6976 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
6977 0 \
6978 -s "16384 bytes written in 1 fragments" \
6979 -c "Read from server: 16384 bytes read"
6980
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006981run_test "Large server packet TLS 1.2 StreamCipher" \
6982 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6983 "$P_CLI force_version=tls1_2 \
6984 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6985 0 \
Andrzej Kurekc19fc552018-06-19 09:37:30 -04006986 -s "16384 bytes written in 1 fragments" \
6987 -c "Read from server: 16384 bytes read"
6988
6989run_test "Large server packet TLS 1.2 StreamCipher, without EtM" \
6990 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
6991 "$P_CLI force_version=tls1_2 \
6992 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
6993 0 \
6994 -s "16384 bytes written in 1 fragments" \
Andrzej Kurek30e731d2017-10-12 13:50:29 +02006995 -c "Read from server: 16384 bytes read"
6996
6997requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
6998run_test "Large server packet TLS 1.2 StreamCipher truncated MAC" \
6999 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
7000 "$P_CLI force_version=tls1_2 \
7001 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
7002 trunc_hmac=1" \
7003 0 \
7004 -c "Read from server: 16384 bytes read"
7005
Andrzej Kurekc19fc552018-06-19 09:37:30 -04007006requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
7007run_test "Large server packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
7008 "$P_SRV response_size=16384 arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
7009 "$P_CLI force_version=tls1_2 \
7010 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
7011 0 \
7012 -s "16384 bytes written in 1 fragments" \
7013 -c "Read from server: 16384 bytes read"
7014
Andrzej Kurek30e731d2017-10-12 13:50:29 +02007015run_test "Large server packet TLS 1.2 AEAD" \
7016 "$P_SRV response_size=16384" \
7017 "$P_CLI force_version=tls1_2 \
7018 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
7019 0 \
7020 -c "Read from server: 16384 bytes read"
7021
7022run_test "Large server packet TLS 1.2 AEAD shorter tag" \
7023 "$P_SRV response_size=16384" \
7024 "$P_CLI force_version=tls1_2 \
7025 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
7026 0 \
7027 -c "Read from server: 16384 bytes read"
7028
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007029# Tests for restartable ECC
7030
7031requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7032run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007033 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007034 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007035 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007036 debug_level=1" \
7037 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007038 -C "x509_verify_cert.*4b00" \
7039 -C "mbedtls_pk_verify.*4b00" \
7040 -C "mbedtls_ecdh_make_public.*4b00" \
7041 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007042
7043requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7044run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007045 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007046 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007047 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007048 debug_level=1 ec_max_ops=0" \
7049 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007050 -C "x509_verify_cert.*4b00" \
7051 -C "mbedtls_pk_verify.*4b00" \
7052 -C "mbedtls_ecdh_make_public.*4b00" \
7053 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007054
7055requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7056run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007057 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007058 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007059 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007060 debug_level=1 ec_max_ops=65535" \
7061 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007062 -C "x509_verify_cert.*4b00" \
7063 -C "mbedtls_pk_verify.*4b00" \
7064 -C "mbedtls_ecdh_make_public.*4b00" \
7065 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007066
7067requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7068run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007069 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007070 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007071 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007072 debug_level=1 ec_max_ops=1000" \
7073 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007074 -c "x509_verify_cert.*4b00" \
7075 -c "mbedtls_pk_verify.*4b00" \
7076 -c "mbedtls_ecdh_make_public.*4b00" \
7077 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007078
7079requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007080run_test "EC restart: TLS, max_ops=1000, badsign" \
7081 "$P_SRV auth_mode=required \
7082 crt_file=data_files/server5-badsign.crt \
7083 key_file=data_files/server5.key" \
7084 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7085 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7086 debug_level=1 ec_max_ops=1000" \
7087 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007088 -c "x509_verify_cert.*4b00" \
7089 -C "mbedtls_pk_verify.*4b00" \
7090 -C "mbedtls_ecdh_make_public.*4b00" \
7091 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007092 -c "! The certificate is not correctly signed by the trusted CA" \
7093 -c "! mbedtls_ssl_handshake returned" \
7094 -c "X509 - Certificate verification failed"
7095
7096requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7097run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
7098 "$P_SRV auth_mode=required \
7099 crt_file=data_files/server5-badsign.crt \
7100 key_file=data_files/server5.key" \
7101 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7102 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7103 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
7104 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007105 -c "x509_verify_cert.*4b00" \
7106 -c "mbedtls_pk_verify.*4b00" \
7107 -c "mbedtls_ecdh_make_public.*4b00" \
7108 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007109 -c "! The certificate is not correctly signed by the trusted CA" \
7110 -C "! mbedtls_ssl_handshake returned" \
7111 -C "X509 - Certificate verification failed"
7112
7113requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7114run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
7115 "$P_SRV auth_mode=required \
7116 crt_file=data_files/server5-badsign.crt \
7117 key_file=data_files/server5.key" \
7118 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7119 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7120 debug_level=1 ec_max_ops=1000 auth_mode=none" \
7121 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007122 -C "x509_verify_cert.*4b00" \
7123 -c "mbedtls_pk_verify.*4b00" \
7124 -c "mbedtls_ecdh_make_public.*4b00" \
7125 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02007126 -C "! The certificate is not correctly signed by the trusted CA" \
7127 -C "! mbedtls_ssl_handshake returned" \
7128 -C "X509 - Certificate verification failed"
7129
7130requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007131run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007132 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007133 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02007134 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007135 dtls=1 debug_level=1 ec_max_ops=1000" \
7136 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007137 -c "x509_verify_cert.*4b00" \
7138 -c "mbedtls_pk_verify.*4b00" \
7139 -c "mbedtls_ecdh_make_public.*4b00" \
7140 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02007141
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007142requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7143run_test "EC restart: TLS, max_ops=1000 no client auth" \
7144 "$P_SRV" \
7145 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7146 debug_level=1 ec_max_ops=1000" \
7147 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007148 -c "x509_verify_cert.*4b00" \
7149 -c "mbedtls_pk_verify.*4b00" \
7150 -c "mbedtls_ecdh_make_public.*4b00" \
7151 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007152
7153requires_config_enabled MBEDTLS_ECP_RESTARTABLE
7154run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
7155 "$P_SRV psk=abc123" \
7156 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
7157 psk=abc123 debug_level=1 ec_max_ops=1000" \
7158 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02007159 -C "x509_verify_cert.*4b00" \
7160 -C "mbedtls_pk_verify.*4b00" \
7161 -C "mbedtls_ecdh_make_public.*4b00" \
7162 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02007163
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007164# Tests of asynchronous private key support in SSL
7165
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007166requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007167run_test "SSL async private: sign, delay=0" \
7168 "$P_SRV \
7169 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007170 "$P_CLI" \
7171 0 \
7172 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007173 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007174
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007175requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007176run_test "SSL async private: sign, delay=1" \
7177 "$P_SRV \
7178 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007179 "$P_CLI" \
7180 0 \
7181 -s "Async sign callback: using key slot " \
7182 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007183 -s "Async resume (slot [0-9]): sign done, status=0"
7184
Gilles Peskine12d0cc12018-04-26 15:06:56 +02007185requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7186run_test "SSL async private: sign, delay=2" \
7187 "$P_SRV \
7188 async_operations=s async_private_delay1=2 async_private_delay2=2" \
7189 "$P_CLI" \
7190 0 \
7191 -s "Async sign callback: using key slot " \
7192 -U "Async sign callback: using key slot " \
7193 -s "Async resume (slot [0-9]): call 1 more times." \
7194 -s "Async resume (slot [0-9]): call 0 more times." \
7195 -s "Async resume (slot [0-9]): sign done, status=0"
7196
Gilles Peskined3268832018-04-26 06:23:59 +02007197# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1
7198# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1.
7199requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7200requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
7201run_test "SSL async private: sign, RSA, TLS 1.1" \
7202 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \
7203 async_operations=s async_private_delay1=0 async_private_delay2=0" \
7204 "$P_CLI force_version=tls1_1" \
7205 0 \
7206 -s "Async sign callback: using key slot " \
7207 -s "Async resume (slot [0-9]): sign done, status=0"
7208
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007209requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine807d74a2018-04-30 10:30:49 +02007210run_test "SSL async private: sign, SNI" \
7211 "$P_SRV debug_level=3 \
7212 async_operations=s async_private_delay1=0 async_private_delay2=0 \
7213 crt_file=data_files/server5.crt key_file=data_files/server5.key \
7214 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
7215 "$P_CLI server_name=polarssl.example" \
7216 0 \
7217 -s "Async sign callback: using key slot " \
7218 -s "Async resume (slot [0-9]): sign done, status=0" \
7219 -s "parse ServerName extension" \
7220 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
7221 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
7222
7223requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007224run_test "SSL async private: decrypt, delay=0" \
7225 "$P_SRV \
7226 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7227 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7228 0 \
7229 -s "Async decrypt callback: using key slot " \
7230 -s "Async resume (slot [0-9]): decrypt done, status=0"
7231
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007232requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007233run_test "SSL async private: decrypt, delay=1" \
7234 "$P_SRV \
7235 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7236 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7237 0 \
7238 -s "Async decrypt callback: using key slot " \
7239 -s "Async resume (slot [0-9]): call 0 more times." \
7240 -s "Async resume (slot [0-9]): decrypt done, status=0"
7241
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007242requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007243run_test "SSL async private: decrypt RSA-PSK, delay=0" \
7244 "$P_SRV psk=abc123 \
7245 async_operations=d async_private_delay1=0 async_private_delay2=0" \
7246 "$P_CLI psk=abc123 \
7247 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7248 0 \
7249 -s "Async decrypt callback: using key slot " \
7250 -s "Async resume (slot [0-9]): decrypt done, status=0"
7251
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007252requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007253run_test "SSL async private: decrypt RSA-PSK, delay=1" \
7254 "$P_SRV psk=abc123 \
7255 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7256 "$P_CLI psk=abc123 \
7257 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
7258 0 \
7259 -s "Async decrypt callback: using key slot " \
7260 -s "Async resume (slot [0-9]): call 0 more times." \
7261 -s "Async resume (slot [0-9]): decrypt done, status=0"
7262
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007263requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007264run_test "SSL async private: sign callback not present" \
7265 "$P_SRV \
7266 async_operations=d async_private_delay1=1 async_private_delay2=1" \
7267 "$P_CLI; [ \$? -eq 1 ] &&
7268 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7269 0 \
7270 -S "Async sign callback" \
7271 -s "! mbedtls_ssl_handshake returned" \
7272 -s "The own private key or pre-shared key is not set, but needed" \
7273 -s "Async resume (slot [0-9]): decrypt done, status=0" \
7274 -s "Successful connection"
7275
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007276requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007277run_test "SSL async private: decrypt callback not present" \
7278 "$P_SRV debug_level=1 \
7279 async_operations=s async_private_delay1=1 async_private_delay2=1" \
7280 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
7281 [ \$? -eq 1 ] && $P_CLI" \
7282 0 \
7283 -S "Async decrypt callback" \
7284 -s "! mbedtls_ssl_handshake returned" \
7285 -s "got no RSA private key" \
7286 -s "Async resume (slot [0-9]): sign done, status=0" \
7287 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007288
7289# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007290requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007291run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007292 "$P_SRV \
7293 async_operations=s async_private_delay1=1 \
7294 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7295 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007296 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7297 0 \
7298 -s "Async sign callback: using key slot 0," \
7299 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007300 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007301
7302# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007303requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007304run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007305 "$P_SRV \
7306 async_operations=s async_private_delay2=1 \
7307 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7308 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007309 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7310 0 \
7311 -s "Async sign callback: using key slot 0," \
7312 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007313 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007314
7315# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007316requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02007317run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007318 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02007319 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007320 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7321 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007322 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7323 0 \
7324 -s "Async sign callback: using key slot 1," \
7325 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007326 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007327
7328# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007329requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007330run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007331 "$P_SRV \
7332 async_operations=s async_private_delay1=1 \
7333 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7334 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007335 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7336 0 \
7337 -s "Async sign callback: no key matches this certificate."
7338
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007339requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007340run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007341 "$P_SRV \
7342 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7343 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007344 "$P_CLI" \
7345 1 \
7346 -s "Async sign callback: injected error" \
7347 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007348 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007349 -s "! mbedtls_ssl_handshake returned"
7350
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007351requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007352run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007353 "$P_SRV \
7354 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7355 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007356 "$P_CLI" \
7357 1 \
7358 -s "Async sign callback: using key slot " \
7359 -S "Async resume" \
7360 -s "Async cancel"
7361
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007362requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007363run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007364 "$P_SRV \
7365 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7366 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007367 "$P_CLI" \
7368 1 \
7369 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007370 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02007371 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007372 -s "! mbedtls_ssl_handshake returned"
7373
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007374requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007375run_test "SSL async private: decrypt, error in start" \
7376 "$P_SRV \
7377 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7378 async_private_error=1" \
7379 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7380 1 \
7381 -s "Async decrypt callback: injected error" \
7382 -S "Async resume" \
7383 -S "Async cancel" \
7384 -s "! mbedtls_ssl_handshake returned"
7385
7386requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7387run_test "SSL async private: decrypt, cancel after start" \
7388 "$P_SRV \
7389 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7390 async_private_error=2" \
7391 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7392 1 \
7393 -s "Async decrypt callback: using key slot " \
7394 -S "Async resume" \
7395 -s "Async cancel"
7396
7397requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
7398run_test "SSL async private: decrypt, error in resume" \
7399 "$P_SRV \
7400 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7401 async_private_error=3" \
7402 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7403 1 \
7404 -s "Async decrypt callback: using key slot " \
7405 -s "Async resume callback: decrypt done but injected error" \
7406 -S "Async cancel" \
7407 -s "! mbedtls_ssl_handshake returned"
7408
7409requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007410run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007411 "$P_SRV \
7412 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7413 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007414 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7415 0 \
7416 -s "Async cancel" \
7417 -s "! mbedtls_ssl_handshake returned" \
7418 -s "Async resume" \
7419 -s "Successful connection"
7420
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007421requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007422run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007423 "$P_SRV \
7424 async_operations=s async_private_delay1=1 async_private_delay2=1 \
7425 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007426 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
7427 0 \
7428 -s "! mbedtls_ssl_handshake returned" \
7429 -s "Async resume" \
7430 -s "Successful connection"
7431
7432# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007433requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007434run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007435 "$P_SRV \
7436 async_operations=s async_private_delay1=1 async_private_error=-2 \
7437 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7438 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007439 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7440 [ \$? -eq 1 ] &&
7441 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7442 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02007443 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007444 -S "Async resume" \
7445 -s "Async cancel" \
7446 -s "! mbedtls_ssl_handshake returned" \
7447 -s "Async sign callback: no key matches this certificate." \
7448 -s "Successful connection"
7449
7450# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007451requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02007452run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007453 "$P_SRV \
7454 async_operations=s async_private_delay1=1 async_private_error=-3 \
7455 key_file=data_files/server5.key crt_file=data_files/server5.crt \
7456 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01007457 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
7458 [ \$? -eq 1 ] &&
7459 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
7460 0 \
7461 -s "Async resume" \
7462 -s "! mbedtls_ssl_handshake returned" \
7463 -s "Async sign callback: no key matches this certificate." \
7464 -s "Successful connection"
7465
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007466requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007467requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007468run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007469 "$P_SRV \
7470 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007471 exchanges=2 renegotiation=1" \
7472 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
7473 0 \
7474 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007475 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007476
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007477requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007478requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007479run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007480 "$P_SRV \
7481 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007482 exchanges=2 renegotiation=1 renegotiate=1" \
7483 "$P_CLI exchanges=2 renegotiation=1" \
7484 0 \
7485 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007486 -s "Async resume (slot [0-9]): sign done, status=0"
7487
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007488requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007489requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007490run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007491 "$P_SRV \
7492 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7493 exchanges=2 renegotiation=1" \
7494 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
7495 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7496 0 \
7497 -s "Async decrypt callback: using key slot " \
7498 -s "Async resume (slot [0-9]): decrypt done, status=0"
7499
Gilles Peskineb74a1c72018-04-24 13:09:22 +02007500requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007501requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02007502run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01007503 "$P_SRV \
7504 async_operations=d async_private_delay1=1 async_private_delay2=1 \
7505 exchanges=2 renegotiation=1 renegotiate=1" \
7506 "$P_CLI exchanges=2 renegotiation=1 \
7507 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
7508 0 \
7509 -s "Async decrypt callback: using key slot " \
7510 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01007511
Ron Eldor58093c82018-06-28 13:22:05 +03007512# Tests for ECC extensions (rfc 4492)
7513
Ron Eldor643df7c2018-06-28 16:17:00 +03007514requires_config_enabled MBEDTLS_AES_C
7515requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7516requires_config_enabled MBEDTLS_SHA256_C
7517requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007518run_test "Force a non ECC ciphersuite in the client side" \
7519 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007520 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007521 0 \
7522 -C "client hello, adding supported_elliptic_curves extension" \
7523 -C "client hello, adding supported_point_formats extension" \
7524 -S "found supported elliptic curves extension" \
7525 -S "found supported point formats extension"
7526
Ron Eldor643df7c2018-06-28 16:17:00 +03007527requires_config_enabled MBEDTLS_AES_C
7528requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7529requires_config_enabled MBEDTLS_SHA256_C
7530requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007531run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03007532 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03007533 "$P_CLI debug_level=3" \
7534 0 \
7535 -C "found supported_point_formats extension" \
7536 -S "server hello, supported_point_formats extension"
7537
Ron Eldor643df7c2018-06-28 16:17:00 +03007538requires_config_enabled MBEDTLS_AES_C
7539requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7540requires_config_enabled MBEDTLS_SHA256_C
7541requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007542run_test "Force an ECC ciphersuite in the client side" \
7543 "$P_SRV debug_level=3" \
7544 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7545 0 \
7546 -c "client hello, adding supported_elliptic_curves extension" \
7547 -c "client hello, adding supported_point_formats extension" \
7548 -s "found supported elliptic curves extension" \
7549 -s "found supported point formats extension"
7550
Ron Eldor643df7c2018-06-28 16:17:00 +03007551requires_config_enabled MBEDTLS_AES_C
7552requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7553requires_config_enabled MBEDTLS_SHA256_C
7554requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03007555run_test "Force an ECC ciphersuite in the server side" \
7556 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
7557 "$P_CLI debug_level=3" \
7558 0 \
7559 -c "found supported_point_formats extension" \
7560 -s "server hello, supported_point_formats extension"
7561
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007562# Tests for DTLS HelloVerifyRequest
7563
7564run_test "DTLS cookie: enabled" \
7565 "$P_SRV dtls=1 debug_level=2" \
7566 "$P_CLI dtls=1 debug_level=2" \
7567 0 \
7568 -s "cookie verification failed" \
7569 -s "cookie verification passed" \
7570 -S "cookie verification skipped" \
7571 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007572 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007573 -S "SSL - The requested feature is not available"
7574
7575run_test "DTLS cookie: disabled" \
7576 "$P_SRV dtls=1 debug_level=2 cookies=0" \
7577 "$P_CLI dtls=1 debug_level=2" \
7578 0 \
7579 -S "cookie verification failed" \
7580 -S "cookie verification passed" \
7581 -s "cookie verification skipped" \
7582 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007583 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007584 -S "SSL - The requested feature is not available"
7585
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007586run_test "DTLS cookie: default (failing)" \
7587 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
7588 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
7589 1 \
7590 -s "cookie verification failed" \
7591 -S "cookie verification passed" \
7592 -S "cookie verification skipped" \
7593 -C "received hello verify request" \
7594 -S "hello verification requested" \
7595 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007596
7597requires_ipv6
7598run_test "DTLS cookie: enabled, IPv6" \
7599 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
7600 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
7601 0 \
7602 -s "cookie verification failed" \
7603 -s "cookie verification passed" \
7604 -S "cookie verification skipped" \
7605 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007606 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02007607 -S "SSL - The requested feature is not available"
7608
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007609run_test "DTLS cookie: enabled, nbio" \
7610 "$P_SRV dtls=1 nbio=2 debug_level=2" \
7611 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7612 0 \
7613 -s "cookie verification failed" \
7614 -s "cookie verification passed" \
7615 -S "cookie verification skipped" \
7616 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02007617 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02007618 -S "SSL - The requested feature is not available"
7619
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007620# Tests for client reconnecting from the same port with DTLS
7621
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007622not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007623run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007624 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7625 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007626 0 \
7627 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007628 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007629 -S "Client initiated reconnection from same port"
7630
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007631not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007632run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007633 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
7634 "$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 +02007635 0 \
7636 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007637 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007638 -s "Client initiated reconnection from same port"
7639
Paul Bakker362689d2016-05-13 10:33:25 +01007640not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
7641run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007642 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
7643 "$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 +02007644 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007645 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02007646 -s "Client initiated reconnection from same port"
7647
Paul Bakker362689d2016-05-13 10:33:25 +01007648only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
7649run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
7650 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
7651 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
7652 0 \
7653 -S "The operation timed out" \
7654 -s "Client initiated reconnection from same port"
7655
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007656run_test "DTLS client reconnect from same port: no cookies" \
7657 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02007658 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
7659 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02007660 -s "The operation timed out" \
7661 -S "Client initiated reconnection from same port"
7662
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01007663run_test "DTLS client reconnect from same port: attacker-injected" \
7664 -p "$P_PXY inject_clihlo=1" \
7665 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
7666 "$P_CLI dtls=1 exchanges=2" \
7667 0 \
7668 -s "possible client reconnect from the same port" \
7669 -S "Client initiated reconnection from same port"
7670
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007671# Tests for various cases of client authentication with DTLS
7672# (focused on handshake flows and message parsing)
7673
7674run_test "DTLS client auth: required" \
7675 "$P_SRV dtls=1 auth_mode=required" \
7676 "$P_CLI dtls=1" \
7677 0 \
7678 -s "Verifying peer X.509 certificate... ok"
7679
7680run_test "DTLS client auth: optional, client has no cert" \
7681 "$P_SRV dtls=1 auth_mode=optional" \
7682 "$P_CLI dtls=1 crt_file=none key_file=none" \
7683 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007684 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007685
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007686run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007687 "$P_SRV dtls=1 auth_mode=none" \
7688 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
7689 0 \
7690 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01007691 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02007692
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02007693run_test "DTLS wrong PSK: badmac alert" \
7694 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
7695 "$P_CLI dtls=1 psk=abc124" \
7696 1 \
7697 -s "SSL - Verification of the message MAC failed" \
7698 -c "SSL - A fatal alert message was received from our peer"
7699
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02007700# Tests for receiving fragmented handshake messages with DTLS
7701
7702requires_gnutls
7703run_test "DTLS reassembly: no fragmentation (gnutls server)" \
7704 "$G_SRV -u --mtu 2048 -a" \
7705 "$P_CLI dtls=1 debug_level=2" \
7706 0 \
7707 -C "found fragmented DTLS handshake message" \
7708 -C "error"
7709
7710requires_gnutls
7711run_test "DTLS reassembly: some fragmentation (gnutls server)" \
7712 "$G_SRV -u --mtu 512" \
7713 "$P_CLI dtls=1 debug_level=2" \
7714 0 \
7715 -c "found fragmented DTLS handshake message" \
7716 -C "error"
7717
7718requires_gnutls
7719run_test "DTLS reassembly: more fragmentation (gnutls server)" \
7720 "$G_SRV -u --mtu 128" \
7721 "$P_CLI dtls=1 debug_level=2" \
7722 0 \
7723 -c "found fragmented DTLS handshake message" \
7724 -C "error"
7725
7726requires_gnutls
7727run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
7728 "$G_SRV -u --mtu 128" \
7729 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7730 0 \
7731 -c "found fragmented DTLS handshake message" \
7732 -C "error"
7733
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007734requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007735requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007736run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
7737 "$G_SRV -u --mtu 256" \
7738 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
7739 0 \
7740 -c "found fragmented DTLS handshake message" \
7741 -c "client hello, adding renegotiation extension" \
7742 -c "found renegotiation extension" \
7743 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007744 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007745 -C "error" \
7746 -s "Extra-header:"
7747
7748requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01007749requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007750run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
7751 "$G_SRV -u --mtu 256" \
7752 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
7753 0 \
7754 -c "found fragmented DTLS handshake message" \
7755 -c "client hello, adding renegotiation extension" \
7756 -c "found renegotiation extension" \
7757 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02007758 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02007759 -C "error" \
7760 -s "Extra-header:"
7761
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007762run_test "DTLS reassembly: no fragmentation (openssl server)" \
7763 "$O_SRV -dtls1 -mtu 2048" \
7764 "$P_CLI dtls=1 debug_level=2" \
7765 0 \
7766 -C "found fragmented DTLS handshake message" \
7767 -C "error"
7768
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007769run_test "DTLS reassembly: some fragmentation (openssl server)" \
7770 "$O_SRV -dtls1 -mtu 768" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007771 "$P_CLI dtls=1 debug_level=2" \
7772 0 \
7773 -c "found fragmented DTLS handshake message" \
7774 -C "error"
7775
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007776run_test "DTLS reassembly: more fragmentation (openssl server)" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007777 "$O_SRV -dtls1 -mtu 256" \
7778 "$P_CLI dtls=1 debug_level=2" \
7779 0 \
7780 -c "found fragmented DTLS handshake message" \
7781 -C "error"
7782
7783run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
7784 "$O_SRV -dtls1 -mtu 256" \
7785 "$P_CLI dtls=1 nbio=2 debug_level=2" \
7786 0 \
7787 -c "found fragmented DTLS handshake message" \
7788 -C "error"
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007789
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007790# Tests for sending fragmented handshake messages with DTLS
7791#
7792# Use client auth when we need the client to send large messages,
7793# and use large cert chains on both sides too (the long chains we have all use
7794# both RSA and ECDSA, but ideally we should have long chains with either).
7795# Sizes reached (UDP payload):
7796# - 2037B for server certificate
7797# - 1542B for client certificate
7798# - 1013B for newsessionticket
7799# - all others below 512B
7800# All those tests assume MAX_CONTENT_LEN is at least 2048
7801
7802requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7803requires_config_enabled MBEDTLS_RSA_C
7804requires_config_enabled MBEDTLS_ECDSA_C
7805requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7806run_test "DTLS fragmenting: none (for reference)" \
7807 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7808 crt_file=data_files/server7_int-ca.crt \
7809 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007810 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007811 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007812 "$P_CLI dtls=1 debug_level=2 \
7813 crt_file=data_files/server8_int-ca2.crt \
7814 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007815 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007816 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007817 0 \
7818 -S "found fragmented DTLS handshake message" \
7819 -C "found fragmented DTLS handshake message" \
7820 -C "error"
7821
7822requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7823requires_config_enabled MBEDTLS_RSA_C
7824requires_config_enabled MBEDTLS_ECDSA_C
7825requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007826run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007827 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7828 crt_file=data_files/server7_int-ca.crt \
7829 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007830 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007831 max_frag_len=1024" \
7832 "$P_CLI dtls=1 debug_level=2 \
7833 crt_file=data_files/server8_int-ca2.crt \
7834 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007835 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007836 max_frag_len=2048" \
7837 0 \
7838 -S "found fragmented DTLS handshake message" \
7839 -c "found fragmented DTLS handshake message" \
7840 -C "error"
7841
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007842# With the MFL extension, the server has no way of forcing
7843# the client to not exceed a certain MTU; hence, the following
7844# test can't be replicated with an MTU proxy such as the one
7845# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007846requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7847requires_config_enabled MBEDTLS_RSA_C
7848requires_config_enabled MBEDTLS_ECDSA_C
7849requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007850run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007851 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7852 crt_file=data_files/server7_int-ca.crt \
7853 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007854 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007855 max_frag_len=512" \
7856 "$P_CLI dtls=1 debug_level=2 \
7857 crt_file=data_files/server8_int-ca2.crt \
7858 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007859 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01007860 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007861 0 \
7862 -S "found fragmented DTLS handshake message" \
7863 -c "found fragmented DTLS handshake message" \
7864 -C "error"
7865
7866requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7867requires_config_enabled MBEDTLS_RSA_C
7868requires_config_enabled MBEDTLS_ECDSA_C
7869requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007870run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007871 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7872 crt_file=data_files/server7_int-ca.crt \
7873 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007874 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007875 max_frag_len=2048" \
7876 "$P_CLI dtls=1 debug_level=2 \
7877 crt_file=data_files/server8_int-ca2.crt \
7878 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007879 hs_timeout=2500-60000 \
7880 max_frag_len=1024" \
7881 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007882 -S "found fragmented DTLS handshake message" \
7883 -c "found fragmented DTLS handshake message" \
7884 -C "error"
7885
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007886# While not required by the standard defining the MFL extension
7887# (according to which it only applies to records, not to datagrams),
7888# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7889# as otherwise there wouldn't be any means to communicate MTU restrictions
7890# to the peer.
7891# The next test checks that no datagrams significantly larger than the
7892# negotiated MFL are sent.
7893requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7894requires_config_enabled MBEDTLS_RSA_C
7895requires_config_enabled MBEDTLS_ECDSA_C
7896requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7897run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007898 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007899 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
7900 crt_file=data_files/server7_int-ca.crt \
7901 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007902 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007903 max_frag_len=2048" \
7904 "$P_CLI dtls=1 debug_level=2 \
7905 crt_file=data_files/server8_int-ca2.crt \
7906 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007907 hs_timeout=2500-60000 \
7908 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007909 0 \
7910 -S "found fragmented DTLS handshake message" \
7911 -c "found fragmented DTLS handshake message" \
7912 -C "error"
7913
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007914requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7915requires_config_enabled MBEDTLS_RSA_C
7916requires_config_enabled MBEDTLS_ECDSA_C
7917requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007918run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007919 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7920 crt_file=data_files/server7_int-ca.crt \
7921 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007922 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007923 max_frag_len=2048" \
7924 "$P_CLI dtls=1 debug_level=2 \
7925 crt_file=data_files/server8_int-ca2.crt \
7926 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007927 hs_timeout=2500-60000 \
7928 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02007929 0 \
7930 -s "found fragmented DTLS handshake message" \
7931 -c "found fragmented DTLS handshake message" \
7932 -C "error"
7933
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007934# While not required by the standard defining the MFL extension
7935# (according to which it only applies to records, not to datagrams),
7936# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
7937# as otherwise there wouldn't be any means to communicate MTU restrictions
7938# to the peer.
7939# The next test checks that no datagrams significantly larger than the
7940# negotiated MFL are sent.
7941requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7942requires_config_enabled MBEDTLS_RSA_C
7943requires_config_enabled MBEDTLS_ECDSA_C
7944requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
7945run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04007946 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007947 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7948 crt_file=data_files/server7_int-ca.crt \
7949 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007950 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007951 max_frag_len=2048" \
7952 "$P_CLI dtls=1 debug_level=2 \
7953 crt_file=data_files/server8_int-ca2.crt \
7954 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007955 hs_timeout=2500-60000 \
7956 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01007957 0 \
7958 -s "found fragmented DTLS handshake message" \
7959 -c "found fragmented DTLS handshake message" \
7960 -C "error"
7961
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007962requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7963requires_config_enabled MBEDTLS_RSA_C
7964requires_config_enabled MBEDTLS_ECDSA_C
7965run_test "DTLS fragmenting: none (for reference) (MTU)" \
7966 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7967 crt_file=data_files/server7_int-ca.crt \
7968 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007969 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007970 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007971 "$P_CLI dtls=1 debug_level=2 \
7972 crt_file=data_files/server8_int-ca2.crt \
7973 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007974 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007975 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007976 0 \
7977 -S "found fragmented DTLS handshake message" \
7978 -C "found fragmented DTLS handshake message" \
7979 -C "error"
7980
7981requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7982requires_config_enabled MBEDTLS_RSA_C
7983requires_config_enabled MBEDTLS_ECDSA_C
7984run_test "DTLS fragmenting: client (MTU)" \
7985 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7986 crt_file=data_files/server7_int-ca.crt \
7987 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007988 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01007989 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007990 "$P_CLI dtls=1 debug_level=2 \
7991 crt_file=data_files/server8_int-ca2.crt \
7992 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007993 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007994 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02007995 0 \
7996 -s "found fragmented DTLS handshake message" \
7997 -C "found fragmented DTLS handshake message" \
7998 -C "error"
7999
8000requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8001requires_config_enabled MBEDTLS_RSA_C
8002requires_config_enabled MBEDTLS_ECDSA_C
8003run_test "DTLS fragmenting: server (MTU)" \
8004 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8005 crt_file=data_files/server7_int-ca.crt \
8006 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008007 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008008 mtu=512" \
8009 "$P_CLI dtls=1 debug_level=2 \
8010 crt_file=data_files/server8_int-ca2.crt \
8011 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008012 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008013 mtu=2048" \
8014 0 \
8015 -S "found fragmented DTLS handshake message" \
8016 -c "found fragmented DTLS handshake message" \
8017 -C "error"
8018
8019requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8020requires_config_enabled MBEDTLS_RSA_C
8021requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008022run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008023 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008024 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8025 crt_file=data_files/server7_int-ca.crt \
8026 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008027 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04008028 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008029 "$P_CLI dtls=1 debug_level=2 \
8030 crt_file=data_files/server8_int-ca2.crt \
8031 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008032 hs_timeout=2500-60000 \
8033 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02008034 0 \
8035 -s "found fragmented DTLS handshake message" \
8036 -c "found fragmented DTLS handshake message" \
8037 -C "error"
8038
Andrzej Kurek77826052018-10-11 07:34:08 -04008039# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008040requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8041requires_config_enabled MBEDTLS_RSA_C
8042requires_config_enabled MBEDTLS_ECDSA_C
8043requires_config_enabled MBEDTLS_SHA256_C
8044requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8045requires_config_enabled MBEDTLS_AES_C
8046requires_config_enabled MBEDTLS_GCM_C
8047run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00008048 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00008049 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8050 crt_file=data_files/server7_int-ca.crt \
8051 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008052 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00008053 mtu=512" \
8054 "$P_CLI dtls=1 debug_level=2 \
8055 crt_file=data_files/server8_int-ca2.crt \
8056 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008057 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8058 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008059 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008060 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008061 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008062 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008063 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008064
Andrzej Kurek7311c782018-10-11 06:49:41 -04008065# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04008066# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008067# The ratio of max/min timeout should ideally equal 4 to accept two
8068# retransmissions, but in some cases (like both the server and client using
8069# fragmentation and auto-reduction) an extra retransmission might occur,
8070# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01008071not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008072requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8073requires_config_enabled MBEDTLS_RSA_C
8074requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008075requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8076requires_config_enabled MBEDTLS_AES_C
8077requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008078run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008079 -p "$P_PXY mtu=508" \
8080 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8081 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008082 key_file=data_files/server7.key \
8083 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008084 "$P_CLI dtls=1 debug_level=2 \
8085 crt_file=data_files/server8_int-ca2.crt \
8086 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008087 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8088 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02008089 0 \
8090 -s "found fragmented DTLS handshake message" \
8091 -c "found fragmented DTLS handshake message" \
8092 -C "error"
8093
Andrzej Kurek77826052018-10-11 07:34:08 -04008094# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01008095only_with_valgrind
8096requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8097requires_config_enabled MBEDTLS_RSA_C
8098requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008099requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8100requires_config_enabled MBEDTLS_AES_C
8101requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02008102run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01008103 -p "$P_PXY mtu=508" \
8104 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8105 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008106 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01008107 hs_timeout=250-10000" \
8108 "$P_CLI dtls=1 debug_level=2 \
8109 crt_file=data_files/server8_int-ca2.crt \
8110 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008111 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01008112 hs_timeout=250-10000" \
8113 0 \
8114 -s "found fragmented DTLS handshake message" \
8115 -c "found fragmented DTLS handshake message" \
8116 -C "error"
8117
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008118# 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 +02008119# OTOH the client might resend if the server is to slow to reset after sending
8120# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008121not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008122requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8123requires_config_enabled MBEDTLS_RSA_C
8124requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008125run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008126 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008127 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8128 crt_file=data_files/server7_int-ca.crt \
8129 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008130 hs_timeout=10000-60000 \
8131 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008132 "$P_CLI dtls=1 debug_level=2 \
8133 crt_file=data_files/server8_int-ca2.crt \
8134 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008135 hs_timeout=10000-60000 \
8136 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008137 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008138 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008139 -s "found fragmented DTLS handshake message" \
8140 -c "found fragmented DTLS handshake message" \
8141 -C "error"
8142
Andrzej Kurek77826052018-10-11 07:34:08 -04008143# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008144# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
8145# OTOH the client might resend if the server is to slow to reset after sending
8146# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008147not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008148requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8149requires_config_enabled MBEDTLS_RSA_C
8150requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008151requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8152requires_config_enabled MBEDTLS_AES_C
8153requires_config_enabled MBEDTLS_GCM_C
8154run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008155 -p "$P_PXY mtu=512" \
8156 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8157 crt_file=data_files/server7_int-ca.crt \
8158 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008159 hs_timeout=10000-60000 \
8160 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008161 "$P_CLI dtls=1 debug_level=2 \
8162 crt_file=data_files/server8_int-ca2.crt \
8163 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008164 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8165 hs_timeout=10000-60000 \
8166 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008167 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008168 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008169 -s "found fragmented DTLS handshake message" \
8170 -c "found fragmented DTLS handshake message" \
8171 -C "error"
8172
Andrzej Kurek7311c782018-10-11 06:49:41 -04008173not_with_valgrind # spurious autoreduction due to timeout
8174requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8175requires_config_enabled MBEDTLS_RSA_C
8176requires_config_enabled MBEDTLS_ECDSA_C
8177run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008178 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008179 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8180 crt_file=data_files/server7_int-ca.crt \
8181 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008182 hs_timeout=10000-60000 \
8183 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008184 "$P_CLI dtls=1 debug_level=2 \
8185 crt_file=data_files/server8_int-ca2.crt \
8186 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008187 hs_timeout=10000-60000 \
8188 mtu=1024 nbio=2" \
8189 0 \
8190 -S "autoreduction" \
8191 -s "found fragmented DTLS handshake message" \
8192 -c "found fragmented DTLS handshake message" \
8193 -C "error"
8194
Andrzej Kurek77826052018-10-11 07:34:08 -04008195# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04008196not_with_valgrind # spurious autoreduction due to timeout
8197requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8198requires_config_enabled MBEDTLS_RSA_C
8199requires_config_enabled MBEDTLS_ECDSA_C
8200requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8201requires_config_enabled MBEDTLS_AES_C
8202requires_config_enabled MBEDTLS_GCM_C
8203run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
8204 -p "$P_PXY mtu=512" \
8205 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8206 crt_file=data_files/server7_int-ca.crt \
8207 key_file=data_files/server7.key \
8208 hs_timeout=10000-60000 \
8209 mtu=512 nbio=2" \
8210 "$P_CLI dtls=1 debug_level=2 \
8211 crt_file=data_files/server8_int-ca2.crt \
8212 key_file=data_files/server8.key \
8213 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
8214 hs_timeout=10000-60000 \
8215 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008216 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008217 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008218 -s "found fragmented DTLS handshake message" \
8219 -c "found fragmented DTLS handshake message" \
8220 -C "error"
8221
Andrzej Kurek77826052018-10-11 07:34:08 -04008222# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01008223# This ensures things still work after session_reset().
8224# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008225# Since we don't support reading fragmented ClientHello yet,
8226# up the MTU to 1450 (larger than ClientHello with session ticket,
8227# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008228# An autoreduction on the client-side might happen if the server is
8229# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02008230# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008231# resumed listening, which would result in a spurious autoreduction.
8232not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008233requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8234requires_config_enabled MBEDTLS_RSA_C
8235requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008236requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8237requires_config_enabled MBEDTLS_AES_C
8238requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008239run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
8240 -p "$P_PXY mtu=1450" \
8241 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8242 crt_file=data_files/server7_int-ca.crt \
8243 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008244 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008245 mtu=1450" \
8246 "$P_CLI dtls=1 debug_level=2 \
8247 crt_file=data_files/server8_int-ca2.crt \
8248 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008249 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008250 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008251 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008252 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008253 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02008254 -s "found fragmented DTLS handshake message" \
8255 -c "found fragmented DTLS handshake message" \
8256 -C "error"
8257
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008258# An autoreduction on the client-side might happen if the server is
8259# slow to reset, therefore omitting '-C "autoreduction"' below.
8260not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008261requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8262requires_config_enabled MBEDTLS_RSA_C
8263requires_config_enabled MBEDTLS_ECDSA_C
8264requires_config_enabled MBEDTLS_SHA256_C
8265requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8266requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8267requires_config_enabled MBEDTLS_CHACHAPOLY_C
8268run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
8269 -p "$P_PXY mtu=512" \
8270 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8271 crt_file=data_files/server7_int-ca.crt \
8272 key_file=data_files/server7.key \
8273 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008274 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008275 mtu=512" \
8276 "$P_CLI dtls=1 debug_level=2 \
8277 crt_file=data_files/server8_int-ca2.crt \
8278 key_file=data_files/server8.key \
8279 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008280 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008281 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008282 mtu=512" \
8283 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008284 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008285 -s "found fragmented DTLS handshake message" \
8286 -c "found fragmented DTLS handshake message" \
8287 -C "error"
8288
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008289# An autoreduction on the client-side might happen if the server is
8290# slow to reset, therefore omitting '-C "autoreduction"' below.
8291not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008292requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8293requires_config_enabled MBEDTLS_RSA_C
8294requires_config_enabled MBEDTLS_ECDSA_C
8295requires_config_enabled MBEDTLS_SHA256_C
8296requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8297requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8298requires_config_enabled MBEDTLS_AES_C
8299requires_config_enabled MBEDTLS_GCM_C
8300run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
8301 -p "$P_PXY mtu=512" \
8302 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8303 crt_file=data_files/server7_int-ca.crt \
8304 key_file=data_files/server7.key \
8305 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008306 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008307 mtu=512" \
8308 "$P_CLI dtls=1 debug_level=2 \
8309 crt_file=data_files/server8_int-ca2.crt \
8310 key_file=data_files/server8.key \
8311 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008312 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008313 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008314 mtu=512" \
8315 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008316 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008317 -s "found fragmented DTLS handshake message" \
8318 -c "found fragmented DTLS handshake message" \
8319 -C "error"
8320
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008321# An autoreduction on the client-side might happen if the server is
8322# slow to reset, therefore omitting '-C "autoreduction"' below.
8323not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008324requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8325requires_config_enabled MBEDTLS_RSA_C
8326requires_config_enabled MBEDTLS_ECDSA_C
8327requires_config_enabled MBEDTLS_SHA256_C
8328requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8329requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8330requires_config_enabled MBEDTLS_AES_C
8331requires_config_enabled MBEDTLS_CCM_C
8332run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008333 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008334 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8335 crt_file=data_files/server7_int-ca.crt \
8336 key_file=data_files/server7.key \
8337 exchanges=2 renegotiation=1 \
8338 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008339 hs_timeout=10000-60000 \
8340 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008341 "$P_CLI dtls=1 debug_level=2 \
8342 crt_file=data_files/server8_int-ca2.crt \
8343 key_file=data_files/server8.key \
8344 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008345 hs_timeout=10000-60000 \
8346 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008347 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008348 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008349 -s "found fragmented DTLS handshake message" \
8350 -c "found fragmented DTLS handshake message" \
8351 -C "error"
8352
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008353# An autoreduction on the client-side might happen if the server is
8354# slow to reset, therefore omitting '-C "autoreduction"' below.
8355not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008356requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8357requires_config_enabled MBEDTLS_RSA_C
8358requires_config_enabled MBEDTLS_ECDSA_C
8359requires_config_enabled MBEDTLS_SHA256_C
8360requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8361requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8362requires_config_enabled MBEDTLS_AES_C
8363requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8364requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
8365run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008366 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008367 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8368 crt_file=data_files/server7_int-ca.crt \
8369 key_file=data_files/server7.key \
8370 exchanges=2 renegotiation=1 \
8371 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008372 hs_timeout=10000-60000 \
8373 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008374 "$P_CLI dtls=1 debug_level=2 \
8375 crt_file=data_files/server8_int-ca2.crt \
8376 key_file=data_files/server8.key \
8377 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008378 hs_timeout=10000-60000 \
8379 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008380 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008381 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008382 -s "found fragmented DTLS handshake message" \
8383 -c "found fragmented DTLS handshake message" \
8384 -C "error"
8385
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008386# An autoreduction on the client-side might happen if the server is
8387# slow to reset, therefore omitting '-C "autoreduction"' below.
8388not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008389requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8390requires_config_enabled MBEDTLS_RSA_C
8391requires_config_enabled MBEDTLS_ECDSA_C
8392requires_config_enabled MBEDTLS_SHA256_C
8393requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8394requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
8395requires_config_enabled MBEDTLS_AES_C
8396requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
8397run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008398 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008399 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8400 crt_file=data_files/server7_int-ca.crt \
8401 key_file=data_files/server7.key \
8402 exchanges=2 renegotiation=1 \
8403 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008404 hs_timeout=10000-60000 \
8405 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008406 "$P_CLI dtls=1 debug_level=2 \
8407 crt_file=data_files/server8_int-ca2.crt \
8408 key_file=data_files/server8.key \
8409 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04008410 hs_timeout=10000-60000 \
8411 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008412 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04008413 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02008414 -s "found fragmented DTLS handshake message" \
8415 -c "found fragmented DTLS handshake message" \
8416 -C "error"
8417
Andrzej Kurek77826052018-10-11 07:34:08 -04008418# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008419requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8420requires_config_enabled MBEDTLS_RSA_C
8421requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008422requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8423requires_config_enabled MBEDTLS_AES_C
8424requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008425client_needs_more_time 2
8426run_test "DTLS fragmenting: proxy MTU + 3d" \
8427 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008428 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008429 crt_file=data_files/server7_int-ca.crt \
8430 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008431 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008432 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008433 crt_file=data_files/server8_int-ca2.crt \
8434 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008435 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008436 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02008437 0 \
8438 -s "found fragmented DTLS handshake message" \
8439 -c "found fragmented DTLS handshake message" \
8440 -C "error"
8441
Andrzej Kurek77826052018-10-11 07:34:08 -04008442# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008443requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8444requires_config_enabled MBEDTLS_RSA_C
8445requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04008446requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
8447requires_config_enabled MBEDTLS_AES_C
8448requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008449client_needs_more_time 2
8450run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
8451 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
8452 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
8453 crt_file=data_files/server7_int-ca.crt \
8454 key_file=data_files/server7.key \
8455 hs_timeout=250-10000 mtu=512 nbio=2" \
8456 "$P_CLI dtls=1 debug_level=2 \
8457 crt_file=data_files/server8_int-ca2.crt \
8458 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04008459 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02008460 hs_timeout=250-10000 mtu=512 nbio=2" \
8461 0 \
8462 -s "found fragmented DTLS handshake message" \
8463 -c "found fragmented DTLS handshake message" \
8464 -C "error"
8465
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008466# interop tests for DTLS fragmentating with reliable connection
8467#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008468# here and below we just want to test that the we fragment in a way that
8469# pleases other implementations, so we don't need the peer to fragment
8470requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8471requires_config_enabled MBEDTLS_RSA_C
8472requires_config_enabled MBEDTLS_ECDSA_C
8473requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008474requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008475run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
8476 "$G_SRV -u" \
8477 "$P_CLI dtls=1 debug_level=2 \
8478 crt_file=data_files/server8_int-ca2.crt \
8479 key_file=data_files/server8.key \
8480 mtu=512 force_version=dtls1_2" \
8481 0 \
8482 -c "fragmenting handshake message" \
8483 -C "error"
8484
8485requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8486requires_config_enabled MBEDTLS_RSA_C
8487requires_config_enabled MBEDTLS_ECDSA_C
8488requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008489requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008490run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \
8491 "$G_SRV -u" \
8492 "$P_CLI dtls=1 debug_level=2 \
8493 crt_file=data_files/server8_int-ca2.crt \
8494 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008495 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008496 0 \
8497 -c "fragmenting handshake message" \
8498 -C "error"
8499
Hanno Beckerb9a00862018-08-28 10:20:22 +01008500# We use --insecure for the GnuTLS client because it expects
8501# the hostname / IP it connects to to be the name used in the
8502# certificate obtained from the server. Here, however, it
8503# connects to 127.0.0.1 while our test certificates use 'localhost'
8504# as the server name in the certificate. This will make the
8505# certifiate validation fail, but passing --insecure makes
8506# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008507requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8508requires_config_enabled MBEDTLS_RSA_C
8509requires_config_enabled MBEDTLS_ECDSA_C
8510requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008511requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008512requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008513run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008514 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008515 crt_file=data_files/server7_int-ca.crt \
8516 key_file=data_files/server7.key \
8517 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008518 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008519 0 \
8520 -s "fragmenting handshake message"
8521
Hanno Beckerb9a00862018-08-28 10:20:22 +01008522# See previous test for the reason to use --insecure
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008523requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8524requires_config_enabled MBEDTLS_RSA_C
8525requires_config_enabled MBEDTLS_ECDSA_C
8526requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02008527requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04008528requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008529run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008530 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008531 crt_file=data_files/server7_int-ca.crt \
8532 key_file=data_files/server7.key \
8533 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02008534 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02008535 0 \
8536 -s "fragmenting handshake message"
8537
8538requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8539requires_config_enabled MBEDTLS_RSA_C
8540requires_config_enabled MBEDTLS_ECDSA_C
8541requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8542run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
8543 "$O_SRV -dtls1_2 -verify 10" \
8544 "$P_CLI dtls=1 debug_level=2 \
8545 crt_file=data_files/server8_int-ca2.crt \
8546 key_file=data_files/server8.key \
8547 mtu=512 force_version=dtls1_2" \
8548 0 \
8549 -c "fragmenting handshake message" \
8550 -C "error"
8551
8552requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8553requires_config_enabled MBEDTLS_RSA_C
8554requires_config_enabled MBEDTLS_ECDSA_C
8555requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8556run_test "DTLS fragmenting: openssl server, DTLS 1.0" \
8557 "$O_SRV -dtls1 -verify 10" \
8558 "$P_CLI dtls=1 debug_level=2 \
8559 crt_file=data_files/server8_int-ca2.crt \
8560 key_file=data_files/server8.key \
8561 mtu=512 force_version=dtls1" \
8562 0 \
8563 -c "fragmenting handshake message" \
8564 -C "error"
8565
8566requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8567requires_config_enabled MBEDTLS_RSA_C
8568requires_config_enabled MBEDTLS_ECDSA_C
8569requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8570run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
8571 "$P_SRV dtls=1 debug_level=2 \
8572 crt_file=data_files/server7_int-ca.crt \
8573 key_file=data_files/server7.key \
8574 mtu=512 force_version=dtls1_2" \
8575 "$O_CLI -dtls1_2" \
8576 0 \
8577 -s "fragmenting handshake message"
8578
8579requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8580requires_config_enabled MBEDTLS_RSA_C
8581requires_config_enabled MBEDTLS_ECDSA_C
8582requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8583run_test "DTLS fragmenting: openssl client, DTLS 1.0" \
8584 "$P_SRV dtls=1 debug_level=2 \
8585 crt_file=data_files/server7_int-ca.crt \
8586 key_file=data_files/server7.key \
8587 mtu=512 force_version=dtls1" \
8588 "$O_CLI -dtls1" \
8589 0 \
8590 -s "fragmenting handshake message"
8591
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008592# interop tests for DTLS fragmentating with unreliable connection
8593#
8594# again we just want to test that the we fragment in a way that
8595# pleases other implementations, so we don't need the peer to fragment
8596requires_gnutls_next
8597requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8598requires_config_enabled MBEDTLS_RSA_C
8599requires_config_enabled MBEDTLS_ECDSA_C
8600requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008601client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008602run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
8603 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8604 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008605 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008606 crt_file=data_files/server8_int-ca2.crt \
8607 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008608 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008609 0 \
8610 -c "fragmenting handshake message" \
8611 -C "error"
8612
8613requires_gnutls_next
8614requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8615requires_config_enabled MBEDTLS_RSA_C
8616requires_config_enabled MBEDTLS_ECDSA_C
8617requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008618client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008619run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \
8620 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8621 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008622 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008623 crt_file=data_files/server8_int-ca2.crt \
8624 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008625 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008626 0 \
8627 -c "fragmenting handshake message" \
8628 -C "error"
8629
k-stachowiak17a38d32019-02-18 15:29:56 +01008630requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008631requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8632requires_config_enabled MBEDTLS_RSA_C
8633requires_config_enabled MBEDTLS_ECDSA_C
8634requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8635client_needs_more_time 4
8636run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
8637 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8638 "$P_SRV dtls=1 debug_level=2 \
8639 crt_file=data_files/server7_int-ca.crt \
8640 key_file=data_files/server7.key \
8641 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008642 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008643 0 \
8644 -s "fragmenting handshake message"
8645
k-stachowiak17a38d32019-02-18 15:29:56 +01008646requires_gnutls_next
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008647requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8648requires_config_enabled MBEDTLS_RSA_C
8649requires_config_enabled MBEDTLS_ECDSA_C
8650requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
8651client_needs_more_time 4
8652run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \
8653 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8654 "$P_SRV dtls=1 debug_level=2 \
8655 crt_file=data_files/server7_int-ca.crt \
8656 key_file=data_files/server7.key \
8657 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008658 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008659 0 \
8660 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008661
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008662## Interop test with OpenSSL might trigger a bug in recent versions (including
8663## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008664## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008665## They should be re-enabled once a fixed version of OpenSSL is available
8666## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01008667skip_next_test
8668requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8669requires_config_enabled MBEDTLS_RSA_C
8670requires_config_enabled MBEDTLS_ECDSA_C
8671requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8672client_needs_more_time 4
8673run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
8674 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8675 "$O_SRV -dtls1_2 -verify 10" \
8676 "$P_CLI dtls=1 debug_level=2 \
8677 crt_file=data_files/server8_int-ca2.crt \
8678 key_file=data_files/server8.key \
8679 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8680 0 \
8681 -c "fragmenting handshake message" \
8682 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008683
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008684skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008685requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8686requires_config_enabled MBEDTLS_RSA_C
8687requires_config_enabled MBEDTLS_ECDSA_C
8688requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008689client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008690run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \
8691 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008692 "$O_SRV -dtls1 -verify 10" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008693 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008694 crt_file=data_files/server8_int-ca2.crt \
8695 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008696 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008697 0 \
8698 -c "fragmenting handshake message" \
8699 -C "error"
8700
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008701skip_next_test
8702requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8703requires_config_enabled MBEDTLS_RSA_C
8704requires_config_enabled MBEDTLS_ECDSA_C
8705requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
8706client_needs_more_time 4
8707run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
8708 -p "$P_PXY drop=8 delay=8 duplicate=8" \
8709 "$P_SRV dtls=1 debug_level=2 \
8710 crt_file=data_files/server7_int-ca.crt \
8711 key_file=data_files/server7.key \
8712 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
8713 "$O_CLI -dtls1_2" \
8714 0 \
8715 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008716
8717# -nbio is added to prevent s_client from blocking in case of duplicated
8718# messages at the end of the handshake
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008719skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008720requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
8721requires_config_enabled MBEDTLS_RSA_C
8722requires_config_enabled MBEDTLS_ECDSA_C
8723requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008724client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008725run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \
8726 -p "$P_PXY drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008727 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008728 crt_file=data_files/server7_int-ca.crt \
8729 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02008730 hs_timeout=250-60000 mtu=512 force_version=dtls1" \
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02008731 "$O_CLI -nbio -dtls1" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02008732 0 \
8733 -s "fragmenting handshake message"
8734
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008735# Tests for specific things with "unreliable" UDP connection
8736
8737not_with_valgrind # spurious resend due to timeout
8738run_test "DTLS proxy: reference" \
8739 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008740 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8741 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008742 0 \
8743 -C "replayed record" \
8744 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01008745 -C "Buffer record from epoch" \
8746 -S "Buffer record from epoch" \
8747 -C "ssl_buffer_message" \
8748 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008749 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008750 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008751 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008752 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008753 -c "HTTP/1.0 200 OK"
8754
8755not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008756run_test "DTLS proxy: duplicate every packet" \
8757 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008758 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
8759 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008760 0 \
8761 -c "replayed record" \
8762 -s "replayed record" \
8763 -c "record from another epoch" \
8764 -s "record from another epoch" \
8765 -S "resend" \
8766 -s "Extra-header:" \
8767 -c "HTTP/1.0 200 OK"
8768
8769run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8770 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008771 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8772 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008773 0 \
8774 -c "replayed record" \
8775 -S "replayed record" \
8776 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008777 -s "record from another epoch" \
8778 -c "resend" \
8779 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008780 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008781 -c "HTTP/1.0 200 OK"
8782
8783run_test "DTLS proxy: multiple records in same datagram" \
8784 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008785 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8786 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008787 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008788 -c "next record in same datagram" \
8789 -s "next record in same datagram"
8790
8791run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8792 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008793 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8794 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008795 0 \
8796 -c "next record in same datagram" \
8797 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008798
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008799run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8800 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008801 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8802 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008803 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008804 -c "discarding invalid record (mac)" \
8805 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008806 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008807 -c "HTTP/1.0 200 OK" \
8808 -S "too many records with bad MAC" \
8809 -S "Verification of the message MAC failed"
8810
8811run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8812 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008813 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8814 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008815 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008816 -C "discarding invalid record (mac)" \
8817 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008818 -S "Extra-header:" \
8819 -C "HTTP/1.0 200 OK" \
8820 -s "too many records with bad MAC" \
8821 -s "Verification of the message MAC failed"
8822
8823run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8824 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008825 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8826 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008827 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008828 -c "discarding invalid record (mac)" \
8829 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008830 -s "Extra-header:" \
8831 -c "HTTP/1.0 200 OK" \
8832 -S "too many records with bad MAC" \
8833 -S "Verification of the message MAC failed"
8834
8835run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8836 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008837 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8838 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008839 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008840 -c "discarding invalid record (mac)" \
8841 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008842 -s "Extra-header:" \
8843 -c "HTTP/1.0 200 OK" \
8844 -s "too many records with bad MAC" \
8845 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008846
8847run_test "DTLS proxy: delay ChangeCipherSpec" \
8848 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008849 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8850 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008851 0 \
8852 -c "record from another epoch" \
8853 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008854 -s "Extra-header:" \
8855 -c "HTTP/1.0 200 OK"
8856
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008857# Tests for reordering support with DTLS
8858
Hanno Becker56cdfd12018-08-17 13:42:15 +01008859run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8860 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008861 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8862 hs_timeout=2500-60000" \
8863 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8864 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008865 0 \
8866 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008867 -c "Next handshake message has been buffered - load"\
8868 -S "Buffering HS message" \
8869 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008870 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008871 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008872 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008873 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008874
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008875run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8876 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008877 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8878 hs_timeout=2500-60000" \
8879 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8880 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008881 0 \
8882 -c "Buffering HS message" \
8883 -c "found fragmented DTLS handshake message"\
8884 -c "Next handshake message 1 not or only partially bufffered" \
8885 -c "Next handshake message has been buffered - load"\
8886 -S "Buffering HS message" \
8887 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008888 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008889 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008890 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008891 -S "Remember CCS message"
8892
Hanno Beckera1adcca2018-08-24 14:41:07 +01008893# The client buffers the ServerKeyExchange before receiving the fragmented
8894# Certificate message; at the time of writing, together these are aroudn 1200b
8895# in size, so that the bound below ensures that the certificate can be reassembled
8896# while keeping the ServerKeyExchange.
8897requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8898run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008899 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008900 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8901 hs_timeout=2500-60000" \
8902 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8903 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008904 0 \
8905 -c "Buffering HS message" \
8906 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008907 -C "attempt to make space by freeing buffered messages" \
8908 -S "Buffering HS message" \
8909 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008910 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008911 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008912 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008913 -S "Remember CCS message"
8914
8915# The size constraints ensure that the delayed certificate message can't
8916# be reassembled while keeping the ServerKeyExchange message, but it can
8917# when dropping it first.
8918requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8919requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8920run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8921 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008922 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8923 hs_timeout=2500-60000" \
8924 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8925 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008926 0 \
8927 -c "Buffering HS message" \
8928 -c "attempt to make space by freeing buffered future messages" \
8929 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008930 -S "Buffering HS message" \
8931 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008932 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008933 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008934 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008935 -S "Remember CCS message"
8936
Hanno Becker56cdfd12018-08-17 13:42:15 +01008937run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8938 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008939 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8940 hs_timeout=2500-60000" \
8941 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8942 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008943 0 \
8944 -C "Buffering HS message" \
8945 -C "Next handshake message has been buffered - load"\
8946 -s "Buffering HS message" \
8947 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008948 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008949 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008950 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008951 -S "Remember CCS message"
8952
8953run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8954 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008955 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8956 hs_timeout=2500-60000" \
8957 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8958 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008959 0 \
8960 -C "Buffering HS message" \
8961 -C "Next handshake message has been buffered - load"\
8962 -S "Buffering HS message" \
8963 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008964 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008965 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008966 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008967 -S "Remember CCS message"
8968
8969run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8970 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008971 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8972 hs_timeout=2500-60000" \
8973 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8974 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008975 0 \
8976 -C "Buffering HS message" \
8977 -C "Next handshake message has been buffered - load"\
8978 -S "Buffering HS message" \
8979 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008980 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008981 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008982 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008983 -s "Remember CCS message"
8984
Hanno Beckera1adcca2018-08-24 14:41:07 +01008985run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008986 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008987 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8988 hs_timeout=2500-60000" \
8989 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8990 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008991 0 \
8992 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008993 -s "Found buffered record from current epoch - load" \
8994 -c "Buffer record from epoch 1" \
8995 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008996
Hanno Beckera1adcca2018-08-24 14:41:07 +01008997# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8998# from the server are delayed, so that the encrypted Finished message
8999# is received and buffered. When the fragmented NewSessionTicket comes
9000# in afterwards, the encrypted Finished message must be freed in order
9001# to make space for the NewSessionTicket to be reassembled.
9002# This works only in very particular circumstances:
9003# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
9004# of the NewSessionTicket, but small enough to also allow buffering of
9005# the encrypted Finished message.
9006# - The MTU setting on the server must be so small that the NewSessionTicket
9007# needs to be fragmented.
9008# - All messages sent by the server must be small enough to be either sent
9009# without fragmentation or be reassembled within the bounds of
9010# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
9011# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02009012requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
9013requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01009014run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
9015 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02009016 "$P_SRV mtu=140 response_size=90 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01009017 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
9018 0 \
9019 -s "Buffer record from epoch 1" \
9020 -s "Found buffered record from current epoch - load" \
9021 -c "Buffer record from epoch 1" \
9022 -C "Found buffered record from current epoch - load" \
9023 -c "Enough space available after freeing future epoch record"
9024
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02009025# Tests for "randomly unreliable connection": try a variety of flows and peers
9026
9027client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02009028run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
9029 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009030 "$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 +02009031 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009032 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009033 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9034 0 \
9035 -s "Extra-header:" \
9036 -c "HTTP/1.0 200 OK"
9037
Janos Follath74537a62016-09-02 13:45:28 +01009038client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009039run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
9040 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009041 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
9042 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009043 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
9044 0 \
9045 -s "Extra-header:" \
9046 -c "HTTP/1.0 200 OK"
9047
Janos Follath74537a62016-09-02 13:45:28 +01009048client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009049run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
9050 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009051 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
9052 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009053 0 \
9054 -s "Extra-header:" \
9055 -c "HTTP/1.0 200 OK"
9056
Janos Follath74537a62016-09-02 13:45:28 +01009057client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009058run_test "DTLS proxy: 3d, FS, client auth" \
9059 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009060 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
9061 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009062 0 \
9063 -s "Extra-header:" \
9064 -c "HTTP/1.0 200 OK"
9065
Janos Follath74537a62016-09-02 13:45:28 +01009066client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009067run_test "DTLS proxy: 3d, FS, ticket" \
9068 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009069 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
9070 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009071 0 \
9072 -s "Extra-header:" \
9073 -c "HTTP/1.0 200 OK"
9074
Janos Follath74537a62016-09-02 13:45:28 +01009075client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02009076run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
9077 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009078 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
9079 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02009080 0 \
9081 -s "Extra-header:" \
9082 -c "HTTP/1.0 200 OK"
9083
Janos Follath74537a62016-09-02 13:45:28 +01009084client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009085run_test "DTLS proxy: 3d, max handshake, nbio" \
9086 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009087 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009088 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009089 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009090 0 \
9091 -s "Extra-header:" \
9092 -c "HTTP/1.0 200 OK"
9093
Janos Follath74537a62016-09-02 13:45:28 +01009094client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009095run_test "DTLS proxy: 3d, min handshake, resumption" \
9096 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009097 "$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 +02009098 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009099 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009100 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02009101 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9102 0 \
9103 -s "a session has been resumed" \
9104 -c "a session has been resumed" \
9105 -s "Extra-header:" \
9106 -c "HTTP/1.0 200 OK"
9107
Janos Follath74537a62016-09-02 13:45:28 +01009108client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009109run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
9110 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009111 "$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 +02009112 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009113 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01009114 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02009115 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
9116 0 \
9117 -s "a session has been resumed" \
9118 -c "a session has been resumed" \
9119 -s "Extra-header:" \
9120 -c "HTTP/1.0 200 OK"
9121
Janos Follath74537a62016-09-02 13:45:28 +01009122client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009123requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009124run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009125 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009126 "$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 +02009127 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009128 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009129 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02009130 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9131 0 \
9132 -c "=> renegotiate" \
9133 -s "=> renegotiate" \
9134 -s "Extra-header:" \
9135 -c "HTTP/1.0 200 OK"
9136
Janos Follath74537a62016-09-02 13:45:28 +01009137client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009138requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009139run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
9140 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009141 "$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 +02009142 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009143 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02009144 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009145 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9146 0 \
9147 -c "=> renegotiate" \
9148 -s "=> renegotiate" \
9149 -s "Extra-header:" \
9150 -c "HTTP/1.0 200 OK"
9151
Janos Follath74537a62016-09-02 13:45:28 +01009152client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009153requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009154run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009155 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009156 "$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 +02009157 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009158 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009159 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009160 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009161 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9162 0 \
9163 -c "=> renegotiate" \
9164 -s "=> renegotiate" \
9165 -s "Extra-header:" \
9166 -c "HTTP/1.0 200 OK"
9167
Janos Follath74537a62016-09-02 13:45:28 +01009168client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01009169requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009170run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009171 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009172 "$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 +02009173 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009174 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009175 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02009176 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02009177 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
9178 0 \
9179 -c "=> renegotiate" \
9180 -s "=> renegotiate" \
9181 -s "Extra-header:" \
9182 -c "HTTP/1.0 200 OK"
9183
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009184## Interop tests with OpenSSL might trigger a bug in recent versions (including
9185## all versions installed on the CI machines), reported here:
9186## Bug report: https://github.com/openssl/openssl/issues/6902
9187## They should be re-enabled once a fixed version of OpenSSL is available
9188## (this should happen in some 1.1.1_ release according to the ticket).
9189skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01009190client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009191not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009192run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009193 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9194 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009195 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009196 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02009197 -c "HTTP/1.0 200 OK"
9198
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009199skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009200client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009201not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009202run_test "DTLS proxy: 3d, openssl server, fragmentation" \
9203 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9204 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009205 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009206 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009207 -c "HTTP/1.0 200 OK"
9208
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02009209skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01009210client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009211not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009212run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
9213 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
9214 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009215 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009216 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009217 -c "HTTP/1.0 200 OK"
9218
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00009219requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01009220client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009221not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009222run_test "DTLS proxy: 3d, gnutls server" \
9223 -p "$P_PXY drop=5 delay=5 duplicate=5" \
9224 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009225 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009226 0 \
9227 -s "Extra-header:" \
9228 -c "Extra-header:"
9229
k-stachowiak17a38d32019-02-18 15:29:56 +01009230requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009231client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009232not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009233run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
9234 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009235 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009236 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02009237 0 \
9238 -s "Extra-header:" \
9239 -c "Extra-header:"
9240
k-stachowiak17a38d32019-02-18 15:29:56 +01009241requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01009242client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02009243not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009244run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
9245 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01009246 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04009247 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02009248 0 \
9249 -s "Extra-header:" \
9250 -c "Extra-header:"
9251
Ron Eldorf75e2522019-05-14 20:38:49 +03009252requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
9253run_test "export keys functionality" \
9254 "$P_SRV eap_tls=1 debug_level=3" \
9255 "$P_CLI eap_tls=1 debug_level=3" \
9256 0 \
9257 -s "exported maclen is " \
9258 -s "exported keylen is " \
9259 -s "exported ivlen is " \
9260 -c "exported maclen is " \
9261 -c "exported keylen is " \
Ron Eldor65d8c262019-06-04 13:05:36 +03009262 -c "exported ivlen is " \
9263 -c "EAP-TLS key material is:"\
9264 -s "EAP-TLS key material is:"\
9265 -c "EAP-TLS IV is:" \
9266 -s "EAP-TLS IV is:"
Ron Eldorf75e2522019-05-14 20:38:49 +03009267
Piotr Nowicki0937ed22019-11-26 16:32:40 +01009268# Test heap memory usage after handshake
9269requires_config_enabled MBEDTLS_MEMORY_DEBUG
9270requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
9271requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
9272run_tests_memory_after_hanshake
9273
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01009274# Final report
9275
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009276echo "------------------------------------------------------------------------"
9277
9278if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009279 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009280else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01009281 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009282fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02009283PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02009284echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01009285
9286exit $FAILS