blob: 81cb774e7aec49deb3e081ff1759f11d21d9a35b [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 Peskine9fa4ed62020-08-26 22:35:46 +0200117 printf " -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
118 printf " -e|--exclude\tMatching tests are excluded (substring or 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
David Horstmann95d516f2021-05-04 18:36:56 +0100377MAX_CONTENT_LEN=16384
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200378MAX_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"
Gilles Peskine231befa2020-08-26 20:05:11 +0200429 printf "%s " "$LINE"
Paul Bakkere20310a2016-05-10 11:18:17 +0100430 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
Dave Rodgman0279c2f2021-02-10 12:45:41 +0000655# check if the given command uses gnutls and sets global variable CMD_IS_GNUTLS
656is_gnutls() {
657 case "$1" in
658 *gnutls-cli*)
659 CMD_IS_GNUTLS=1
660 ;;
661 *gnutls-serv*)
662 CMD_IS_GNUTLS=1
663 ;;
664 *)
665 CMD_IS_GNUTLS=0
666 ;;
667 esac
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100668}
669
Johan Pascal9bc50b02020-09-24 12:01:13 +0200670# Compare file content
671# Usage: find_in_both pattern file1 file2
672# extract from file1 the first line matching the pattern
673# check in file2 that the same line can be found
674find_in_both() {
675 srv_pattern=$(grep -m 1 "$1" "$2");
676 if [ -z "$srv_pattern" ]; then
677 return 1;
678 fi
679
680 if grep "$srv_pattern" $3 >/dev/null; then :
Johan Pascal10403152020-10-09 20:43:51 +0200681 return 0;
Johan Pascal9bc50b02020-09-24 12:01:13 +0200682 else
683 return 1;
684 fi
685}
686
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200687# Usage: run_test name [-p proxy_cmd] srv_cmd cli_cmd cli_exit [option [...]]
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100688# Options: -s pattern pattern that must be present in server output
689# -c pattern pattern that must be present in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100690# -u pattern lines after pattern must be unique in client output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100691# -f call shell function on client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100692# -S pattern pattern that must be absent in server output
693# -C pattern pattern that must be absent in client output
Simon Butcher8e004102016-10-14 00:48:33 +0100694# -U pattern lines after pattern must be unique in server output
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100695# -F call shell function on server output
Johan Pascal9bc50b02020-09-24 12:01:13 +0200696# -g call shell function on server and client output
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100697run_test() {
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100698 NAME="$1"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200699 shift 1
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100700
Gilles Peskine9fa4ed62020-08-26 22:35:46 +0200701 if is_excluded "$NAME"; then
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +0200702 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200703 # There was no request to run the test, so don't record its outcome.
Manuel Pégourié-Gonnard417d46c2014-03-13 19:17:53 +0100704 return
705 fi
706
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100707 print_name "$NAME"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100708
Paul Bakkerb7584a52016-05-10 10:50:43 +0100709 # Do we only run numbered tests?
Gilles Peskine64457492020-08-26 21:53:33 +0200710 if [ -n "$RUN_TEST_NUMBER" ]; then
711 case ",$RUN_TEST_NUMBER," in
712 *",$TESTS,"*) :;;
713 *) SKIP_NEXT="YES";;
714 esac
Paul Bakkerb7584a52016-05-10 10:50:43 +0100715 fi
716
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200717 # does this test use a proxy?
718 if [ "X$1" = "X-p" ]; then
719 PXY_CMD="$2"
720 shift 2
721 else
722 PXY_CMD=""
723 fi
724
725 # get commands and client output
726 SRV_CMD="$1"
727 CLI_CMD="$2"
728 CLI_EXPECT="$3"
729 shift 3
730
Hanno Becker91e72c32019-05-10 14:38:42 +0100731 # Check if test uses files
Gilles Peskine64457492020-08-26 21:53:33 +0200732 case "$SRV_CMD $CLI_CMD" in
733 *data_files/*)
734 requires_config_enabled MBEDTLS_FS_IO;;
735 esac
Hanno Becker91e72c32019-05-10 14:38:42 +0100736
Gilles Peskine0d721652020-06-26 23:35:53 +0200737 # If the client or serve requires a ciphersuite, check that it's enabled.
738 maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
739 maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
Hanno Becker9d76d562018-11-16 17:27:29 +0000740
741 # should we skip?
742 if [ "X$SKIP_NEXT" = "XYES" ]; then
743 SKIP_NEXT="NO"
Gilles Peskine560280b2019-09-16 15:17:38 +0200744 record_outcome "SKIP"
Hanno Becker9d76d562018-11-16 17:27:29 +0000745 SKIPS=$(( $SKIPS + 1 ))
746 return
747 fi
748
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +0200749 # update DTLS variable
750 detect_dtls "$SRV_CMD"
751
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200752 # if the test uses DTLS but no custom proxy, add a simple proxy
753 # as it provides timing info that's useful to debug failures
Manuel Pégourié-Gonnard70fce982020-06-25 09:54:46 +0200754 if [ -z "$PXY_CMD" ] && [ "$DTLS" -eq 1 ]; then
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200755 PXY_CMD="$P_PXY"
Manuel Pégourié-Gonnard8779e9a2020-07-16 10:19:32 +0200756 case " $SRV_CMD " in
757 *' server_addr=::1 '*)
758 PXY_CMD="$PXY_CMD server_addr=::1 listen_addr=::1";;
759 esac
Manuel Pégourié-Gonnardf4557862020-06-08 11:40:06 +0200760 fi
761
Dave Rodgman0279c2f2021-02-10 12:45:41 +0000762 # update CMD_IS_GNUTLS variable
763 is_gnutls "$SRV_CMD"
764
765 # if the server uses gnutls but doesn't set priority, explicitly
766 # set the default priority
767 if [ "$CMD_IS_GNUTLS" -eq 1 ]; then
768 case "$SRV_CMD" in
769 *--priority*) :;;
770 *) SRV_CMD="$SRV_CMD --priority=NORMAL";;
771 esac
772 fi
773
774 # update CMD_IS_GNUTLS variable
775 is_gnutls "$CLI_CMD"
776
777 # if the client uses gnutls but doesn't set priority, explicitly
778 # set the default priority
779 if [ "$CMD_IS_GNUTLS" -eq 1 ]; then
780 case "$CLI_CMD" in
781 *--priority*) :;;
782 *) CLI_CMD="$CLI_CMD --priority=NORMAL";;
783 esac
784 fi
785
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100786 # fix client port
787 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +0200788 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g )
789 else
790 CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$SRV_PORT/g )
791 fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +0200792
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100793 # prepend valgrind to our commands if active
794 if [ "$MEMCHECK" -gt 0 ]; then
795 if is_polar "$SRV_CMD"; then
796 SRV_CMD="valgrind --leak-check=full $SRV_CMD"
797 fi
798 if is_polar "$CLI_CMD"; then
799 CLI_CMD="valgrind --leak-check=full $CLI_CMD"
800 fi
801 fi
802
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200803 TIMES_LEFT=2
804 while [ $TIMES_LEFT -gt 0 ]; do
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200805 TIMES_LEFT=$(( $TIMES_LEFT - 1 ))
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200806
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200807 # run the commands
808 if [ -n "$PXY_CMD" ]; then
Manuel Pégourié-Gonnarda3b994f2020-07-27 09:45:32 +0200809 printf "# %s\n%s\n" "$NAME" "$PXY_CMD" > $PXY_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200810 $PXY_CMD >> $PXY_OUT 2>&1 &
811 PXY_PID=$!
Unknownd364f4c2019-09-02 10:42:57 -0400812 wait_proxy_start "$PXY_PORT" "$PXY_PID"
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200813 fi
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200814
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200815 check_osrv_dtls
Gilles Peskine231befa2020-08-26 20:05:11 +0200816 printf '# %s\n%s\n' "$NAME" "$SRV_CMD" > $SRV_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200817 provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
818 SRV_PID=$!
Gilles Peskine418b5362017-12-14 18:58:42 +0100819 wait_server_start "$SRV_PORT" "$SRV_PID"
Manuel Pégourié-Gonnardc0f6a692014-08-30 22:41:47 +0200820
Gilles Peskine231befa2020-08-26 20:05:11 +0200821 printf '# %s\n%s\n' "$NAME" "$CLI_CMD" > $CLI_OUT
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200822 eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
823 wait_client_done
Manuel Pégourié-Gonnarde01af4c2014-03-25 14:16:44 +0100824
Hanno Beckercadb5bb2017-05-26 13:56:10 +0100825 sleep 0.05
826
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200827 # terminate the server (and the proxy)
828 kill $SRV_PID
829 wait $SRV_PID
Gilles Peskine7f919de2021-02-02 23:29:03 +0100830 SRV_RET=$?
Hanno Beckerd82d8462017-05-29 21:37:46 +0100831
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200832 if [ -n "$PXY_CMD" ]; then
833 kill $PXY_PID >/dev/null 2>&1
834 wait $PXY_PID
835 fi
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100836
Manuel Pégourié-Gonnardab5f7b42015-08-04 21:01:37 +0200837 # retry only on timeouts
838 if grep '===CLIENT_TIMEOUT===' $CLI_OUT >/dev/null; then
839 printf "RETRY "
840 else
841 TIMES_LEFT=0
842 fi
Manuel Pégourié-Gonnarda365add2015-08-04 20:57:59 +0200843 done
844
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100845 # check if the client and server went at least to the handshake stage
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200846 # (useful to avoid tests with only negative assertions and non-zero
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100847 # expected client exit to incorrectly succeed in case of catastrophic
848 # failure)
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100849 if is_polar "$SRV_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200850 if grep "Performing the SSL/TLS handshake" $SRV_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100851 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100852 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100853 return
854 fi
855 fi
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100856 if is_polar "$CLI_CMD"; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200857 if grep "Performing the SSL/TLS handshake" $CLI_OUT >/dev/null; then :;
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100858 else
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +0100859 fail "server or client failed to reach handshake stage"
Manuel Pégourié-Gonnard677884d2014-02-25 16:42:31 +0100860 return
861 fi
862 fi
863
Gilles Peskineaaf866e2021-02-09 21:01:33 +0100864 # Check server exit code (only for Mbed TLS: GnuTLS and OpenSSL don't
865 # exit with status 0 when interrupted by a signal, and we don't really
866 # care anyway), in case e.g. the server reports a memory leak.
867 if [ $SRV_RET != 0 ] && is_polar "$SRV_CMD"; then
Gilles Peskine7f919de2021-02-02 23:29:03 +0100868 fail "Server exited with status $SRV_RET"
Manuel Pégourié-Gonnardf8bdbb52014-02-21 09:20:14 +0100869 return
870 fi
871
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100872 # check client exit code
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +0100873 if [ \( "$CLI_EXPECT" = 0 -a "$CLI_EXIT" != 0 \) -o \
874 \( "$CLI_EXPECT" != 0 -a "$CLI_EXIT" = 0 \) ]
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +0100875 then
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200876 fail "bad client exit code (expected $CLI_EXPECT, got $CLI_EXIT)"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100877 return
878 fi
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100879
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100880 # check other assertions
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +0200881 # lines beginning with == are added by valgrind, ignore them
Paul Bakker1f650922016-05-13 10:16:46 +0100882 # lines with 'Serious error when reading debug info', are valgrind issues as well
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100883 while [ $# -gt 0 ]
884 do
885 case $1 in
886 "-s")
Paul Bakker1f650922016-05-13 10:16:46 +0100887 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 +0100888 fail "pattern '$2' MUST be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100889 return
890 fi
891 ;;
892
893 "-c")
Paul Bakker1f650922016-05-13 10:16:46 +0100894 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 +0100895 fail "pattern '$2' MUST be present in the Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100896 return
897 fi
898 ;;
899
900 "-S")
Paul Bakker1f650922016-05-13 10:16:46 +0100901 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 +0100902 fail "pattern '$2' MUST NOT be present in the Server output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100903 return
904 fi
905 ;;
906
907 "-C")
Paul Bakker1f650922016-05-13 10:16:46 +0100908 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 +0100909 fail "pattern '$2' MUST NOT be present in the Client output"
910 return
911 fi
912 ;;
913
914 # The filtering in the following two options (-u and -U) do the following
915 # - ignore valgrind output
Antonin Décimo36e89b52019-01-23 15:24:37 +0100916 # - filter out everything but lines right after the pattern occurrences
Simon Butcher8e004102016-10-14 00:48:33 +0100917 # - keep one of each non-unique line
918 # - count how many lines remain
919 # A line with '--' will remain in the result from previous outputs, so the number of lines in the result will be 1
920 # if there were no duplicates.
921 "-U")
922 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
923 fail "lines following pattern '$2' must be unique in Server output"
924 return
925 fi
926 ;;
927
928 "-u")
929 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
930 fail "lines following pattern '$2' must be unique in Client output"
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100931 return
932 fi
933 ;;
Andres Amaya Garcia93993de2017-09-06 15:38:07 +0100934 "-F")
935 if ! $2 "$SRV_OUT"; then
936 fail "function call to '$2' failed on Server output"
937 return
938 fi
939 ;;
940 "-f")
941 if ! $2 "$CLI_OUT"; then
942 fail "function call to '$2' failed on Client output"
943 return
944 fi
945 ;;
Johan Pascal9bc50b02020-09-24 12:01:13 +0200946 "-g")
947 if ! eval "$2 '$SRV_OUT' '$CLI_OUT'"; then
948 fail "function call to '$2' failed on Server and Client output"
949 return
950 fi
951 ;;
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100952
953 *)
Paul Bakker1ebc0c52014-05-22 15:47:58 +0200954 echo "Unknown test: $1" >&2
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100955 exit 1
956 esac
957 shift 2
958 done
959
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100960 # check valgrind's results
961 if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200962 if is_polar "$SRV_CMD" && has_mem_err $SRV_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100963 fail "Server has memory errors"
964 return
965 fi
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +0200966 if is_polar "$CLI_CMD" && has_mem_err $CLI_OUT; then
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +0100967 fail "Client has memory errors"
968 return
969 fi
970 fi
971
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100972 # if we're here, everything is ok
Gilles Peskine560280b2019-09-16 15:17:38 +0200973 record_outcome "PASS"
Paul Bakkeracaac852016-05-10 11:47:13 +0100974 if [ "$PRESERVE_LOGS" -gt 0 ]; then
975 mv $SRV_OUT o-srv-${TESTS}.log
976 mv $CLI_OUT o-cli-${TESTS}.log
Hanno Becker7be2e5b2018-08-20 12:21:35 +0100977 if [ -n "$PXY_CMD" ]; then
978 mv $PXY_OUT o-pxy-${TESTS}.log
979 fi
Paul Bakkeracaac852016-05-10 11:47:13 +0100980 fi
981
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +0200982 rm -f $SRV_OUT $CLI_OUT $PXY_OUT
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +0100983}
984
Hanno Becker9b5853c2018-11-16 17:28:40 +0000985run_test_psa() {
986 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
Hanno Beckere9420c22018-11-20 11:37:34 +0000987 run_test "PSA-supported ciphersuite: $1" \
Hanno Becker4c8c7aa2019-04-10 09:25:41 +0100988 "$P_SRV debug_level=3 force_version=tls1_2" \
989 "$P_CLI debug_level=3 force_version=tls1_2 force_ciphersuite=$1" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000990 0 \
991 -c "Successfully setup PSA-based decryption cipher context" \
992 -c "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500993 -c "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500994 -c "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000995 -s "Successfully setup PSA-based decryption cipher context" \
996 -s "Successfully setup PSA-based encryption cipher context" \
Andrzej Kurek683d77e2019-01-30 03:50:42 -0500997 -s "PSA calc verify" \
Andrzej Kurek92dd4d02019-01-30 04:10:19 -0500998 -s "calc PSA finished" \
Hanno Becker9b5853c2018-11-16 17:28:40 +0000999 -C "Failed to setup PSA-based cipher context"\
1000 -S "Failed to setup PSA-based cipher context"\
1001 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +00001002 -c "Perform PSA-based ECDH computation."\
Andrzej Kureke85414e2019-01-15 05:23:59 -05001003 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Hanno Becker9b5853c2018-11-16 17:28:40 +00001004 -S "error" \
1005 -C "error"
1006}
1007
Hanno Becker354e2482019-01-08 11:40:25 +00001008run_test_psa_force_curve() {
1009 requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1010 run_test "PSA - ECDH with $1" \
Gilles Peskine12b5b382021-06-02 10:00:42 +02001011 "$P_SRV debug_level=4 force_version=tls1_2 curves=$1" \
Hanno Becker354e2482019-01-08 11:40:25 +00001012 "$P_CLI debug_level=4 force_version=tls1_2 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 curves=$1" \
1013 0 \
Hanno Becker28f78442019-02-18 16:47:50 +00001014 -c "Successfully setup PSA-based decryption cipher context" \
1015 -c "Successfully setup PSA-based encryption cipher context" \
1016 -c "PSA calc verify" \
1017 -c "calc PSA finished" \
1018 -s "Successfully setup PSA-based decryption cipher context" \
1019 -s "Successfully setup PSA-based encryption cipher context" \
1020 -s "PSA calc verify" \
1021 -s "calc PSA finished" \
1022 -C "Failed to setup PSA-based cipher context"\
1023 -S "Failed to setup PSA-based cipher context"\
Hanno Becker354e2482019-01-08 11:40:25 +00001024 -s "Protocol is TLSv1.2" \
Hanno Becker28f78442019-02-18 16:47:50 +00001025 -c "Perform PSA-based ECDH computation."\
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001026 -c "Perform PSA-based computation of digest of ServerKeyExchange" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001027 -S "error" \
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001028 -C "error"
1029}
1030
Piotr Nowicki0937ed22019-11-26 16:32:40 +01001031# Test that the server's memory usage after a handshake is reduced when a client specifies
1032# a maximum fragment length.
1033# first argument ($1) is MFL for SSL client
1034# second argument ($2) is memory usage for SSL client with default MFL (16k)
1035run_test_memory_after_hanshake_with_mfl()
1036{
1037 # The test passes if the difference is around 2*(16k-MFL)
Gilles Peskine5b428d72020-08-26 21:52:23 +02001038 MEMORY_USAGE_LIMIT="$(( $2 - ( 2 * ( 16384 - $1 )) ))"
Piotr Nowicki0937ed22019-11-26 16:32:40 +01001039
1040 # Leave some margin for robustness
1041 MEMORY_USAGE_LIMIT="$(( ( MEMORY_USAGE_LIMIT * 110 ) / 100 ))"
1042
1043 run_test "Handshake memory usage (MFL $1)" \
1044 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
1045 "$P_CLI debug_level=3 force_version=tls1_2 \
1046 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1047 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM max_frag_len=$1" \
1048 0 \
1049 -F "handshake_memory_check $MEMORY_USAGE_LIMIT"
1050}
1051
1052
1053# Test that the server's memory usage after a handshake is reduced when a client specifies
1054# different values of Maximum Fragment Length: default (16k), 4k, 2k, 1k and 512 bytes
1055run_tests_memory_after_hanshake()
1056{
1057 # all tests in this sequence requires the same configuration (see requires_config_enabled())
1058 SKIP_THIS_TESTS="$SKIP_NEXT"
1059
1060 # first test with default MFU is to get reference memory usage
1061 MEMORY_USAGE_MFL_16K=0
1062 run_test "Handshake memory usage initial (MFL 16384 - default)" \
1063 "$P_SRV debug_level=3 auth_mode=required force_version=tls1_2" \
1064 "$P_CLI debug_level=3 force_version=tls1_2 \
1065 crt_file=data_files/server5.crt key_file=data_files/server5.key \
1066 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM" \
1067 0 \
1068 -F "handshake_memory_get MEMORY_USAGE_MFL_16K"
1069
1070 SKIP_NEXT="$SKIP_THIS_TESTS"
1071 run_test_memory_after_hanshake_with_mfl 4096 "$MEMORY_USAGE_MFL_16K"
1072
1073 SKIP_NEXT="$SKIP_THIS_TESTS"
1074 run_test_memory_after_hanshake_with_mfl 2048 "$MEMORY_USAGE_MFL_16K"
1075
1076 SKIP_NEXT="$SKIP_THIS_TESTS"
1077 run_test_memory_after_hanshake_with_mfl 1024 "$MEMORY_USAGE_MFL_16K"
1078
1079 SKIP_NEXT="$SKIP_THIS_TESTS"
1080 run_test_memory_after_hanshake_with_mfl 512 "$MEMORY_USAGE_MFL_16K"
1081}
1082
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001083cleanup() {
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001084 rm -f $CLI_OUT $SRV_OUT $PXY_OUT $SESSION
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001085 rm -f context_srv.txt
1086 rm -f context_cli.txt
Manuel Pégourié-Gonnarda6189f02014-09-20 13:15:43 +02001087 test -n "${SRV_PID:-}" && kill $SRV_PID >/dev/null 2>&1
1088 test -n "${PXY_PID:-}" && kill $PXY_PID >/dev/null 2>&1
1089 test -n "${CLI_PID:-}" && kill $CLI_PID >/dev/null 2>&1
1090 test -n "${DOG_PID:-}" && kill $DOG_PID >/dev/null 2>&1
Manuel Pégourié-Gonnarda9062e92014-02-25 16:21:22 +01001091 exit 1
1092}
1093
Manuel Pégourié-Gonnard9dea8bd2014-02-26 18:21:02 +01001094#
1095# MAIN
1096#
1097
Manuel Pégourié-Gonnard913030c2014-03-28 10:12:38 +01001098get_options "$@"
1099
Gilles Peskine9fa4ed62020-08-26 22:35:46 +02001100# Optimize filters: if $FILTER and $EXCLUDE can be expressed as shell
1101# patterns rather than regular expressions, use a case statement instead
1102# of calling grep. To keep the optimizer simple, it is incomplete and only
1103# detects simple cases: plain substring, everything, nothing.
1104#
1105# As an exception, the character '.' is treated as an ordinary character
1106# if it is the only special character in the string. This is because it's
1107# rare to need "any one character", but needing a literal '.' is common
1108# (e.g. '-f "DTLS 1.2"').
1109need_grep=
1110case "$FILTER" in
1111 '^$') simple_filter=;;
1112 '.*') simple_filter='*';;
Gilles Peskineb09e0012020-09-29 23:48:39 +02001113 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskine9fa4ed62020-08-26 22:35:46 +02001114 need_grep=1;;
1115 *) # No regexp or shell-pattern special character
1116 simple_filter="*$FILTER*";;
1117esac
1118case "$EXCLUDE" in
1119 '^$') simple_exclude=;;
1120 '.*') simple_exclude='*';;
Gilles Peskineb09e0012020-09-29 23:48:39 +02001121 *[][$+*?\\^{\|}]*) # Regexp special characters (other than .), we need grep
Gilles Peskine9fa4ed62020-08-26 22:35:46 +02001122 need_grep=1;;
1123 *) # No regexp or shell-pattern special character
1124 simple_exclude="*$EXCLUDE*";;
1125esac
1126if [ -n "$need_grep" ]; then
1127 is_excluded () {
1128 ! echo "$1" | grep "$FILTER" | grep -q -v "$EXCLUDE"
1129 }
1130else
1131 is_excluded () {
1132 case "$1" in
1133 $simple_exclude) true;;
1134 $simple_filter) false;;
1135 *) true;;
1136 esac
1137 }
1138fi
1139
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001140# sanity checks, avoid an avalanche of errors
Hanno Becker4ac73e72017-10-23 15:27:37 +01001141P_SRV_BIN="${P_SRV%%[ ]*}"
1142P_CLI_BIN="${P_CLI%%[ ]*}"
1143P_PXY_BIN="${P_PXY%%[ ]*}"
Hanno Becker17c04932017-10-10 14:44:53 +01001144if [ ! -x "$P_SRV_BIN" ]; then
1145 echo "Command '$P_SRV_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001146 exit 1
1147fi
Hanno Becker17c04932017-10-10 14:44:53 +01001148if [ ! -x "$P_CLI_BIN" ]; then
1149 echo "Command '$P_CLI_BIN' is not an executable file"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001150 exit 1
1151fi
Hanno Becker17c04932017-10-10 14:44:53 +01001152if [ ! -x "$P_PXY_BIN" ]; then
1153 echo "Command '$P_PXY_BIN' is not an executable file"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001154 exit 1
1155fi
Simon Butcher3c0d7b82016-05-23 11:13:17 +01001156if [ "$MEMCHECK" -gt 0 ]; then
1157 if which valgrind >/dev/null 2>&1; then :; else
1158 echo "Memcheck not possible. Valgrind not found"
1159 exit 1
1160 fi
1161fi
Manuel Pégourié-Gonnard74faf3c2014-03-13 18:47:44 +01001162if which $OPENSSL_CMD >/dev/null 2>&1; then :; else
1163 echo "Command '$OPENSSL_CMD' not found"
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01001164 exit 1
1165fi
1166
Manuel Pégourié-Gonnard32f8f4d2014-05-29 11:31:20 +02001167# used by watchdog
1168MAIN_PID="$$"
1169
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001170# We use somewhat arbitrary delays for tests:
1171# - how long do we wait for the server to start (when lsof not available)?
1172# - how long do we allow for the client to finish?
1173# (not to check performance, just to avoid waiting indefinitely)
1174# Things are slower with valgrind, so give extra time here.
1175#
1176# Note: without lsof, there is a trade-off between the running time of this
1177# script and the risk of spurious errors because we didn't wait long enough.
1178# The watchdog delay on the other hand doesn't affect normal running time of
1179# the script, only the case where a client or server gets stuck.
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001180if [ "$MEMCHECK" -gt 0 ]; then
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001181 START_DELAY=6
1182 DOG_DELAY=60
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001183else
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001184 START_DELAY=2
1185 DOG_DELAY=20
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001186fi
Manuel Pégourié-Gonnard0d225da2018-01-22 10:22:09 +01001187
1188# some particular tests need more time:
1189# - for the client, we multiply the usual watchdog limit by a factor
1190# - for the server, we sleep for a number of seconds after the client exits
1191# see client_need_more_time() and server_needs_more_time()
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02001192CLI_DELAY_FACTOR=1
Janos Follath74537a62016-09-02 13:45:28 +01001193SRV_DELAY_SECONDS=0
Manuel Pégourié-Gonnard0c1ec472014-06-20 18:41:11 +02001194
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02001195# fix commands to use this port, force IPv4 while at it
Manuel Pégourié-Gonnard0af1ba32015-01-21 11:44:33 +00001196# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001197P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
1198P_CLI="$P_CLI server_addr=127.0.0.1 server_port=+SRV_PORT"
Andres AGf04f54d2016-10-10 15:46:20 +01001199P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 listen_port=$PXY_PORT ${SEED:+"seed=$SEED"}"
Gilles Peskine96f5bae2021-04-01 14:00:11 +02001200O_SRV="$O_SRV -accept $SRV_PORT"
Johan Pascal43f94902020-09-22 12:25:52 +02001201O_CLI="$O_CLI -connect localhost:+SRV_PORT"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001202G_SRV="$G_SRV -p $SRV_PORT"
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001203G_CLI="$G_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard8066b812014-05-28 22:59:30 +02001204
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001205if [ -n "${OPENSSL_LEGACY:-}" ]; then
1206 O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem"
1207 O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT"
1208fi
1209
Hanno Becker58e9dc32018-08-17 15:53:21 +01001210if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001211 G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT"
1212fi
1213
Hanno Becker58e9dc32018-08-17 15:53:21 +01001214if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02001215 G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02001216fi
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001217
Gilles Peskine62469d92017-05-10 10:13:59 +02001218# Allow SHA-1, because many of our test certificates use it
1219P_SRV="$P_SRV allow_sha1=1"
1220P_CLI="$P_CLI allow_sha1=1"
1221
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001222# Also pick a unique name for intermediate files
1223SRV_OUT="srv_out.$$"
1224CLI_OUT="cli_out.$$"
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02001225PXY_OUT="pxy_out.$$"
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02001226SESSION="session.$$"
1227
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02001228SKIP_NEXT="NO"
1229
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01001230trap cleanup INT TERM HUP
1231
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001232# Basic test
1233
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001234# Checks that:
1235# - things work with all ciphersuites active (used with config-full in all.sh)
Gilles Peskine799eee62021-06-02 22:14:15 +02001236# - the expected parameters are selected
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001237# ("signature_algorithm ext: 6" means SHA-512 (highest common hash))
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001238run_test "Default" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001239 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001240 "$P_CLI" \
1241 0 \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001242 -s "Protocol is TLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001243 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001244 -s "client hello v3, signature_algorithm ext: 6" \
Gilles Peskine799eee62021-06-02 22:14:15 +02001245 -s "ECDHE curve: x25519" \
Manuel Pégourié-Gonnard480905d2014-08-21 19:38:32 +02001246 -S "error" \
1247 -C "error"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001248
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001249run_test "Default, DTLS" \
1250 "$P_SRV dtls=1" \
1251 "$P_CLI dtls=1" \
1252 0 \
1253 -s "Protocol is DTLSv1.2" \
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001254 -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256"
Manuel Pégourié-Gonnard3bb08012015-01-22 13:34:21 +00001255
Hanno Becker721f7c12020-08-17 12:17:32 +01001256run_test "TLS client auth: required" \
1257 "$P_SRV auth_mode=required" \
1258 "$P_CLI" \
1259 0 \
1260 -s "Verifying peer X.509 certificate... ok"
1261
Hanno Becker2f54a3c2020-08-17 12:14:06 +01001262requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1263requires_config_enabled MBEDTLS_ECDSA_C
1264requires_config_enabled MBEDTLS_SHA256_C
1265run_test "TLS: password protected client key" \
1266 "$P_SRV auth_mode=required" \
1267 "$P_CLI crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
1268 0
1269
1270requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1271requires_config_enabled MBEDTLS_ECDSA_C
1272requires_config_enabled MBEDTLS_SHA256_C
1273run_test "TLS: password protected server key" \
1274 "$P_SRV crt_file=data_files/server5.crt key_file=data_files/server5.key.enc key_pwd=PolarSSLTest" \
1275 "$P_CLI" \
1276 0
1277
1278requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1279requires_config_enabled MBEDTLS_ECDSA_C
1280requires_config_enabled MBEDTLS_RSA_C
1281requires_config_enabled MBEDTLS_SHA256_C
1282run_test "TLS: password protected server key, two certificates" \
1283 "$P_SRV \
1284 key_file=data_files/server5.key.enc key_pwd=PolarSSLTest crt_file=data_files/server5.crt \
1285 key_file2=data_files/server2.key.enc key_pwd2=PolarSSLTest crt_file2=data_files/server2.crt" \
1286 "$P_CLI" \
1287 0
1288
Hanno Becker746aaf32019-03-28 15:25:23 +00001289requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1290run_test "CA callback on client" \
1291 "$P_SRV debug_level=3" \
1292 "$P_CLI ca_callback=1 debug_level=3 " \
1293 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001294 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001295 -S "error" \
1296 -C "error"
1297
1298requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1299requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1300requires_config_enabled MBEDTLS_ECDSA_C
1301requires_config_enabled MBEDTLS_SHA256_C
1302run_test "CA callback on server" \
1303 "$P_SRV auth_mode=required" \
1304 "$P_CLI ca_callback=1 debug_level=3 crt_file=data_files/server5.crt \
1305 key_file=data_files/server5.key" \
1306 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01001307 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00001308 -s "Verifying peer X.509 certificate... ok" \
1309 -S "error" \
1310 -C "error"
1311
Manuel Pégourié-Gonnardcfdf8f42018-11-08 09:52:25 +01001312# Test using an opaque private key for client authentication
1313requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
1314requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
1315requires_config_enabled MBEDTLS_ECDSA_C
1316requires_config_enabled MBEDTLS_SHA256_C
1317run_test "Opaque key for client authentication" \
1318 "$P_SRV auth_mode=required" \
1319 "$P_CLI key_opaque=1 crt_file=data_files/server5.crt \
1320 key_file=data_files/server5.key" \
1321 0 \
1322 -c "key type: Opaque" \
1323 -s "Verifying peer X.509 certificate... ok" \
1324 -S "error" \
1325 -C "error"
1326
Hanno Becker9b5853c2018-11-16 17:28:40 +00001327# Test ciphersuites which we expect to be fully supported by PSA Crypto
1328# and check that we don't fall back to Mbed TLS' internal crypto primitives.
1329run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM
1330run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8
1331run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM
1332run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8
1333run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
1334run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
1335run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
1336run_test_psa TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
1337run_test_psa TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
1338
Hanno Becker354e2482019-01-08 11:40:25 +00001339requires_config_enabled MBEDTLS_ECP_DP_SECP521R1_ENABLED
1340run_test_psa_force_curve "secp521r1"
1341requires_config_enabled MBEDTLS_ECP_DP_BP512R1_ENABLED
1342run_test_psa_force_curve "brainpoolP512r1"
1343requires_config_enabled MBEDTLS_ECP_DP_SECP384R1_ENABLED
1344run_test_psa_force_curve "secp384r1"
1345requires_config_enabled MBEDTLS_ECP_DP_BP384R1_ENABLED
1346run_test_psa_force_curve "brainpoolP384r1"
1347requires_config_enabled MBEDTLS_ECP_DP_SECP256R1_ENABLED
1348run_test_psa_force_curve "secp256r1"
1349requires_config_enabled MBEDTLS_ECP_DP_SECP256K1_ENABLED
1350run_test_psa_force_curve "secp256k1"
1351requires_config_enabled MBEDTLS_ECP_DP_BP256R1_ENABLED
1352run_test_psa_force_curve "brainpoolP256r1"
1353requires_config_enabled MBEDTLS_ECP_DP_SECP224R1_ENABLED
1354run_test_psa_force_curve "secp224r1"
Gilles Peskinedefdc3b2021-03-23 13:59:58 +01001355## SECP224K1 is buggy via the PSA API
1356## (https://github.com/ARMmbed/mbedtls/issues/3541),
1357## so it is disabled in PSA even when it's enabled in Mbed TLS.
1358## The proper dependency would be on PSA_WANT_ECC_SECP_K1_224 but
1359## dependencies on PSA symbols in ssl-opt.sh are not implemented yet.
1360#requires_config_enabled MBEDTLS_ECP_DP_SECP224K1_ENABLED
1361#run_test_psa_force_curve "secp224k1"
Hanno Becker354e2482019-01-08 11:40:25 +00001362requires_config_enabled MBEDTLS_ECP_DP_SECP192R1_ENABLED
1363run_test_psa_force_curve "secp192r1"
1364requires_config_enabled MBEDTLS_ECP_DP_SECP192K1_ENABLED
1365run_test_psa_force_curve "secp192k1"
1366
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001367# Test current time in ServerHello
1368requires_config_enabled MBEDTLS_HAVE_TIME
Manuel Pégourié-Gonnardce66d5e2018-06-14 11:11:15 +02001369run_test "ServerHello contains gmt_unix_time" \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001370 "$P_SRV debug_level=3" \
1371 "$P_CLI debug_level=3" \
1372 0 \
Andres Amaya Garciab84c40b2017-09-06 15:44:01 +01001373 -f "check_server_hello_time" \
1374 -F "check_server_hello_time"
1375
Simon Butcher8e004102016-10-14 00:48:33 +01001376# Test for uniqueness of IVs in AEAD ciphersuites
1377run_test "Unique IV in GCM" \
1378 "$P_SRV exchanges=20 debug_level=4" \
1379 "$P_CLI exchanges=20 debug_level=4 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
1380 0 \
1381 -u "IV used" \
1382 -U "IV used"
1383
Janos Follathee11be62019-04-04 12:03:30 +01001384# Tests for certificate verification callback
1385run_test "Configuration-specific CRT verification callback" \
1386 "$P_SRV debug_level=3" \
1387 "$P_CLI context_crt_cb=0 debug_level=3" \
1388 0 \
Janos Follathee11be62019-04-04 12:03:30 +01001389 -S "error" \
1390 -c "Verify requested for " \
1391 -c "Use configuration-specific verification callback" \
1392 -C "Use context-specific verification callback" \
1393 -C "error"
1394
Hanno Beckerefb440a2019-04-03 13:04:33 +01001395run_test "Context-specific CRT verification callback" \
1396 "$P_SRV debug_level=3" \
1397 "$P_CLI context_crt_cb=1 debug_level=3" \
1398 0 \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001399 -S "error" \
Janos Follathee11be62019-04-04 12:03:30 +01001400 -c "Verify requested for " \
1401 -c "Use context-specific verification callback" \
1402 -C "Use configuration-specific verification callback" \
Hanno Beckerefb440a2019-04-03 13:04:33 +01001403 -C "error"
1404
Gilles Peskinebc70a182017-05-09 15:59:24 +02001405# Tests for SHA-1 support
Gilles Peskinebc70a182017-05-09 15:59:24 +02001406run_test "SHA-1 forbidden by default in server certificate" \
1407 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1408 "$P_CLI debug_level=2 allow_sha1=0" \
1409 1 \
1410 -c "The certificate is signed with an unacceptable hash"
1411
1412run_test "SHA-1 explicitly allowed in server certificate" \
1413 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
1414 "$P_CLI allow_sha1=1" \
1415 0
1416
1417run_test "SHA-256 allowed by default in server certificate" \
1418 "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
1419 "$P_CLI allow_sha1=0" \
1420 0
1421
1422run_test "SHA-1 forbidden by default in client certificate" \
1423 "$P_SRV auth_mode=required allow_sha1=0" \
1424 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1425 1 \
1426 -s "The certificate is signed with an unacceptable hash"
1427
1428run_test "SHA-1 explicitly allowed in client certificate" \
1429 "$P_SRV auth_mode=required allow_sha1=1" \
1430 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
1431 0
1432
1433run_test "SHA-256 allowed by default in client certificate" \
1434 "$P_SRV auth_mode=required allow_sha1=0" \
1435 "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
1436 0
1437
Hanno Becker7ae8a762018-08-14 15:43:35 +01001438# Tests for datagram packing
1439run_test "DTLS: multiple records in same datagram, client and server" \
1440 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1441 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1442 0 \
1443 -c "next record in same datagram" \
1444 -s "next record in same datagram"
1445
1446run_test "DTLS: multiple records in same datagram, client only" \
1447 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1448 "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \
1449 0 \
1450 -s "next record in same datagram" \
1451 -C "next record in same datagram"
1452
1453run_test "DTLS: multiple records in same datagram, server only" \
1454 "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \
1455 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1456 0 \
1457 -S "next record in same datagram" \
1458 -c "next record in same datagram"
1459
1460run_test "DTLS: multiple records in same datagram, neither client nor server" \
1461 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
1462 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
1463 0 \
1464 -S "next record in same datagram" \
1465 -C "next record in same datagram"
1466
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001467# Tests for Truncated HMAC extension
1468
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001469run_test "Truncated HMAC: client default, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001470 "$P_SRV debug_level=4" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001471 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001472 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001473 -s "dumping 'expected mac' (20 bytes)" \
1474 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01001475
Hanno Becker32c55012017-11-10 08:42:54 +00001476requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001477run_test "Truncated HMAC: client disabled, server default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02001478 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001479 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Manuel Pégourié-Gonnardeaadc502014-02-20 11:01:30 +01001480 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001481 -s "dumping 'expected mac' (20 bytes)" \
1482 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001483
Hanno Becker32c55012017-11-10 08:42:54 +00001484requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001485run_test "Truncated HMAC: client enabled, server default" \
1486 "$P_SRV debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001487 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001488 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001489 -s "dumping 'expected mac' (20 bytes)" \
1490 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001491
Hanno Becker32c55012017-11-10 08:42:54 +00001492requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001493run_test "Truncated HMAC: client enabled, server disabled" \
1494 "$P_SRV debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001495 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001496 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001497 -s "dumping 'expected mac' (20 bytes)" \
1498 -S "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001499
Hanno Becker32c55012017-11-10 08:42:54 +00001500requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001501run_test "Truncated HMAC: client disabled, server enabled" \
1502 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001503 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker34d0c3f2017-11-17 15:46:24 +00001504 0 \
1505 -s "dumping 'expected mac' (20 bytes)" \
1506 -S "dumping 'expected mac' (10 bytes)"
1507
1508requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001509run_test "Truncated HMAC: client enabled, server enabled" \
1510 "$P_SRV debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001511 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnarde117a8f2015-01-09 12:39:35 +01001512 0 \
Hanno Becker992b6872017-11-09 18:57:39 +00001513 -S "dumping 'expected mac' (20 bytes)" \
1514 -s "dumping 'expected mac' (10 bytes)"
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001515
Hanno Becker4c4f4102017-11-10 09:16:05 +00001516run_test "Truncated HMAC, DTLS: client default, server default" \
1517 "$P_SRV dtls=1 debug_level=4" \
1518 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
1519 0 \
1520 -s "dumping 'expected mac' (20 bytes)" \
1521 -S "dumping 'expected mac' (10 bytes)"
1522
1523requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1524run_test "Truncated HMAC, DTLS: client disabled, server default" \
1525 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001526 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001527 0 \
1528 -s "dumping 'expected mac' (20 bytes)" \
1529 -S "dumping 'expected mac' (10 bytes)"
1530
1531requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1532run_test "Truncated HMAC, DTLS: client enabled, server default" \
1533 "$P_SRV dtls=1 debug_level=4" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001534 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001535 0 \
1536 -s "dumping 'expected mac' (20 bytes)" \
1537 -S "dumping 'expected mac' (10 bytes)"
1538
1539requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1540run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
1541 "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001542 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001543 0 \
1544 -s "dumping 'expected mac' (20 bytes)" \
1545 -S "dumping 'expected mac' (10 bytes)"
1546
1547requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1548run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
1549 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001550 "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
Hanno Becker4c4f4102017-11-10 09:16:05 +00001551 0 \
1552 -s "dumping 'expected mac' (20 bytes)" \
1553 -S "dumping 'expected mac' (10 bytes)"
1554
1555requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
1556run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
1557 "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
Hanno Becker909f9a32017-11-21 17:10:12 +00001558 "$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 +01001559 0 \
1560 -S "dumping 'expected mac' (20 bytes)" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01001561 -s "dumping 'expected mac' (10 bytes)"
1562
Jarno Lamsa2937d812019-06-04 11:33:23 +03001563# Tests for Context serialization
1564
1565requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001566run_test "Context serialization, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001567 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001568 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1569 0 \
1570 -c "Deserializing connection..." \
1571 -S "Deserializing connection..."
1572
1573requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1574run_test "Context serialization, client serializes, ChaChaPoly" \
1575 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1576 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1577 0 \
1578 -c "Deserializing connection..." \
1579 -S "Deserializing connection..."
1580
1581requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1582run_test "Context serialization, client serializes, GCM" \
1583 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1584 "$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 +03001585 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001586 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001587 -S "Deserializing connection..."
1588
1589requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001590requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1591run_test "Context serialization, client serializes, with CID" \
1592 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1593 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1594 0 \
1595 -c "Deserializing connection..." \
1596 -S "Deserializing connection..."
1597
1598requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001599run_test "Context serialization, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001600 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001601 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1602 0 \
1603 -C "Deserializing connection..." \
1604 -s "Deserializing connection..."
1605
1606requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1607run_test "Context serialization, server serializes, ChaChaPoly" \
1608 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1609 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1610 0 \
1611 -C "Deserializing connection..." \
1612 -s "Deserializing connection..."
1613
1614requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1615run_test "Context serialization, server serializes, GCM" \
1616 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1617 "$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 +03001618 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001619 -C "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001620 -s "Deserializing connection..."
1621
1622requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001623requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1624run_test "Context serialization, server serializes, with CID" \
1625 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1626 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1627 0 \
1628 -C "Deserializing connection..." \
1629 -s "Deserializing connection..."
1630
1631requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001632run_test "Context serialization, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001633 "$P_SRV dtls=1 serialize=1 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001634 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1635 0 \
1636 -c "Deserializing connection..." \
1637 -s "Deserializing connection..."
1638
1639requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1640run_test "Context serialization, both serialize, ChaChaPoly" \
1641 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1642 "$P_CLI dtls=1 serialize=1 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1643 0 \
1644 -c "Deserializing connection..." \
1645 -s "Deserializing connection..."
1646
1647requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1648run_test "Context serialization, both serialize, GCM" \
1649 "$P_SRV dtls=1 serialize=1 exchanges=2" \
1650 "$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 +03001651 0 \
Jarno Lamsacbee1b32019-06-04 15:18:19 +03001652 -c "Deserializing connection..." \
Jarno Lamsa2937d812019-06-04 11:33:23 +03001653 -s "Deserializing connection..."
1654
Jarno Lamsac2376f02019-06-06 10:44:14 +03001655requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001656requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1657run_test "Context serialization, both serialize, with CID" \
1658 "$P_SRV dtls=1 serialize=1 exchanges=2 cid=1 cid_val=dead" \
1659 "$P_CLI dtls=1 serialize=1 exchanges=2 cid=1 cid_val=beef" \
1660 0 \
1661 -c "Deserializing connection..." \
1662 -s "Deserializing connection..."
1663
1664requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001665run_test "Context serialization, re-init, client serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001666 "$P_SRV dtls=1 serialize=0 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001667 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1668 0 \
1669 -c "Deserializing connection..." \
1670 -S "Deserializing connection..."
1671
1672requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1673run_test "Context serialization, re-init, client serializes, ChaChaPoly" \
1674 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1675 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1676 0 \
1677 -c "Deserializing connection..." \
1678 -S "Deserializing connection..."
1679
1680requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1681run_test "Context serialization, re-init, client serializes, GCM" \
1682 "$P_SRV dtls=1 serialize=0 exchanges=2" \
1683 "$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 +03001684 0 \
1685 -c "Deserializing connection..." \
1686 -S "Deserializing connection..."
1687
Jarno Lamsac2376f02019-06-06 10:44:14 +03001688requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001689requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1690run_test "Context serialization, re-init, client serializes, with CID" \
1691 "$P_SRV dtls=1 serialize=0 exchanges=2 cid=1 cid_val=dead" \
1692 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1693 0 \
1694 -c "Deserializing connection..." \
1695 -S "Deserializing connection..."
1696
1697requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001698run_test "Context serialization, re-init, server serializes, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001699 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001700 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1701 0 \
1702 -C "Deserializing connection..." \
1703 -s "Deserializing connection..."
1704
1705requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1706run_test "Context serialization, re-init, server serializes, ChaChaPoly" \
1707 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1708 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1709 0 \
1710 -C "Deserializing connection..." \
1711 -s "Deserializing connection..."
1712
1713requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1714run_test "Context serialization, re-init, server serializes, GCM" \
1715 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1716 "$P_CLI dtls=1 serialize=0 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001717 0 \
1718 -C "Deserializing connection..." \
1719 -s "Deserializing connection..."
1720
Jarno Lamsac2376f02019-06-06 10:44:14 +03001721requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Becker1b18fd32019-08-30 11:18:59 +01001722requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1723run_test "Context serialization, re-init, server serializes, with CID" \
1724 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1725 "$P_CLI dtls=1 serialize=0 exchanges=2 cid=1 cid_val=beef" \
1726 0 \
1727 -C "Deserializing connection..." \
1728 -s "Deserializing connection..."
1729
1730requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001731run_test "Context serialization, re-init, both serialize, CCM" \
Manuel Pégourié-Gonnard862b3192019-07-23 14:13:43 +02001732 "$P_SRV dtls=1 serialize=2 exchanges=2" \
Hanno Beckere0b90ec2019-08-30 11:32:12 +01001733 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1734 0 \
1735 -c "Deserializing connection..." \
1736 -s "Deserializing connection..."
1737
1738requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1739run_test "Context serialization, re-init, both serialize, ChaChaPoly" \
1740 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1741 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
1742 0 \
1743 -c "Deserializing connection..." \
1744 -s "Deserializing connection..."
1745
1746requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1747run_test "Context serialization, re-init, both serialize, GCM" \
1748 "$P_SRV dtls=1 serialize=2 exchanges=2" \
1749 "$P_CLI dtls=1 serialize=2 exchanges=2 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256" \
Jarno Lamsac2376f02019-06-06 10:44:14 +03001750 0 \
1751 -c "Deserializing connection..." \
1752 -s "Deserializing connection..."
1753
Hanno Becker1b18fd32019-08-30 11:18:59 +01001754requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1755requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
1756run_test "Context serialization, re-init, both serialize, with CID" \
1757 "$P_SRV dtls=1 serialize=2 exchanges=2 cid=1 cid_val=dead" \
1758 "$P_CLI dtls=1 serialize=2 exchanges=2 cid=1 cid_val=beef" \
1759 0 \
1760 -c "Deserializing connection..." \
1761 -s "Deserializing connection..."
1762
Piotr Nowicki3de298f2020-04-16 14:35:19 +02001763requires_config_enabled MBEDTLS_SSL_CONTEXT_SERIALIZATION
1764run_test "Saving the serialized context to a file" \
1765 "$P_SRV dtls=1 serialize=1 context_file=context_srv.txt" \
1766 "$P_CLI dtls=1 serialize=1 context_file=context_cli.txt" \
1767 0 \
1768 -s "Save serialized context to a file... ok" \
1769 -c "Save serialized context to a file... ok"
1770rm -f context_srv.txt
1771rm -f context_cli.txt
1772
Hanno Becker7cf463e2019-04-09 18:08:47 +01001773# Tests for DTLS Connection ID extension
1774
Hanno Becker7cf463e2019-04-09 18:08:47 +01001775# So far, the CID API isn't implemented, so we can't
1776# grep for output witnessing its use. This needs to be
1777# changed once the CID extension is implemented.
1778
Hanno Beckera0e20d02019-05-15 14:03:01 +01001779requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001780run_test "Connection ID: Cli enabled, Srv disabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001781 "$P_SRV debug_level=3 dtls=1 cid=0" \
1782 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1783 0 \
1784 -s "Disable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001785 -s "found CID extension" \
1786 -s "Client sent CID extension, but CID disabled" \
Hanno Becker6b78c832019-04-25 17:01:43 +01001787 -c "Enable use of CID extension." \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001788 -c "client hello, adding CID extension" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001789 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001790 -C "found CID extension" \
1791 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001792 -C "Copy CIDs into SSL transform" \
1793 -c "Use of Connection ID was rejected by the server"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001794
Hanno Beckera0e20d02019-05-15 14:03:01 +01001795requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001796run_test "Connection ID: Cli disabled, Srv enabled" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001797 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1798 "$P_CLI debug_level=3 dtls=1 cid=0" \
1799 0 \
1800 -c "Disable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001801 -C "client hello, adding CID extension" \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001802 -S "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001803 -s "Enable use of CID extension." \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001804 -S "server hello, adding CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001805 -C "found CID extension" \
1806 -S "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01001807 -C "Copy CIDs into SSL transform" \
Hanno Beckerb3e9dd52019-05-08 13:19:53 +01001808 -s "Use of Connection ID was not offered by client"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001809
Hanno Beckera0e20d02019-05-15 14:03:01 +01001810requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001811run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001812 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1813 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef" \
1814 0 \
1815 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001816 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001817 -c "client hello, adding CID extension" \
1818 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001819 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001820 -s "server hello, adding CID extension" \
1821 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001822 -c "Use of CID extension negotiated" \
1823 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001824 -c "Copy CIDs into SSL transform" \
1825 -c "Peer CID (length 2 Bytes): de ad" \
1826 -s "Peer CID (length 2 Bytes): be ef" \
1827 -s "Use of Connection ID has been negotiated" \
1828 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001829
Hanno Beckera0e20d02019-05-15 14:03:01 +01001830requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001831run_test "Connection ID, 3D: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001832 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001833 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead" \
1834 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef" \
1835 0 \
1836 -c "Enable use of CID extension." \
1837 -s "Enable use of CID extension." \
1838 -c "client hello, adding CID extension" \
1839 -s "found CID extension" \
1840 -s "Use of CID extension negotiated" \
1841 -s "server hello, adding CID extension" \
1842 -c "found CID extension" \
1843 -c "Use of CID extension negotiated" \
1844 -s "Copy CIDs into SSL transform" \
1845 -c "Copy CIDs into SSL transform" \
1846 -c "Peer CID (length 2 Bytes): de ad" \
1847 -s "Peer CID (length 2 Bytes): be ef" \
1848 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001849 -c "Use of Connection ID has been negotiated" \
1850 -c "ignoring unexpected CID" \
1851 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001852
Hanno Beckera0e20d02019-05-15 14:03:01 +01001853requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001854run_test "Connection ID, MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
1855 -p "$P_PXY mtu=800" \
1856 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1857 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1858 0 \
1859 -c "Enable use of CID extension." \
1860 -s "Enable use of CID extension." \
1861 -c "client hello, adding CID extension" \
1862 -s "found CID extension" \
1863 -s "Use of CID extension negotiated" \
1864 -s "server hello, adding CID extension" \
1865 -c "found CID extension" \
1866 -c "Use of CID extension negotiated" \
1867 -s "Copy CIDs into SSL transform" \
1868 -c "Copy CIDs into SSL transform" \
1869 -c "Peer CID (length 2 Bytes): de ad" \
1870 -s "Peer CID (length 2 Bytes): be ef" \
1871 -s "Use of Connection ID has been negotiated" \
1872 -c "Use of Connection ID has been negotiated"
1873
Hanno Beckera0e20d02019-05-15 14:03:01 +01001874requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001875run_test "Connection ID, 3D+MTU: Cli+Srv enabled, Cli+Srv CID nonempty" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001876 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01001877 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead" \
1878 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef" \
1879 0 \
1880 -c "Enable use of CID extension." \
1881 -s "Enable use of CID extension." \
1882 -c "client hello, adding CID extension" \
1883 -s "found CID extension" \
1884 -s "Use of CID extension negotiated" \
1885 -s "server hello, adding CID extension" \
1886 -c "found CID extension" \
1887 -c "Use of CID extension negotiated" \
1888 -s "Copy CIDs into SSL transform" \
1889 -c "Copy CIDs into SSL transform" \
1890 -c "Peer CID (length 2 Bytes): de ad" \
1891 -s "Peer CID (length 2 Bytes): be ef" \
1892 -s "Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01001893 -c "Use of Connection ID has been negotiated" \
1894 -c "ignoring unexpected CID" \
1895 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01001896
Hanno Beckera0e20d02019-05-15 14:03:01 +01001897requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001898run_test "Connection ID: Cli+Srv enabled, Cli CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001899 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1900 "$P_CLI debug_level=3 dtls=1 cid=1" \
1901 0 \
1902 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001903 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001904 -c "client hello, adding CID extension" \
1905 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001906 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001907 -s "server hello, adding CID extension" \
1908 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001909 -c "Use of CID extension negotiated" \
1910 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001911 -c "Copy CIDs into SSL transform" \
1912 -c "Peer CID (length 4 Bytes): de ad be ef" \
1913 -s "Peer CID (length 0 Bytes):" \
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, Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001919 "$P_SRV debug_level=3 dtls=1 cid=1" \
1920 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
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 -s "Peer CID (length 4 Bytes): de ad be ef" \
1933 -c "Peer CID (length 0 Bytes):" \
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+Srv CID empty" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001939 "$P_SRV debug_level=3 dtls=1 cid=1" \
1940 "$P_CLI debug_level=3 dtls=1 cid=1" \
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 Beckerfcffdcc2019-04-26 17:19:46 +01001951 -c "Copy CIDs into SSL transform" \
1952 -S "Use of Connection ID has been negotiated" \
1953 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001954
Hanno Beckera0e20d02019-05-15 14:03:01 +01001955requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001956run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001957 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
1958 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1959 0 \
1960 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001961 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001962 -c "client hello, adding CID extension" \
1963 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001964 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001965 -s "server hello, adding CID extension" \
1966 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001967 -c "Use of CID extension negotiated" \
1968 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001969 -c "Copy CIDs into SSL transform" \
1970 -c "Peer CID (length 2 Bytes): de ad" \
1971 -s "Peer CID (length 2 Bytes): be ef" \
1972 -s "Use of Connection ID has been negotiated" \
1973 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01001974
Hanno Beckera0e20d02019-05-15 14:03:01 +01001975requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01001976run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001977 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
1978 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
1979 0 \
1980 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01001981 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01001982 -c "client hello, adding CID extension" \
1983 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01001984 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01001985 -s "server hello, adding CID extension" \
1986 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01001987 -c "Use of CID extension negotiated" \
1988 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01001989 -c "Copy CIDs into SSL transform" \
1990 -c "Peer CID (length 4 Bytes): de ad be ef" \
1991 -s "Peer CID (length 0 Bytes):" \
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, Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01001997 "$P_SRV debug_level=3 dtls=1 cid=1" \
1998 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
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 -s "Peer CID (length 4 Bytes): de ad be ef" \
2011 -c "Peer CID (length 0 Bytes):" \
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+Srv CID empty, AES-128-CCM-8" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002017 "$P_SRV debug_level=3 dtls=1 cid=1" \
2018 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" \
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 Beckerfcffdcc2019-04-26 17:19:46 +01002029 -c "Copy CIDs into SSL transform" \
2030 -S "Use of Connection ID has been negotiated" \
2031 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002032
Hanno Beckera0e20d02019-05-15 14:03:01 +01002033requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002034run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID nonempty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002035 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead" \
2036 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2037 0 \
2038 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002039 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002040 -c "client hello, adding CID extension" \
2041 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002042 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002043 -s "server hello, adding CID extension" \
2044 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002045 -c "Use of CID extension negotiated" \
2046 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002047 -c "Copy CIDs into SSL transform" \
2048 -c "Peer CID (length 2 Bytes): de ad" \
2049 -s "Peer CID (length 2 Bytes): be ef" \
2050 -s "Use of Connection ID has been negotiated" \
2051 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002052
Hanno Beckera0e20d02019-05-15 14:03:01 +01002053requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002054run_test "Connection ID: Cli+Srv enabled, Cli CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002055 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=deadbeef" \
2056 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2057 0 \
2058 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002059 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002060 -c "client hello, adding CID extension" \
2061 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002062 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002063 -s "server hello, adding CID extension" \
2064 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002065 -c "Use of CID extension negotiated" \
2066 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002067 -c "Copy CIDs into SSL transform" \
2068 -c "Peer CID (length 4 Bytes): de ad be ef" \
2069 -s "Peer CID (length 0 Bytes):" \
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 Becker78c91372019-05-08 13:31:15 +01002074run_test "Connection ID: Cli+Srv enabled, Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002075 "$P_SRV debug_level=3 dtls=1 cid=1" \
2076 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=deadbeef force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2077 0 \
2078 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002079 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002080 -c "client hello, adding CID extension" \
2081 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002082 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002083 -s "server hello, adding CID extension" \
2084 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002085 -c "Use of CID extension negotiated" \
2086 -s "Copy CIDs into SSL transform" \
Hanno Becker2749a672019-05-03 17:04:23 +01002087 -c "Copy CIDs into SSL transform" \
2088 -s "Peer CID (length 4 Bytes): de ad be ef" \
2089 -c "Peer CID (length 0 Bytes):" \
2090 -s "Use of Connection ID has been negotiated" \
2091 -c "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002092
Hanno Beckera0e20d02019-05-15 14:03:01 +01002093requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002094run_test "Connection ID: Cli+Srv enabled, Cli+Srv CID empty, AES-128-CBC" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002095 "$P_SRV debug_level=3 dtls=1 cid=1" \
2096 "$P_CLI debug_level=3 dtls=1 cid=1 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
2097 0 \
2098 -c "Enable use of CID extension." \
Hanno Becker6b78c832019-04-25 17:01:43 +01002099 -s "Enable use of CID extension." \
Hanno Becker7dee2c62019-04-26 14:17:56 +01002100 -c "client hello, adding CID extension" \
2101 -s "found CID extension" \
Hanno Becker4bc9e9d2019-04-26 16:00:29 +01002102 -s "Use of CID extension negotiated" \
Hanno Beckera6a4c762019-04-26 16:13:31 +01002103 -s "server hello, adding CID extension" \
2104 -c "found CID extension" \
Hanno Becker9ecb6c62019-04-26 16:23:52 +01002105 -c "Use of CID extension negotiated" \
2106 -s "Copy CIDs into SSL transform" \
Hanno Beckerfcffdcc2019-04-26 17:19:46 +01002107 -c "Copy CIDs into SSL transform" \
2108 -S "Use of Connection ID has been negotiated" \
2109 -C "Use of Connection ID has been negotiated"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002110
Hanno Beckera0e20d02019-05-15 14:03:01 +01002111requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker9bae30d2019-04-23 11:52:44 +01002112requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002113run_test "Connection ID: Cli+Srv enabled, renegotiate without change of CID" \
Hanno Beckerf157a972019-04-25 16:05:45 +01002114 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2115 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2116 0 \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002117 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2118 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2119 -s "(initial handshake) Use of Connection ID has been negotiated" \
2120 -c "(initial handshake) Use of Connection ID has been negotiated" \
2121 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2122 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2123 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2124 -c "(after renegotiation) Use of Connection ID has been negotiated"
2125
Hanno Beckera0e20d02019-05-15 14:03:01 +01002126requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002127requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002128run_test "Connection ID: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002129 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2130 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2131 0 \
2132 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2133 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2134 -s "(initial handshake) Use of Connection ID has been negotiated" \
2135 -c "(initial handshake) Use of Connection ID has been negotiated" \
2136 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2137 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2138 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2139 -c "(after renegotiation) Use of Connection ID has been negotiated"
2140
Hanno Beckera0e20d02019-05-15 14:03:01 +01002141requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002142requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002143run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate with different CID" \
2144 "$P_SRV debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=dead cid_val_renego=beef renegotiation=1" \
2145 "$P_CLI debug_level=3 dtls=1 cid=1 dgram_packing=0 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2146 0 \
2147 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2148 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2149 -s "(initial handshake) Use of Connection ID has been negotiated" \
2150 -c "(initial handshake) Use of Connection ID has been negotiated" \
2151 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2152 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2153 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2154 -c "(after renegotiation) Use of Connection ID has been negotiated"
2155
Hanno Beckera0e20d02019-05-15 14:03:01 +01002156requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002157requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002158run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate with different CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002159 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002160 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_val_renego=beef renegotiation=1" \
2161 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_val_renego=dead renegotiation=1 renegotiate=1" \
2162 0 \
2163 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2164 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2165 -s "(initial handshake) Use of Connection ID has been negotiated" \
2166 -c "(initial handshake) Use of Connection ID has been negotiated" \
2167 -c "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2168 -s "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2169 -s "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002170 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2171 -c "ignoring unexpected CID" \
2172 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002173
Hanno Beckera0e20d02019-05-15 14:03:01 +01002174requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002175requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2176run_test "Connection ID: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002177 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2178 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2179 0 \
2180 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2181 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2182 -s "(initial handshake) Use of Connection ID has been negotiated" \
2183 -c "(initial handshake) Use of Connection ID has been negotiated" \
2184 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2185 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2186 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2187 -S "(after renegotiation) Use of Connection ID has been negotiated"
2188
Hanno Beckera0e20d02019-05-15 14:03:01 +01002189requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002190requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002191run_test "Connection ID, no packing: Cli+Srv enabled, renegotiate without CID" \
2192 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2193 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2194 0 \
2195 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2196 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2197 -s "(initial handshake) Use of Connection ID has been negotiated" \
2198 -c "(initial handshake) Use of Connection ID has been negotiated" \
2199 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2200 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2201 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2202 -S "(after renegotiation) Use of Connection ID has been negotiated"
2203
Hanno Beckera0e20d02019-05-15 14:03:01 +01002204requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002205requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002206run_test "Connection ID, 3D+MTU: Cli+Srv enabled, renegotiate without CID" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002207 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002208 "$P_SRV debug_level=3 mtu=800 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2209 "$P_CLI debug_level=3 mtu=800 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2210 0 \
2211 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2212 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2213 -s "(initial handshake) Use of Connection ID has been negotiated" \
2214 -c "(initial handshake) Use of Connection ID has been negotiated" \
2215 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2216 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2217 -C "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002218 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2219 -c "ignoring unexpected CID" \
2220 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002221
Hanno Beckera0e20d02019-05-15 14:03:01 +01002222requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002223requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2224run_test "Connection ID: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002225 "$P_SRV debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2226 "$P_CLI debug_level=3 dtls=1 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2227 0 \
2228 -S "(initial handshake) Use of Connection ID has been negotiated" \
2229 -C "(initial handshake) Use of Connection ID has been negotiated" \
2230 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2231 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2232 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2233 -s "(after renegotiation) Use of Connection ID has been negotiated"
2234
Hanno Beckera0e20d02019-05-15 14:03:01 +01002235requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002236requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Beckerc2045b02019-05-08 16:20:46 +01002237run_test "Connection ID, no packing: Cli+Srv enabled, CID on renegotiation" \
2238 "$P_SRV debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2239 "$P_CLI debug_level=3 dtls=1 dgram_packing=0 cid=0 cid_renego=1 cid_val_renego=beef renegotiation=1 renegotiate=1" \
2240 0 \
2241 -S "(initial handshake) Use of Connection ID has been negotiated" \
2242 -C "(initial handshake) Use of Connection ID has been negotiated" \
2243 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2244 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2245 -c "(after renegotiation) Use of Connection ID has been negotiated" \
2246 -s "(after renegotiation) Use of Connection ID has been negotiated"
2247
Hanno Beckera0e20d02019-05-15 14:03:01 +01002248requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerc2045b02019-05-08 16:20:46 +01002249requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002250run_test "Connection ID, 3D+MTU: Cli+Srv enabled, CID on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002251 -p "$P_PXY mtu=800 drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002252 "$P_SRV debug_level=3 mtu=800 dtls=1 dgram_packing=1 cid=0 cid_renego=1 cid_val_renego=dead renegotiation=1" \
2253 "$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" \
2254 0 \
2255 -S "(initial handshake) Use of Connection ID has been negotiated" \
2256 -C "(initial handshake) Use of Connection ID has been negotiated" \
2257 -c "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2258 -s "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2259 -c "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002260 -s "(after renegotiation) Use of Connection ID has been negotiated" \
2261 -c "ignoring unexpected CID" \
2262 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002263
Hanno Beckera0e20d02019-05-15 14:03:01 +01002264requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002265requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2266run_test "Connection ID: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002267 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2268 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2269 0 \
2270 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2271 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2272 -s "(initial handshake) Use of Connection ID has been negotiated" \
2273 -c "(initial handshake) Use of Connection ID has been negotiated" \
2274 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2275 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2276 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2277 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2278 -s "(after renegotiation) Use of Connection ID was not offered by client"
2279
Hanno Beckera0e20d02019-05-15 14:03:01 +01002280requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002281requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Hanno Becker78c91372019-05-08 13:31:15 +01002282run_test "Connection ID, 3D: Cli+Srv enabled, Cli disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002283 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Becker78c91372019-05-08 13:31:15 +01002284 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead renegotiation=1" \
2285 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef cid_renego=0 renegotiation=1 renegotiate=1" \
2286 0 \
2287 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2288 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2289 -s "(initial handshake) Use of Connection ID has been negotiated" \
2290 -c "(initial handshake) Use of Connection ID has been negotiated" \
2291 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2292 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2293 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2294 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002295 -s "(after renegotiation) Use of Connection ID was not offered by client" \
2296 -c "ignoring unexpected CID" \
2297 -s "ignoring unexpected CID"
Hanno Becker78c91372019-05-08 13:31:15 +01002298
Hanno Beckera0e20d02019-05-15 14:03:01 +01002299requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002300requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2301run_test "Connection ID: Cli+Srv enabled, Srv disables on renegotiation" \
2302 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2303 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2304 0 \
2305 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2306 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2307 -s "(initial handshake) Use of Connection ID has been negotiated" \
2308 -c "(initial handshake) Use of Connection ID has been negotiated" \
2309 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2310 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2311 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2312 -S "(after renegotiation) Use of Connection ID has been negotiated" \
2313 -c "(after renegotiation) Use of Connection ID was rejected by the server"
2314
Hanno Beckera0e20d02019-05-15 14:03:01 +01002315requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
Hanno Becker78c91372019-05-08 13:31:15 +01002316requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
2317run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002318 -p "$P_PXY drop=5 delay=5 duplicate=5 bad_cid=1" \
Hanno Beckerb42ec0d2019-05-03 17:30:59 +01002319 "$P_SRV debug_level=3 dtls=1 cid=1 cid_val=dead cid_renego=0 renegotiation=1" \
2320 "$P_CLI debug_level=3 dtls=1 cid=1 cid_val=beef renegotiation=1 renegotiate=1" \
2321 0 \
2322 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2323 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2324 -s "(initial handshake) Use of Connection ID has been negotiated" \
2325 -c "(initial handshake) Use of Connection ID has been negotiated" \
2326 -C "(after renegotiation) Peer CID (length 2 Bytes): de ad" \
2327 -S "(after renegotiation) Peer CID (length 2 Bytes): be ef" \
2328 -C "(after renegotiation) Use of Connection ID has been negotiated" \
2329 -S "(after renegotiation) Use of Connection ID has been negotiated" \
Hanno Beckerd0ac5fa2019-05-24 10:11:23 +01002330 -c "(after renegotiation) Use of Connection ID was rejected by the server" \
2331 -c "ignoring unexpected CID" \
2332 -s "ignoring unexpected CID"
Hanno Becker7cf463e2019-04-09 18:08:47 +01002333
Andrzej Kurekb6577832020-06-08 07:08:03 -04002334requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2335requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2336run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
2337 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2338 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
2339 0 \
2340 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2341 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2342 -s "(initial handshake) Use of Connection ID has been negotiated" \
2343 -c "(initial handshake) Use of Connection ID has been negotiated" \
2344 -s "Reallocating in_buf" \
2345 -s "Reallocating out_buf"
2346
2347requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
2348requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2349run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
2350 "$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
2351 "$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
2352 0 \
2353 -c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
2354 -s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
2355 -s "(initial handshake) Use of Connection ID has been negotiated" \
2356 -c "(initial handshake) Use of Connection ID has been negotiated" \
2357 -s "Reallocating in_buf" \
2358 -s "Reallocating out_buf"
2359
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002360# Tests for Encrypt-then-MAC extension
2361
2362run_test "Encrypt then MAC: default" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002363 "$P_SRV debug_level=3 \
2364 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002365 "$P_CLI debug_level=3" \
2366 0 \
2367 -c "client hello, adding encrypt_then_mac extension" \
2368 -s "found encrypt then mac extension" \
2369 -s "server hello, adding encrypt then mac extension" \
2370 -c "found encrypt_then_mac extension" \
2371 -c "using encrypt then mac" \
2372 -s "using encrypt then mac"
2373
2374run_test "Encrypt then MAC: client enabled, server disabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002375 "$P_SRV debug_level=3 etm=0 \
2376 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002377 "$P_CLI debug_level=3 etm=1" \
2378 0 \
2379 -c "client hello, adding encrypt_then_mac extension" \
2380 -s "found encrypt then mac extension" \
2381 -S "server hello, adding encrypt then mac extension" \
2382 -C "found encrypt_then_mac extension" \
2383 -C "using encrypt then mac" \
2384 -S "using encrypt then mac"
2385
Manuel Pégourié-Gonnard78e745f2014-11-04 15:44:06 +01002386run_test "Encrypt then MAC: client enabled, aead cipher" \
2387 "$P_SRV debug_level=3 etm=1 \
2388 force_ciphersuite=TLS-RSA-WITH-AES-128-GCM-SHA256" \
2389 "$P_CLI debug_level=3 etm=1" \
2390 0 \
2391 -c "client hello, adding encrypt_then_mac extension" \
2392 -s "found encrypt then mac extension" \
2393 -S "server hello, adding encrypt then mac extension" \
2394 -C "found encrypt_then_mac extension" \
2395 -C "using encrypt then mac" \
2396 -S "using encrypt then mac"
2397
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002398run_test "Encrypt then MAC: client disabled, server enabled" \
Manuel Pégourié-Gonnard0098e7d2014-10-28 13:08:59 +01002399 "$P_SRV debug_level=3 etm=1 \
2400 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
Manuel Pégourié-Gonnard699cafa2014-10-27 13:57:03 +01002401 "$P_CLI debug_level=3 etm=0" \
2402 0 \
2403 -C "client hello, adding encrypt_then_mac extension" \
2404 -S "found encrypt then mac extension" \
2405 -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
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002445# Test sending and receiving empty application data records
2446
2447run_test "Encrypt then MAC: empty application data record" \
2448 "$P_SRV auth_mode=none debug_level=4 etm=1" \
2449 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA" \
2450 0 \
2451 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2452 -s "dumping 'input payload after decrypt' (0 bytes)" \
2453 -c "0 bytes written in 1 fragments"
2454
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002455run_test "Encrypt then MAC: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002456 "$P_SRV auth_mode=none debug_level=4 etm=0" \
2457 "$P_CLI auth_mode=none etm=0 request_size=0" \
2458 0 \
2459 -s "dumping 'input payload after decrypt' (0 bytes)" \
2460 -c "0 bytes written in 1 fragments"
2461
2462run_test "Encrypt then MAC, DTLS: empty application data record" \
2463 "$P_SRV auth_mode=none debug_level=4 etm=1 dtls=1" \
2464 "$P_CLI auth_mode=none etm=1 request_size=0 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA dtls=1" \
2465 0 \
2466 -S "0000: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f" \
2467 -s "dumping 'input payload after decrypt' (0 bytes)" \
2468 -c "0 bytes written in 1 fragments"
2469
Manuel Pégourié-Gonnard9e2c80f2020-03-24 10:53:39 +01002470run_test "Encrypt then MAC, DTLS: disabled, empty application data record" \
Andres Amaya Garcia4c761fa2018-07-10 20:08:04 +01002471 "$P_SRV auth_mode=none debug_level=4 etm=0 dtls=1" \
2472 "$P_CLI auth_mode=none etm=0 request_size=0 dtls=1" \
2473 0 \
2474 -s "dumping 'input payload after decrypt' (0 bytes)" \
2475 -c "0 bytes written in 1 fragments"
2476
Manuel Pégourié-Gonnard3ff78232015-01-08 11:15:09 +01002477# Tests for CBC 1/n-1 record splitting
2478
2479run_test "CBC Record splitting: TLS 1.2, no splitting" \
2480 "$P_SRV" \
2481 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
2482 request_size=123 force_version=tls1_2" \
2483 0 \
2484 -s "Read from client: 123 bytes read" \
2485 -S "Read from client: 1 bytes read" \
2486 -S "122 bytes read"
2487
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002488# Tests for Session Tickets
2489
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002490run_test "Session resume using tickets: basic" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002491 "$P_SRV debug_level=3 tickets=1" \
2492 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002493 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002494 -c "client hello, adding session ticket extension" \
2495 -s "found session ticket extension" \
2496 -s "server hello, adding session ticket extension" \
2497 -c "found session_ticket extension" \
2498 -c "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002499 -S "session successfully restored from cache" \
2500 -s "session successfully restored from ticket" \
2501 -s "a session has been resumed" \
2502 -c "a session has been resumed"
2503
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002504run_test "Session resume using tickets: cache disabled" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002505 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2506 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002507 0 \
2508 -c "client hello, adding session ticket extension" \
2509 -s "found session ticket extension" \
2510 -s "server hello, adding session ticket extension" \
2511 -c "found session_ticket extension" \
2512 -c "parse new session ticket" \
2513 -S "session successfully restored from cache" \
2514 -s "session successfully restored from ticket" \
2515 -s "a session has been resumed" \
2516 -c "a session has been resumed"
2517
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002518run_test "Session resume using tickets: timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002519 "$P_SRV debug_level=3 tickets=1 cache_max=0 ticket_timeout=1" \
2520 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnarddbe1ee12014-02-21 09:18:13 +01002521 0 \
2522 -c "client hello, adding session ticket extension" \
2523 -s "found session ticket extension" \
2524 -s "server hello, adding session ticket extension" \
2525 -c "found session_ticket extension" \
2526 -c "parse new session ticket" \
2527 -S "session successfully restored from cache" \
2528 -S "session successfully restored from ticket" \
2529 -S "a session has been resumed" \
2530 -C "a session has been resumed"
2531
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002532run_test "Session resume using tickets: session copy" \
2533 "$P_SRV debug_level=3 tickets=1 cache_max=0" \
2534 "$P_CLI debug_level=3 tickets=1 reconnect=1 reco_mode=0" \
2535 0 \
2536 -c "client hello, adding session ticket extension" \
2537 -s "found session ticket extension" \
2538 -s "server hello, adding session ticket extension" \
2539 -c "found session_ticket extension" \
2540 -c "parse new session ticket" \
2541 -S "session successfully restored from cache" \
2542 -s "session successfully restored from ticket" \
2543 -s "a session has been resumed" \
2544 -c "a session has been resumed"
2545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002546run_test "Session resume using tickets: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002547 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002548 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002549 0 \
2550 -c "client hello, adding session ticket extension" \
2551 -c "found session_ticket extension" \
2552 -c "parse new session ticket" \
2553 -c "a session has been resumed"
2554
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002555run_test "Session resume using tickets: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002556 "$P_SRV debug_level=3 tickets=1" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002557 "( $O_CLI -sess_out $SESSION; \
2558 $O_CLI -sess_in $SESSION; \
2559 rm -f $SESSION )" \
Manuel Pégourié-Gonnardfccd3252014-02-25 17:14:15 +01002560 0 \
2561 -s "found session ticket extension" \
2562 -s "server hello, adding session ticket extension" \
2563 -S "session successfully restored from cache" \
2564 -s "session successfully restored from ticket" \
2565 -s "a session has been resumed"
2566
Hanno Becker1d739932018-08-21 13:55:22 +01002567# Tests for Session Tickets with DTLS
2568
2569run_test "Session resume using tickets, DTLS: basic" \
2570 "$P_SRV debug_level=3 dtls=1 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002571 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002572 0 \
2573 -c "client hello, adding session ticket extension" \
2574 -s "found session ticket extension" \
2575 -s "server hello, adding session ticket extension" \
2576 -c "found session_ticket extension" \
2577 -c "parse new session ticket" \
2578 -S "session successfully restored from cache" \
2579 -s "session successfully restored from ticket" \
2580 -s "a session has been resumed" \
2581 -c "a session has been resumed"
2582
2583run_test "Session resume using tickets, DTLS: cache disabled" \
2584 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002585 "$P_CLI debug_level=3 dtls=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002586 0 \
2587 -c "client hello, adding session ticket extension" \
2588 -s "found session ticket extension" \
2589 -s "server hello, adding session ticket extension" \
2590 -c "found session_ticket extension" \
2591 -c "parse new session ticket" \
2592 -S "session successfully restored from cache" \
2593 -s "session successfully restored from ticket" \
2594 -s "a session has been resumed" \
2595 -c "a session has been resumed"
2596
2597run_test "Session resume using tickets, DTLS: timeout" \
2598 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0 ticket_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002599 "$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 +01002600 0 \
2601 -c "client hello, adding session ticket extension" \
2602 -s "found session ticket extension" \
2603 -s "server hello, adding session ticket extension" \
2604 -c "found session_ticket extension" \
2605 -c "parse new session ticket" \
2606 -S "session successfully restored from cache" \
2607 -S "session successfully restored from ticket" \
2608 -S "a session has been resumed" \
2609 -C "a session has been resumed"
2610
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002611run_test "Session resume using tickets, DTLS: session copy" \
2612 "$P_SRV debug_level=3 dtls=1 tickets=1 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002613 "$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 +02002614 0 \
2615 -c "client hello, adding session ticket extension" \
2616 -s "found session ticket extension" \
2617 -s "server hello, adding session ticket extension" \
2618 -c "found session_ticket extension" \
2619 -c "parse new session ticket" \
2620 -S "session successfully restored from cache" \
2621 -s "session successfully restored from ticket" \
2622 -s "a session has been resumed" \
2623 -c "a session has been resumed"
2624
TRodziewicz4ca18aa2021-05-20 14:46:20 +02002625run_test "Session resume using tickets, DTLS: openssl server" \
2626 "$O_SRV -dtls" \
2627 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1" \
2628 0 \
2629 -c "client hello, adding session ticket extension" \
2630 -c "found session_ticket extension" \
2631 -c "parse new session ticket" \
2632 -c "a session has been resumed"
2633
2634run_test "Session resume using tickets, DTLS: openssl client" \
2635 "$P_SRV dtls=1 debug_level=3 tickets=1" \
2636 "( $O_CLI -dtls -sess_out $SESSION; \
2637 $O_CLI -dtls -sess_in $SESSION; \
2638 rm -f $SESSION )" \
2639 0 \
2640 -s "found session ticket extension" \
2641 -s "server hello, adding session ticket extension" \
2642 -S "session successfully restored from cache" \
2643 -s "session successfully restored from ticket" \
2644 -s "a session has been resumed"
2645
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002646# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002647
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002648run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002649 "$P_SRV debug_level=3 tickets=0" \
2650 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002651 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002652 -c "client hello, adding session ticket extension" \
2653 -s "found session ticket extension" \
2654 -S "server hello, adding session ticket extension" \
2655 -C "found session_ticket extension" \
2656 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002657 -s "session successfully restored from cache" \
2658 -S "session successfully restored from ticket" \
2659 -s "a session has been resumed" \
2660 -c "a session has been resumed"
2661
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002662run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002663 "$P_SRV debug_level=3 tickets=1" \
2664 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002665 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002666 -C "client hello, adding session ticket extension" \
2667 -S "found session ticket extension" \
2668 -S "server hello, adding session ticket extension" \
2669 -C "found session_ticket extension" \
2670 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002671 -s "session successfully restored from cache" \
2672 -S "session successfully restored from ticket" \
2673 -s "a session has been resumed" \
2674 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002675
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002676run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002677 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2678 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002679 0 \
2680 -S "session successfully restored from cache" \
2681 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002682 -S "a session has been resumed" \
2683 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002684
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002685run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002686 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2687 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002688 0 \
2689 -s "session successfully restored from cache" \
2690 -S "session successfully restored from ticket" \
2691 -s "a session has been resumed" \
2692 -c "a session has been resumed"
2693
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002694run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002695 "$P_SRV debug_level=3 tickets=0" \
2696 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002697 0 \
2698 -s "session successfully restored from cache" \
2699 -S "session successfully restored from ticket" \
2700 -s "a session has been resumed" \
2701 -c "a session has been resumed"
2702
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002703run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002704 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2705 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002706 0 \
2707 -S "session successfully restored from cache" \
2708 -S "session successfully restored from ticket" \
2709 -S "a session has been resumed" \
2710 -C "a session has been resumed"
2711
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002712run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002713 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2714 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002715 0 \
2716 -s "session successfully restored from cache" \
2717 -S "session successfully restored from ticket" \
2718 -s "a session has been resumed" \
2719 -c "a session has been resumed"
2720
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002721run_test "Session resume using cache: session copy" \
2722 "$P_SRV debug_level=3 tickets=0" \
2723 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2724 0 \
2725 -s "session successfully restored from cache" \
2726 -S "session successfully restored from ticket" \
2727 -s "a session has been resumed" \
2728 -c "a session has been resumed"
2729
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002730run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002731 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002732 "( $O_CLI -sess_out $SESSION; \
2733 $O_CLI -sess_in $SESSION; \
2734 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002735 0 \
2736 -s "found session ticket extension" \
2737 -S "server hello, adding session ticket extension" \
2738 -s "session successfully restored from cache" \
2739 -S "session successfully restored from ticket" \
2740 -s "a session has been resumed"
2741
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002742run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002743 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002744 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002745 0 \
2746 -C "found session_ticket extension" \
2747 -C "parse new session ticket" \
2748 -c "a session has been resumed"
2749
Hanno Becker1d739932018-08-21 13:55:22 +01002750# Tests for Session Resume based on session-ID and cache, DTLS
2751
2752run_test "Session resume using cache, DTLS: tickets enabled on client" \
2753 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002754 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002755 0 \
2756 -c "client hello, adding session ticket extension" \
2757 -s "found session ticket extension" \
2758 -S "server hello, adding session ticket extension" \
2759 -C "found session_ticket extension" \
2760 -C "parse new session ticket" \
2761 -s "session successfully restored from cache" \
2762 -S "session successfully restored from ticket" \
2763 -s "a session has been resumed" \
2764 -c "a session has been resumed"
2765
2766run_test "Session resume using cache, DTLS: tickets enabled on server" \
2767 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002768 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002769 0 \
2770 -C "client hello, adding session ticket extension" \
2771 -S "found session ticket extension" \
2772 -S "server hello, adding session ticket extension" \
2773 -C "found session_ticket extension" \
2774 -C "parse new session ticket" \
2775 -s "session successfully restored from cache" \
2776 -S "session successfully restored from ticket" \
2777 -s "a session has been resumed" \
2778 -c "a session has been resumed"
2779
2780run_test "Session resume using cache, DTLS: cache_max=0" \
2781 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002782 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002783 0 \
2784 -S "session successfully restored from cache" \
2785 -S "session successfully restored from ticket" \
2786 -S "a session has been resumed" \
2787 -C "a session has been resumed"
2788
2789run_test "Session resume using cache, DTLS: cache_max=1" \
2790 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002791 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002792 0 \
2793 -s "session successfully restored from cache" \
2794 -S "session successfully restored from ticket" \
2795 -s "a session has been resumed" \
2796 -c "a session has been resumed"
2797
2798run_test "Session resume using cache, DTLS: timeout > delay" \
2799 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002800 "$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 +01002801 0 \
2802 -s "session successfully restored from cache" \
2803 -S "session successfully restored from ticket" \
2804 -s "a session has been resumed" \
2805 -c "a session has been resumed"
2806
2807run_test "Session resume using cache, DTLS: timeout < delay" \
2808 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002809 "$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 +01002810 0 \
2811 -S "session successfully restored from cache" \
2812 -S "session successfully restored from ticket" \
2813 -S "a session has been resumed" \
2814 -C "a session has been resumed"
2815
2816run_test "Session resume using cache, DTLS: no timeout" \
2817 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002818 "$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 +01002819 0 \
2820 -s "session successfully restored from cache" \
2821 -S "session successfully restored from ticket" \
2822 -s "a session has been resumed" \
2823 -c "a session has been resumed"
2824
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002825run_test "Session resume using cache, DTLS: session copy" \
2826 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002827 "$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 +02002828 0 \
2829 -s "session successfully restored from cache" \
2830 -S "session successfully restored from ticket" \
2831 -s "a session has been resumed" \
2832 -c "a session has been resumed"
2833
TRodziewicz4ca18aa2021-05-20 14:46:20 +02002834run_test "Session resume using cache, DTLS: openssl client" \
2835 "$P_SRV dtls=1 debug_level=3 tickets=0" \
2836 "( $O_CLI -dtls -sess_out $SESSION; \
2837 $O_CLI -dtls -sess_in $SESSION; \
2838 rm -f $SESSION )" \
2839 0 \
2840 -s "found session ticket extension" \
2841 -S "server hello, adding session ticket extension" \
2842 -s "session successfully restored from cache" \
2843 -S "session successfully restored from ticket" \
2844 -s "a session has been resumed"
2845
2846run_test "Session resume using cache, DTLS: openssl server" \
2847 "$O_SRV -dtls" \
2848 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1" \
2849 0 \
2850 -C "found session_ticket extension" \
2851 -C "parse new session ticket" \
2852 -c "a session has been resumed"
2853
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002854# Tests for Max Fragment Length extension
2855
David Horstmann95d516f2021-05-04 18:36:56 +01002856if [ "$MAX_IN_LEN" -lt "4096" ]; then
2857 printf '%s defines MBEDTLS_SSL_IN_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n' "${CONFIG_H}"
2858 exit 1
2859fi
2860
2861if [ "$MAX_OUT_LEN" -lt "4096" ]; then
2862 printf '%s defines MBEDTLS_SSL_OUT_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n' "${CONFIG_H}"
Hanno Becker6428f8d2017-09-22 16:58:50 +01002863 exit 1
2864fi
2865
Angus Grattonc4dd0732018-04-11 16:28:39 +10002866if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskine231befa2020-08-26 20:05:11 +02002867 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10002868fi
2869
Hanno Becker4aed27e2017-09-18 15:00:34 +01002870requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002871run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002872 "$P_SRV debug_level=3" \
2873 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002874 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01002875 -c "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
2876 -c "Maximum outgoing record payload length is $MAX_CONTENT_LEN" \
2877 -s "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
2878 -s "Maximum outgoing record payload length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002879 -C "client hello, adding max_fragment_length extension" \
2880 -S "found max fragment length extension" \
2881 -S "server hello, max_fragment_length extension" \
2882 -C "found max_fragment_length extension"
2883
Hanno Becker4aed27e2017-09-18 15:00:34 +01002884requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002885run_test "Max fragment length: enabled, default, larger message" \
2886 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002887 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002888 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01002889 -c "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
2890 -c "Maximum outgoing record payload length is $MAX_CONTENT_LEN" \
2891 -s "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
2892 -s "Maximum outgoing record payload length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002893 -C "client hello, adding max_fragment_length extension" \
2894 -S "found max fragment length extension" \
2895 -S "server hello, max_fragment_length extension" \
2896 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002897 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2898 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002899 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002900
2901requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2902run_test "Max fragment length, DTLS: enabled, default, larger message" \
2903 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002904 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002905 1 \
Hanno Becker59d36702021-06-08 05:35:29 +01002906 -c "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
2907 -c "Maximum outgoing record payload length is $MAX_CONTENT_LEN" \
2908 -s "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
2909 -s "Maximum outgoing record payload length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002910 -C "client hello, adding max_fragment_length extension" \
2911 -S "found max fragment length extension" \
2912 -S "server hello, max_fragment_length extension" \
2913 -C "found max_fragment_length extension" \
2914 -c "fragment larger than.*maximum "
2915
Angus Grattonc4dd0732018-04-11 16:28:39 +10002916# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2917# (session fragment length will be 16384 regardless of mbedtls
2918# content length configuration.)
2919
Hanno Beckerc5266962017-09-18 15:01:50 +01002920requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2921run_test "Max fragment length: disabled, larger message" \
2922 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002923 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002924 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01002925 -C "Maximum incoming record payload length is 16384" \
2926 -C "Maximum outgoing record payload length is 16384" \
2927 -S "Maximum incoming record payload length is 16384" \
2928 -S "Maximum outgoing record payload length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002929 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2930 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002931 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002932
2933requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2934run_test "Max fragment length DTLS: disabled, larger message" \
2935 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002936 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002937 1 \
Hanno Becker59d36702021-06-08 05:35:29 +01002938 -C "Maximum incoming record payload length is 16384" \
2939 -C "Maximum outgoing record payload length is 16384" \
2940 -S "Maximum incoming record payload length is 16384" \
2941 -S "Maximum outgoing record payload length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002942 -c "fragment larger than.*maximum "
2943
2944requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002945run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002946 "$P_SRV debug_level=3" \
2947 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002948 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01002949 -c "Maximum incoming record payload length is 4096" \
2950 -c "Maximum outgoing record payload length is 4096" \
2951 -s "Maximum incoming record payload length is 4096" \
2952 -s "Maximum outgoing record payload length is 4096" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002953 -c "client hello, adding max_fragment_length extension" \
2954 -s "found max fragment length extension" \
2955 -s "server hello, max_fragment_length extension" \
2956 -c "found max_fragment_length extension"
2957
2958requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2959run_test "Max fragment length: client 512, server 1024" \
2960 "$P_SRV debug_level=3 max_frag_len=1024" \
2961 "$P_CLI debug_level=3 max_frag_len=512" \
2962 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01002963 -c "Maximum incoming record payload length is 512" \
2964 -c "Maximum outgoing record payload length is 512" \
2965 -s "Maximum incoming record payload length is 512" \
2966 -s "Maximum outgoing record payload length is 512" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002967 -c "client hello, adding max_fragment_length extension" \
2968 -s "found max fragment length extension" \
2969 -s "server hello, max_fragment_length extension" \
2970 -c "found max_fragment_length extension"
2971
2972requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2973run_test "Max fragment length: client 512, server 2048" \
2974 "$P_SRV debug_level=3 max_frag_len=2048" \
2975 "$P_CLI debug_level=3 max_frag_len=512" \
2976 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01002977 -c "Maximum incoming record payload length is 512" \
2978 -c "Maximum outgoing record payload length is 512" \
2979 -s "Maximum incoming record payload length is 512" \
2980 -s "Maximum outgoing record payload length is 512" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002981 -c "client hello, adding max_fragment_length extension" \
2982 -s "found max fragment length extension" \
2983 -s "server hello, max_fragment_length extension" \
2984 -c "found max_fragment_length extension"
2985
2986requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2987run_test "Max fragment length: client 512, server 4096" \
2988 "$P_SRV debug_level=3 max_frag_len=4096" \
2989 "$P_CLI debug_level=3 max_frag_len=512" \
2990 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01002991 -c "Maximum incoming record payload length is 512" \
2992 -c "Maximum outgoing record payload length is 512" \
2993 -s "Maximum incoming record payload length is 512" \
2994 -s "Maximum outgoing record payload length is 512" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002995 -c "client hello, adding max_fragment_length extension" \
2996 -s "found max fragment length extension" \
2997 -s "server hello, max_fragment_length extension" \
2998 -c "found max_fragment_length extension"
2999
3000requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3001run_test "Max fragment length: client 1024, server 512" \
3002 "$P_SRV debug_level=3 max_frag_len=512" \
3003 "$P_CLI debug_level=3 max_frag_len=1024" \
3004 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003005 -c "Maximum incoming record payload length is 1024" \
3006 -c "Maximum outgoing record payload length is 1024" \
3007 -s "Maximum incoming record payload length is 1024" \
3008 -s "Maximum outgoing record payload length is 512" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003009 -c "client hello, adding max_fragment_length extension" \
3010 -s "found max fragment length extension" \
3011 -s "server hello, max_fragment_length extension" \
3012 -c "found max_fragment_length extension"
3013
3014requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3015run_test "Max fragment length: client 1024, server 2048" \
3016 "$P_SRV debug_level=3 max_frag_len=2048" \
3017 "$P_CLI debug_level=3 max_frag_len=1024" \
3018 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003019 -c "Maximum incoming record payload length is 1024" \
3020 -c "Maximum outgoing record payload length is 1024" \
3021 -s "Maximum incoming record payload length is 1024" \
3022 -s "Maximum outgoing record payload length is 1024" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003023 -c "client hello, adding max_fragment_length extension" \
3024 -s "found max fragment length extension" \
3025 -s "server hello, max_fragment_length extension" \
3026 -c "found max_fragment_length extension"
3027
3028requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3029run_test "Max fragment length: client 1024, server 4096" \
3030 "$P_SRV debug_level=3 max_frag_len=4096" \
3031 "$P_CLI debug_level=3 max_frag_len=1024" \
3032 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003033 -c "Maximum incoming record payload length is 1024" \
3034 -c "Maximum outgoing record payload length is 1024" \
3035 -s "Maximum incoming record payload length is 1024" \
3036 -s "Maximum outgoing record payload length is 1024" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003037 -c "client hello, adding max_fragment_length extension" \
3038 -s "found max fragment length extension" \
3039 -s "server hello, max_fragment_length extension" \
3040 -c "found max_fragment_length extension"
3041
3042requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3043run_test "Max fragment length: client 2048, server 512" \
3044 "$P_SRV debug_level=3 max_frag_len=512" \
3045 "$P_CLI debug_level=3 max_frag_len=2048" \
3046 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003047 -c "Maximum incoming record payload length is 2048" \
3048 -c "Maximum outgoing record payload length is 2048" \
3049 -s "Maximum incoming record payload length is 2048" \
3050 -s "Maximum outgoing record payload length is 512" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003051 -c "client hello, adding max_fragment_length extension" \
3052 -s "found max fragment length extension" \
3053 -s "server hello, max_fragment_length extension" \
3054 -c "found max_fragment_length extension"
3055
3056requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3057run_test "Max fragment length: client 2048, server 1024" \
3058 "$P_SRV debug_level=3 max_frag_len=1024" \
3059 "$P_CLI debug_level=3 max_frag_len=2048" \
3060 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003061 -c "Maximum incoming record payload length is 2048" \
3062 -c "Maximum outgoing record payload length is 2048" \
3063 -s "Maximum incoming record payload length is 2048" \
3064 -s "Maximum outgoing record payload length is 1024" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003065 -c "client hello, adding max_fragment_length extension" \
3066 -s "found max fragment length extension" \
3067 -s "server hello, max_fragment_length extension" \
3068 -c "found max_fragment_length extension"
3069
3070requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3071run_test "Max fragment length: client 2048, server 4096" \
3072 "$P_SRV debug_level=3 max_frag_len=4096" \
3073 "$P_CLI debug_level=3 max_frag_len=2048" \
3074 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003075 -c "Maximum incoming record payload length is 2048" \
3076 -c "Maximum outgoing record payload length is 2048" \
3077 -s "Maximum incoming record payload length is 2048" \
3078 -s "Maximum outgoing record payload length is 2048" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003079 -c "client hello, adding max_fragment_length extension" \
3080 -s "found max fragment length extension" \
3081 -s "server hello, max_fragment_length extension" \
3082 -c "found max_fragment_length extension"
3083
3084requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3085run_test "Max fragment length: client 4096, server 512" \
3086 "$P_SRV debug_level=3 max_frag_len=512" \
3087 "$P_CLI debug_level=3 max_frag_len=4096" \
3088 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003089 -c "Maximum incoming record payload length is 4096" \
3090 -c "Maximum outgoing record payload length is 4096" \
3091 -s "Maximum incoming record payload length is 4096" \
3092 -s "Maximum outgoing record payload length is 512" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003093 -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
3098requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3099run_test "Max fragment length: client 4096, server 1024" \
3100 "$P_SRV debug_level=3 max_frag_len=1024" \
3101 "$P_CLI debug_level=3 max_frag_len=4096" \
3102 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003103 -c "Maximum incoming record payload length is 4096" \
3104 -c "Maximum outgoing record payload length is 4096" \
3105 -s "Maximum incoming record payload length is 4096" \
3106 -s "Maximum outgoing record payload length is 1024" \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003107 -c "client hello, adding max_fragment_length extension" \
3108 -s "found max fragment length extension" \
3109 -s "server hello, max_fragment_length extension" \
3110 -c "found max_fragment_length extension"
3111
3112requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3113run_test "Max fragment length: client 4096, server 2048" \
3114 "$P_SRV debug_level=3 max_frag_len=2048" \
3115 "$P_CLI debug_level=3 max_frag_len=4096" \
3116 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003117 -c "Maximum incoming record payload length is 4096" \
3118 -c "Maximum outgoing record payload length is 4096" \
3119 -s "Maximum incoming record payload length is 4096" \
3120 -s "Maximum outgoing record payload length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003121 -c "client hello, adding max_fragment_length extension" \
3122 -s "found max fragment length extension" \
3123 -s "server hello, max_fragment_length extension" \
3124 -c "found max_fragment_length extension"
3125
Hanno Becker4aed27e2017-09-18 15:00:34 +01003126requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003127run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003128 "$P_SRV debug_level=3 max_frag_len=4096" \
3129 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003130 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003131 -c "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
3132 -c "Maximum outgoing record payload length is $MAX_CONTENT_LEN" \
3133 -s "Maximum incoming record payload length is $MAX_CONTENT_LEN" \
3134 -s "Maximum outgoing record payload length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003135 -C "client hello, adding max_fragment_length extension" \
3136 -S "found max fragment length extension" \
3137 -S "server hello, max_fragment_length extension" \
3138 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003139
Hanno Becker4aed27e2017-09-18 15:00:34 +01003140requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003141requires_gnutls
3142run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003143 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003144 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003145 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003146 -c "Maximum incoming record payload length is 4096" \
3147 -c "Maximum outgoing record payload length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003148 -c "client hello, adding max_fragment_length extension" \
3149 -c "found max_fragment_length extension"
3150
Hanno Becker4aed27e2017-09-18 15:00:34 +01003151requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003152run_test "Max fragment length: client, message just fits" \
3153 "$P_SRV debug_level=3" \
3154 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3155 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003156 -c "Maximum incoming record payload length is 2048" \
3157 -c "Maximum outgoing record payload length is 2048" \
3158 -s "Maximum incoming record payload length is 2048" \
3159 -s "Maximum outgoing record payload length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003160 -c "client hello, adding max_fragment_length extension" \
3161 -s "found max fragment length extension" \
3162 -s "server hello, max_fragment_length extension" \
3163 -c "found max_fragment_length extension" \
3164 -c "2048 bytes written in 1 fragments" \
3165 -s "2048 bytes read"
3166
Hanno Becker4aed27e2017-09-18 15:00:34 +01003167requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003168run_test "Max fragment length: client, larger message" \
3169 "$P_SRV debug_level=3" \
3170 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3171 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003172 -c "Maximum incoming record payload length is 2048" \
3173 -c "Maximum outgoing record payload length is 2048" \
3174 -s "Maximum incoming record payload length is 2048" \
3175 -s "Maximum outgoing record payload length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003176 -c "client hello, adding max_fragment_length extension" \
3177 -s "found max fragment length extension" \
3178 -s "server hello, max_fragment_length extension" \
3179 -c "found max_fragment_length extension" \
3180 -c "2345 bytes written in 2 fragments" \
3181 -s "2048 bytes read" \
3182 -s "297 bytes read"
3183
Hanno Becker4aed27e2017-09-18 15:00:34 +01003184requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003185run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003186 "$P_SRV debug_level=3 dtls=1" \
3187 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3188 1 \
Hanno Becker59d36702021-06-08 05:35:29 +01003189 -c "Maximum incoming record payload length is 2048" \
3190 -c "Maximum outgoing record payload length is 2048" \
3191 -s "Maximum incoming record payload length is 2048" \
3192 -s "Maximum outgoing record payload length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003193 -c "client hello, adding max_fragment_length extension" \
3194 -s "found max fragment length extension" \
3195 -s "server hello, max_fragment_length extension" \
3196 -c "found max_fragment_length extension" \
3197 -c "fragment larger than.*maximum"
3198
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003199# Tests for renegotiation
3200
Hanno Becker6a243642017-10-12 15:18:45 +01003201# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003202run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003203 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003204 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003205 0 \
3206 -C "client hello, adding renegotiation extension" \
3207 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3208 -S "found renegotiation extension" \
3209 -s "server hello, secure renegotiation extension" \
3210 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003211 -C "=> renegotiate" \
3212 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003213 -S "write hello request"
3214
Hanno Becker6a243642017-10-12 15:18:45 +01003215requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003216run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003217 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003218 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003219 0 \
3220 -c "client hello, adding renegotiation extension" \
3221 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3222 -s "found renegotiation extension" \
3223 -s "server hello, secure renegotiation extension" \
3224 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003225 -c "=> renegotiate" \
3226 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003227 -S "write hello request"
3228
Hanno Becker6a243642017-10-12 15:18:45 +01003229requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003230run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003231 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003232 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003233 0 \
3234 -c "client hello, adding renegotiation extension" \
3235 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3236 -s "found renegotiation extension" \
3237 -s "server hello, secure renegotiation extension" \
3238 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003239 -c "=> renegotiate" \
3240 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003241 -s "write hello request"
3242
Janos Follathb0f148c2017-10-05 12:29:42 +01003243# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3244# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3245# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003246requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003247run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3248 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3249 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3250 0 \
3251 -c "client hello, adding renegotiation extension" \
3252 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3253 -s "found renegotiation extension" \
3254 -s "server hello, secure renegotiation extension" \
3255 -c "found renegotiation extension" \
3256 -c "=> renegotiate" \
3257 -s "=> renegotiate" \
3258 -S "write hello request" \
3259 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3260
3261# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3262# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3263# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003264requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003265run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3266 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3267 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3268 0 \
3269 -c "client hello, adding renegotiation extension" \
3270 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3271 -s "found renegotiation extension" \
3272 -s "server hello, secure renegotiation extension" \
3273 -c "found renegotiation extension" \
3274 -c "=> renegotiate" \
3275 -s "=> renegotiate" \
3276 -s "write hello request" \
3277 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3278
Hanno Becker6a243642017-10-12 15:18:45 +01003279requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003280run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003281 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003282 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003283 0 \
3284 -c "client hello, adding renegotiation extension" \
3285 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3286 -s "found renegotiation extension" \
3287 -s "server hello, secure renegotiation extension" \
3288 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003289 -c "=> renegotiate" \
3290 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003291 -s "write hello request"
3292
Hanno Becker6a243642017-10-12 15:18:45 +01003293requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003294requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3295run_test "Renegotiation with max fragment length: client 2048, server 512" \
3296 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3297 "$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" \
3298 0 \
Hanno Becker59d36702021-06-08 05:35:29 +01003299 -c "Maximum incoming record payload length is 2048" \
3300 -c "Maximum outgoing record payload length is 2048" \
3301 -s "Maximum incoming record payload length is 2048" \
3302 -s "Maximum outgoing record payload length is 512" \
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003303 -c "client hello, adding max_fragment_length extension" \
3304 -s "found max fragment length extension" \
3305 -s "server hello, max_fragment_length extension" \
3306 -c "found max_fragment_length extension" \
3307 -c "client hello, adding renegotiation extension" \
3308 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3309 -s "found renegotiation extension" \
3310 -s "server hello, secure renegotiation extension" \
3311 -c "found renegotiation extension" \
3312 -c "=> renegotiate" \
3313 -s "=> renegotiate" \
3314 -s "write hello request"
3315
3316requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003317run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003318 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003319 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003320 1 \
3321 -c "client hello, adding renegotiation extension" \
3322 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3323 -S "found renegotiation extension" \
3324 -s "server hello, secure renegotiation extension" \
3325 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003326 -c "=> renegotiate" \
3327 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003328 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003329 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003330 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003331
Hanno Becker6a243642017-10-12 15:18:45 +01003332requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003333run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003334 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003335 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003336 0 \
3337 -C "client hello, adding renegotiation extension" \
3338 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3339 -S "found renegotiation extension" \
3340 -s "server hello, secure renegotiation extension" \
3341 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003342 -C "=> renegotiate" \
3343 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003344 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003345 -S "SSL - An unexpected message was received from our peer" \
3346 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003347
Hanno Becker6a243642017-10-12 15:18:45 +01003348requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003349run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003350 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003351 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003352 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003353 0 \
3354 -C "client hello, adding renegotiation extension" \
3355 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3356 -S "found renegotiation extension" \
3357 -s "server hello, secure renegotiation extension" \
3358 -c "found renegotiation extension" \
3359 -C "=> renegotiate" \
3360 -S "=> renegotiate" \
3361 -s "write hello request" \
3362 -S "SSL - An unexpected message was received from our peer" \
3363 -S "failed"
3364
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003365# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003366requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003367run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003368 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003369 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003370 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003371 0 \
3372 -C "client hello, adding renegotiation extension" \
3373 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3374 -S "found renegotiation extension" \
3375 -s "server hello, secure renegotiation extension" \
3376 -c "found renegotiation extension" \
3377 -C "=> renegotiate" \
3378 -S "=> renegotiate" \
3379 -s "write hello request" \
3380 -S "SSL - An unexpected message was received from our peer" \
3381 -S "failed"
3382
Hanno Becker6a243642017-10-12 15:18:45 +01003383requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003384run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003385 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003386 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003387 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003388 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" \
3394 -C "=> renegotiate" \
3395 -S "=> renegotiate" \
3396 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003397 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003398
Hanno Becker6a243642017-10-12 15:18:45 +01003399requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003400run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003401 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003402 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003403 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003404 0 \
3405 -c "client hello, adding renegotiation extension" \
3406 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3407 -s "found renegotiation extension" \
3408 -s "server hello, secure renegotiation extension" \
3409 -c "found renegotiation extension" \
3410 -c "=> renegotiate" \
3411 -s "=> renegotiate" \
3412 -s "write hello request" \
3413 -S "SSL - An unexpected message was received from our peer" \
3414 -S "failed"
3415
Hanno Becker6a243642017-10-12 15:18:45 +01003416requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003417run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003418 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003419 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3420 0 \
3421 -C "client hello, adding renegotiation extension" \
3422 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3423 -S "found renegotiation extension" \
3424 -s "server hello, secure renegotiation extension" \
3425 -c "found renegotiation extension" \
3426 -S "record counter limit reached: renegotiate" \
3427 -C "=> renegotiate" \
3428 -S "=> renegotiate" \
3429 -S "write hello request" \
3430 -S "SSL - An unexpected message was received from our peer" \
3431 -S "failed"
3432
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003433# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003434requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003435run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003436 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003437 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003438 0 \
3439 -c "client hello, adding renegotiation extension" \
3440 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3441 -s "found renegotiation extension" \
3442 -s "server hello, secure renegotiation extension" \
3443 -c "found renegotiation extension" \
3444 -s "record counter limit reached: renegotiate" \
3445 -c "=> renegotiate" \
3446 -s "=> renegotiate" \
3447 -s "write hello request" \
3448 -S "SSL - An unexpected message was received from our peer" \
3449 -S "failed"
3450
Hanno Becker6a243642017-10-12 15:18:45 +01003451requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003452run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003453 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003454 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003455 0 \
3456 -c "client hello, adding renegotiation extension" \
3457 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3458 -s "found renegotiation extension" \
3459 -s "server hello, secure renegotiation extension" \
3460 -c "found renegotiation extension" \
3461 -s "record counter limit reached: renegotiate" \
3462 -c "=> renegotiate" \
3463 -s "=> renegotiate" \
3464 -s "write hello request" \
3465 -S "SSL - An unexpected message was received from our peer" \
3466 -S "failed"
3467
Hanno Becker6a243642017-10-12 15:18:45 +01003468requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003469run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003470 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003471 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3472 0 \
3473 -C "client hello, adding renegotiation extension" \
3474 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3475 -S "found renegotiation extension" \
3476 -s "server hello, secure renegotiation extension" \
3477 -c "found renegotiation extension" \
3478 -S "record counter limit reached: renegotiate" \
3479 -C "=> renegotiate" \
3480 -S "=> renegotiate" \
3481 -S "write hello request" \
3482 -S "SSL - An unexpected message was received from our peer" \
3483 -S "failed"
3484
Hanno Becker6a243642017-10-12 15:18:45 +01003485requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003486run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003487 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003488 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003489 0 \
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
Hanno Becker6a243642017-10-12 15:18:45 +01003499requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003500run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003501 "$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 +02003502 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003503 0 \
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" \
3509 -c "=> renegotiate" \
3510 -s "=> renegotiate" \
3511 -s "write hello request"
3512
Hanno Becker6a243642017-10-12 15:18:45 +01003513requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003514run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003515 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003516 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003517 0 \
3518 -c "client hello, adding renegotiation extension" \
3519 -c "found renegotiation extension" \
3520 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003521 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003522 -C "error" \
3523 -c "HTTP/1.0 200 [Oo][Kk]"
3524
Paul Bakker539d9722015-02-08 16:18:35 +01003525requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003526requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003527run_test "Renegotiation: gnutls server strict, client-initiated" \
3528 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003529 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003530 0 \
3531 -c "client hello, adding renegotiation extension" \
3532 -c "found renegotiation extension" \
3533 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003534 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003535 -C "error" \
3536 -c "HTTP/1.0 200 [Oo][Kk]"
3537
Paul Bakker539d9722015-02-08 16:18:35 +01003538requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003539requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003540run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3541 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3542 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3543 1 \
3544 -c "client hello, adding renegotiation extension" \
3545 -C "found renegotiation extension" \
3546 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003547 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003548 -c "error" \
3549 -C "HTTP/1.0 200 [Oo][Kk]"
3550
Paul Bakker539d9722015-02-08 16:18:35 +01003551requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003552requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003553run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3554 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3555 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3556 allow_legacy=0" \
3557 1 \
3558 -c "client hello, adding renegotiation extension" \
3559 -C "found renegotiation extension" \
3560 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003561 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003562 -c "error" \
3563 -C "HTTP/1.0 200 [Oo][Kk]"
3564
Paul Bakker539d9722015-02-08 16:18:35 +01003565requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003566requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003567run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3568 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3569 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3570 allow_legacy=1" \
3571 0 \
3572 -c "client hello, adding renegotiation extension" \
3573 -C "found renegotiation extension" \
3574 -c "=> renegotiate" \
3575 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003576 -C "error" \
3577 -c "HTTP/1.0 200 [Oo][Kk]"
3578
Hanno Becker6a243642017-10-12 15:18:45 +01003579requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003580run_test "Renegotiation: DTLS, client-initiated" \
3581 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3582 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3583 0 \
3584 -c "client hello, adding renegotiation extension" \
3585 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3586 -s "found renegotiation extension" \
3587 -s "server hello, secure renegotiation extension" \
3588 -c "found renegotiation extension" \
3589 -c "=> renegotiate" \
3590 -s "=> renegotiate" \
3591 -S "write hello request"
3592
Hanno Becker6a243642017-10-12 15:18:45 +01003593requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003594run_test "Renegotiation: DTLS, server-initiated" \
3595 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003596 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3597 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003598 0 \
3599 -c "client hello, adding renegotiation extension" \
3600 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3601 -s "found renegotiation extension" \
3602 -s "server hello, secure renegotiation extension" \
3603 -c "found renegotiation extension" \
3604 -c "=> renegotiate" \
3605 -s "=> renegotiate" \
3606 -s "write hello request"
3607
Hanno Becker6a243642017-10-12 15:18:45 +01003608requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003609run_test "Renegotiation: DTLS, renego_period overflow" \
3610 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3611 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3612 0 \
3613 -c "client hello, adding renegotiation extension" \
3614 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3615 -s "found renegotiation extension" \
3616 -s "server hello, secure renegotiation extension" \
3617 -s "record counter limit reached: renegotiate" \
3618 -c "=> renegotiate" \
3619 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003620 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003621
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003622requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003623requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003624run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3625 "$G_SRV -u --mtu 4096" \
3626 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3627 0 \
3628 -c "client hello, adding renegotiation extension" \
3629 -c "found renegotiation extension" \
3630 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003631 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003632 -C "error" \
3633 -s "Extra-header:"
3634
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003635# Test for the "secure renegotation" extension only (no actual renegotiation)
3636
Paul Bakker539d9722015-02-08 16:18:35 +01003637requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003638run_test "Renego ext: gnutls server strict, client default" \
3639 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3640 "$P_CLI debug_level=3" \
3641 0 \
3642 -c "found renegotiation extension" \
3643 -C "error" \
3644 -c "HTTP/1.0 200 [Oo][Kk]"
3645
Paul Bakker539d9722015-02-08 16:18:35 +01003646requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003647run_test "Renego ext: gnutls server unsafe, client default" \
3648 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3649 "$P_CLI debug_level=3" \
3650 0 \
3651 -C "found renegotiation extension" \
3652 -C "error" \
3653 -c "HTTP/1.0 200 [Oo][Kk]"
3654
Paul Bakker539d9722015-02-08 16:18:35 +01003655requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003656run_test "Renego ext: gnutls server unsafe, client break legacy" \
3657 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3658 "$P_CLI debug_level=3 allow_legacy=-1" \
3659 1 \
3660 -C "found renegotiation extension" \
3661 -c "error" \
3662 -C "HTTP/1.0 200 [Oo][Kk]"
3663
Paul Bakker539d9722015-02-08 16:18:35 +01003664requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003665run_test "Renego ext: gnutls client strict, server default" \
3666 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003667 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003668 0 \
3669 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3670 -s "server hello, secure renegotiation extension"
3671
Paul Bakker539d9722015-02-08 16:18:35 +01003672requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003673run_test "Renego ext: gnutls client unsafe, server default" \
3674 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003675 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003676 0 \
3677 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3678 -S "server hello, secure renegotiation extension"
3679
Paul Bakker539d9722015-02-08 16:18:35 +01003680requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003681run_test "Renego ext: gnutls client unsafe, server break legacy" \
3682 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003683 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003684 1 \
3685 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3686 -S "server hello, secure renegotiation extension"
3687
Janos Follath0b242342016-02-17 10:11:21 +00003688# Tests for silently dropping trailing extra bytes in .der certificates
3689
3690requires_gnutls
3691run_test "DER format: no trailing bytes" \
3692 "$P_SRV crt_file=data_files/server5-der0.crt \
3693 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003694 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003695 0 \
3696 -c "Handshake was completed" \
3697
3698requires_gnutls
3699run_test "DER format: with a trailing zero byte" \
3700 "$P_SRV crt_file=data_files/server5-der1a.crt \
3701 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003702 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003703 0 \
3704 -c "Handshake was completed" \
3705
3706requires_gnutls
3707run_test "DER format: with a trailing random byte" \
3708 "$P_SRV crt_file=data_files/server5-der1b.crt \
3709 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003710 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003711 0 \
3712 -c "Handshake was completed" \
3713
3714requires_gnutls
3715run_test "DER format: with 2 trailing random bytes" \
3716 "$P_SRV crt_file=data_files/server5-der2.crt \
3717 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003718 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003719 0 \
3720 -c "Handshake was completed" \
3721
3722requires_gnutls
3723run_test "DER format: with 4 trailing random bytes" \
3724 "$P_SRV crt_file=data_files/server5-der4.crt \
3725 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003726 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003727 0 \
3728 -c "Handshake was completed" \
3729
3730requires_gnutls
3731run_test "DER format: with 8 trailing random bytes" \
3732 "$P_SRV crt_file=data_files/server5-der8.crt \
3733 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003734 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003735 0 \
3736 -c "Handshake was completed" \
3737
3738requires_gnutls
3739run_test "DER format: with 9 trailing random bytes" \
3740 "$P_SRV crt_file=data_files/server5-der9.crt \
3741 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003742 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003743 0 \
3744 -c "Handshake was completed" \
3745
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003746# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3747# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003748
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003749run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003750 "$P_SRV crt_file=data_files/server5-badsign.crt \
3751 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003752 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003753 1 \
3754 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003755 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003756 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003757 -c "X509 - Certificate verification failed"
3758
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003759run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003760 "$P_SRV crt_file=data_files/server5-badsign.crt \
3761 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003762 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003763 0 \
3764 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003765 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003766 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003767 -C "X509 - Certificate verification failed"
3768
Hanno Beckere6706e62017-05-15 16:05:15 +01003769run_test "Authentication: server goodcert, client optional, no trusted CA" \
3770 "$P_SRV" \
3771 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3772 0 \
3773 -c "x509_verify_cert() returned" \
3774 -c "! The certificate is not correctly signed by the trusted CA" \
3775 -c "! Certificate verification flags"\
3776 -C "! mbedtls_ssl_handshake returned" \
3777 -C "X509 - Certificate verification failed" \
3778 -C "SSL - No CA Chain is set, but required to operate"
3779
3780run_test "Authentication: server goodcert, client required, no trusted CA" \
3781 "$P_SRV" \
3782 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3783 1 \
3784 -c "x509_verify_cert() returned" \
3785 -c "! The certificate is not correctly signed by the trusted CA" \
3786 -c "! Certificate verification flags"\
3787 -c "! mbedtls_ssl_handshake returned" \
3788 -c "SSL - No CA Chain is set, but required to operate"
3789
3790# The purpose of the next two tests is to test the client's behaviour when receiving a server
3791# certificate with an unsupported elliptic curve. This should usually not happen because
3792# the client informs the server about the supported curves - it does, though, in the
3793# corner case of a static ECDH suite, because the server doesn't check the curve on that
3794# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3795# different means to have the server ignoring the client's supported curve list.
3796
3797requires_config_enabled MBEDTLS_ECP_C
3798run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3799 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3800 crt_file=data_files/server5.ku-ka.crt" \
3801 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3802 1 \
3803 -c "bad certificate (EC key curve)"\
3804 -c "! Certificate verification flags"\
3805 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3806
3807requires_config_enabled MBEDTLS_ECP_C
3808run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3809 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3810 crt_file=data_files/server5.ku-ka.crt" \
3811 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3812 1 \
3813 -c "bad certificate (EC key curve)"\
3814 -c "! Certificate verification flags"\
3815 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3816
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003817run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003818 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003819 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003820 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003821 0 \
3822 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003823 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003824 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003825 -C "X509 - Certificate verification failed"
3826
Simon Butcher99000142016-10-13 17:21:01 +01003827run_test "Authentication: client SHA256, server required" \
3828 "$P_SRV auth_mode=required" \
3829 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3830 key_file=data_files/server6.key \
3831 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3832 0 \
3833 -c "Supported Signature Algorithm found: 4," \
3834 -c "Supported Signature Algorithm found: 5,"
3835
3836run_test "Authentication: client SHA384, server required" \
3837 "$P_SRV auth_mode=required" \
3838 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3839 key_file=data_files/server6.key \
3840 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3841 0 \
3842 -c "Supported Signature Algorithm found: 4," \
3843 -c "Supported Signature Algorithm found: 5,"
3844
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003845run_test "Authentication: client has no cert, server required (TLS)" \
3846 "$P_SRV debug_level=3 auth_mode=required" \
3847 "$P_CLI debug_level=3 crt_file=none \
3848 key_file=data_files/server5.key" \
3849 1 \
3850 -S "skip write certificate request" \
3851 -C "skip parse certificate request" \
3852 -c "got a certificate request" \
3853 -c "= write certificate$" \
3854 -C "skip write certificate$" \
3855 -S "x509_verify_cert() returned" \
3856 -s "client has no certificate" \
3857 -s "! mbedtls_ssl_handshake returned" \
3858 -c "! mbedtls_ssl_handshake returned" \
3859 -s "No client certification received from the client, but required by the authentication mode"
3860
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003861run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003862 "$P_SRV debug_level=3 auth_mode=required" \
3863 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003864 key_file=data_files/server5.key" \
3865 1 \
3866 -S "skip write certificate request" \
3867 -C "skip parse certificate request" \
3868 -c "got a certificate request" \
3869 -C "skip write certificate" \
3870 -C "skip write certificate verify" \
3871 -S "skip parse certificate verify" \
3872 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003873 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003874 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003875 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003876 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003877 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003878# We don't check that the client receives the alert because it might
3879# detect that its write end of the connection is closed and abort
3880# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003881
Janos Follath89baba22017-04-10 14:34:35 +01003882run_test "Authentication: client cert not trusted, server required" \
3883 "$P_SRV debug_level=3 auth_mode=required" \
3884 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3885 key_file=data_files/server5.key" \
3886 1 \
3887 -S "skip write certificate request" \
3888 -C "skip parse certificate request" \
3889 -c "got a certificate request" \
3890 -C "skip write certificate" \
3891 -C "skip write certificate verify" \
3892 -S "skip parse certificate verify" \
3893 -s "x509_verify_cert() returned" \
3894 -s "! The certificate is not correctly signed by the trusted CA" \
3895 -s "! mbedtls_ssl_handshake returned" \
3896 -c "! mbedtls_ssl_handshake returned" \
3897 -s "X509 - Certificate verification failed"
3898
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003899run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003900 "$P_SRV debug_level=3 auth_mode=optional" \
3901 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003902 key_file=data_files/server5.key" \
3903 0 \
3904 -S "skip write certificate request" \
3905 -C "skip parse certificate request" \
3906 -c "got a certificate request" \
3907 -C "skip write certificate" \
3908 -C "skip write certificate verify" \
3909 -S "skip parse certificate verify" \
3910 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003911 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003912 -S "! mbedtls_ssl_handshake returned" \
3913 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003914 -S "X509 - Certificate verification failed"
3915
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003916run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003917 "$P_SRV debug_level=3 auth_mode=none" \
3918 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003919 key_file=data_files/server5.key" \
3920 0 \
3921 -s "skip write certificate request" \
3922 -C "skip parse certificate request" \
3923 -c "got no certificate request" \
3924 -c "skip write certificate" \
3925 -c "skip write certificate verify" \
3926 -s "skip parse certificate verify" \
3927 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003928 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003929 -S "! mbedtls_ssl_handshake returned" \
3930 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003931 -S "X509 - Certificate verification failed"
3932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003933run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003934 "$P_SRV debug_level=3 auth_mode=optional" \
3935 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003936 0 \
3937 -S "skip write certificate request" \
3938 -C "skip parse certificate request" \
3939 -c "got a certificate request" \
3940 -C "skip write certificate$" \
3941 -C "got no certificate to send" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003942 -c "skip write certificate verify" \
3943 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003944 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003945 -S "! mbedtls_ssl_handshake returned" \
3946 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003947 -S "X509 - Certificate verification failed"
3948
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003949run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003950 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003951 "$O_CLI" \
3952 0 \
3953 -S "skip write certificate request" \
3954 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003955 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003956 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003957 -S "X509 - Certificate verification failed"
3958
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003959run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003960 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003961 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003962 0 \
3963 -C "skip parse certificate request" \
3964 -c "got a certificate request" \
3965 -C "skip write certificate$" \
3966 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003967 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003968
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003969run_test "Authentication: client no cert, openssl server required" \
3970 "$O_SRV -Verify 10" \
3971 "$P_CLI debug_level=3 crt_file=none key_file=none" \
3972 1 \
3973 -C "skip parse certificate request" \
3974 -c "got a certificate request" \
3975 -C "skip write certificate$" \
3976 -c "skip write certificate verify" \
3977 -c "! mbedtls_ssl_handshake returned"
3978
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003979# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3980# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003981
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003982MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003983MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003984
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003985if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskine231befa2020-08-26 20:05:11 +02003986 cat <<EOF
3987${CONFIG_H} contains a value for the configuration of
3988MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
3989test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01003990
Gilles Peskine231befa2020-08-26 20:05:11 +02003991The tests assume this value and if it changes, the tests in this
3992script should also be adjusted.
3993EOF
Simon Butcher06b78632017-07-28 01:00:17 +01003994 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003995fi
3996
Angus Grattonc4dd0732018-04-11 16:28:39 +10003997requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003998run_test "Authentication: server max_int chain, client default" \
3999 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4000 key_file=data_files/dir-maxpath/09.key" \
4001 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4002 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004003 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004004
Angus Grattonc4dd0732018-04-11 16:28:39 +10004005requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004006run_test "Authentication: server max_int+1 chain, client default" \
4007 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4008 key_file=data_files/dir-maxpath/10.key" \
4009 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4010 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004011 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004012
Angus Grattonc4dd0732018-04-11 16:28:39 +10004013requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004014run_test "Authentication: server max_int+1 chain, client optional" \
4015 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4016 key_file=data_files/dir-maxpath/10.key" \
4017 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4018 auth_mode=optional" \
4019 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004020 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004021
Angus Grattonc4dd0732018-04-11 16:28:39 +10004022requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004023run_test "Authentication: server max_int+1 chain, client none" \
4024 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4025 key_file=data_files/dir-maxpath/10.key" \
4026 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4027 auth_mode=none" \
4028 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004029 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004030
Angus Grattonc4dd0732018-04-11 16:28:39 +10004031requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004032run_test "Authentication: client max_int+1 chain, server default" \
4033 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
4034 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4035 key_file=data_files/dir-maxpath/10.key" \
4036 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004037 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004038
Angus Grattonc4dd0732018-04-11 16:28:39 +10004039requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004040run_test "Authentication: client max_int+1 chain, server optional" \
4041 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4042 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4043 key_file=data_files/dir-maxpath/10.key" \
4044 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004045 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004046
Angus Grattonc4dd0732018-04-11 16:28:39 +10004047requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004048run_test "Authentication: client max_int+1 chain, server required" \
4049 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4050 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4051 key_file=data_files/dir-maxpath/10.key" \
4052 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004053 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004054
Angus Grattonc4dd0732018-04-11 16:28:39 +10004055requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004056run_test "Authentication: client max_int chain, server required" \
4057 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4058 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4059 key_file=data_files/dir-maxpath/09.key" \
4060 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004061 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004062
Janos Follath89baba22017-04-10 14:34:35 +01004063# Tests for CA list in CertificateRequest messages
4064
4065run_test "Authentication: send CA list in CertificateRequest (default)" \
4066 "$P_SRV debug_level=3 auth_mode=required" \
4067 "$P_CLI crt_file=data_files/server6.crt \
4068 key_file=data_files/server6.key" \
4069 0 \
4070 -s "requested DN"
4071
4072run_test "Authentication: do not send CA list in CertificateRequest" \
4073 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4074 "$P_CLI crt_file=data_files/server6.crt \
4075 key_file=data_files/server6.key" \
4076 0 \
4077 -S "requested DN"
4078
4079run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4080 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4081 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4082 key_file=data_files/server5.key" \
4083 1 \
4084 -S "requested DN" \
4085 -s "x509_verify_cert() returned" \
4086 -s "! The certificate is not correctly signed by the trusted CA" \
4087 -s "! mbedtls_ssl_handshake returned" \
4088 -c "! mbedtls_ssl_handshake returned" \
4089 -s "X509 - Certificate verification failed"
4090
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004091# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4092# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004093
4094requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4095run_test "Authentication, CA callback: server badcert, client required" \
4096 "$P_SRV crt_file=data_files/server5-badsign.crt \
4097 key_file=data_files/server5.key" \
4098 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4099 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004100 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004101 -c "x509_verify_cert() returned" \
4102 -c "! The certificate is not correctly signed by the trusted CA" \
4103 -c "! mbedtls_ssl_handshake returned" \
4104 -c "X509 - Certificate verification failed"
4105
4106requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4107run_test "Authentication, CA callback: server badcert, client optional" \
4108 "$P_SRV crt_file=data_files/server5-badsign.crt \
4109 key_file=data_files/server5.key" \
4110 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4111 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004112 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004113 -c "x509_verify_cert() returned" \
4114 -c "! The certificate is not correctly signed by the trusted CA" \
4115 -C "! mbedtls_ssl_handshake returned" \
4116 -C "X509 - Certificate verification failed"
4117
4118# The purpose of the next two tests is to test the client's behaviour when receiving a server
4119# certificate with an unsupported elliptic curve. This should usually not happen because
4120# the client informs the server about the supported curves - it does, though, in the
4121# corner case of a static ECDH suite, because the server doesn't check the curve on that
4122# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4123# different means to have the server ignoring the client's supported curve list.
4124
4125requires_config_enabled MBEDTLS_ECP_C
4126requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4127run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4128 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4129 crt_file=data_files/server5.ku-ka.crt" \
4130 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4131 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004132 -c "use CA callback for X.509 CRT verification" \
4133 -c "bad certificate (EC key curve)" \
4134 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004135 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4136
4137requires_config_enabled MBEDTLS_ECP_C
4138requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4139run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4140 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4141 crt_file=data_files/server5.ku-ka.crt" \
4142 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4143 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004144 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004145 -c "bad certificate (EC key curve)"\
4146 -c "! Certificate verification flags"\
4147 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4148
4149requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4150run_test "Authentication, CA callback: client SHA256, server required" \
4151 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4152 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4153 key_file=data_files/server6.key \
4154 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4155 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004156 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004157 -c "Supported Signature Algorithm found: 4," \
4158 -c "Supported Signature Algorithm found: 5,"
4159
4160requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4161run_test "Authentication, CA callback: client SHA384, server required" \
4162 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4163 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4164 key_file=data_files/server6.key \
4165 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4166 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004167 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004168 -c "Supported Signature Algorithm found: 4," \
4169 -c "Supported Signature Algorithm found: 5,"
4170
4171requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4172run_test "Authentication, CA callback: client badcert, server required" \
4173 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4174 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4175 key_file=data_files/server5.key" \
4176 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004177 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004178 -S "skip write certificate request" \
4179 -C "skip parse certificate request" \
4180 -c "got a certificate request" \
4181 -C "skip write certificate" \
4182 -C "skip write certificate verify" \
4183 -S "skip parse certificate verify" \
4184 -s "x509_verify_cert() returned" \
4185 -s "! The certificate is not correctly signed by the trusted CA" \
4186 -s "! mbedtls_ssl_handshake returned" \
4187 -s "send alert level=2 message=48" \
4188 -c "! mbedtls_ssl_handshake returned" \
4189 -s "X509 - Certificate verification failed"
4190# We don't check that the client receives the alert because it might
4191# detect that its write end of the connection is closed and abort
4192# before reading the alert message.
4193
4194requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4195run_test "Authentication, CA callback: client cert not trusted, server required" \
4196 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4197 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4198 key_file=data_files/server5.key" \
4199 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004200 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004201 -S "skip write certificate request" \
4202 -C "skip parse certificate request" \
4203 -c "got a certificate request" \
4204 -C "skip write certificate" \
4205 -C "skip write certificate verify" \
4206 -S "skip parse certificate verify" \
4207 -s "x509_verify_cert() returned" \
4208 -s "! The certificate is not correctly signed by the trusted CA" \
4209 -s "! mbedtls_ssl_handshake returned" \
4210 -c "! mbedtls_ssl_handshake returned" \
4211 -s "X509 - Certificate verification failed"
4212
4213requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4214run_test "Authentication, CA callback: client badcert, server optional" \
4215 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4216 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4217 key_file=data_files/server5.key" \
4218 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004219 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004220 -S "skip write certificate request" \
4221 -C "skip parse certificate request" \
4222 -c "got a certificate request" \
4223 -C "skip write certificate" \
4224 -C "skip write certificate verify" \
4225 -S "skip parse certificate verify" \
4226 -s "x509_verify_cert() returned" \
4227 -s "! The certificate is not correctly signed by the trusted CA" \
4228 -S "! mbedtls_ssl_handshake returned" \
4229 -C "! mbedtls_ssl_handshake returned" \
4230 -S "X509 - Certificate verification failed"
4231
4232requires_full_size_output_buffer
4233requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4234run_test "Authentication, CA callback: server max_int chain, client default" \
4235 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4236 key_file=data_files/dir-maxpath/09.key" \
4237 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4238 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004239 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004240 -C "X509 - A fatal error occurred"
4241
4242requires_full_size_output_buffer
4243requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4244run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4245 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4246 key_file=data_files/dir-maxpath/10.key" \
4247 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4248 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004249 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004250 -c "X509 - A fatal error occurred"
4251
4252requires_full_size_output_buffer
4253requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4254run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4255 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4256 key_file=data_files/dir-maxpath/10.key" \
4257 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4258 debug_level=3 auth_mode=optional" \
4259 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004260 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004261 -c "X509 - A fatal error occurred"
4262
4263requires_full_size_output_buffer
4264requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4265run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4266 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4267 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4268 key_file=data_files/dir-maxpath/10.key" \
4269 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004270 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004271 -s "X509 - A fatal error occurred"
4272
4273requires_full_size_output_buffer
4274requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4275run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4276 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4277 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4278 key_file=data_files/dir-maxpath/10.key" \
4279 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004280 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004281 -s "X509 - A fatal error occurred"
4282
4283requires_full_size_output_buffer
4284requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4285run_test "Authentication, CA callback: client max_int chain, server required" \
4286 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4287 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4288 key_file=data_files/dir-maxpath/09.key" \
4289 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004290 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004291 -S "X509 - A fatal error occurred"
4292
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004293# Tests for certificate selection based on SHA verson
4294
Hanno Beckerc5722d12020-10-09 11:10:42 +01004295requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004296run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4297 "$P_SRV crt_file=data_files/server5.crt \
4298 key_file=data_files/server5.key \
4299 crt_file2=data_files/server5-sha1.crt \
4300 key_file2=data_files/server5.key" \
4301 "$P_CLI force_version=tls1_2" \
4302 0 \
4303 -c "signed using.*ECDSA with SHA256" \
4304 -C "signed using.*ECDSA with SHA1"
4305
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004306# tests for SNI
4307
Hanno Beckerc5722d12020-10-09 11:10:42 +01004308requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004309run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004310 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004311 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004312 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004313 0 \
4314 -S "parse ServerName extension" \
4315 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4316 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004317
Hanno Beckerc5722d12020-10-09 11:10:42 +01004318requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004319run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004320 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004321 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004322 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 +02004323 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004324 0 \
4325 -s "parse ServerName extension" \
4326 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4327 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004328
Hanno Beckerc5722d12020-10-09 11:10:42 +01004329requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004330run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004331 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004332 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004333 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 +02004334 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004335 0 \
4336 -s "parse ServerName extension" \
4337 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4338 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004339
Hanno Beckerc5722d12020-10-09 11:10:42 +01004340requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004341run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004342 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004343 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004344 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 +02004345 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004346 1 \
4347 -s "parse ServerName extension" \
4348 -s "ssl_sni_wrapper() returned" \
4349 -s "mbedtls_ssl_handshake returned" \
4350 -c "mbedtls_ssl_handshake returned" \
4351 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004352
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004353run_test "SNI: client auth no override: optional" \
4354 "$P_SRV debug_level=3 auth_mode=optional \
4355 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4356 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4357 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004358 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004359 -S "skip write certificate request" \
4360 -C "skip parse certificate request" \
4361 -c "got a certificate request" \
4362 -C "skip write certificate" \
4363 -C "skip write certificate verify" \
4364 -S "skip parse certificate verify"
4365
4366run_test "SNI: client auth override: none -> optional" \
4367 "$P_SRV debug_level=3 auth_mode=none \
4368 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4369 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4370 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004371 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004372 -S "skip write certificate request" \
4373 -C "skip parse certificate request" \
4374 -c "got a certificate request" \
4375 -C "skip write certificate" \
4376 -C "skip write certificate verify" \
4377 -S "skip parse certificate verify"
4378
4379run_test "SNI: client auth override: optional -> none" \
4380 "$P_SRV debug_level=3 auth_mode=optional \
4381 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4382 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4383 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004384 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004385 -s "skip write certificate request" \
4386 -C "skip parse certificate request" \
4387 -c "got no certificate request" \
4388 -c "skip write certificate" \
4389 -c "skip write certificate verify" \
4390 -s "skip parse certificate verify"
4391
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004392run_test "SNI: CA no override" \
4393 "$P_SRV debug_level=3 auth_mode=optional \
4394 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4395 ca_file=data_files/test-ca.crt \
4396 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4397 "$P_CLI debug_level=3 server_name=localhost \
4398 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4399 1 \
4400 -S "skip write certificate request" \
4401 -C "skip parse certificate request" \
4402 -c "got a certificate request" \
4403 -C "skip write certificate" \
4404 -C "skip write certificate verify" \
4405 -S "skip parse certificate verify" \
4406 -s "x509_verify_cert() returned" \
4407 -s "! The certificate is not correctly signed by the trusted CA" \
4408 -S "The certificate has been revoked (is on a CRL)"
4409
4410run_test "SNI: CA override" \
4411 "$P_SRV debug_level=3 auth_mode=optional \
4412 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4413 ca_file=data_files/test-ca.crt \
4414 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4415 "$P_CLI debug_level=3 server_name=localhost \
4416 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4417 0 \
4418 -S "skip write certificate request" \
4419 -C "skip parse certificate request" \
4420 -c "got a certificate request" \
4421 -C "skip write certificate" \
4422 -C "skip write certificate verify" \
4423 -S "skip parse certificate verify" \
4424 -S "x509_verify_cert() returned" \
4425 -S "! The certificate is not correctly signed by the trusted CA" \
4426 -S "The certificate has been revoked (is on a CRL)"
4427
4428run_test "SNI: CA override with CRL" \
4429 "$P_SRV debug_level=3 auth_mode=optional \
4430 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4431 ca_file=data_files/test-ca.crt \
4432 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4433 "$P_CLI debug_level=3 server_name=localhost \
4434 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4435 1 \
4436 -S "skip write certificate request" \
4437 -C "skip parse certificate request" \
4438 -c "got a certificate request" \
4439 -C "skip write certificate" \
4440 -C "skip write certificate verify" \
4441 -S "skip parse certificate verify" \
4442 -s "x509_verify_cert() returned" \
4443 -S "! The certificate is not correctly signed by the trusted CA" \
4444 -s "The certificate has been revoked (is on a CRL)"
4445
Andres AG1a834452016-12-07 10:01:30 +00004446# Tests for SNI and DTLS
4447
Hanno Beckerc5722d12020-10-09 11:10:42 +01004448requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004449run_test "SNI: DTLS, no SNI callback" \
4450 "$P_SRV debug_level=3 dtls=1 \
4451 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4452 "$P_CLI server_name=localhost dtls=1" \
4453 0 \
4454 -S "parse ServerName extension" \
4455 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4456 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4457
Hanno Beckerc5722d12020-10-09 11:10:42 +01004458requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004459run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004460 "$P_SRV debug_level=3 dtls=1 \
4461 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4462 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4463 "$P_CLI server_name=localhost dtls=1" \
4464 0 \
4465 -s "parse ServerName extension" \
4466 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4467 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4468
Hanno Beckerc5722d12020-10-09 11:10:42 +01004469requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004470run_test "SNI: DTLS, matching cert 2" \
4471 "$P_SRV debug_level=3 dtls=1 \
4472 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4473 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4474 "$P_CLI server_name=polarssl.example dtls=1" \
4475 0 \
4476 -s "parse ServerName extension" \
4477 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4478 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4479
4480run_test "SNI: DTLS, no matching cert" \
4481 "$P_SRV debug_level=3 dtls=1 \
4482 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4483 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4484 "$P_CLI server_name=nonesuch.example dtls=1" \
4485 1 \
4486 -s "parse ServerName extension" \
4487 -s "ssl_sni_wrapper() returned" \
4488 -s "mbedtls_ssl_handshake returned" \
4489 -c "mbedtls_ssl_handshake returned" \
4490 -c "SSL - A fatal alert message was received from our peer"
4491
4492run_test "SNI: DTLS, client auth no override: optional" \
4493 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4494 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4495 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4496 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4497 0 \
4498 -S "skip write certificate request" \
4499 -C "skip parse certificate request" \
4500 -c "got a certificate request" \
4501 -C "skip write certificate" \
4502 -C "skip write certificate verify" \
4503 -S "skip parse certificate verify"
4504
4505run_test "SNI: DTLS, client auth override: none -> optional" \
4506 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4507 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4508 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4509 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4510 0 \
4511 -S "skip write certificate request" \
4512 -C "skip parse certificate request" \
4513 -c "got a certificate request" \
4514 -C "skip write certificate" \
4515 -C "skip write certificate verify" \
4516 -S "skip parse certificate verify"
4517
4518run_test "SNI: DTLS, client auth override: optional -> none" \
4519 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4520 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4521 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4522 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4523 0 \
4524 -s "skip write certificate request" \
4525 -C "skip parse certificate request" \
4526 -c "got no certificate request" \
4527 -c "skip write certificate" \
4528 -c "skip write certificate verify" \
4529 -s "skip parse certificate verify"
4530
4531run_test "SNI: DTLS, CA no override" \
4532 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4533 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4534 ca_file=data_files/test-ca.crt \
4535 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4536 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4537 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4538 1 \
4539 -S "skip write certificate request" \
4540 -C "skip parse certificate request" \
4541 -c "got a certificate request" \
4542 -C "skip write certificate" \
4543 -C "skip write certificate verify" \
4544 -S "skip parse certificate verify" \
4545 -s "x509_verify_cert() returned" \
4546 -s "! The certificate is not correctly signed by the trusted CA" \
4547 -S "The certificate has been revoked (is on a CRL)"
4548
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004549run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004550 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4551 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4552 ca_file=data_files/test-ca.crt \
4553 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4554 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4555 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4556 0 \
4557 -S "skip write certificate request" \
4558 -C "skip parse certificate request" \
4559 -c "got a certificate request" \
4560 -C "skip write certificate" \
4561 -C "skip write certificate verify" \
4562 -S "skip parse certificate verify" \
4563 -S "x509_verify_cert() returned" \
4564 -S "! The certificate is not correctly signed by the trusted CA" \
4565 -S "The certificate has been revoked (is on a CRL)"
4566
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004567run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004568 "$P_SRV debug_level=3 auth_mode=optional \
4569 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4570 ca_file=data_files/test-ca.crt \
4571 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4572 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4573 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4574 1 \
4575 -S "skip write certificate request" \
4576 -C "skip parse certificate request" \
4577 -c "got a certificate request" \
4578 -C "skip write certificate" \
4579 -C "skip write certificate verify" \
4580 -S "skip parse certificate verify" \
4581 -s "x509_verify_cert() returned" \
4582 -S "! The certificate is not correctly signed by the trusted CA" \
4583 -s "The certificate has been revoked (is on a CRL)"
4584
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004585# Tests for non-blocking I/O: exercise a variety of handshake flows
4586
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004587run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004588 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4589 "$P_CLI nbio=2 tickets=0" \
4590 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004591 -S "mbedtls_ssl_handshake returned" \
4592 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004593 -c "Read from server: .* bytes read"
4594
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004595run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004596 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4597 "$P_CLI nbio=2 tickets=0" \
4598 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004599 -S "mbedtls_ssl_handshake returned" \
4600 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004601 -c "Read from server: .* bytes read"
4602
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004603run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004604 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4605 "$P_CLI nbio=2 tickets=1" \
4606 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004607 -S "mbedtls_ssl_handshake returned" \
4608 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004609 -c "Read from server: .* bytes read"
4610
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004611run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004612 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4613 "$P_CLI nbio=2 tickets=1" \
4614 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004615 -S "mbedtls_ssl_handshake returned" \
4616 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004617 -c "Read from server: .* bytes read"
4618
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004619run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004620 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4621 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4622 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004623 -S "mbedtls_ssl_handshake returned" \
4624 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004625 -c "Read from server: .* bytes read"
4626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004627run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004628 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4629 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4630 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004631 -S "mbedtls_ssl_handshake returned" \
4632 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004633 -c "Read from server: .* bytes read"
4634
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004635run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004636 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4637 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4638 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004639 -S "mbedtls_ssl_handshake returned" \
4640 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004641 -c "Read from server: .* bytes read"
4642
Hanno Becker00076712017-11-15 16:39:08 +00004643# Tests for event-driven I/O: exercise a variety of handshake flows
4644
4645run_test "Event-driven I/O: basic handshake" \
4646 "$P_SRV event=1 tickets=0 auth_mode=none" \
4647 "$P_CLI event=1 tickets=0" \
4648 0 \
4649 -S "mbedtls_ssl_handshake returned" \
4650 -C "mbedtls_ssl_handshake returned" \
4651 -c "Read from server: .* bytes read"
4652
4653run_test "Event-driven I/O: client auth" \
4654 "$P_SRV event=1 tickets=0 auth_mode=required" \
4655 "$P_CLI event=1 tickets=0" \
4656 0 \
4657 -S "mbedtls_ssl_handshake returned" \
4658 -C "mbedtls_ssl_handshake returned" \
4659 -c "Read from server: .* bytes read"
4660
4661run_test "Event-driven I/O: ticket" \
4662 "$P_SRV event=1 tickets=1 auth_mode=none" \
4663 "$P_CLI event=1 tickets=1" \
4664 0 \
4665 -S "mbedtls_ssl_handshake returned" \
4666 -C "mbedtls_ssl_handshake returned" \
4667 -c "Read from server: .* bytes read"
4668
4669run_test "Event-driven I/O: ticket + client auth" \
4670 "$P_SRV event=1 tickets=1 auth_mode=required" \
4671 "$P_CLI event=1 tickets=1" \
4672 0 \
4673 -S "mbedtls_ssl_handshake returned" \
4674 -C "mbedtls_ssl_handshake returned" \
4675 -c "Read from server: .* bytes read"
4676
4677run_test "Event-driven I/O: ticket + client auth + resume" \
4678 "$P_SRV event=1 tickets=1 auth_mode=required" \
4679 "$P_CLI event=1 tickets=1 reconnect=1" \
4680 0 \
4681 -S "mbedtls_ssl_handshake returned" \
4682 -C "mbedtls_ssl_handshake returned" \
4683 -c "Read from server: .* bytes read"
4684
4685run_test "Event-driven I/O: ticket + resume" \
4686 "$P_SRV event=1 tickets=1 auth_mode=none" \
4687 "$P_CLI event=1 tickets=1 reconnect=1" \
4688 0 \
4689 -S "mbedtls_ssl_handshake returned" \
4690 -C "mbedtls_ssl_handshake returned" \
4691 -c "Read from server: .* bytes read"
4692
4693run_test "Event-driven I/O: session-id resume" \
4694 "$P_SRV event=1 tickets=0 auth_mode=none" \
4695 "$P_CLI event=1 tickets=0 reconnect=1" \
4696 0 \
4697 -S "mbedtls_ssl_handshake returned" \
4698 -C "mbedtls_ssl_handshake returned" \
4699 -c "Read from server: .* bytes read"
4700
Hanno Becker6a33f592018-03-13 11:38:46 +00004701run_test "Event-driven I/O, DTLS: basic handshake" \
4702 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4703 "$P_CLI dtls=1 event=1 tickets=0" \
4704 0 \
4705 -c "Read from server: .* bytes read"
4706
4707run_test "Event-driven I/O, DTLS: client auth" \
4708 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4709 "$P_CLI dtls=1 event=1 tickets=0" \
4710 0 \
4711 -c "Read from server: .* bytes read"
4712
4713run_test "Event-driven I/O, DTLS: ticket" \
4714 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4715 "$P_CLI dtls=1 event=1 tickets=1" \
4716 0 \
4717 -c "Read from server: .* bytes read"
4718
4719run_test "Event-driven I/O, DTLS: ticket + client auth" \
4720 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4721 "$P_CLI dtls=1 event=1 tickets=1" \
4722 0 \
4723 -c "Read from server: .* bytes read"
4724
4725run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4726 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004727 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004728 0 \
4729 -c "Read from server: .* bytes read"
4730
4731run_test "Event-driven I/O, DTLS: ticket + resume" \
4732 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004733 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004734 0 \
4735 -c "Read from server: .* bytes read"
4736
4737run_test "Event-driven I/O, DTLS: session-id resume" \
4738 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004739 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004740 0 \
4741 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004742
4743# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4744# During session resumption, the client will send its ApplicationData record
4745# within the same datagram as the Finished messages. In this situation, the
4746# server MUST NOT idle on the underlying transport after handshake completion,
4747# because the ApplicationData request has already been queued internally.
4748run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004749 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004750 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004751 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004752 0 \
4753 -c "Read from server: .* bytes read"
4754
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004755# Tests for version negotiation
4756
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004757run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004758 "$P_SRV" \
4759 "$P_CLI" \
4760 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004761 -S "mbedtls_ssl_handshake returned" \
4762 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004763 -s "Protocol is TLSv1.2" \
4764 -c "Protocol is TLSv1.2"
4765
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004766# Tests for ALPN extension
4767
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004768run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004769 "$P_SRV debug_level=3" \
4770 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004771 0 \
4772 -C "client hello, adding alpn extension" \
4773 -S "found alpn extension" \
4774 -C "got an alert message, type: \\[2:120]" \
4775 -S "server hello, adding alpn extension" \
4776 -C "found alpn extension " \
4777 -C "Application Layer Protocol is" \
4778 -S "Application Layer Protocol is"
4779
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004780run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004781 "$P_SRV debug_level=3" \
4782 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004783 0 \
4784 -c "client hello, adding alpn extension" \
4785 -s "found alpn extension" \
4786 -C "got an alert message, type: \\[2:120]" \
4787 -S "server hello, adding alpn extension" \
4788 -C "found alpn extension " \
4789 -c "Application Layer Protocol is (none)" \
4790 -S "Application Layer Protocol is"
4791
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004792run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004793 "$P_SRV debug_level=3 alpn=abc,1234" \
4794 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004795 0 \
4796 -C "client hello, adding alpn extension" \
4797 -S "found alpn extension" \
4798 -C "got an alert message, type: \\[2:120]" \
4799 -S "server hello, adding alpn extension" \
4800 -C "found alpn extension " \
4801 -C "Application Layer Protocol is" \
4802 -s "Application Layer Protocol is (none)"
4803
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004804run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004805 "$P_SRV debug_level=3 alpn=abc,1234" \
4806 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004807 0 \
4808 -c "client hello, adding alpn extension" \
4809 -s "found alpn extension" \
4810 -C "got an alert message, type: \\[2:120]" \
4811 -s "server hello, adding alpn extension" \
4812 -c "found alpn extension" \
4813 -c "Application Layer Protocol is abc" \
4814 -s "Application Layer Protocol is abc"
4815
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004816run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004817 "$P_SRV debug_level=3 alpn=abc,1234" \
4818 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004819 0 \
4820 -c "client hello, adding alpn extension" \
4821 -s "found alpn extension" \
4822 -C "got an alert message, type: \\[2:120]" \
4823 -s "server hello, adding alpn extension" \
4824 -c "found alpn extension" \
4825 -c "Application Layer Protocol is abc" \
4826 -s "Application Layer Protocol is abc"
4827
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004828run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004829 "$P_SRV debug_level=3 alpn=abc,1234" \
4830 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004831 0 \
4832 -c "client hello, adding alpn extension" \
4833 -s "found alpn extension" \
4834 -C "got an alert message, type: \\[2:120]" \
4835 -s "server hello, adding alpn extension" \
4836 -c "found alpn extension" \
4837 -c "Application Layer Protocol is 1234" \
4838 -s "Application Layer Protocol is 1234"
4839
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004840run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004841 "$P_SRV debug_level=3 alpn=abc,123" \
4842 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004843 1 \
4844 -c "client hello, adding alpn extension" \
4845 -s "found alpn extension" \
4846 -c "got an alert message, type: \\[2:120]" \
4847 -S "server hello, adding alpn extension" \
4848 -C "found alpn extension" \
4849 -C "Application Layer Protocol is 1234" \
4850 -S "Application Layer Protocol is 1234"
4851
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004852
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004853# Tests for keyUsage in leaf certificates, part 1:
4854# server-side certificate/suite selection
4855
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004856run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004857 "$P_SRV key_file=data_files/server2.key \
4858 crt_file=data_files/server2.ku-ds.crt" \
4859 "$P_CLI" \
4860 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004861 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004862
4863
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004864run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004865 "$P_SRV key_file=data_files/server2.key \
4866 crt_file=data_files/server2.ku-ke.crt" \
4867 "$P_CLI" \
4868 0 \
4869 -c "Ciphersuite is TLS-RSA-WITH-"
4870
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004871run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004872 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004873 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004874 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004875 1 \
4876 -C "Ciphersuite is "
4877
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004878run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004879 "$P_SRV key_file=data_files/server5.key \
4880 crt_file=data_files/server5.ku-ds.crt" \
4881 "$P_CLI" \
4882 0 \
4883 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4884
4885
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004886run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004887 "$P_SRV key_file=data_files/server5.key \
4888 crt_file=data_files/server5.ku-ka.crt" \
4889 "$P_CLI" \
4890 0 \
4891 -c "Ciphersuite is TLS-ECDH-"
4892
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004893run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004894 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004895 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004896 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004897 1 \
4898 -C "Ciphersuite is "
4899
4900# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004901# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004902
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004903run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004904 "$O_SRV -key data_files/server2.key \
4905 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004906 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004907 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4908 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004909 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004910 -C "Processing of the Certificate handshake message failed" \
4911 -c "Ciphersuite is TLS-"
4912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004913run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004914 "$O_SRV -key data_files/server2.key \
4915 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004916 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004917 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4918 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004919 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004920 -C "Processing of the Certificate handshake message failed" \
4921 -c "Ciphersuite is TLS-"
4922
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004923run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004924 "$O_SRV -key data_files/server2.key \
4925 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004926 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004927 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4928 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004929 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004930 -C "Processing of the Certificate handshake message failed" \
4931 -c "Ciphersuite is TLS-"
4932
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004933run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004934 "$O_SRV -key data_files/server2.key \
4935 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004936 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004937 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4938 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004939 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004940 -c "Processing of the Certificate handshake message failed" \
4941 -C "Ciphersuite is TLS-"
4942
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004943run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4944 "$O_SRV -key data_files/server2.key \
4945 -cert data_files/server2.ku-ke.crt" \
4946 "$P_CLI debug_level=1 auth_mode=optional \
4947 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4948 0 \
4949 -c "bad certificate (usage extensions)" \
4950 -C "Processing of the Certificate handshake message failed" \
4951 -c "Ciphersuite is TLS-" \
4952 -c "! Usage does not match the keyUsage extension"
4953
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004954run_test "keyUsage cli: DigitalSignature, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004955 "$O_SRV -key data_files/server2.key \
4956 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004957 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004958 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4959 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004960 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004961 -C "Processing of the Certificate handshake message failed" \
4962 -c "Ciphersuite is TLS-"
4963
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004964run_test "keyUsage cli: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004965 "$O_SRV -key data_files/server2.key \
4966 -cert data_files/server2.ku-ds.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004967 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004968 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4969 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004970 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004971 -c "Processing of the Certificate handshake message failed" \
4972 -C "Ciphersuite is TLS-"
4973
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004974run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4975 "$O_SRV -key data_files/server2.key \
4976 -cert data_files/server2.ku-ds.crt" \
4977 "$P_CLI debug_level=1 auth_mode=optional \
4978 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4979 0 \
4980 -c "bad certificate (usage extensions)" \
4981 -C "Processing of the Certificate handshake message failed" \
4982 -c "Ciphersuite is TLS-" \
4983 -c "! Usage does not match the keyUsage extension"
4984
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004985# Tests for keyUsage in leaf certificates, part 3:
4986# server-side checking of client cert
4987
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004988run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004989 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004990 "$O_CLI -key data_files/server2.key \
4991 -cert data_files/server2.ku-ds.crt" \
4992 0 \
4993 -S "bad certificate (usage extensions)" \
4994 -S "Processing of the Certificate handshake message failed"
4995
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004996run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004997 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004998 "$O_CLI -key data_files/server2.key \
4999 -cert data_files/server2.ku-ke.crt" \
5000 0 \
5001 -s "bad certificate (usage extensions)" \
5002 -S "Processing of the Certificate handshake message failed"
5003
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005004run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005005 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005006 "$O_CLI -key data_files/server2.key \
5007 -cert data_files/server2.ku-ke.crt" \
5008 1 \
5009 -s "bad certificate (usage extensions)" \
5010 -s "Processing of the Certificate handshake message failed"
5011
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005012run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005013 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005014 "$O_CLI -key data_files/server5.key \
5015 -cert data_files/server5.ku-ds.crt" \
5016 0 \
5017 -S "bad certificate (usage extensions)" \
5018 -S "Processing of the Certificate handshake message failed"
5019
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005020run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005021 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02005022 "$O_CLI -key data_files/server5.key \
5023 -cert data_files/server5.ku-ka.crt" \
5024 0 \
5025 -s "bad certificate (usage extensions)" \
5026 -S "Processing of the Certificate handshake message failed"
5027
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005028# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
5029
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005030run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005031 "$P_SRV key_file=data_files/server5.key \
5032 crt_file=data_files/server5.eku-srv.crt" \
5033 "$P_CLI" \
5034 0
5035
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005036run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005037 "$P_SRV key_file=data_files/server5.key \
5038 crt_file=data_files/server5.eku-srv.crt" \
5039 "$P_CLI" \
5040 0
5041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005042run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005043 "$P_SRV key_file=data_files/server5.key \
5044 crt_file=data_files/server5.eku-cs_any.crt" \
5045 "$P_CLI" \
5046 0
5047
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005048run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005049 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005050 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005051 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005052 1
5053
5054# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5055
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005056run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005057 "$O_SRV -key data_files/server5.key \
5058 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005059 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005060 0 \
5061 -C "bad certificate (usage extensions)" \
5062 -C "Processing of the Certificate handshake message failed" \
5063 -c "Ciphersuite is TLS-"
5064
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005065run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005066 "$O_SRV -key data_files/server5.key \
5067 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005068 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005069 0 \
5070 -C "bad certificate (usage extensions)" \
5071 -C "Processing of the Certificate handshake message failed" \
5072 -c "Ciphersuite is TLS-"
5073
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005074run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005075 "$O_SRV -key data_files/server5.key \
5076 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005077 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005078 0 \
5079 -C "bad certificate (usage extensions)" \
5080 -C "Processing of the Certificate handshake message failed" \
5081 -c "Ciphersuite is TLS-"
5082
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005083run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005084 "$O_SRV -key data_files/server5.key \
5085 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005086 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005087 1 \
5088 -c "bad certificate (usage extensions)" \
5089 -c "Processing of the Certificate handshake message failed" \
5090 -C "Ciphersuite is TLS-"
5091
5092# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5093
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005094run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005095 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005096 "$O_CLI -key data_files/server5.key \
5097 -cert data_files/server5.eku-cli.crt" \
5098 0 \
5099 -S "bad certificate (usage extensions)" \
5100 -S "Processing of the Certificate handshake message failed"
5101
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005102run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005103 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005104 "$O_CLI -key data_files/server5.key \
5105 -cert data_files/server5.eku-srv_cli.crt" \
5106 0 \
5107 -S "bad certificate (usage extensions)" \
5108 -S "Processing of the Certificate handshake message failed"
5109
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005110run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005111 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005112 "$O_CLI -key data_files/server5.key \
5113 -cert data_files/server5.eku-cs_any.crt" \
5114 0 \
5115 -S "bad certificate (usage extensions)" \
5116 -S "Processing of the Certificate handshake message failed"
5117
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005118run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005119 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005120 "$O_CLI -key data_files/server5.key \
5121 -cert data_files/server5.eku-cs.crt" \
5122 0 \
5123 -s "bad certificate (usage extensions)" \
5124 -S "Processing of the Certificate handshake message failed"
5125
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005126run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005127 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005128 "$O_CLI -key data_files/server5.key \
5129 -cert data_files/server5.eku-cs.crt" \
5130 1 \
5131 -s "bad certificate (usage extensions)" \
5132 -s "Processing of the Certificate handshake message failed"
5133
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005134# Tests for DHM parameters loading
5135
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005136run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005137 "$P_SRV" \
5138 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5139 debug_level=3" \
5140 0 \
5141 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005142 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005143
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005144run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005145 "$P_SRV dhm_file=data_files/dhparams.pem" \
5146 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5147 debug_level=3" \
5148 0 \
5149 -c "value of 'DHM: P ' (1024 bits)" \
5150 -c "value of 'DHM: G ' (2 bits)"
5151
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005152# Tests for DHM client-side size checking
5153
5154run_test "DHM size: server default, client default, OK" \
5155 "$P_SRV" \
5156 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5157 debug_level=1" \
5158 0 \
5159 -C "DHM prime too short:"
5160
5161run_test "DHM size: server default, client 2048, OK" \
5162 "$P_SRV" \
5163 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5164 debug_level=1 dhmlen=2048" \
5165 0 \
5166 -C "DHM prime too short:"
5167
5168run_test "DHM size: server 1024, client default, OK" \
5169 "$P_SRV dhm_file=data_files/dhparams.pem" \
5170 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5171 debug_level=1" \
5172 0 \
5173 -C "DHM prime too short:"
5174
Gilles Peskinec6b0d962020-12-08 22:31:52 +01005175run_test "DHM size: server 999, client 999, OK" \
5176 "$P_SRV dhm_file=data_files/dh.999.pem" \
5177 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5178 debug_level=1 dhmlen=999" \
5179 0 \
5180 -C "DHM prime too short:"
5181
5182run_test "DHM size: server 1000, client 1000, OK" \
5183 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5184 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5185 debug_level=1 dhmlen=1000" \
5186 0 \
5187 -C "DHM prime too short:"
5188
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005189run_test "DHM size: server 1000, client default, rejected" \
5190 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5191 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5192 debug_level=1" \
5193 1 \
5194 -c "DHM prime too short:"
5195
Gilles Peskinec6b0d962020-12-08 22:31:52 +01005196run_test "DHM size: server 1000, client 1001, rejected" \
5197 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5198 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5199 debug_level=1 dhmlen=1001" \
5200 1 \
5201 -c "DHM prime too short:"
5202
5203run_test "DHM size: server 999, client 1000, rejected" \
5204 "$P_SRV dhm_file=data_files/dh.999.pem" \
5205 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5206 debug_level=1 dhmlen=1000" \
5207 1 \
5208 -c "DHM prime too short:"
5209
5210run_test "DHM size: server 998, client 999, rejected" \
5211 "$P_SRV dhm_file=data_files/dh.998.pem" \
5212 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5213 debug_level=1 dhmlen=999" \
5214 1 \
5215 -c "DHM prime too short:"
5216
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005217run_test "DHM size: server default, client 2049, rejected" \
5218 "$P_SRV" \
5219 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5220 debug_level=1 dhmlen=2049" \
5221 1 \
5222 -c "DHM prime too short:"
5223
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005224# Tests for PSK callback
5225
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005226run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005227 "$P_SRV psk=abc123 psk_identity=foo" \
5228 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5229 psk_identity=foo psk=abc123" \
5230 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005231 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005232 -S "SSL - Unknown identity received" \
5233 -S "SSL - Verification of the message MAC failed"
5234
Hanno Beckerf7027512018-10-23 15:27:39 +01005235requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5236run_test "PSK callback: opaque psk on client, no callback" \
5237 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5238 "$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 +00005239 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005240 0 \
5241 -c "skip PMS generation for opaque PSK"\
5242 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005243 -C "session hash for extended master secret"\
5244 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005245 -S "SSL - None of the common ciphersuites is usable" \
5246 -S "SSL - Unknown identity received" \
5247 -S "SSL - Verification of the message MAC failed"
5248
5249requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5250run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5251 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5252 "$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 +00005253 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005254 0 \
5255 -c "skip PMS generation for opaque PSK"\
5256 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005257 -C "session hash for extended master secret"\
5258 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005259 -S "SSL - None of the common ciphersuites is usable" \
5260 -S "SSL - Unknown identity received" \
5261 -S "SSL - Verification of the message MAC failed"
5262
5263requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5264run_test "PSK callback: opaque psk on client, no callback, EMS" \
5265 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5266 "$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 +00005267 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005268 0 \
5269 -c "skip PMS generation for opaque PSK"\
5270 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005271 -c "session hash for extended master secret"\
5272 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005273 -S "SSL - None of the common ciphersuites is usable" \
5274 -S "SSL - Unknown identity received" \
5275 -S "SSL - Verification of the message MAC failed"
5276
5277requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5278run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5279 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5280 "$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 +00005281 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005282 0 \
5283 -c "skip PMS generation for opaque PSK"\
5284 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005285 -c "session hash for extended master secret"\
5286 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005287 -S "SSL - None of the common ciphersuites is usable" \
5288 -S "SSL - Unknown identity received" \
5289 -S "SSL - Verification of the message MAC failed"
5290
Hanno Becker28c79dc2018-10-26 13:15:08 +01005291requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5292run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005293 "$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 +01005294 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5295 psk_identity=foo psk=abc123" \
5296 0 \
5297 -C "skip PMS generation for opaque PSK"\
5298 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005299 -C "session hash for extended master secret"\
5300 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005301 -S "SSL - None of the common ciphersuites is usable" \
5302 -S "SSL - Unknown identity received" \
5303 -S "SSL - Verification of the message MAC failed"
5304
5305requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5306run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005307 "$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 +01005308 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5309 psk_identity=foo psk=abc123" \
5310 0 \
5311 -C "skip PMS generation for opaque PSK"\
5312 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005313 -C "session hash for extended master secret"\
5314 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005315 -S "SSL - None of the common ciphersuites is usable" \
5316 -S "SSL - Unknown identity received" \
5317 -S "SSL - Verification of the message MAC failed"
5318
5319requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5320run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005321 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005322 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5323 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5324 psk_identity=foo psk=abc123 extended_ms=1" \
5325 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005326 -c "session hash for extended master secret"\
5327 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005328 -C "skip PMS generation for opaque PSK"\
5329 -s "skip PMS generation for opaque PSK"\
5330 -S "SSL - None of the common ciphersuites is usable" \
5331 -S "SSL - Unknown identity received" \
5332 -S "SSL - Verification of the message MAC failed"
5333
5334requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5335run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005336 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005337 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5338 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5339 psk_identity=foo psk=abc123 extended_ms=1" \
5340 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005341 -c "session hash for extended master secret"\
5342 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005343 -C "skip PMS generation for opaque PSK"\
5344 -s "skip PMS generation for opaque PSK"\
5345 -S "SSL - None of the common ciphersuites is usable" \
5346 -S "SSL - Unknown identity received" \
5347 -S "SSL - Verification of the message MAC failed"
5348
5349requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5350run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005351 "$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 +01005352 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5353 psk_identity=def psk=beef" \
5354 0 \
5355 -C "skip PMS generation for opaque PSK"\
5356 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005357 -C "session hash for extended master secret"\
5358 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005359 -S "SSL - None of the common ciphersuites is usable" \
5360 -S "SSL - Unknown identity received" \
5361 -S "SSL - Verification of the message MAC failed"
5362
5363requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5364run_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 +00005365 "$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 +01005366 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5367 psk_identity=def psk=beef" \
5368 0 \
5369 -C "skip PMS generation for opaque PSK"\
5370 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005371 -C "session hash for extended master secret"\
5372 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005373 -S "SSL - None of the common ciphersuites is usable" \
5374 -S "SSL - Unknown identity received" \
5375 -S "SSL - Verification of the message MAC failed"
5376
5377requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5378run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005379 "$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 +01005380 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5381 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5382 psk_identity=abc psk=dead extended_ms=1" \
5383 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005384 -c "session hash for extended master secret"\
5385 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005386 -C "skip PMS generation for opaque PSK"\
5387 -s "skip PMS generation for opaque PSK"\
5388 -S "SSL - None of the common ciphersuites is usable" \
5389 -S "SSL - Unknown identity received" \
5390 -S "SSL - Verification of the message MAC failed"
5391
5392requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5393run_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 +00005394 "$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 +01005395 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5396 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5397 psk_identity=abc psk=dead extended_ms=1" \
5398 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005399 -c "session hash for extended master secret"\
5400 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005401 -C "skip PMS generation for opaque PSK"\
5402 -s "skip PMS generation for opaque PSK"\
5403 -S "SSL - None of the common ciphersuites is usable" \
5404 -S "SSL - Unknown identity received" \
5405 -S "SSL - Verification of the message MAC failed"
5406
5407requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5408run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005409 "$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 +01005410 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5411 psk_identity=def psk=beef" \
5412 0 \
5413 -C "skip PMS generation for opaque PSK"\
5414 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005415 -C "session hash for extended master secret"\
5416 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005417 -S "SSL - None of the common ciphersuites is usable" \
5418 -S "SSL - Unknown identity received" \
5419 -S "SSL - Verification of the message MAC failed"
5420
5421requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5422run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005423 "$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 +01005424 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5425 psk_identity=def psk=beef" \
5426 0 \
5427 -C "skip PMS generation for opaque PSK"\
5428 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005429 -C "session hash for extended master secret"\
5430 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005431 -S "SSL - None of the common ciphersuites is usable" \
5432 -S "SSL - Unknown identity received" \
5433 -S "SSL - Verification of the message MAC failed"
5434
5435requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5436run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005437 "$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 +01005438 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5439 psk_identity=def psk=beef" \
5440 0 \
5441 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005442 -C "session hash for extended master secret"\
5443 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005444 -S "SSL - None of the common ciphersuites is usable" \
5445 -S "SSL - Unknown identity received" \
5446 -S "SSL - Verification of the message MAC failed"
5447
5448requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5449run_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 +00005450 "$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 +01005451 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5452 psk_identity=def psk=beef" \
5453 0 \
5454 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005455 -C "session hash for extended master secret"\
5456 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005457 -S "SSL - None of the common ciphersuites is usable" \
5458 -S "SSL - Unknown identity received" \
5459 -S "SSL - Verification of the message MAC failed"
5460
5461requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5462run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005463 "$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 +01005464 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5465 psk_identity=def psk=beef" \
5466 1 \
5467 -s "SSL - Verification of the message MAC failed"
5468
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005469run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005470 "$P_SRV" \
5471 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5472 psk_identity=foo psk=abc123" \
5473 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005474 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005475 -S "SSL - Unknown identity received" \
5476 -S "SSL - Verification of the message MAC failed"
5477
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005478run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005479 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5480 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5481 psk_identity=foo psk=abc123" \
5482 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005483 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005484 -s "SSL - Unknown identity received" \
5485 -S "SSL - Verification of the message MAC failed"
5486
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005487run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005488 "$P_SRV psk_list=abc,dead,def,beef" \
5489 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5490 psk_identity=abc psk=dead" \
5491 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005492 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005493 -S "SSL - Unknown identity received" \
5494 -S "SSL - Verification of the message MAC failed"
5495
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005496run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005497 "$P_SRV psk_list=abc,dead,def,beef" \
5498 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5499 psk_identity=def psk=beef" \
5500 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005501 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005502 -S "SSL - Unknown identity received" \
5503 -S "SSL - Verification of the message MAC failed"
5504
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005505run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005506 "$P_SRV psk_list=abc,dead,def,beef" \
5507 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5508 psk_identity=ghi psk=beef" \
5509 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005510 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005511 -s "SSL - Unknown identity received" \
5512 -S "SSL - Verification of the message MAC failed"
5513
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005514run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005515 "$P_SRV psk_list=abc,dead,def,beef" \
5516 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5517 psk_identity=abc psk=beef" \
5518 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005519 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005520 -S "SSL - Unknown identity received" \
5521 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005522
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005523# Tests for EC J-PAKE
5524
Hanno Beckerfa452c42020-08-14 15:42:49 +01005525requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005526run_test "ECJPAKE: client not configured" \
5527 "$P_SRV debug_level=3" \
5528 "$P_CLI debug_level=3" \
5529 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005530 -C "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005531 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005532 -S "found ecjpake kkpp extension" \
5533 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005534 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005535 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005536 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005537 -S "None of the common ciphersuites is usable"
5538
Hanno Beckerfa452c42020-08-14 15:42:49 +01005539requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005540run_test "ECJPAKE: server not configured" \
5541 "$P_SRV debug_level=3" \
5542 "$P_CLI debug_level=3 ecjpake_pw=bla \
5543 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5544 1 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005545 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005546 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005547 -s "found ecjpake kkpp extension" \
5548 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005549 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005550 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005551 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005552 -s "None of the common ciphersuites is usable"
5553
Hanno Beckerfa452c42020-08-14 15:42:49 +01005554requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005555run_test "ECJPAKE: working, TLS" \
5556 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5557 "$P_CLI debug_level=3 ecjpake_pw=bla \
5558 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005559 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005560 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005561 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005562 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005563 -s "found ecjpake kkpp extension" \
5564 -S "skip ecjpake kkpp extension" \
5565 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005566 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005567 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005568 -S "None of the common ciphersuites is usable" \
5569 -S "SSL - Verification of the message MAC failed"
5570
Janos Follath74537a62016-09-02 13:45:28 +01005571server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005572requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005573run_test "ECJPAKE: password mismatch, TLS" \
5574 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5575 "$P_CLI debug_level=3 ecjpake_pw=bad \
5576 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5577 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005578 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005579 -s "SSL - Verification of the message MAC failed"
5580
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005581requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005582run_test "ECJPAKE: working, DTLS" \
5583 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5584 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5585 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5586 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005587 -c "re-using cached ecjpake parameters" \
5588 -S "SSL - Verification of the message MAC failed"
5589
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005590requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005591run_test "ECJPAKE: working, DTLS, no cookie" \
5592 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5593 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5594 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5595 0 \
5596 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005597 -S "SSL - Verification of the message MAC failed"
5598
Janos Follath74537a62016-09-02 13:45:28 +01005599server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005600requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005601run_test "ECJPAKE: password mismatch, DTLS" \
5602 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5603 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5604 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5605 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005606 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005607 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005608
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005609# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005610requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005611run_test "ECJPAKE: working, DTLS, nolog" \
5612 "$P_SRV dtls=1 ecjpake_pw=bla" \
5613 "$P_CLI dtls=1 ecjpake_pw=bla \
5614 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5615 0
5616
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005617# Test for ClientHello without extensions
5618
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005619requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005620run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005621 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005622 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005623 0 \
5624 -s "dumping 'client hello extensions' (0 bytes)"
5625
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005626# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005627
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005628run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005629 "$P_SRV" \
5630 "$P_CLI request_size=100" \
5631 0 \
5632 -s "Read from client: 100 bytes read$"
5633
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005634run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005635 "$P_SRV" \
5636 "$P_CLI request_size=500" \
5637 0 \
5638 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005639
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005640# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005641
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005642run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005643 "$P_SRV" \
5644 "$P_CLI request_size=1 force_version=tls1_2 \
5645 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5646 0 \
5647 -s "Read from client: 1 bytes read"
5648
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005649run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005650 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005651 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005652 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005653 0 \
5654 -s "Read from client: 1 bytes read"
5655
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005656run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005657 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005658 "$P_CLI request_size=1 force_version=tls1_2 \
5659 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005660 0 \
5661 -s "Read from client: 1 bytes read"
5662
Hanno Becker32c55012017-11-10 08:42:54 +00005663requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005664run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005665 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005666 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005667 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005668 0 \
5669 -s "Read from client: 1 bytes read"
5670
Hanno Becker8501f982017-11-10 08:59:04 +00005671requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005672run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005673 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005674 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005675 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005676 0 \
5677 -s "Read from client: 1 bytes read"
5678
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005679run_test "Small client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005680 "$P_SRV" \
5681 "$P_CLI request_size=1 force_version=tls1_2 \
5682 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5683 0 \
5684 -s "Read from client: 1 bytes read"
5685
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005686run_test "Small client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005687 "$P_SRV" \
5688 "$P_CLI request_size=1 force_version=tls1_2 \
5689 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5690 0 \
5691 -s "Read from client: 1 bytes read"
5692
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005693# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005694
5695requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005696run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005697 "$P_SRV dtls=1 force_version=dtls1_2" \
5698 "$P_CLI dtls=1 request_size=1 \
5699 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5700 0 \
5701 -s "Read from client: 1 bytes read"
5702
5703requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005704run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005705 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005706 "$P_CLI dtls=1 request_size=1 \
5707 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5708 0 \
5709 -s "Read from client: 1 bytes read"
5710
5711requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5712requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005713run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005714 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005715 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005716 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005717 0 \
5718 -s "Read from client: 1 bytes read"
5719
5720requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5721requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005722run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005723 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005724 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005725 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005726 0 \
5727 -s "Read from client: 1 bytes read"
5728
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005729# Tests for small server packets
5730
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005731run_test "Small server packet TLS 1.2 BlockCipher" \
5732 "$P_SRV response_size=1" \
5733 "$P_CLI force_version=tls1_2 \
5734 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5735 0 \
5736 -c "Read from server: 1 bytes read"
5737
5738run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5739 "$P_SRV response_size=1" \
5740 "$P_CLI force_version=tls1_2 \
5741 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5742 0 \
5743 -c "Read from server: 1 bytes read"
5744
5745run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5746 "$P_SRV response_size=1" \
5747 "$P_CLI force_version=tls1_2 \
5748 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5749 0 \
5750 -c "Read from server: 1 bytes read"
5751
5752requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5753run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5754 "$P_SRV response_size=1 trunc_hmac=1" \
5755 "$P_CLI force_version=tls1_2 \
5756 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5757 0 \
5758 -c "Read from server: 1 bytes read"
5759
5760requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5761run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5762 "$P_SRV response_size=1 trunc_hmac=1" \
5763 "$P_CLI force_version=tls1_2 \
5764 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5765 0 \
5766 -c "Read from server: 1 bytes read"
5767
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005768run_test "Small server packet TLS 1.2 AEAD" \
5769 "$P_SRV response_size=1" \
5770 "$P_CLI force_version=tls1_2 \
5771 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5772 0 \
5773 -c "Read from server: 1 bytes read"
5774
5775run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5776 "$P_SRV response_size=1" \
5777 "$P_CLI force_version=tls1_2 \
5778 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5779 0 \
5780 -c "Read from server: 1 bytes read"
5781
5782# Tests for small server packets in DTLS
5783
5784requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005785run_test "Small server packet DTLS 1.2" \
5786 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5787 "$P_CLI dtls=1 \
5788 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5789 0 \
5790 -c "Read from server: 1 bytes read"
5791
5792requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5793run_test "Small server packet DTLS 1.2, without EtM" \
5794 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5795 "$P_CLI dtls=1 \
5796 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5797 0 \
5798 -c "Read from server: 1 bytes read"
5799
5800requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5801requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5802run_test "Small server packet DTLS 1.2, truncated hmac" \
5803 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5804 "$P_CLI dtls=1 \
5805 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5806 0 \
5807 -c "Read from server: 1 bytes read"
5808
5809requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5810requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5811run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5812 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5813 "$P_CLI dtls=1 \
5814 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5815 0 \
5816 -c "Read from server: 1 bytes read"
5817
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005818# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005819
Angus Grattonc4dd0732018-04-11 16:28:39 +10005820# How many fragments do we expect to write $1 bytes?
5821fragments_for_write() {
5822 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5823}
5824
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005825run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005826 "$P_SRV" \
5827 "$P_CLI request_size=16384 force_version=tls1_2 \
5828 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5829 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005830 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5831 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005832
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005833run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005834 "$P_SRV" \
5835 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
5836 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5837 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005838 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005839
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005840run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005841 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005842 "$P_CLI request_size=16384 force_version=tls1_2 \
5843 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005844 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005845 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5846 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005847
Hanno Becker32c55012017-11-10 08:42:54 +00005848requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005849run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005850 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005851 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005852 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005853 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005854 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005855
Hanno Becker278fc7a2017-11-10 09:16:28 +00005856requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005857run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005858 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005859 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005860 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005861 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005862 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5863 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005864
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005865run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005866 "$P_SRV" \
5867 "$P_CLI request_size=16384 force_version=tls1_2 \
5868 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5869 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005870 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5871 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005872
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005873run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005874 "$P_SRV" \
5875 "$P_CLI request_size=16384 force_version=tls1_2 \
5876 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5877 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005878 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5879 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005880
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005881run_test "Large server packet TLS 1.2 BlockCipher" \
5882 "$P_SRV response_size=16384" \
5883 "$P_CLI force_version=tls1_2 \
5884 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5885 0 \
5886 -c "Read from server: 16384 bytes read"
5887
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005888run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5889 "$P_SRV response_size=16384" \
5890 "$P_CLI force_version=tls1_2 etm=0 \
5891 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5892 0 \
5893 -s "16384 bytes written in 1 fragments" \
5894 -c "Read from server: 16384 bytes read"
5895
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005896run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5897 "$P_SRV response_size=16384" \
5898 "$P_CLI force_version=tls1_2 \
5899 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5900 0 \
5901 -c "Read from server: 16384 bytes read"
5902
5903requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5904run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5905 "$P_SRV response_size=16384" \
5906 "$P_CLI force_version=tls1_2 \
5907 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5908 trunc_hmac=1" \
5909 0 \
5910 -c "Read from server: 16384 bytes read"
5911
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005912run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5913 "$P_SRV response_size=16384 trunc_hmac=1" \
5914 "$P_CLI force_version=tls1_2 \
5915 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5916 0 \
5917 -s "16384 bytes written in 1 fragments" \
5918 -c "Read from server: 16384 bytes read"
5919
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005920run_test "Large server packet TLS 1.2 AEAD" \
5921 "$P_SRV response_size=16384" \
5922 "$P_CLI force_version=tls1_2 \
5923 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5924 0 \
5925 -c "Read from server: 16384 bytes read"
5926
5927run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5928 "$P_SRV response_size=16384" \
5929 "$P_CLI force_version=tls1_2 \
5930 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5931 0 \
5932 -c "Read from server: 16384 bytes read"
5933
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005934# Tests for restartable ECC
5935
5936requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5937run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005938 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005939 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005940 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005941 debug_level=1" \
5942 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005943 -C "x509_verify_cert.*4b00" \
5944 -C "mbedtls_pk_verify.*4b00" \
5945 -C "mbedtls_ecdh_make_public.*4b00" \
5946 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005947
5948requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5949run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005950 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005951 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005952 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005953 debug_level=1 ec_max_ops=0" \
5954 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005955 -C "x509_verify_cert.*4b00" \
5956 -C "mbedtls_pk_verify.*4b00" \
5957 -C "mbedtls_ecdh_make_public.*4b00" \
5958 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005959
5960requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5961run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005962 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005963 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005964 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005965 debug_level=1 ec_max_ops=65535" \
5966 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005967 -C "x509_verify_cert.*4b00" \
5968 -C "mbedtls_pk_verify.*4b00" \
5969 -C "mbedtls_ecdh_make_public.*4b00" \
5970 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005971
5972requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5973run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005974 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005975 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005976 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005977 debug_level=1 ec_max_ops=1000" \
5978 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005979 -c "x509_verify_cert.*4b00" \
5980 -c "mbedtls_pk_verify.*4b00" \
5981 -c "mbedtls_ecdh_make_public.*4b00" \
5982 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005983
5984requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005985run_test "EC restart: TLS, max_ops=1000, badsign" \
5986 "$P_SRV auth_mode=required \
5987 crt_file=data_files/server5-badsign.crt \
5988 key_file=data_files/server5.key" \
5989 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5990 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5991 debug_level=1 ec_max_ops=1000" \
5992 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005993 -c "x509_verify_cert.*4b00" \
5994 -C "mbedtls_pk_verify.*4b00" \
5995 -C "mbedtls_ecdh_make_public.*4b00" \
5996 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005997 -c "! The certificate is not correctly signed by the trusted CA" \
5998 -c "! mbedtls_ssl_handshake returned" \
5999 -c "X509 - Certificate verification failed"
6000
6001requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6002run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
6003 "$P_SRV auth_mode=required \
6004 crt_file=data_files/server5-badsign.crt \
6005 key_file=data_files/server5.key" \
6006 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6007 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6008 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
6009 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006010 -c "x509_verify_cert.*4b00" \
6011 -c "mbedtls_pk_verify.*4b00" \
6012 -c "mbedtls_ecdh_make_public.*4b00" \
6013 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006014 -c "! The certificate is not correctly signed by the trusted CA" \
6015 -C "! mbedtls_ssl_handshake returned" \
6016 -C "X509 - Certificate verification failed"
6017
6018requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6019run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
6020 "$P_SRV auth_mode=required \
6021 crt_file=data_files/server5-badsign.crt \
6022 key_file=data_files/server5.key" \
6023 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6024 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6025 debug_level=1 ec_max_ops=1000 auth_mode=none" \
6026 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006027 -C "x509_verify_cert.*4b00" \
6028 -c "mbedtls_pk_verify.*4b00" \
6029 -c "mbedtls_ecdh_make_public.*4b00" \
6030 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006031 -C "! The certificate is not correctly signed by the trusted CA" \
6032 -C "! mbedtls_ssl_handshake returned" \
6033 -C "X509 - Certificate verification failed"
6034
6035requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006036run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006037 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006038 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006039 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006040 dtls=1 debug_level=1 ec_max_ops=1000" \
6041 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006042 -c "x509_verify_cert.*4b00" \
6043 -c "mbedtls_pk_verify.*4b00" \
6044 -c "mbedtls_ecdh_make_public.*4b00" \
6045 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006046
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006047requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6048run_test "EC restart: TLS, max_ops=1000 no client auth" \
6049 "$P_SRV" \
6050 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6051 debug_level=1 ec_max_ops=1000" \
6052 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006053 -c "x509_verify_cert.*4b00" \
6054 -c "mbedtls_pk_verify.*4b00" \
6055 -c "mbedtls_ecdh_make_public.*4b00" \
6056 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006057
6058requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6059run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6060 "$P_SRV psk=abc123" \
6061 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6062 psk=abc123 debug_level=1 ec_max_ops=1000" \
6063 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006064 -C "x509_verify_cert.*4b00" \
6065 -C "mbedtls_pk_verify.*4b00" \
6066 -C "mbedtls_ecdh_make_public.*4b00" \
6067 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006068
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006069# Tests of asynchronous private key support in SSL
6070
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006071requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006072run_test "SSL async private: sign, delay=0" \
6073 "$P_SRV \
6074 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006075 "$P_CLI" \
6076 0 \
6077 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006078 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006079
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006080requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006081run_test "SSL async private: sign, delay=1" \
6082 "$P_SRV \
6083 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006084 "$P_CLI" \
6085 0 \
6086 -s "Async sign callback: using key slot " \
6087 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006088 -s "Async resume (slot [0-9]): sign done, status=0"
6089
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006090requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6091run_test "SSL async private: sign, delay=2" \
6092 "$P_SRV \
6093 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6094 "$P_CLI" \
6095 0 \
6096 -s "Async sign callback: using key slot " \
6097 -U "Async sign callback: using key slot " \
6098 -s "Async resume (slot [0-9]): call 1 more times." \
6099 -s "Async resume (slot [0-9]): call 0 more times." \
6100 -s "Async resume (slot [0-9]): sign done, status=0"
6101
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006102requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerc5722d12020-10-09 11:10:42 +01006103requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Gilles Peskine807d74a2018-04-30 10:30:49 +02006104run_test "SSL async private: sign, SNI" \
6105 "$P_SRV debug_level=3 \
6106 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6107 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6108 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6109 "$P_CLI server_name=polarssl.example" \
6110 0 \
6111 -s "Async sign callback: using key slot " \
6112 -s "Async resume (slot [0-9]): sign done, status=0" \
6113 -s "parse ServerName extension" \
6114 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6115 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6116
6117requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006118run_test "SSL async private: decrypt, delay=0" \
6119 "$P_SRV \
6120 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6121 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6122 0 \
6123 -s "Async decrypt callback: using key slot " \
6124 -s "Async resume (slot [0-9]): decrypt done, status=0"
6125
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006126requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006127run_test "SSL async private: decrypt, delay=1" \
6128 "$P_SRV \
6129 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6130 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6131 0 \
6132 -s "Async decrypt callback: using key slot " \
6133 -s "Async resume (slot [0-9]): call 0 more times." \
6134 -s "Async resume (slot [0-9]): decrypt done, status=0"
6135
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006136requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006137run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6138 "$P_SRV psk=abc123 \
6139 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6140 "$P_CLI psk=abc123 \
6141 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6142 0 \
6143 -s "Async decrypt callback: using key slot " \
6144 -s "Async resume (slot [0-9]): decrypt done, status=0"
6145
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006146requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006147run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6148 "$P_SRV psk=abc123 \
6149 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6150 "$P_CLI psk=abc123 \
6151 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6152 0 \
6153 -s "Async decrypt callback: using key slot " \
6154 -s "Async resume (slot [0-9]): call 0 more times." \
6155 -s "Async resume (slot [0-9]): decrypt done, status=0"
6156
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006157requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006158run_test "SSL async private: sign callback not present" \
6159 "$P_SRV \
6160 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6161 "$P_CLI; [ \$? -eq 1 ] &&
6162 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6163 0 \
6164 -S "Async sign callback" \
6165 -s "! mbedtls_ssl_handshake returned" \
6166 -s "The own private key or pre-shared key is not set, but needed" \
6167 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6168 -s "Successful connection"
6169
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006170requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006171run_test "SSL async private: decrypt callback not present" \
6172 "$P_SRV debug_level=1 \
6173 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6174 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6175 [ \$? -eq 1 ] && $P_CLI" \
6176 0 \
6177 -S "Async decrypt callback" \
6178 -s "! mbedtls_ssl_handshake returned" \
6179 -s "got no RSA private key" \
6180 -s "Async resume (slot [0-9]): sign done, status=0" \
6181 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006182
6183# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006184requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006185run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006186 "$P_SRV \
6187 async_operations=s async_private_delay1=1 \
6188 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6189 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006190 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6191 0 \
6192 -s "Async sign callback: using key slot 0," \
6193 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006194 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006195
6196# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006197requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006198run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006199 "$P_SRV \
6200 async_operations=s async_private_delay2=1 \
6201 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6202 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006203 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6204 0 \
6205 -s "Async sign callback: using key slot 0," \
6206 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006207 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006208
6209# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006210requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006211run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006212 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006213 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006214 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6215 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006216 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6217 0 \
6218 -s "Async sign callback: using key slot 1," \
6219 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006220 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006221
6222# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006223requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006224run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006225 "$P_SRV \
6226 async_operations=s async_private_delay1=1 \
6227 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6228 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006229 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6230 0 \
6231 -s "Async sign callback: no key matches this certificate."
6232
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006233requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006234run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006235 "$P_SRV \
6236 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6237 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006238 "$P_CLI" \
6239 1 \
6240 -s "Async sign callback: injected error" \
6241 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006242 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006243 -s "! mbedtls_ssl_handshake returned"
6244
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006245requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006246run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006247 "$P_SRV \
6248 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6249 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006250 "$P_CLI" \
6251 1 \
6252 -s "Async sign callback: using key slot " \
6253 -S "Async resume" \
6254 -s "Async cancel"
6255
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006256requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006257run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006258 "$P_SRV \
6259 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6260 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006261 "$P_CLI" \
6262 1 \
6263 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006264 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006265 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006266 -s "! mbedtls_ssl_handshake returned"
6267
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006268requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006269run_test "SSL async private: decrypt, error in start" \
6270 "$P_SRV \
6271 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6272 async_private_error=1" \
6273 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6274 1 \
6275 -s "Async decrypt callback: injected error" \
6276 -S "Async resume" \
6277 -S "Async cancel" \
6278 -s "! mbedtls_ssl_handshake returned"
6279
6280requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6281run_test "SSL async private: decrypt, cancel after start" \
6282 "$P_SRV \
6283 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6284 async_private_error=2" \
6285 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6286 1 \
6287 -s "Async decrypt callback: using key slot " \
6288 -S "Async resume" \
6289 -s "Async cancel"
6290
6291requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6292run_test "SSL async private: decrypt, error in resume" \
6293 "$P_SRV \
6294 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6295 async_private_error=3" \
6296 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6297 1 \
6298 -s "Async decrypt callback: using key slot " \
6299 -s "Async resume callback: decrypt done but injected error" \
6300 -S "Async cancel" \
6301 -s "! mbedtls_ssl_handshake returned"
6302
6303requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006304run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006305 "$P_SRV \
6306 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6307 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006308 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6309 0 \
6310 -s "Async cancel" \
6311 -s "! mbedtls_ssl_handshake returned" \
6312 -s "Async resume" \
6313 -s "Successful connection"
6314
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006315requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006316run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006317 "$P_SRV \
6318 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6319 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006320 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6321 0 \
6322 -s "! mbedtls_ssl_handshake returned" \
6323 -s "Async resume" \
6324 -s "Successful connection"
6325
6326# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006327requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006328run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006329 "$P_SRV \
6330 async_operations=s async_private_delay1=1 async_private_error=-2 \
6331 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6332 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006333 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6334 [ \$? -eq 1 ] &&
6335 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6336 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006337 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006338 -S "Async resume" \
6339 -s "Async cancel" \
6340 -s "! mbedtls_ssl_handshake returned" \
6341 -s "Async sign callback: no key matches this certificate." \
6342 -s "Successful connection"
6343
6344# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006345requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006346run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006347 "$P_SRV \
6348 async_operations=s async_private_delay1=1 async_private_error=-3 \
6349 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6350 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006351 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6352 [ \$? -eq 1 ] &&
6353 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6354 0 \
6355 -s "Async resume" \
6356 -s "! mbedtls_ssl_handshake returned" \
6357 -s "Async sign callback: no key matches this certificate." \
6358 -s "Successful connection"
6359
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006360requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006361requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006362run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006363 "$P_SRV \
6364 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006365 exchanges=2 renegotiation=1" \
6366 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6367 0 \
6368 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006369 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006370
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006371requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006372requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006373run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006374 "$P_SRV \
6375 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006376 exchanges=2 renegotiation=1 renegotiate=1" \
6377 "$P_CLI exchanges=2 renegotiation=1" \
6378 0 \
6379 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006380 -s "Async resume (slot [0-9]): sign done, status=0"
6381
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006382requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006383requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006384run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006385 "$P_SRV \
6386 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6387 exchanges=2 renegotiation=1" \
6388 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6389 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6390 0 \
6391 -s "Async decrypt callback: using key slot " \
6392 -s "Async resume (slot [0-9]): decrypt done, status=0"
6393
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006394requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006395requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006396run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006397 "$P_SRV \
6398 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6399 exchanges=2 renegotiation=1 renegotiate=1" \
6400 "$P_CLI exchanges=2 renegotiation=1 \
6401 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6402 0 \
6403 -s "Async decrypt callback: using key slot " \
6404 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006405
Ron Eldor58093c82018-06-28 13:22:05 +03006406# Tests for ECC extensions (rfc 4492)
6407
Ron Eldor643df7c2018-06-28 16:17:00 +03006408requires_config_enabled MBEDTLS_AES_C
6409requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6410requires_config_enabled MBEDTLS_SHA256_C
6411requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006412run_test "Force a non ECC ciphersuite in the client side" \
6413 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006414 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006415 0 \
6416 -C "client hello, adding supported_elliptic_curves extension" \
6417 -C "client hello, adding supported_point_formats extension" \
6418 -S "found supported elliptic curves extension" \
6419 -S "found supported point formats extension"
6420
Ron Eldor643df7c2018-06-28 16:17:00 +03006421requires_config_enabled MBEDTLS_AES_C
6422requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6423requires_config_enabled MBEDTLS_SHA256_C
6424requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006425run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006426 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006427 "$P_CLI debug_level=3" \
6428 0 \
6429 -C "found supported_point_formats extension" \
6430 -S "server hello, supported_point_formats extension"
6431
Ron Eldor643df7c2018-06-28 16:17:00 +03006432requires_config_enabled MBEDTLS_AES_C
6433requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6434requires_config_enabled MBEDTLS_SHA256_C
6435requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006436run_test "Force an ECC ciphersuite in the client side" \
6437 "$P_SRV debug_level=3" \
6438 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6439 0 \
6440 -c "client hello, adding supported_elliptic_curves extension" \
6441 -c "client hello, adding supported_point_formats extension" \
6442 -s "found supported elliptic curves extension" \
6443 -s "found supported point formats extension"
6444
Ron Eldor643df7c2018-06-28 16:17:00 +03006445requires_config_enabled MBEDTLS_AES_C
6446requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6447requires_config_enabled MBEDTLS_SHA256_C
6448requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006449run_test "Force an ECC ciphersuite in the server side" \
6450 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6451 "$P_CLI debug_level=3" \
6452 0 \
6453 -c "found supported_point_formats extension" \
6454 -s "server hello, supported_point_formats extension"
6455
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006456# Tests for DTLS HelloVerifyRequest
6457
6458run_test "DTLS cookie: enabled" \
6459 "$P_SRV dtls=1 debug_level=2" \
6460 "$P_CLI dtls=1 debug_level=2" \
6461 0 \
6462 -s "cookie verification failed" \
6463 -s "cookie verification passed" \
6464 -S "cookie verification skipped" \
6465 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006466 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006467 -S "SSL - The requested feature is not available"
6468
6469run_test "DTLS cookie: disabled" \
6470 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6471 "$P_CLI dtls=1 debug_level=2" \
6472 0 \
6473 -S "cookie verification failed" \
6474 -S "cookie verification passed" \
6475 -s "cookie verification skipped" \
6476 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006477 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006478 -S "SSL - The requested feature is not available"
6479
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006480run_test "DTLS cookie: default (failing)" \
6481 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6482 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6483 1 \
6484 -s "cookie verification failed" \
6485 -S "cookie verification passed" \
6486 -S "cookie verification skipped" \
6487 -C "received hello verify request" \
6488 -S "hello verification requested" \
6489 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006490
6491requires_ipv6
6492run_test "DTLS cookie: enabled, IPv6" \
6493 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6494 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
6495 0 \
6496 -s "cookie verification failed" \
6497 -s "cookie verification passed" \
6498 -S "cookie verification skipped" \
6499 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006500 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006501 -S "SSL - The requested feature is not available"
6502
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006503run_test "DTLS cookie: enabled, nbio" \
6504 "$P_SRV dtls=1 nbio=2 debug_level=2" \
6505 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6506 0 \
6507 -s "cookie verification failed" \
6508 -s "cookie verification passed" \
6509 -S "cookie verification skipped" \
6510 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006511 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006512 -S "SSL - The requested feature is not available"
6513
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006514# Tests for client reconnecting from the same port with DTLS
6515
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006516not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006517run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02006518 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
6519 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006520 0 \
6521 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006522 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006523 -S "Client initiated reconnection from same port"
6524
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006525not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006526run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02006527 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
6528 "$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 +02006529 0 \
6530 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006531 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006532 -s "Client initiated reconnection from same port"
6533
Paul Bakker362689d2016-05-13 10:33:25 +01006534not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
6535run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006536 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
6537 "$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 +02006538 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006539 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006540 -s "Client initiated reconnection from same port"
6541
Paul Bakker362689d2016-05-13 10:33:25 +01006542only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
6543run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
6544 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
6545 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
6546 0 \
6547 -S "The operation timed out" \
6548 -s "Client initiated reconnection from same port"
6549
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006550run_test "DTLS client reconnect from same port: no cookies" \
6551 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02006552 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
6553 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006554 -s "The operation timed out" \
6555 -S "Client initiated reconnection from same port"
6556
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01006557run_test "DTLS client reconnect from same port: attacker-injected" \
6558 -p "$P_PXY inject_clihlo=1" \
6559 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
6560 "$P_CLI dtls=1 exchanges=2" \
6561 0 \
6562 -s "possible client reconnect from the same port" \
6563 -S "Client initiated reconnection from same port"
6564
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006565# Tests for various cases of client authentication with DTLS
6566# (focused on handshake flows and message parsing)
6567
6568run_test "DTLS client auth: required" \
6569 "$P_SRV dtls=1 auth_mode=required" \
6570 "$P_CLI dtls=1" \
6571 0 \
6572 -s "Verifying peer X.509 certificate... ok"
6573
6574run_test "DTLS client auth: optional, client has no cert" \
6575 "$P_SRV dtls=1 auth_mode=optional" \
6576 "$P_CLI dtls=1 crt_file=none key_file=none" \
6577 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006578 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006579
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006580run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006581 "$P_SRV dtls=1 auth_mode=none" \
6582 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
6583 0 \
6584 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006585 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006586
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02006587run_test "DTLS wrong PSK: badmac alert" \
6588 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
6589 "$P_CLI dtls=1 psk=abc124" \
6590 1 \
6591 -s "SSL - Verification of the message MAC failed" \
6592 -c "SSL - A fatal alert message was received from our peer"
6593
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02006594# Tests for receiving fragmented handshake messages with DTLS
6595
6596requires_gnutls
6597run_test "DTLS reassembly: no fragmentation (gnutls server)" \
6598 "$G_SRV -u --mtu 2048 -a" \
6599 "$P_CLI dtls=1 debug_level=2" \
6600 0 \
6601 -C "found fragmented DTLS handshake message" \
6602 -C "error"
6603
6604requires_gnutls
6605run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6606 "$G_SRV -u --mtu 512" \
6607 "$P_CLI dtls=1 debug_level=2" \
6608 0 \
6609 -c "found fragmented DTLS handshake message" \
6610 -C "error"
6611
6612requires_gnutls
6613run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6614 "$G_SRV -u --mtu 128" \
6615 "$P_CLI dtls=1 debug_level=2" \
6616 0 \
6617 -c "found fragmented DTLS handshake message" \
6618 -C "error"
6619
6620requires_gnutls
6621run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6622 "$G_SRV -u --mtu 128" \
6623 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6624 0 \
6625 -c "found fragmented DTLS handshake message" \
6626 -C "error"
6627
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006628requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006629requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006630run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6631 "$G_SRV -u --mtu 256" \
6632 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6633 0 \
6634 -c "found fragmented DTLS handshake message" \
6635 -c "client hello, adding renegotiation extension" \
6636 -c "found renegotiation extension" \
6637 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006638 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006639 -C "error" \
6640 -s "Extra-header:"
6641
6642requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006643requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006644run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6645 "$G_SRV -u --mtu 256" \
6646 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6647 0 \
6648 -c "found fragmented DTLS handshake message" \
6649 -c "client hello, adding renegotiation extension" \
6650 -c "found renegotiation extension" \
6651 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006652 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006653 -C "error" \
6654 -s "Extra-header:"
6655
TRodziewicz4ca18aa2021-05-20 14:46:20 +02006656run_test "DTLS reassembly: no fragmentation (openssl server)" \
6657 "$O_SRV -dtls -mtu 2048" \
6658 "$P_CLI dtls=1 debug_level=2" \
6659 0 \
6660 -C "found fragmented DTLS handshake message" \
6661 -C "error"
6662
6663run_test "DTLS reassembly: some fragmentation (openssl server)" \
6664 "$O_SRV -dtls -mtu 768" \
6665 "$P_CLI dtls=1 debug_level=2" \
6666 0 \
6667 -c "found fragmented DTLS handshake message" \
6668 -C "error"
6669
6670run_test "DTLS reassembly: more fragmentation (openssl server)" \
6671 "$O_SRV -dtls -mtu 256" \
6672 "$P_CLI dtls=1 debug_level=2" \
6673 0 \
6674 -c "found fragmented DTLS handshake message" \
6675 -C "error"
6676
6677run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \
6678 "$O_SRV -dtls -mtu 256" \
6679 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6680 0 \
6681 -c "found fragmented DTLS handshake message" \
6682 -C "error"
6683
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006684# Tests for sending fragmented handshake messages with DTLS
6685#
6686# Use client auth when we need the client to send large messages,
6687# and use large cert chains on both sides too (the long chains we have all use
6688# both RSA and ECDSA, but ideally we should have long chains with either).
6689# Sizes reached (UDP payload):
6690# - 2037B for server certificate
6691# - 1542B for client certificate
6692# - 1013B for newsessionticket
6693# - all others below 512B
6694# All those tests assume MAX_CONTENT_LEN is at least 2048
6695
6696requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6697requires_config_enabled MBEDTLS_RSA_C
6698requires_config_enabled MBEDTLS_ECDSA_C
6699requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6700run_test "DTLS fragmenting: none (for reference)" \
6701 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6702 crt_file=data_files/server7_int-ca.crt \
6703 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006704 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006705 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006706 "$P_CLI dtls=1 debug_level=2 \
6707 crt_file=data_files/server8_int-ca2.crt \
6708 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006709 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006710 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006711 0 \
6712 -S "found fragmented DTLS handshake message" \
6713 -C "found fragmented DTLS handshake message" \
6714 -C "error"
6715
6716requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6717requires_config_enabled MBEDTLS_RSA_C
6718requires_config_enabled MBEDTLS_ECDSA_C
6719requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006720run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006721 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6722 crt_file=data_files/server7_int-ca.crt \
6723 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006724 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006725 max_frag_len=1024" \
6726 "$P_CLI dtls=1 debug_level=2 \
6727 crt_file=data_files/server8_int-ca2.crt \
6728 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006729 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006730 max_frag_len=2048" \
6731 0 \
6732 -S "found fragmented DTLS handshake message" \
6733 -c "found fragmented DTLS handshake message" \
6734 -C "error"
6735
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006736# With the MFL extension, the server has no way of forcing
6737# the client to not exceed a certain MTU; hence, the following
6738# test can't be replicated with an MTU proxy such as the one
6739# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006740requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6741requires_config_enabled MBEDTLS_RSA_C
6742requires_config_enabled MBEDTLS_ECDSA_C
6743requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006744run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006745 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6746 crt_file=data_files/server7_int-ca.crt \
6747 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006748 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006749 max_frag_len=512" \
6750 "$P_CLI dtls=1 debug_level=2 \
6751 crt_file=data_files/server8_int-ca2.crt \
6752 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006753 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006754 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006755 0 \
6756 -S "found fragmented DTLS handshake message" \
6757 -c "found fragmented DTLS handshake message" \
6758 -C "error"
6759
6760requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6761requires_config_enabled MBEDTLS_RSA_C
6762requires_config_enabled MBEDTLS_ECDSA_C
6763requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006764run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006765 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6766 crt_file=data_files/server7_int-ca.crt \
6767 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006768 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006769 max_frag_len=2048" \
6770 "$P_CLI dtls=1 debug_level=2 \
6771 crt_file=data_files/server8_int-ca2.crt \
6772 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006773 hs_timeout=2500-60000 \
6774 max_frag_len=1024" \
6775 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006776 -S "found fragmented DTLS handshake message" \
6777 -c "found fragmented DTLS handshake message" \
6778 -C "error"
6779
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006780# While not required by the standard defining the MFL extension
6781# (according to which it only applies to records, not to datagrams),
6782# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6783# as otherwise there wouldn't be any means to communicate MTU restrictions
6784# to the peer.
6785# The next test checks that no datagrams significantly larger than the
6786# negotiated MFL are sent.
6787requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6788requires_config_enabled MBEDTLS_RSA_C
6789requires_config_enabled MBEDTLS_ECDSA_C
6790requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6791run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006792 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006793 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6794 crt_file=data_files/server7_int-ca.crt \
6795 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006796 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006797 max_frag_len=2048" \
6798 "$P_CLI dtls=1 debug_level=2 \
6799 crt_file=data_files/server8_int-ca2.crt \
6800 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006801 hs_timeout=2500-60000 \
6802 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006803 0 \
6804 -S "found fragmented DTLS handshake message" \
6805 -c "found fragmented DTLS handshake message" \
6806 -C "error"
6807
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006808requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6809requires_config_enabled MBEDTLS_RSA_C
6810requires_config_enabled MBEDTLS_ECDSA_C
6811requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006812run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006813 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6814 crt_file=data_files/server7_int-ca.crt \
6815 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006816 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006817 max_frag_len=2048" \
6818 "$P_CLI dtls=1 debug_level=2 \
6819 crt_file=data_files/server8_int-ca2.crt \
6820 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006821 hs_timeout=2500-60000 \
6822 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006823 0 \
6824 -s "found fragmented DTLS handshake message" \
6825 -c "found fragmented DTLS handshake message" \
6826 -C "error"
6827
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006828# While not required by the standard defining the MFL extension
6829# (according to which it only applies to records, not to datagrams),
6830# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6831# as otherwise there wouldn't be any means to communicate MTU restrictions
6832# to the peer.
6833# The next test checks that no datagrams significantly larger than the
6834# negotiated MFL are sent.
6835requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6836requires_config_enabled MBEDTLS_RSA_C
6837requires_config_enabled MBEDTLS_ECDSA_C
6838requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6839run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006840 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006841 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6842 crt_file=data_files/server7_int-ca.crt \
6843 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006844 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006845 max_frag_len=2048" \
6846 "$P_CLI dtls=1 debug_level=2 \
6847 crt_file=data_files/server8_int-ca2.crt \
6848 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006849 hs_timeout=2500-60000 \
6850 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006851 0 \
6852 -s "found fragmented DTLS handshake message" \
6853 -c "found fragmented DTLS handshake message" \
6854 -C "error"
6855
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006856requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6857requires_config_enabled MBEDTLS_RSA_C
6858requires_config_enabled MBEDTLS_ECDSA_C
6859run_test "DTLS fragmenting: none (for reference) (MTU)" \
6860 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6861 crt_file=data_files/server7_int-ca.crt \
6862 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006863 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006864 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006865 "$P_CLI dtls=1 debug_level=2 \
6866 crt_file=data_files/server8_int-ca2.crt \
6867 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006868 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006869 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006870 0 \
6871 -S "found fragmented DTLS handshake message" \
6872 -C "found fragmented DTLS handshake message" \
6873 -C "error"
6874
6875requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6876requires_config_enabled MBEDTLS_RSA_C
6877requires_config_enabled MBEDTLS_ECDSA_C
6878run_test "DTLS fragmenting: client (MTU)" \
6879 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6880 crt_file=data_files/server7_int-ca.crt \
6881 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006882 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006883 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006884 "$P_CLI dtls=1 debug_level=2 \
6885 crt_file=data_files/server8_int-ca2.crt \
6886 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006887 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006888 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006889 0 \
6890 -s "found fragmented DTLS handshake message" \
6891 -C "found fragmented DTLS handshake message" \
6892 -C "error"
6893
6894requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6895requires_config_enabled MBEDTLS_RSA_C
6896requires_config_enabled MBEDTLS_ECDSA_C
6897run_test "DTLS fragmenting: server (MTU)" \
6898 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6899 crt_file=data_files/server7_int-ca.crt \
6900 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006901 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006902 mtu=512" \
6903 "$P_CLI dtls=1 debug_level=2 \
6904 crt_file=data_files/server8_int-ca2.crt \
6905 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006906 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006907 mtu=2048" \
6908 0 \
6909 -S "found fragmented DTLS handshake message" \
6910 -c "found fragmented DTLS handshake message" \
6911 -C "error"
6912
6913requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6914requires_config_enabled MBEDTLS_RSA_C
6915requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006916run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006917 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006918 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6919 crt_file=data_files/server7_int-ca.crt \
6920 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006921 hs_timeout=2500-60000 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006922 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006923 "$P_CLI dtls=1 debug_level=2 \
6924 crt_file=data_files/server8_int-ca2.crt \
6925 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006926 hs_timeout=2500-60000 \
6927 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006928 0 \
6929 -s "found fragmented DTLS handshake message" \
6930 -c "found fragmented DTLS handshake message" \
6931 -C "error"
6932
Andrzej Kurek77826052018-10-11 07:34:08 -04006933# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006934requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6935requires_config_enabled MBEDTLS_RSA_C
6936requires_config_enabled MBEDTLS_ECDSA_C
6937requires_config_enabled MBEDTLS_SHA256_C
6938requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6939requires_config_enabled MBEDTLS_AES_C
6940requires_config_enabled MBEDTLS_GCM_C
6941run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006942 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006943 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6944 crt_file=data_files/server7_int-ca.crt \
6945 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006946 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006947 mtu=512" \
6948 "$P_CLI dtls=1 debug_level=2 \
6949 crt_file=data_files/server8_int-ca2.crt \
6950 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006951 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6952 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006953 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006954 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006955 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006956 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006957 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006958
Andrzej Kurek7311c782018-10-11 06:49:41 -04006959# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006960# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006961# The ratio of max/min timeout should ideally equal 4 to accept two
6962# retransmissions, but in some cases (like both the server and client using
6963# fragmentation and auto-reduction) an extra retransmission might occur,
6964# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006965not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006966requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6967requires_config_enabled MBEDTLS_RSA_C
6968requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006969requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6970requires_config_enabled MBEDTLS_AES_C
6971requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02006972run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006973 -p "$P_PXY mtu=508" \
6974 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6975 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006976 key_file=data_files/server7.key \
6977 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006978 "$P_CLI dtls=1 debug_level=2 \
6979 crt_file=data_files/server8_int-ca2.crt \
6980 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006981 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6982 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006983 0 \
6984 -s "found fragmented DTLS handshake message" \
6985 -c "found fragmented DTLS handshake message" \
6986 -C "error"
6987
Andrzej Kurek77826052018-10-11 07:34:08 -04006988# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006989only_with_valgrind
6990requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6991requires_config_enabled MBEDTLS_RSA_C
6992requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006993requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6994requires_config_enabled MBEDTLS_AES_C
6995requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02006996run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01006997 -p "$P_PXY mtu=508" \
6998 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6999 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007000 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01007001 hs_timeout=250-10000" \
7002 "$P_CLI dtls=1 debug_level=2 \
7003 crt_file=data_files/server8_int-ca2.crt \
7004 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007005 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01007006 hs_timeout=250-10000" \
7007 0 \
7008 -s "found fragmented DTLS handshake message" \
7009 -c "found fragmented DTLS handshake message" \
7010 -C "error"
7011
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007012# 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 +02007013# OTOH the client might resend if the server is to slow to reset after sending
7014# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007015not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007016requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7017requires_config_enabled MBEDTLS_RSA_C
7018requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007019run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007020 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007021 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7022 crt_file=data_files/server7_int-ca.crt \
7023 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007024 hs_timeout=10000-60000 \
7025 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007026 "$P_CLI dtls=1 debug_level=2 \
7027 crt_file=data_files/server8_int-ca2.crt \
7028 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007029 hs_timeout=10000-60000 \
7030 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007031 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007032 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007033 -s "found fragmented DTLS handshake message" \
7034 -c "found fragmented DTLS handshake message" \
7035 -C "error"
7036
Andrzej Kurek77826052018-10-11 07:34:08 -04007037# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007038# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
7039# OTOH the client might resend if the server is to slow to reset after sending
7040# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007041not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007042requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7043requires_config_enabled MBEDTLS_RSA_C
7044requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007045requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7046requires_config_enabled MBEDTLS_AES_C
7047requires_config_enabled MBEDTLS_GCM_C
7048run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007049 -p "$P_PXY mtu=512" \
7050 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7051 crt_file=data_files/server7_int-ca.crt \
7052 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007053 hs_timeout=10000-60000 \
7054 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007055 "$P_CLI dtls=1 debug_level=2 \
7056 crt_file=data_files/server8_int-ca2.crt \
7057 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007058 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7059 hs_timeout=10000-60000 \
7060 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007061 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007062 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007063 -s "found fragmented DTLS handshake message" \
7064 -c "found fragmented DTLS handshake message" \
7065 -C "error"
7066
Andrzej Kurek7311c782018-10-11 06:49:41 -04007067not_with_valgrind # spurious autoreduction due to timeout
7068requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7069requires_config_enabled MBEDTLS_RSA_C
7070requires_config_enabled MBEDTLS_ECDSA_C
7071run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007072 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007073 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7074 crt_file=data_files/server7_int-ca.crt \
7075 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007076 hs_timeout=10000-60000 \
7077 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007078 "$P_CLI dtls=1 debug_level=2 \
7079 crt_file=data_files/server8_int-ca2.crt \
7080 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007081 hs_timeout=10000-60000 \
7082 mtu=1024 nbio=2" \
7083 0 \
7084 -S "autoreduction" \
7085 -s "found fragmented DTLS handshake message" \
7086 -c "found fragmented DTLS handshake message" \
7087 -C "error"
7088
Andrzej Kurek77826052018-10-11 07:34:08 -04007089# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007090not_with_valgrind # spurious autoreduction due to timeout
7091requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7092requires_config_enabled MBEDTLS_RSA_C
7093requires_config_enabled MBEDTLS_ECDSA_C
7094requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7095requires_config_enabled MBEDTLS_AES_C
7096requires_config_enabled MBEDTLS_GCM_C
7097run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7098 -p "$P_PXY mtu=512" \
7099 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7100 crt_file=data_files/server7_int-ca.crt \
7101 key_file=data_files/server7.key \
7102 hs_timeout=10000-60000 \
7103 mtu=512 nbio=2" \
7104 "$P_CLI dtls=1 debug_level=2 \
7105 crt_file=data_files/server8_int-ca2.crt \
7106 key_file=data_files/server8.key \
7107 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7108 hs_timeout=10000-60000 \
7109 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007110 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007111 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007112 -s "found fragmented DTLS handshake message" \
7113 -c "found fragmented DTLS handshake message" \
7114 -C "error"
7115
Andrzej Kurek77826052018-10-11 07:34:08 -04007116# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007117# This ensures things still work after session_reset().
7118# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007119# Since we don't support reading fragmented ClientHello yet,
7120# up the MTU to 1450 (larger than ClientHello with session ticket,
7121# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007122# An autoreduction on the client-side might happen if the server is
7123# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007124# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007125# resumed listening, which would result in a spurious autoreduction.
7126not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007127requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7128requires_config_enabled MBEDTLS_RSA_C
7129requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007130requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7131requires_config_enabled MBEDTLS_AES_C
7132requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007133run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7134 -p "$P_PXY mtu=1450" \
7135 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7136 crt_file=data_files/server7_int-ca.crt \
7137 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007138 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007139 mtu=1450" \
7140 "$P_CLI dtls=1 debug_level=2 \
7141 crt_file=data_files/server8_int-ca2.crt \
7142 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007143 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007144 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01007145 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007146 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007147 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007148 -s "found fragmented DTLS handshake message" \
7149 -c "found fragmented DTLS handshake message" \
7150 -C "error"
7151
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007152# An autoreduction on the client-side might happen if the server is
7153# slow to reset, therefore omitting '-C "autoreduction"' below.
7154not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007155requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7156requires_config_enabled MBEDTLS_RSA_C
7157requires_config_enabled MBEDTLS_ECDSA_C
7158requires_config_enabled MBEDTLS_SHA256_C
7159requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7160requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7161requires_config_enabled MBEDTLS_CHACHAPOLY_C
7162run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7163 -p "$P_PXY mtu=512" \
7164 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7165 crt_file=data_files/server7_int-ca.crt \
7166 key_file=data_files/server7.key \
7167 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007168 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007169 mtu=512" \
7170 "$P_CLI dtls=1 debug_level=2 \
7171 crt_file=data_files/server8_int-ca2.crt \
7172 key_file=data_files/server8.key \
7173 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007174 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007175 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007176 mtu=512" \
7177 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007178 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007179 -s "found fragmented DTLS handshake message" \
7180 -c "found fragmented DTLS handshake message" \
7181 -C "error"
7182
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007183# An autoreduction on the client-side might happen if the server is
7184# slow to reset, therefore omitting '-C "autoreduction"' below.
7185not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007186requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7187requires_config_enabled MBEDTLS_RSA_C
7188requires_config_enabled MBEDTLS_ECDSA_C
7189requires_config_enabled MBEDTLS_SHA256_C
7190requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7191requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7192requires_config_enabled MBEDTLS_AES_C
7193requires_config_enabled MBEDTLS_GCM_C
7194run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7195 -p "$P_PXY mtu=512" \
7196 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7197 crt_file=data_files/server7_int-ca.crt \
7198 key_file=data_files/server7.key \
7199 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007200 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007201 mtu=512" \
7202 "$P_CLI dtls=1 debug_level=2 \
7203 crt_file=data_files/server8_int-ca2.crt \
7204 key_file=data_files/server8.key \
7205 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007206 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007207 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007208 mtu=512" \
7209 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007210 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007211 -s "found fragmented DTLS handshake message" \
7212 -c "found fragmented DTLS handshake message" \
7213 -C "error"
7214
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007215# An autoreduction on the client-side might happen if the server is
7216# slow to reset, therefore omitting '-C "autoreduction"' below.
7217not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007218requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7219requires_config_enabled MBEDTLS_RSA_C
7220requires_config_enabled MBEDTLS_ECDSA_C
7221requires_config_enabled MBEDTLS_SHA256_C
7222requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7223requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7224requires_config_enabled MBEDTLS_AES_C
7225requires_config_enabled MBEDTLS_CCM_C
7226run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007227 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007228 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7229 crt_file=data_files/server7_int-ca.crt \
7230 key_file=data_files/server7.key \
7231 exchanges=2 renegotiation=1 \
7232 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007233 hs_timeout=10000-60000 \
7234 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007235 "$P_CLI dtls=1 debug_level=2 \
7236 crt_file=data_files/server8_int-ca2.crt \
7237 key_file=data_files/server8.key \
7238 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007239 hs_timeout=10000-60000 \
7240 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007241 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007242 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007243 -s "found fragmented DTLS handshake message" \
7244 -c "found fragmented DTLS handshake message" \
7245 -C "error"
7246
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007247# An autoreduction on the client-side might happen if the server is
7248# slow to reset, therefore omitting '-C "autoreduction"' below.
7249not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007250requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7251requires_config_enabled MBEDTLS_RSA_C
7252requires_config_enabled MBEDTLS_ECDSA_C
7253requires_config_enabled MBEDTLS_SHA256_C
7254requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7255requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7256requires_config_enabled MBEDTLS_AES_C
7257requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7258requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7259run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007260 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007261 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7262 crt_file=data_files/server7_int-ca.crt \
7263 key_file=data_files/server7.key \
7264 exchanges=2 renegotiation=1 \
7265 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007266 hs_timeout=10000-60000 \
7267 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007268 "$P_CLI dtls=1 debug_level=2 \
7269 crt_file=data_files/server8_int-ca2.crt \
7270 key_file=data_files/server8.key \
7271 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007272 hs_timeout=10000-60000 \
7273 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007274 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007275 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007276 -s "found fragmented DTLS handshake message" \
7277 -c "found fragmented DTLS handshake message" \
7278 -C "error"
7279
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007280# An autoreduction on the client-side might happen if the server is
7281# slow to reset, therefore omitting '-C "autoreduction"' below.
7282not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007283requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7284requires_config_enabled MBEDTLS_RSA_C
7285requires_config_enabled MBEDTLS_ECDSA_C
7286requires_config_enabled MBEDTLS_SHA256_C
7287requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7288requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7289requires_config_enabled MBEDTLS_AES_C
7290requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7291run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007292 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007293 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7294 crt_file=data_files/server7_int-ca.crt \
7295 key_file=data_files/server7.key \
7296 exchanges=2 renegotiation=1 \
7297 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007298 hs_timeout=10000-60000 \
7299 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007300 "$P_CLI dtls=1 debug_level=2 \
7301 crt_file=data_files/server8_int-ca2.crt \
7302 key_file=data_files/server8.key \
7303 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007304 hs_timeout=10000-60000 \
7305 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007306 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007307 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007308 -s "found fragmented DTLS handshake message" \
7309 -c "found fragmented DTLS handshake message" \
7310 -C "error"
7311
Andrzej Kurek77826052018-10-11 07:34:08 -04007312# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007313requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7314requires_config_enabled MBEDTLS_RSA_C
7315requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007316requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7317requires_config_enabled MBEDTLS_AES_C
7318requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007319client_needs_more_time 2
7320run_test "DTLS fragmenting: proxy MTU + 3d" \
7321 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007322 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007323 crt_file=data_files/server7_int-ca.crt \
7324 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007325 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007326 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007327 crt_file=data_files/server8_int-ca2.crt \
7328 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007329 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007330 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007331 0 \
7332 -s "found fragmented DTLS handshake message" \
7333 -c "found fragmented DTLS handshake message" \
7334 -C "error"
7335
Andrzej Kurek77826052018-10-11 07:34:08 -04007336# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007337requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7338requires_config_enabled MBEDTLS_RSA_C
7339requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007340requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7341requires_config_enabled MBEDTLS_AES_C
7342requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007343client_needs_more_time 2
7344run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7345 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7346 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7347 crt_file=data_files/server7_int-ca.crt \
7348 key_file=data_files/server7.key \
7349 hs_timeout=250-10000 mtu=512 nbio=2" \
7350 "$P_CLI dtls=1 debug_level=2 \
7351 crt_file=data_files/server8_int-ca2.crt \
7352 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007353 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007354 hs_timeout=250-10000 mtu=512 nbio=2" \
7355 0 \
7356 -s "found fragmented DTLS handshake message" \
7357 -c "found fragmented DTLS handshake message" \
7358 -C "error"
7359
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007360# interop tests for DTLS fragmentating with reliable connection
7361#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007362# here and below we just want to test that the we fragment in a way that
7363# pleases other implementations, so we don't need the peer to fragment
7364requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7365requires_config_enabled MBEDTLS_RSA_C
7366requires_config_enabled MBEDTLS_ECDSA_C
7367requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007368requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007369run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7370 "$G_SRV -u" \
7371 "$P_CLI dtls=1 debug_level=2 \
7372 crt_file=data_files/server8_int-ca2.crt \
7373 key_file=data_files/server8.key \
7374 mtu=512 force_version=dtls1_2" \
7375 0 \
7376 -c "fragmenting handshake message" \
7377 -C "error"
7378
Hanno Beckerb9a00862018-08-28 10:20:22 +01007379# We use --insecure for the GnuTLS client because it expects
7380# the hostname / IP it connects to to be the name used in the
7381# certificate obtained from the server. Here, however, it
7382# connects to 127.0.0.1 while our test certificates use 'localhost'
7383# as the server name in the certificate. This will make the
7384# certifiate validation fail, but passing --insecure makes
7385# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007386requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7387requires_config_enabled MBEDTLS_RSA_C
7388requires_config_enabled MBEDTLS_ECDSA_C
7389requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007390requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007391requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007392run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007393 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007394 crt_file=data_files/server7_int-ca.crt \
7395 key_file=data_files/server7.key \
7396 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007397 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007398 0 \
7399 -s "fragmenting handshake message"
7400
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007401requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7402requires_config_enabled MBEDTLS_RSA_C
7403requires_config_enabled MBEDTLS_ECDSA_C
7404requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7405run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7406 "$O_SRV -dtls1_2 -verify 10" \
7407 "$P_CLI dtls=1 debug_level=2 \
7408 crt_file=data_files/server8_int-ca2.crt \
7409 key_file=data_files/server8.key \
7410 mtu=512 force_version=dtls1_2" \
7411 0 \
7412 -c "fragmenting handshake message" \
7413 -C "error"
7414
7415requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7416requires_config_enabled MBEDTLS_RSA_C
7417requires_config_enabled MBEDTLS_ECDSA_C
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007418requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7419run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7420 "$P_SRV dtls=1 debug_level=2 \
7421 crt_file=data_files/server7_int-ca.crt \
7422 key_file=data_files/server7.key \
7423 mtu=512 force_version=dtls1_2" \
7424 "$O_CLI -dtls1_2" \
7425 0 \
7426 -s "fragmenting handshake message"
7427
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007428# interop tests for DTLS fragmentating with unreliable connection
7429#
7430# again we just want to test that the we fragment in a way that
7431# pleases other implementations, so we don't need the peer to fragment
7432requires_gnutls_next
7433requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7434requires_config_enabled MBEDTLS_RSA_C
7435requires_config_enabled MBEDTLS_ECDSA_C
7436requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007437client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007438run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
7439 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7440 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007441 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007442 crt_file=data_files/server8_int-ca2.crt \
7443 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007444 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007445 0 \
7446 -c "fragmenting handshake message" \
7447 -C "error"
7448
7449requires_gnutls_next
7450requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7451requires_config_enabled MBEDTLS_RSA_C
7452requires_config_enabled MBEDTLS_ECDSA_C
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007453requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7454client_needs_more_time 4
7455run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
7456 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7457 "$P_SRV dtls=1 debug_level=2 \
7458 crt_file=data_files/server7_int-ca.crt \
7459 key_file=data_files/server7.key \
7460 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01007461 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007462 0 \
7463 -s "fragmenting handshake message"
7464
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007465## Interop test with OpenSSL might trigger a bug in recent versions (including
7466## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007467## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007468## They should be re-enabled once a fixed version of OpenSSL is available
7469## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007470skip_next_test
7471requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7472requires_config_enabled MBEDTLS_RSA_C
7473requires_config_enabled MBEDTLS_ECDSA_C
7474requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7475client_needs_more_time 4
7476run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
7477 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7478 "$O_SRV -dtls1_2 -verify 10" \
7479 "$P_CLI dtls=1 debug_level=2 \
7480 crt_file=data_files/server8_int-ca2.crt \
7481 key_file=data_files/server8.key \
7482 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7483 0 \
7484 -c "fragmenting handshake message" \
7485 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007486
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007487skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007488requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7489requires_config_enabled MBEDTLS_RSA_C
7490requires_config_enabled MBEDTLS_ECDSA_C
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007491requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7492client_needs_more_time 4
7493run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
7494 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7495 "$P_SRV dtls=1 debug_level=2 \
7496 crt_file=data_files/server7_int-ca.crt \
7497 key_file=data_files/server7.key \
7498 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7499 "$O_CLI -dtls1_2" \
7500 0 \
7501 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007502
Ron Eldorb4655392018-07-05 18:25:39 +03007503# Tests for DTLS-SRTP (RFC 5764)
7504requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7505run_test "DTLS-SRTP all profiles supported" \
7506 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7507 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7508 0 \
7509 -s "found use_srtp extension" \
7510 -s "found srtp profile" \
7511 -s "selected srtp profile" \
7512 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007513 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007514 -c "client hello, adding use_srtp extension" \
7515 -c "found use_srtp extension" \
7516 -c "found srtp profile" \
7517 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007518 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007519 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007520 -C "error"
7521
Johan Pascal9bc50b02020-09-24 12:01:13 +02007522
Ron Eldorb4655392018-07-05 18:25:39 +03007523requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7524run_test "DTLS-SRTP server supports all profiles. Client supports one profile." \
7525 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
Johan Pascal43f94902020-09-22 12:25:52 +02007526 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=5 debug_level=3" \
Ron Eldorb4655392018-07-05 18:25:39 +03007527 0 \
7528 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007529 -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
7530 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
Ron Eldorb4655392018-07-05 18:25:39 +03007531 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007532 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007533 -c "client hello, adding use_srtp extension" \
7534 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007535 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
Ron Eldorb4655392018-07-05 18:25:39 +03007536 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007537 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007538 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007539 -C "error"
7540
7541requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007542run_test "DTLS-SRTP server supports one profile. Client supports all profiles." \
Johan Pascal43f94902020-09-22 12:25:52 +02007543 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldorb4655392018-07-05 18:25:39 +03007544 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7545 0 \
7546 -s "found use_srtp extension" \
7547 -s "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007548 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007549 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007550 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007551 -c "client hello, adding use_srtp extension" \
7552 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007553 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007554 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007555 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007556 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007557 -C "error"
7558
7559requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7560run_test "DTLS-SRTP server and Client support only one matching profile." \
7561 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7562 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7563 0 \
7564 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007565 -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
7566 -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007567 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007568 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007569 -c "client hello, adding use_srtp extension" \
7570 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007571 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007572 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007573 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007574 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007575 -C "error"
7576
7577requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7578run_test "DTLS-SRTP server and Client support only one different profile." \
7579 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
Johan Pascal43f94902020-09-22 12:25:52 +02007580 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldorb4655392018-07-05 18:25:39 +03007581 0 \
7582 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007583 -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007584 -S "selected srtp profile" \
7585 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007586 -S "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007587 -c "client hello, adding use_srtp extension" \
7588 -C "found use_srtp extension" \
7589 -C "found srtp profile" \
7590 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007591 -C "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007592 -C "error"
7593
7594requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7595run_test "DTLS-SRTP server doesn't support use_srtp extension." \
7596 "$P_SRV dtls=1 debug_level=3" \
7597 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7598 0 \
7599 -s "found use_srtp extension" \
7600 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007601 -S "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007602 -c "client hello, adding use_srtp extension" \
7603 -C "found use_srtp extension" \
7604 -C "found srtp profile" \
7605 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007606 -C "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007607 -C "error"
7608
7609requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7610run_test "DTLS-SRTP all profiles supported. mki used" \
7611 "$P_SRV dtls=1 use_srtp=1 support_mki=1 debug_level=3" \
7612 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
7613 0 \
7614 -s "found use_srtp extension" \
7615 -s "found srtp profile" \
7616 -s "selected srtp profile" \
7617 -s "server hello, adding use_srtp extension" \
7618 -s "dumping 'using mki' (8 bytes)" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007619 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007620 -c "client hello, adding use_srtp extension" \
7621 -c "found use_srtp extension" \
7622 -c "found srtp profile" \
7623 -c "selected srtp profile" \
7624 -c "dumping 'sending mki' (8 bytes)" \
7625 -c "dumping 'received mki' (8 bytes)" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007626 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007627 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Johan Pascal20c7db32020-10-26 22:45:58 +01007628 -g "find_in_both '^ *DTLS-SRTP mki value: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007629 -C "error"
7630
7631requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7632run_test "DTLS-SRTP all profiles supported. server doesn't support mki." \
7633 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7634 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
7635 0 \
7636 -s "found use_srtp extension" \
7637 -s "found srtp profile" \
7638 -s "selected srtp profile" \
7639 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007640 -s "DTLS-SRTP key material is"\
Johan Pascal5ef72d22020-10-28 17:05:47 +01007641 -s "DTLS-SRTP no mki value negotiated"\
Ron Eldorb4655392018-07-05 18:25:39 +03007642 -S "dumping 'using mki' (8 bytes)" \
7643 -c "client hello, adding use_srtp extension" \
7644 -c "found use_srtp extension" \
7645 -c "found srtp profile" \
7646 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007647 -c "DTLS-SRTP key material is"\
Johan Pascal5ef72d22020-10-28 17:05:47 +01007648 -c "DTLS-SRTP no mki value negotiated"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007649 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007650 -c "dumping 'sending mki' (8 bytes)" \
7651 -C "dumping 'received mki' (8 bytes)" \
7652 -C "error"
7653
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007654requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
TRodziewicz4ca18aa2021-05-20 14:46:20 +02007655run_test "DTLS-SRTP all profiles supported. openssl client." \
7656 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7657 "$O_CLI -dtls -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7658 0 \
7659 -s "found use_srtp extension" \
7660 -s "found srtp profile" \
7661 -s "selected srtp profile" \
7662 -s "server hello, adding use_srtp extension" \
7663 -s "DTLS-SRTP key material is"\
7664 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
7665 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_80"
7666
7667requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7668run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl client." \
7669 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7670 "$O_CLI -dtls -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7671 0 \
7672 -s "found use_srtp extension" \
7673 -s "found srtp profile" \
7674 -s "selected srtp profile" \
7675 -s "server hello, adding use_srtp extension" \
7676 -s "DTLS-SRTP key material is"\
7677 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
7678 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
7679
7680requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7681run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl client." \
7682 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7683 "$O_CLI -dtls -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7684 0 \
7685 -s "found use_srtp extension" \
7686 -s "found srtp profile" \
7687 -s "selected srtp profile" \
7688 -s "server hello, adding use_srtp extension" \
7689 -s "DTLS-SRTP key material is"\
7690 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
7691 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
7692
7693requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7694run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl client." \
7695 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7696 "$O_CLI -dtls -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7697 0 \
7698 -s "found use_srtp extension" \
7699 -s "found srtp profile" \
7700 -s "selected srtp profile" \
7701 -s "server hello, adding use_srtp extension" \
7702 -s "DTLS-SRTP key material is"\
7703 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
7704 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
7705
7706requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7707run_test "DTLS-SRTP server and Client support only one matching profile. openssl client." \
7708 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7709 "$O_CLI -dtls -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7710 0 \
7711 -s "found use_srtp extension" \
7712 -s "found srtp profile" \
7713 -s "selected srtp profile" \
7714 -s "server hello, adding use_srtp extension" \
7715 -s "DTLS-SRTP key material is"\
7716 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
7717 -c "SRTP Extension negotiated, profile=SRTP_AES128_CM_SHA1_32"
7718
7719requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7720run_test "DTLS-SRTP server and Client support only one different profile. openssl client." \
7721 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \
7722 "$O_CLI -dtls -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7723 0 \
7724 -s "found use_srtp extension" \
7725 -s "found srtp profile" \
7726 -S "selected srtp profile" \
7727 -S "server hello, adding use_srtp extension" \
7728 -S "DTLS-SRTP key material is"\
7729 -C "SRTP Extension negotiated, profile"
7730
7731requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7732run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl client" \
7733 "$P_SRV dtls=1 debug_level=3" \
7734 "$O_CLI -dtls -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7735 0 \
7736 -s "found use_srtp extension" \
7737 -S "server hello, adding use_srtp extension" \
7738 -S "DTLS-SRTP key material is"\
7739 -C "SRTP Extension negotiated, profile"
7740
7741requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7742run_test "DTLS-SRTP all profiles supported. openssl server" \
7743 "$O_SRV -dtls -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7744 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7745 0 \
7746 -c "client hello, adding use_srtp extension" \
7747 -c "found use_srtp extension" \
7748 -c "found srtp profile" \
7749 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
7750 -c "DTLS-SRTP key material is"\
7751 -C "error"
7752
7753requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7754run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. openssl server." \
7755 "$O_SRV -dtls -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32:SRTP_AES128_CM_SHA1_80 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7756 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7757 0 \
7758 -c "client hello, adding use_srtp extension" \
7759 -c "found use_srtp extension" \
7760 -c "found srtp profile" \
7761 -c "selected srtp profile" \
7762 -c "DTLS-SRTP key material is"\
7763 -C "error"
7764
7765requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7766run_test "DTLS-SRTP server supports all profiles. Client supports one profile. openssl server." \
7767 "$O_SRV -dtls -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7768 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7769 0 \
7770 -c "client hello, adding use_srtp extension" \
7771 -c "found use_srtp extension" \
7772 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
7773 -c "selected srtp profile" \
7774 -c "DTLS-SRTP key material is"\
7775 -C "error"
7776
7777requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7778run_test "DTLS-SRTP server supports one profile. Client supports all profiles. openssl server." \
7779 "$O_SRV -dtls -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7780 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7781 0 \
7782 -c "client hello, adding use_srtp extension" \
7783 -c "found use_srtp extension" \
7784 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
7785 -c "selected srtp profile" \
7786 -c "DTLS-SRTP key material is"\
7787 -C "error"
7788
7789requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7790run_test "DTLS-SRTP server and Client support only one matching profile. openssl server." \
7791 "$O_SRV -dtls -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7792 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7793 0 \
7794 -c "client hello, adding use_srtp extension" \
7795 -c "found use_srtp extension" \
7796 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
7797 -c "selected srtp profile" \
7798 -c "DTLS-SRTP key material is"\
7799 -C "error"
7800
7801requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7802run_test "DTLS-SRTP server and Client support only one different profile. openssl server." \
7803 "$O_SRV -dtls -verify 0 -use_srtp SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7804 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
7805 0 \
7806 -c "client hello, adding use_srtp extension" \
7807 -C "found use_srtp extension" \
7808 -C "found srtp profile" \
7809 -C "selected srtp profile" \
7810 -C "DTLS-SRTP key material is"\
7811 -C "error"
7812
7813requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7814run_test "DTLS-SRTP server doesn't support use_srtp extension. openssl server" \
7815 "$O_SRV -dtls" \
7816 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7817 0 \
7818 -c "client hello, adding use_srtp extension" \
7819 -C "found use_srtp extension" \
7820 -C "found srtp profile" \
7821 -C "selected srtp profile" \
7822 -C "DTLS-SRTP key material is"\
7823 -C "error"
7824
7825requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7826run_test "DTLS-SRTP all profiles supported. server doesn't support mki. openssl server." \
7827 "$O_SRV -dtls -verify 0 -use_srtp SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32 -keymatexport 'EXTRACTOR-dtls_srtp' -keymatexportlen 60" \
7828 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
7829 0 \
7830 -c "client hello, adding use_srtp extension" \
7831 -c "found use_srtp extension" \
7832 -c "found srtp profile" \
7833 -c "selected srtp profile" \
7834 -c "DTLS-SRTP key material is"\
7835 -c "DTLS-SRTP no mki value negotiated"\
7836 -c "dumping 'sending mki' (8 bytes)" \
7837 -C "dumping 'received mki' (8 bytes)" \
7838 -C "error"
7839
7840requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007841requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007842run_test "DTLS-SRTP all profiles supported. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007843 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7844 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007845 0 \
7846 -s "found use_srtp extension" \
7847 -s "found srtp profile" \
7848 -s "selected srtp profile" \
7849 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007850 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007851 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_80"
7852
7853requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007854requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007855run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007856 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7857 "$G_CLI -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007858 0 \
7859 -s "found use_srtp extension" \
7860 -s "found srtp profile" \
7861 -s "selected srtp profile" \
7862 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007863 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007864 -c "SRTP profile: SRTP_NULL_HMAC_SHA1_80"
7865
7866requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007867requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007868run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007869 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7870 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007871 0 \
7872 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007873 -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
7874 -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007875 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007876 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007877 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
7878
7879requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007880requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007881run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls client." \
Johan Pascal43f94902020-09-22 12:25:52 +02007882 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldor5d991c92019-01-15 18:54:03 +02007883 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007884 0 \
7885 -s "found use_srtp extension" \
7886 -s "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007887 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007888 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007889 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007890 -c "SRTP profile: SRTP_NULL_SHA1_32"
7891
7892requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007893requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007894run_test "DTLS-SRTP server and Client support only one matching profile. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007895 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7896 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007897 0 \
7898 -s "found use_srtp extension" \
7899 -s "found srtp profile" \
7900 -s "selected srtp profile" \
7901 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007902 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007903 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
7904
7905requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007906requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007907run_test "DTLS-SRTP server and Client support only one different profile. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007908 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \
7909 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007910 0 \
7911 -s "found use_srtp extension" \
7912 -s "found srtp profile" \
7913 -S "selected srtp profile" \
7914 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007915 -S "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007916 -C "SRTP profile:"
7917
7918requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007919requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007920run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls client" \
Ron Eldor5d991c92019-01-15 18:54:03 +02007921 "$P_SRV dtls=1 debug_level=3" \
7922 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007923 0 \
7924 -s "found use_srtp extension" \
7925 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007926 -S "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007927 -C "SRTP profile:"
7928
7929requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007930requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007931run_test "DTLS-SRTP all profiles supported. gnutls server" \
7932 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
7933 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7934 0 \
7935 -c "client hello, adding use_srtp extension" \
7936 -c "found use_srtp extension" \
7937 -c "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007938 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007939 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007940 -C "error"
7941
7942requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007943requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007944run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls server." \
7945 "$G_SRV -u --srtp-profiles=SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
7946 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7947 0 \
7948 -c "client hello, adding use_srtp extension" \
7949 -c "found use_srtp extension" \
7950 -c "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007951 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007952 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007953 -C "error"
7954
7955requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007956requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007957run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls server." \
7958 "$G_SRV -u --srtp-profiles=SRTP_NULL_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_AES128_CM_HMAC_SHA1_80:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
7959 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7960 0 \
7961 -c "client hello, adding use_srtp extension" \
7962 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007963 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007964 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007965 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007966 -C "error"
7967
7968requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007969requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007970run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls server." \
7971 "$G_SRV -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007972 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007973 0 \
7974 -c "client hello, adding use_srtp extension" \
7975 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007976 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007977 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007978 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007979 -C "error"
7980
7981requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007982requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007983run_test "DTLS-SRTP server and Client support only one matching profile. gnutls server." \
7984 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
7985 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7986 0 \
7987 -c "client hello, adding use_srtp extension" \
7988 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007989 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007990 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007991 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007992 -C "error"
7993
7994requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007995requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007996run_test "DTLS-SRTP server and Client support only one different profile. gnutls server." \
7997 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
Johan Pascal43f94902020-09-22 12:25:52 +02007998 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007999 0 \
8000 -c "client hello, adding use_srtp extension" \
8001 -C "found use_srtp extension" \
8002 -C "found srtp profile" \
8003 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02008004 -C "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03008005 -C "error"
8006
8007requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02008008requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03008009run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls server" \
8010 "$G_SRV -u" \
8011 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
8012 0 \
8013 -c "client hello, adding use_srtp extension" \
8014 -C "found use_srtp extension" \
8015 -C "found srtp profile" \
8016 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02008017 -C "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03008018 -C "error"
8019
8020requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02008021requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03008022run_test "DTLS-SRTP all profiles supported. mki used. gnutls server." \
8023 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_80:SRTP_AES128_CM_HMAC_SHA1_32:SRTP_NULL_HMAC_SHA1_80:SRTP_NULL_SHA1_32" \
8024 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
8025 0 \
8026 -c "client hello, adding use_srtp extension" \
8027 -c "found use_srtp extension" \
8028 -c "found srtp profile" \
8029 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02008030 -c "DTLS-SRTP key material is"\
Johan Pascal20c7db32020-10-26 22:45:58 +01008031 -c "DTLS-SRTP mki value:"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03008032 -c "dumping 'sending mki' (8 bytes)" \
8033 -c "dumping 'received mki' (8 bytes)" \
8034 -C "error"
8035
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02008036# Tests for specific things with "unreliable" UDP connection
8037
8038not_with_valgrind # spurious resend due to timeout
8039run_test "DTLS proxy: reference" \
8040 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008041 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
8042 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02008043 0 \
8044 -C "replayed record" \
8045 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01008046 -C "Buffer record from epoch" \
8047 -S "Buffer record from epoch" \
8048 -C "ssl_buffer_message" \
8049 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02008050 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008051 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008052 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008053 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02008054 -c "HTTP/1.0 200 OK"
8055
8056not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008057run_test "DTLS proxy: duplicate every packet" \
8058 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02008059 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
8060 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02008061 0 \
8062 -c "replayed record" \
8063 -s "replayed record" \
8064 -c "record from another epoch" \
8065 -s "record from another epoch" \
8066 -S "resend" \
8067 -s "Extra-header:" \
8068 -c "HTTP/1.0 200 OK"
8069
8070run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
8071 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008072 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
8073 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008074 0 \
8075 -c "replayed record" \
8076 -S "replayed record" \
8077 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008078 -s "record from another epoch" \
8079 -c "resend" \
8080 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008081 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008082 -c "HTTP/1.0 200 OK"
8083
8084run_test "DTLS proxy: multiple records in same datagram" \
8085 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008086 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8087 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008088 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008089 -c "next record in same datagram" \
8090 -s "next record in same datagram"
8091
8092run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
8093 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008094 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
8095 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008096 0 \
8097 -c "next record in same datagram" \
8098 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008099
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02008100run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
8101 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008102 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
8103 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02008104 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008105 -c "discarding invalid record (mac)" \
8106 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008107 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008108 -c "HTTP/1.0 200 OK" \
8109 -S "too many records with bad MAC" \
8110 -S "Verification of the message MAC failed"
8111
8112run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
8113 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008114 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
8115 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008116 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008117 -C "discarding invalid record (mac)" \
8118 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008119 -S "Extra-header:" \
8120 -C "HTTP/1.0 200 OK" \
8121 -s "too many records with bad MAC" \
8122 -s "Verification of the message MAC failed"
8123
8124run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
8125 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008126 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
8127 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008128 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008129 -c "discarding invalid record (mac)" \
8130 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008131 -s "Extra-header:" \
8132 -c "HTTP/1.0 200 OK" \
8133 -S "too many records with bad MAC" \
8134 -S "Verification of the message MAC failed"
8135
8136run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
8137 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01008138 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
8139 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008140 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02008141 -c "discarding invalid record (mac)" \
8142 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02008143 -s "Extra-header:" \
8144 -c "HTTP/1.0 200 OK" \
8145 -s "too many records with bad MAC" \
8146 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008147
8148run_test "DTLS proxy: delay ChangeCipherSpec" \
8149 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01008150 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
8151 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008152 0 \
8153 -c "record from another epoch" \
8154 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008155 -s "Extra-header:" \
8156 -c "HTTP/1.0 200 OK"
8157
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008158# Tests for reordering support with DTLS
8159
Hanno Becker56cdfd12018-08-17 13:42:15 +01008160run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
8161 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008162 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8163 hs_timeout=2500-60000" \
8164 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8165 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01008166 0 \
8167 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008168 -c "Next handshake message has been buffered - load"\
8169 -S "Buffering HS message" \
8170 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008171 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008172 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008173 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008174 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01008175
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008176run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
8177 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008178 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8179 hs_timeout=2500-60000" \
8180 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8181 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008182 0 \
8183 -c "Buffering HS message" \
8184 -c "found fragmented DTLS handshake message"\
8185 -c "Next handshake message 1 not or only partially bufffered" \
8186 -c "Next handshake message has been buffered - load"\
8187 -S "Buffering HS message" \
8188 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008189 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01008190 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008191 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01008192 -S "Remember CCS message"
8193
Hanno Beckera1adcca2018-08-24 14:41:07 +01008194# The client buffers the ServerKeyExchange before receiving the fragmented
8195# Certificate message; at the time of writing, together these are aroudn 1200b
8196# in size, so that the bound below ensures that the certificate can be reassembled
8197# while keeping the ServerKeyExchange.
8198requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
8199run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01008200 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008201 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8202 hs_timeout=2500-60000" \
8203 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8204 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01008205 0 \
8206 -c "Buffering HS message" \
8207 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01008208 -C "attempt to make space by freeing buffered messages" \
8209 -S "Buffering HS message" \
8210 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008211 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008212 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008213 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008214 -S "Remember CCS message"
8215
8216# The size constraints ensure that the delayed certificate message can't
8217# be reassembled while keeping the ServerKeyExchange message, but it can
8218# when dropping it first.
8219requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
8220requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
8221run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
8222 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008223 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8224 hs_timeout=2500-60000" \
8225 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8226 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01008227 0 \
8228 -c "Buffering HS message" \
8229 -c "attempt to make space by freeing buffered future messages" \
8230 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01008231 -S "Buffering HS message" \
8232 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01008233 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008234 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008235 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01008236 -S "Remember CCS message"
8237
Hanno Becker56cdfd12018-08-17 13:42:15 +01008238run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
8239 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008240 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
8241 hs_timeout=2500-60000" \
8242 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8243 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008244 0 \
8245 -C "Buffering HS message" \
8246 -C "Next handshake message has been buffered - load"\
8247 -s "Buffering HS message" \
8248 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008249 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008250 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008251 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008252 -S "Remember CCS message"
8253
8254run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8255 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008256 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8257 hs_timeout=2500-60000" \
8258 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8259 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008260 0 \
8261 -C "Buffering HS message" \
8262 -C "Next handshake message has been buffered - load"\
8263 -S "Buffering HS message" \
8264 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008265 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008266 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008267 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008268 -S "Remember CCS message"
8269
8270run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8271 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008272 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8273 hs_timeout=2500-60000" \
8274 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8275 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008276 0 \
8277 -C "Buffering HS message" \
8278 -C "Next handshake message has been buffered - load"\
8279 -S "Buffering HS message" \
8280 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008281 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008282 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008283 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008284 -s "Remember CCS message"
8285
Hanno Beckera1adcca2018-08-24 14:41:07 +01008286run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008287 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008288 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8289 hs_timeout=2500-60000" \
8290 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8291 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008292 0 \
8293 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008294 -s "Found buffered record from current epoch - load" \
8295 -c "Buffer record from epoch 1" \
8296 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008297
Hanno Beckera1adcca2018-08-24 14:41:07 +01008298# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8299# from the server are delayed, so that the encrypted Finished message
8300# is received and buffered. When the fragmented NewSessionTicket comes
8301# in afterwards, the encrypted Finished message must be freed in order
8302# to make space for the NewSessionTicket to be reassembled.
8303# This works only in very particular circumstances:
8304# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8305# of the NewSessionTicket, but small enough to also allow buffering of
8306# the encrypted Finished message.
8307# - The MTU setting on the server must be so small that the NewSessionTicket
8308# needs to be fragmented.
8309# - All messages sent by the server must be small enough to be either sent
8310# without fragmentation or be reassembled within the bounds of
8311# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8312# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008313requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8314requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008315run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8316 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008317 "$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 +01008318 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8319 0 \
8320 -s "Buffer record from epoch 1" \
8321 -s "Found buffered record from current epoch - load" \
8322 -c "Buffer record from epoch 1" \
8323 -C "Found buffered record from current epoch - load" \
8324 -c "Enough space available after freeing future epoch record"
8325
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008326# Tests for "randomly unreliable connection": try a variety of flows and peers
8327
8328client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008329run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8330 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008331 "$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 +02008332 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008333 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008334 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8335 0 \
8336 -s "Extra-header:" \
8337 -c "HTTP/1.0 200 OK"
8338
Janos Follath74537a62016-09-02 13:45:28 +01008339client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008340run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8341 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008342 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8343 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008344 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8345 0 \
8346 -s "Extra-header:" \
8347 -c "HTTP/1.0 200 OK"
8348
Janos Follath74537a62016-09-02 13:45:28 +01008349client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008350run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8351 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008352 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8353 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008354 0 \
8355 -s "Extra-header:" \
8356 -c "HTTP/1.0 200 OK"
8357
Janos Follath74537a62016-09-02 13:45:28 +01008358client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008359run_test "DTLS proxy: 3d, FS, client auth" \
8360 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008361 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8362 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008363 0 \
8364 -s "Extra-header:" \
8365 -c "HTTP/1.0 200 OK"
8366
Janos Follath74537a62016-09-02 13:45:28 +01008367client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008368run_test "DTLS proxy: 3d, FS, ticket" \
8369 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008370 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8371 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008372 0 \
8373 -s "Extra-header:" \
8374 -c "HTTP/1.0 200 OK"
8375
Janos Follath74537a62016-09-02 13:45:28 +01008376client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008377run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8378 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008379 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8380 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008381 0 \
8382 -s "Extra-header:" \
8383 -c "HTTP/1.0 200 OK"
8384
Janos Follath74537a62016-09-02 13:45:28 +01008385client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008386run_test "DTLS proxy: 3d, max handshake, nbio" \
8387 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008388 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008389 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008390 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008391 0 \
8392 -s "Extra-header:" \
8393 -c "HTTP/1.0 200 OK"
8394
Janos Follath74537a62016-09-02 13:45:28 +01008395client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008396run_test "DTLS proxy: 3d, min handshake, resumption" \
8397 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008398 "$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 +02008399 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008400 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008401 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008402 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8403 0 \
8404 -s "a session has been resumed" \
8405 -c "a session has been resumed" \
8406 -s "Extra-header:" \
8407 -c "HTTP/1.0 200 OK"
8408
Janos Follath74537a62016-09-02 13:45:28 +01008409client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008410run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8411 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008412 "$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 +02008413 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008414 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008415 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008416 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8417 0 \
8418 -s "a session has been resumed" \
8419 -c "a session has been resumed" \
8420 -s "Extra-header:" \
8421 -c "HTTP/1.0 200 OK"
8422
Janos Follath74537a62016-09-02 13:45:28 +01008423client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008424requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008425run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008426 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008427 "$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 +02008428 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008429 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008430 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008431 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8432 0 \
8433 -c "=> renegotiate" \
8434 -s "=> renegotiate" \
8435 -s "Extra-header:" \
8436 -c "HTTP/1.0 200 OK"
8437
Janos Follath74537a62016-09-02 13:45:28 +01008438client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008439requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008440run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8441 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008442 "$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 +02008443 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008444 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008445 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008446 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8447 0 \
8448 -c "=> renegotiate" \
8449 -s "=> renegotiate" \
8450 -s "Extra-header:" \
8451 -c "HTTP/1.0 200 OK"
8452
Janos Follath74537a62016-09-02 13:45:28 +01008453client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008454requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008455run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008456 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008457 "$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 +02008458 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008459 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008460 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008461 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008462 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8463 0 \
8464 -c "=> renegotiate" \
8465 -s "=> renegotiate" \
8466 -s "Extra-header:" \
8467 -c "HTTP/1.0 200 OK"
8468
Janos Follath74537a62016-09-02 13:45:28 +01008469client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008470requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008471run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008472 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008473 "$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 +02008474 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008475 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008476 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008477 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008478 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8479 0 \
8480 -c "=> renegotiate" \
8481 -s "=> renegotiate" \
8482 -s "Extra-header:" \
8483 -c "HTTP/1.0 200 OK"
8484
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008485## Interop tests with OpenSSL might trigger a bug in recent versions (including
8486## all versions installed on the CI machines), reported here:
8487## Bug report: https://github.com/openssl/openssl/issues/6902
8488## They should be re-enabled once a fixed version of OpenSSL is available
8489## (this should happen in some 1.1.1_ release according to the ticket).
8490skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008491client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008492not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008493run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008494 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8495 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008496 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008497 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008498 -c "HTTP/1.0 200 OK"
8499
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008500skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008501client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008502not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008503run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8504 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8505 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008506 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008507 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008508 -c "HTTP/1.0 200 OK"
8509
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008510skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008511client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008512not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008513run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8514 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8515 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008516 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008517 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008518 -c "HTTP/1.0 200 OK"
8519
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008520requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008521client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008522not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008523run_test "DTLS proxy: 3d, gnutls server" \
8524 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8525 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008526 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008527 0 \
8528 -s "Extra-header:" \
8529 -c "Extra-header:"
8530
k-stachowiak17a38d32019-02-18 15:29:56 +01008531requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008532client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008533not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008534run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8535 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008536 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008537 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008538 0 \
8539 -s "Extra-header:" \
8540 -c "Extra-header:"
8541
k-stachowiak17a38d32019-02-18 15:29:56 +01008542requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008543client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008544not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008545run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8546 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008547 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008548 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008549 0 \
8550 -s "Extra-header:" \
8551 -c "Extra-header:"
8552
Ron Eldorf75e2522019-05-14 20:38:49 +03008553requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
8554run_test "export keys functionality" \
8555 "$P_SRV eap_tls=1 debug_level=3" \
8556 "$P_CLI eap_tls=1 debug_level=3" \
8557 0 \
8558 -s "exported maclen is " \
8559 -s "exported keylen is " \
8560 -s "exported ivlen is " \
8561 -c "exported maclen is " \
8562 -c "exported keylen is " \
Ron Eldor65d8c262019-06-04 13:05:36 +03008563 -c "exported ivlen is " \
8564 -c "EAP-TLS key material is:"\
8565 -s "EAP-TLS key material is:"\
8566 -c "EAP-TLS IV is:" \
8567 -s "EAP-TLS IV is:"
Ron Eldorf75e2522019-05-14 20:38:49 +03008568
Piotr Nowicki0937ed22019-11-26 16:32:40 +01008569# Test heap memory usage after handshake
8570requires_config_enabled MBEDTLS_MEMORY_DEBUG
8571requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
8572requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
8573run_tests_memory_after_hanshake
8574
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008575# Final report
8576
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008577echo "------------------------------------------------------------------------"
8578
8579if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008580 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008581else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008582 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008583fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008584PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008585echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008586
8587exit $FAILS