blob: 59cb834badc4fa147bd243c86ca3277691b0ed41 [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" \
1011 "$P_SRV debug_level=4 force_version=tls1_2" \
1012 "$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)
1236# - the expected (highest security) parameters are selected
1237# ("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" \
1245 -s "ECDHE curve: secp521r1" \
1246 -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
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002625# Tests for Session Resume based on session-ID and cache
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002626
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002627run_test "Session resume using cache: tickets enabled on client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002628 "$P_SRV debug_level=3 tickets=0" \
2629 "$P_CLI debug_level=3 tickets=1 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002630 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002631 -c "client hello, adding session ticket extension" \
2632 -s "found session ticket extension" \
2633 -S "server hello, adding session ticket extension" \
2634 -C "found session_ticket extension" \
2635 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002636 -s "session successfully restored from cache" \
2637 -S "session successfully restored from ticket" \
2638 -s "a session has been resumed" \
2639 -c "a session has been resumed"
2640
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002641run_test "Session resume using cache: tickets enabled on server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002642 "$P_SRV debug_level=3 tickets=1" \
2643 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002644 0 \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002645 -C "client hello, adding session ticket extension" \
2646 -S "found session ticket extension" \
2647 -S "server hello, adding session ticket extension" \
2648 -C "found session_ticket extension" \
2649 -C "parse new session ticket" \
Manuel Pégourié-Gonnardf7c52012014-02-20 11:43:46 +01002650 -s "session successfully restored from cache" \
2651 -S "session successfully restored from ticket" \
2652 -s "a session has been resumed" \
2653 -c "a session has been resumed"
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002654
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002655run_test "Session resume using cache: cache_max=0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002656 "$P_SRV debug_level=3 tickets=0 cache_max=0" \
2657 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002658 0 \
2659 -S "session successfully restored from cache" \
2660 -S "session successfully restored from ticket" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002661 -S "a session has been resumed" \
2662 -C "a session has been resumed"
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002663
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002664run_test "Session resume using cache: cache_max=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002665 "$P_SRV debug_level=3 tickets=0 cache_max=1" \
2666 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002667 0 \
2668 -s "session successfully restored from cache" \
2669 -S "session successfully restored from ticket" \
2670 -s "a session has been resumed" \
2671 -c "a session has been resumed"
2672
Manuel Pégourié-Gonnard6df31962015-05-04 10:55:47 +02002673run_test "Session resume using cache: timeout > delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002674 "$P_SRV debug_level=3 tickets=0" \
2675 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=0" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002676 0 \
2677 -s "session successfully restored from cache" \
2678 -S "session successfully restored from ticket" \
2679 -s "a session has been resumed" \
2680 -c "a session has been resumed"
2681
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002682run_test "Session resume using cache: timeout < delay" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002683 "$P_SRV debug_level=3 tickets=0 cache_timeout=1" \
2684 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnardc55a5b72014-02-20 22:50:56 +01002685 0 \
2686 -S "session successfully restored from cache" \
2687 -S "session successfully restored from ticket" \
2688 -S "a session has been resumed" \
2689 -C "a session has been resumed"
2690
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002691run_test "Session resume using cache: no timeout" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002692 "$P_SRV debug_level=3 tickets=0 cache_timeout=0" \
2693 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_delay=2" \
Manuel Pégourié-Gonnard4c883452014-02-20 21:32:41 +01002694 0 \
2695 -s "session successfully restored from cache" \
2696 -S "session successfully restored from ticket" \
2697 -s "a session has been resumed" \
2698 -c "a session has been resumed"
2699
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002700run_test "Session resume using cache: session copy" \
2701 "$P_SRV debug_level=3 tickets=0" \
2702 "$P_CLI debug_level=3 tickets=0 reconnect=1 reco_mode=0" \
2703 0 \
2704 -s "session successfully restored from cache" \
2705 -S "session successfully restored from ticket" \
2706 -s "a session has been resumed" \
2707 -c "a session has been resumed"
2708
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002709run_test "Session resume using cache: openssl client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002710 "$P_SRV debug_level=3 tickets=0" \
Manuel Pégourié-Gonnardbc3b16c2014-05-28 23:06:50 +02002711 "( $O_CLI -sess_out $SESSION; \
2712 $O_CLI -sess_in $SESSION; \
2713 rm -f $SESSION )" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002714 0 \
2715 -s "found session ticket extension" \
2716 -S "server hello, adding session ticket extension" \
2717 -s "session successfully restored from cache" \
2718 -S "session successfully restored from ticket" \
2719 -s "a session has been resumed"
2720
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002721run_test "Session resume using cache: openssl server" \
Manuel Pégourié-Gonnardf7a26902014-02-27 12:25:54 +01002722 "$O_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002723 "$P_CLI debug_level=3 tickets=0 reconnect=1" \
Manuel Pégourié-Gonnarddb735f62014-02-25 17:57:59 +01002724 0 \
2725 -C "found session_ticket extension" \
2726 -C "parse new session ticket" \
2727 -c "a session has been resumed"
2728
Hanno Becker1d739932018-08-21 13:55:22 +01002729# Tests for Session Resume based on session-ID and cache, DTLS
2730
2731run_test "Session resume using cache, DTLS: tickets enabled on client" \
2732 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002733 "$P_CLI dtls=1 debug_level=3 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002734 0 \
2735 -c "client hello, adding session ticket extension" \
2736 -s "found session ticket extension" \
2737 -S "server hello, adding session ticket extension" \
2738 -C "found session_ticket extension" \
2739 -C "parse new session ticket" \
2740 -s "session successfully restored from cache" \
2741 -S "session successfully restored from ticket" \
2742 -s "a session has been resumed" \
2743 -c "a session has been resumed"
2744
2745run_test "Session resume using cache, DTLS: tickets enabled on server" \
2746 "$P_SRV dtls=1 debug_level=3 tickets=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002747 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002748 0 \
2749 -C "client hello, adding session ticket extension" \
2750 -S "found session ticket extension" \
2751 -S "server hello, adding session ticket extension" \
2752 -C "found session_ticket extension" \
2753 -C "parse new session ticket" \
2754 -s "session successfully restored from cache" \
2755 -S "session successfully restored from ticket" \
2756 -s "a session has been resumed" \
2757 -c "a session has been resumed"
2758
2759run_test "Session resume using cache, DTLS: cache_max=0" \
2760 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002761 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002762 0 \
2763 -S "session successfully restored from cache" \
2764 -S "session successfully restored from ticket" \
2765 -S "a session has been resumed" \
2766 -C "a session has been resumed"
2767
2768run_test "Session resume using cache, DTLS: cache_max=1" \
2769 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_max=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002770 "$P_CLI dtls=1 debug_level=3 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker1d739932018-08-21 13:55:22 +01002771 0 \
2772 -s "session successfully restored from cache" \
2773 -S "session successfully restored from ticket" \
2774 -s "a session has been resumed" \
2775 -c "a session has been resumed"
2776
2777run_test "Session resume using cache, DTLS: timeout > delay" \
2778 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002779 "$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 +01002780 0 \
2781 -s "session successfully restored from cache" \
2782 -S "session successfully restored from ticket" \
2783 -s "a session has been resumed" \
2784 -c "a session has been resumed"
2785
2786run_test "Session resume using cache, DTLS: timeout < delay" \
2787 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=1" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002788 "$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 +01002789 0 \
2790 -S "session successfully restored from cache" \
2791 -S "session successfully restored from ticket" \
2792 -S "a session has been resumed" \
2793 -C "a session has been resumed"
2794
2795run_test "Session resume using cache, DTLS: no timeout" \
2796 "$P_SRV dtls=1 debug_level=3 tickets=0 cache_timeout=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002797 "$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 +01002798 0 \
2799 -s "session successfully restored from cache" \
2800 -S "session successfully restored from ticket" \
2801 -s "a session has been resumed" \
2802 -c "a session has been resumed"
2803
Manuel Pégourié-Gonnarda7c37652019-05-20 12:46:26 +02002804run_test "Session resume using cache, DTLS: session copy" \
2805 "$P_SRV dtls=1 debug_level=3 tickets=0" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01002806 "$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 +02002807 0 \
2808 -s "session successfully restored from cache" \
2809 -S "session successfully restored from ticket" \
2810 -s "a session has been resumed" \
2811 -c "a session has been resumed"
2812
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01002813# Tests for Max Fragment Length extension
2814
David Horstmann95d516f2021-05-04 18:36:56 +01002815if [ "$MAX_IN_LEN" -lt "4096" ]; then
2816 printf '%s defines MBEDTLS_SSL_IN_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n' "${CONFIG_H}"
2817 exit 1
2818fi
2819
2820if [ "$MAX_OUT_LEN" -lt "4096" ]; then
2821 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 +01002822 exit 1
2823fi
2824
Angus Grattonc4dd0732018-04-11 16:28:39 +10002825if [ $MAX_CONTENT_LEN -ne 16384 ]; then
Gilles Peskine231befa2020-08-26 20:05:11 +02002826 echo "Using non-default maximum content length $MAX_CONTENT_LEN"
Angus Grattonc4dd0732018-04-11 16:28:39 +10002827fi
2828
Hanno Becker4aed27e2017-09-18 15:00:34 +01002829requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002830run_test "Max fragment length: enabled, default" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002831 "$P_SRV debug_level=3" \
2832 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002833 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002834 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2835 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2836 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2837 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002838 -C "client hello, adding max_fragment_length extension" \
2839 -S "found max fragment length extension" \
2840 -S "server hello, max_fragment_length extension" \
2841 -C "found max_fragment_length extension"
2842
Hanno Becker4aed27e2017-09-18 15:00:34 +01002843requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Hanno Beckerc5266962017-09-18 15:01:50 +01002844run_test "Max fragment length: enabled, default, larger message" \
2845 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002846 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002847 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002848 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2849 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2850 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2851 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002852 -C "client hello, adding max_fragment_length extension" \
2853 -S "found max fragment length extension" \
2854 -S "server hello, max_fragment_length extension" \
2855 -C "found max_fragment_length extension" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002856 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2857 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002858 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002859
2860requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2861run_test "Max fragment length, DTLS: enabled, default, larger message" \
2862 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002863 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002864 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002865 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
2866 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
2867 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
2868 -s "Maximum output fragment length is $MAX_CONTENT_LEN" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002869 -C "client hello, adding max_fragment_length extension" \
2870 -S "found max fragment length extension" \
2871 -S "server hello, max_fragment_length extension" \
2872 -C "found max_fragment_length extension" \
2873 -c "fragment larger than.*maximum "
2874
Angus Grattonc4dd0732018-04-11 16:28:39 +10002875# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled
2876# (session fragment length will be 16384 regardless of mbedtls
2877# content length configuration.)
2878
Hanno Beckerc5266962017-09-18 15:01:50 +01002879requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2880run_test "Max fragment length: disabled, larger message" \
2881 "$P_SRV debug_level=3" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002882 "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002883 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002884 -C "Maximum input fragment length is 16384" \
2885 -C "Maximum output fragment length is 16384" \
2886 -S "Maximum input fragment length is 16384" \
2887 -S "Maximum output fragment length is 16384" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002888 -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \
2889 -s "$MAX_CONTENT_LEN bytes read" \
Hanno Becker9cfabe32017-10-18 14:42:01 +01002890 -s "1 bytes read"
Hanno Beckerc5266962017-09-18 15:01:50 +01002891
2892requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2893run_test "Max fragment length DTLS: disabled, larger message" \
2894 "$P_SRV debug_level=3 dtls=1" \
Angus Grattonc4dd0732018-04-11 16:28:39 +10002895 "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002896 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002897 -C "Maximum input fragment length is 16384" \
2898 -C "Maximum output fragment length is 16384" \
2899 -S "Maximum input fragment length is 16384" \
2900 -S "Maximum output fragment length is 16384" \
Hanno Beckerc5266962017-09-18 15:01:50 +01002901 -c "fragment larger than.*maximum "
2902
2903requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02002904run_test "Max fragment length: used by client" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02002905 "$P_SRV debug_level=3" \
2906 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01002907 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04002908 -c "Maximum input fragment length is 4096" \
2909 -c "Maximum output fragment length is 4096" \
2910 -s "Maximum input fragment length is 4096" \
2911 -s "Maximum output fragment length is 4096" \
2912 -c "client hello, adding max_fragment_length extension" \
2913 -s "found max fragment length extension" \
2914 -s "server hello, max_fragment_length extension" \
2915 -c "found max_fragment_length extension"
2916
2917requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2918run_test "Max fragment length: client 512, server 1024" \
2919 "$P_SRV debug_level=3 max_frag_len=1024" \
2920 "$P_CLI debug_level=3 max_frag_len=512" \
2921 0 \
2922 -c "Maximum input fragment length is 512" \
2923 -c "Maximum output fragment length is 512" \
2924 -s "Maximum input fragment length is 512" \
2925 -s "Maximum output fragment length is 512" \
2926 -c "client hello, adding max_fragment_length extension" \
2927 -s "found max fragment length extension" \
2928 -s "server hello, max_fragment_length extension" \
2929 -c "found max_fragment_length extension"
2930
2931requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2932run_test "Max fragment length: client 512, server 2048" \
2933 "$P_SRV debug_level=3 max_frag_len=2048" \
2934 "$P_CLI debug_level=3 max_frag_len=512" \
2935 0 \
2936 -c "Maximum input fragment length is 512" \
2937 -c "Maximum output fragment length is 512" \
2938 -s "Maximum input fragment length is 512" \
2939 -s "Maximum output fragment length is 512" \
2940 -c "client hello, adding max_fragment_length extension" \
2941 -s "found max fragment length extension" \
2942 -s "server hello, max_fragment_length extension" \
2943 -c "found max_fragment_length extension"
2944
2945requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2946run_test "Max fragment length: client 512, server 4096" \
2947 "$P_SRV debug_level=3 max_frag_len=4096" \
2948 "$P_CLI debug_level=3 max_frag_len=512" \
2949 0 \
2950 -c "Maximum input fragment length is 512" \
2951 -c "Maximum output fragment length is 512" \
2952 -s "Maximum input fragment length is 512" \
2953 -s "Maximum output fragment length is 512" \
2954 -c "client hello, adding max_fragment_length extension" \
2955 -s "found max fragment length extension" \
2956 -s "server hello, max_fragment_length extension" \
2957 -c "found max_fragment_length extension"
2958
2959requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2960run_test "Max fragment length: client 1024, server 512" \
2961 "$P_SRV debug_level=3 max_frag_len=512" \
2962 "$P_CLI debug_level=3 max_frag_len=1024" \
2963 0 \
2964 -c "Maximum input fragment length is 1024" \
2965 -c "Maximum output fragment length is 1024" \
2966 -s "Maximum input fragment length is 1024" \
2967 -s "Maximum output fragment length is 512" \
2968 -c "client hello, adding max_fragment_length extension" \
2969 -s "found max fragment length extension" \
2970 -s "server hello, max_fragment_length extension" \
2971 -c "found max_fragment_length extension"
2972
2973requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2974run_test "Max fragment length: client 1024, server 2048" \
2975 "$P_SRV debug_level=3 max_frag_len=2048" \
2976 "$P_CLI debug_level=3 max_frag_len=1024" \
2977 0 \
2978 -c "Maximum input fragment length is 1024" \
2979 -c "Maximum output fragment length is 1024" \
2980 -s "Maximum input fragment length is 1024" \
2981 -s "Maximum output fragment length is 1024" \
2982 -c "client hello, adding max_fragment_length extension" \
2983 -s "found max fragment length extension" \
2984 -s "server hello, max_fragment_length extension" \
2985 -c "found max_fragment_length extension"
2986
2987requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2988run_test "Max fragment length: client 1024, server 4096" \
2989 "$P_SRV debug_level=3 max_frag_len=4096" \
2990 "$P_CLI debug_level=3 max_frag_len=1024" \
2991 0 \
2992 -c "Maximum input fragment length is 1024" \
2993 -c "Maximum output fragment length is 1024" \
2994 -s "Maximum input fragment length is 1024" \
2995 -s "Maximum output fragment length is 1024" \
2996 -c "client hello, adding max_fragment_length extension" \
2997 -s "found max fragment length extension" \
2998 -s "server hello, max_fragment_length extension" \
2999 -c "found max_fragment_length extension"
3000
3001requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3002run_test "Max fragment length: client 2048, server 512" \
3003 "$P_SRV debug_level=3 max_frag_len=512" \
3004 "$P_CLI debug_level=3 max_frag_len=2048" \
3005 0 \
3006 -c "Maximum input fragment length is 2048" \
3007 -c "Maximum output fragment length is 2048" \
3008 -s "Maximum input fragment length is 2048" \
3009 -s "Maximum output fragment length is 512" \
3010 -c "client hello, adding max_fragment_length extension" \
3011 -s "found max fragment length extension" \
3012 -s "server hello, max_fragment_length extension" \
3013 -c "found max_fragment_length extension"
3014
3015requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3016run_test "Max fragment length: client 2048, server 1024" \
3017 "$P_SRV debug_level=3 max_frag_len=1024" \
3018 "$P_CLI debug_level=3 max_frag_len=2048" \
3019 0 \
3020 -c "Maximum input fragment length is 2048" \
3021 -c "Maximum output fragment length is 2048" \
3022 -s "Maximum input fragment length is 2048" \
3023 -s "Maximum output fragment length is 1024" \
3024 -c "client hello, adding max_fragment_length extension" \
3025 -s "found max fragment length extension" \
3026 -s "server hello, max_fragment_length extension" \
3027 -c "found max_fragment_length extension"
3028
3029requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3030run_test "Max fragment length: client 2048, server 4096" \
3031 "$P_SRV debug_level=3 max_frag_len=4096" \
3032 "$P_CLI debug_level=3 max_frag_len=2048" \
3033 0 \
3034 -c "Maximum input fragment length is 2048" \
3035 -c "Maximum output fragment length is 2048" \
3036 -s "Maximum input fragment length is 2048" \
3037 -s "Maximum output fragment length is 2048" \
3038 -c "client hello, adding max_fragment_length extension" \
3039 -s "found max fragment length extension" \
3040 -s "server hello, max_fragment_length extension" \
3041 -c "found max_fragment_length extension"
3042
3043requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3044run_test "Max fragment length: client 4096, server 512" \
3045 "$P_SRV debug_level=3 max_frag_len=512" \
3046 "$P_CLI debug_level=3 max_frag_len=4096" \
3047 0 \
3048 -c "Maximum input fragment length is 4096" \
3049 -c "Maximum output fragment length is 4096" \
3050 -s "Maximum input fragment length is 4096" \
3051 -s "Maximum output fragment length is 512" \
3052 -c "client hello, adding max_fragment_length extension" \
3053 -s "found max fragment length extension" \
3054 -s "server hello, max_fragment_length extension" \
3055 -c "found max_fragment_length extension"
3056
3057requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3058run_test "Max fragment length: client 4096, server 1024" \
3059 "$P_SRV debug_level=3 max_frag_len=1024" \
3060 "$P_CLI debug_level=3 max_frag_len=4096" \
3061 0 \
3062 -c "Maximum input fragment length is 4096" \
3063 -c "Maximum output fragment length is 4096" \
3064 -s "Maximum input fragment length is 4096" \
3065 -s "Maximum output fragment length is 1024" \
3066 -c "client hello, adding max_fragment_length extension" \
3067 -s "found max fragment length extension" \
3068 -s "server hello, max_fragment_length extension" \
3069 -c "found max_fragment_length extension"
3070
3071requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3072run_test "Max fragment length: client 4096, server 2048" \
3073 "$P_SRV debug_level=3 max_frag_len=2048" \
3074 "$P_CLI debug_level=3 max_frag_len=4096" \
3075 0 \
3076 -c "Maximum input fragment length is 4096" \
3077 -c "Maximum output fragment length is 4096" \
3078 -s "Maximum input fragment length is 4096" \
3079 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003080 -c "client hello, adding max_fragment_length extension" \
3081 -s "found max fragment length extension" \
3082 -s "server hello, max_fragment_length extension" \
3083 -c "found max_fragment_length extension"
3084
Hanno Becker4aed27e2017-09-18 15:00:34 +01003085requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003086run_test "Max fragment length: used by server" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003087 "$P_SRV debug_level=3 max_frag_len=4096" \
3088 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003089 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003090 -c "Maximum input fragment length is $MAX_CONTENT_LEN" \
3091 -c "Maximum output fragment length is $MAX_CONTENT_LEN" \
3092 -s "Maximum input fragment length is $MAX_CONTENT_LEN" \
3093 -s "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardde143782014-02-20 14:50:42 +01003094 -C "client hello, adding max_fragment_length extension" \
3095 -S "found max fragment length extension" \
3096 -S "server hello, max_fragment_length extension" \
3097 -C "found max_fragment_length extension"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003098
Hanno Becker4aed27e2017-09-18 15:00:34 +01003099requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003100requires_gnutls
3101run_test "Max fragment length: gnutls server" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003102 "$G_SRV" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003103 "$P_CLI debug_level=3 max_frag_len=4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003104 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003105 -c "Maximum input fragment length is 4096" \
3106 -c "Maximum output fragment length is 4096" \
Manuel Pégourié-Gonnardbaa7f072014-08-20 20:15:53 +02003107 -c "client hello, adding max_fragment_length extension" \
3108 -c "found max_fragment_length extension"
3109
Hanno Becker4aed27e2017-09-18 15:00:34 +01003110requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003111run_test "Max fragment length: client, message just fits" \
3112 "$P_SRV debug_level=3" \
3113 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
3114 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003115 -c "Maximum input fragment length is 2048" \
3116 -c "Maximum output fragment length is 2048" \
3117 -s "Maximum input fragment length is 2048" \
3118 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003119 -c "client hello, adding max_fragment_length extension" \
3120 -s "found max fragment length extension" \
3121 -s "server hello, max_fragment_length extension" \
3122 -c "found max_fragment_length extension" \
3123 -c "2048 bytes written in 1 fragments" \
3124 -s "2048 bytes read"
3125
Hanno Becker4aed27e2017-09-18 15:00:34 +01003126requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003127run_test "Max fragment length: client, larger message" \
3128 "$P_SRV debug_level=3" \
3129 "$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
3130 0 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003131 -c "Maximum input fragment length is 2048" \
3132 -c "Maximum output fragment length is 2048" \
3133 -s "Maximum input fragment length is 2048" \
3134 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003135 -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" \
3139 -c "2345 bytes written in 2 fragments" \
3140 -s "2048 bytes read" \
3141 -s "297 bytes read"
3142
Hanno Becker4aed27e2017-09-18 15:00:34 +01003143requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnard23eb74d2015-01-21 14:37:13 +00003144run_test "Max fragment length: DTLS client, larger message" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003145 "$P_SRV debug_level=3 dtls=1" \
3146 "$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
3147 1 \
Andrzej Kurek90c6e842020-04-03 05:25:29 -04003148 -c "Maximum input fragment length is 2048" \
3149 -c "Maximum output fragment length is 2048" \
3150 -s "Maximum input fragment length is 2048" \
3151 -s "Maximum output fragment length is 2048" \
Manuel Pégourié-Gonnard37e08e12014-10-13 17:55:52 +02003152 -c "client hello, adding max_fragment_length extension" \
3153 -s "found max fragment length extension" \
3154 -s "server hello, max_fragment_length extension" \
3155 -c "found max_fragment_length extension" \
3156 -c "fragment larger than.*maximum"
3157
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003158# Tests for renegotiation
3159
Hanno Becker6a243642017-10-12 15:18:45 +01003160# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003161run_test "Renegotiation: none, for reference" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003162 "$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003163 "$P_CLI debug_level=3 exchanges=2" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003164 0 \
3165 -C "client hello, adding renegotiation extension" \
3166 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3167 -S "found renegotiation extension" \
3168 -s "server hello, secure renegotiation extension" \
3169 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003170 -C "=> renegotiate" \
3171 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003172 -S "write hello request"
3173
Hanno Becker6a243642017-10-12 15:18:45 +01003174requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003175run_test "Renegotiation: client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003176 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003177 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003178 0 \
3179 -c "client hello, adding renegotiation extension" \
3180 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3181 -s "found renegotiation extension" \
3182 -s "server hello, secure renegotiation extension" \
3183 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003184 -c "=> renegotiate" \
3185 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003186 -S "write hello request"
3187
Hanno Becker6a243642017-10-12 15:18:45 +01003188requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003189run_test "Renegotiation: server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003190 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003191 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003192 0 \
3193 -c "client hello, adding renegotiation extension" \
3194 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3195 -s "found renegotiation extension" \
3196 -s "server hello, secure renegotiation extension" \
3197 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003198 -c "=> renegotiate" \
3199 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003200 -s "write hello request"
3201
Janos Follathb0f148c2017-10-05 12:29:42 +01003202# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3203# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3204# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003205requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003206run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
3207 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
3208 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
3209 0 \
3210 -c "client hello, adding renegotiation extension" \
3211 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3212 -s "found renegotiation extension" \
3213 -s "server hello, secure renegotiation extension" \
3214 -c "found renegotiation extension" \
3215 -c "=> renegotiate" \
3216 -s "=> renegotiate" \
3217 -S "write hello request" \
3218 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3219
3220# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
3221# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
3222# algorithm stronger than SHA-1 is enabled in config.h
Hanno Becker6a243642017-10-12 15:18:45 +01003223requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Janos Follathb0f148c2017-10-05 12:29:42 +01003224run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
3225 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
3226 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3227 0 \
3228 -c "client hello, adding renegotiation extension" \
3229 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3230 -s "found renegotiation extension" \
3231 -s "server hello, secure renegotiation extension" \
3232 -c "found renegotiation extension" \
3233 -c "=> renegotiate" \
3234 -s "=> renegotiate" \
3235 -s "write hello request" \
3236 -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
3237
Hanno Becker6a243642017-10-12 15:18:45 +01003238requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003239run_test "Renegotiation: double" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003240 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003241 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003242 0 \
3243 -c "client hello, adding renegotiation extension" \
3244 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3245 -s "found renegotiation extension" \
3246 -s "server hello, secure renegotiation extension" \
3247 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003248 -c "=> renegotiate" \
3249 -s "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003250 -s "write hello request"
3251
Hanno Becker6a243642017-10-12 15:18:45 +01003252requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andrzej Kurek8ea68722020-04-03 06:40:47 -04003253requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
3254run_test "Renegotiation with max fragment length: client 2048, server 512" \
3255 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1 max_frag_len=512" \
3256 "$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" \
3257 0 \
3258 -c "Maximum input fragment length is 2048" \
3259 -c "Maximum output fragment length is 2048" \
3260 -s "Maximum input fragment length is 2048" \
3261 -s "Maximum output fragment length is 512" \
3262 -c "client hello, adding max_fragment_length extension" \
3263 -s "found max fragment length extension" \
3264 -s "server hello, max_fragment_length extension" \
3265 -c "found max_fragment_length extension" \
3266 -c "client hello, adding renegotiation extension" \
3267 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3268 -s "found renegotiation extension" \
3269 -s "server hello, secure renegotiation extension" \
3270 -c "found renegotiation extension" \
3271 -c "=> renegotiate" \
3272 -s "=> renegotiate" \
3273 -s "write hello request"
3274
3275requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003276run_test "Renegotiation: client-initiated, server-rejected" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003277 "$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003278 "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003279 1 \
3280 -c "client hello, adding renegotiation extension" \
3281 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3282 -S "found renegotiation extension" \
3283 -s "server hello, secure renegotiation extension" \
3284 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003285 -c "=> renegotiate" \
3286 -S "=> renegotiate" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003287 -S "write hello request" \
Manuel Pégourié-Gonnard65919622014-08-19 12:50:30 +02003288 -c "SSL - Unexpected message at ServerHello in renegotiation" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003289 -c "failed"
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003290
Hanno Becker6a243642017-10-12 15:18:45 +01003291requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003292run_test "Renegotiation: server-initiated, client-rejected, default" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003293 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003294 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003295 0 \
3296 -C "client hello, adding renegotiation extension" \
3297 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3298 -S "found renegotiation extension" \
3299 -s "server hello, secure renegotiation extension" \
3300 -c "found renegotiation extension" \
Manuel Pégourié-Gonnardc73339f2014-02-26 16:35:27 +01003301 -C "=> renegotiate" \
3302 -S "=> renegotiate" \
Manuel Pégourié-Gonnard780d6712014-02-20 17:19:59 +01003303 -s "write hello request" \
Manuel Pégourié-Gonnarda9964db2014-07-03 19:29:16 +02003304 -S "SSL - An unexpected message was received from our peer" \
3305 -S "failed"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01003306
Hanno Becker6a243642017-10-12 15:18:45 +01003307requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003308run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003309 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003310 renego_delay=-1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003311 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003312 0 \
3313 -C "client hello, adding renegotiation extension" \
3314 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3315 -S "found renegotiation extension" \
3316 -s "server hello, secure renegotiation extension" \
3317 -c "found renegotiation extension" \
3318 -C "=> renegotiate" \
3319 -S "=> renegotiate" \
3320 -s "write hello request" \
3321 -S "SSL - An unexpected message was received from our peer" \
3322 -S "failed"
3323
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003324# delay 2 for 1 alert record + 1 application data record
Hanno Becker6a243642017-10-12 15:18:45 +01003325requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003326run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003327 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003328 renego_delay=2 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003329 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003330 0 \
3331 -C "client hello, adding renegotiation extension" \
3332 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3333 -S "found renegotiation extension" \
3334 -s "server hello, secure renegotiation extension" \
3335 -c "found renegotiation extension" \
3336 -C "=> renegotiate" \
3337 -S "=> renegotiate" \
3338 -s "write hello request" \
3339 -S "SSL - An unexpected message was received from our peer" \
3340 -S "failed"
3341
Hanno Becker6a243642017-10-12 15:18:45 +01003342requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003343run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003344 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003345 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003346 "$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003347 0 \
3348 -C "client hello, adding renegotiation extension" \
3349 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3350 -S "found renegotiation extension" \
3351 -s "server hello, secure renegotiation extension" \
3352 -c "found renegotiation extension" \
3353 -C "=> renegotiate" \
3354 -S "=> renegotiate" \
3355 -s "write hello request" \
Manuel Pégourié-Gonnarda8c0a0d2014-08-15 12:07:38 +02003356 -s "SSL - An unexpected message was received from our peer"
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003357
Hanno Becker6a243642017-10-12 15:18:45 +01003358requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003359run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003360 "$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003361 renego_delay=0 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003362 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardfae355e2014-07-04 14:32:27 +02003363 0 \
3364 -c "client hello, adding renegotiation extension" \
3365 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3366 -s "found renegotiation extension" \
3367 -s "server hello, secure renegotiation extension" \
3368 -c "found renegotiation extension" \
3369 -c "=> renegotiate" \
3370 -s "=> renegotiate" \
3371 -s "write hello request" \
3372 -S "SSL - An unexpected message was received from our peer" \
3373 -S "failed"
3374
Hanno Becker6a243642017-10-12 15:18:45 +01003375requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003376run_test "Renegotiation: periodic, just below period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003377 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003378 "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
3379 0 \
3380 -C "client hello, adding renegotiation extension" \
3381 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3382 -S "found renegotiation extension" \
3383 -s "server hello, secure renegotiation extension" \
3384 -c "found renegotiation extension" \
3385 -S "record counter limit reached: renegotiate" \
3386 -C "=> renegotiate" \
3387 -S "=> renegotiate" \
3388 -S "write hello request" \
3389 -S "SSL - An unexpected message was received from our peer" \
3390 -S "failed"
3391
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003392# one extra exchange to be able to complete renego
Hanno Becker6a243642017-10-12 15:18:45 +01003393requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003394run_test "Renegotiation: periodic, just above period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003395 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003396 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003397 0 \
3398 -c "client hello, adding renegotiation extension" \
3399 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3400 -s "found renegotiation extension" \
3401 -s "server hello, secure renegotiation extension" \
3402 -c "found renegotiation extension" \
3403 -s "record counter limit reached: renegotiate" \
3404 -c "=> renegotiate" \
3405 -s "=> renegotiate" \
3406 -s "write hello request" \
3407 -S "SSL - An unexpected message was received from our peer" \
3408 -S "failed"
3409
Hanno Becker6a243642017-10-12 15:18:45 +01003410requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003411run_test "Renegotiation: periodic, two times period" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003412 "$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard9835bc02015-01-14 14:41:58 +01003413 "$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003414 0 \
3415 -c "client hello, adding renegotiation extension" \
3416 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3417 -s "found renegotiation extension" \
3418 -s "server hello, secure renegotiation extension" \
3419 -c "found renegotiation extension" \
3420 -s "record counter limit reached: renegotiate" \
3421 -c "=> renegotiate" \
3422 -s "=> renegotiate" \
3423 -s "write hello request" \
3424 -S "SSL - An unexpected message was received from our peer" \
3425 -S "failed"
3426
Hanno Becker6a243642017-10-12 15:18:45 +01003427requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003428run_test "Renegotiation: periodic, above period, disabled" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003429 "$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
Manuel Pégourié-Gonnard590f4162014-11-05 14:23:03 +01003430 "$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
3431 0 \
3432 -C "client hello, adding renegotiation extension" \
3433 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3434 -S "found renegotiation extension" \
3435 -s "server hello, secure renegotiation extension" \
3436 -c "found renegotiation extension" \
3437 -S "record counter limit reached: renegotiate" \
3438 -C "=> renegotiate" \
3439 -S "=> renegotiate" \
3440 -S "write hello request" \
3441 -S "SSL - An unexpected message was received from our peer" \
3442 -S "failed"
3443
Hanno Becker6a243642017-10-12 15:18:45 +01003444requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003445run_test "Renegotiation: nbio, client-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003446 "$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003447 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003448 0 \
3449 -c "client hello, adding renegotiation extension" \
3450 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3451 -s "found renegotiation extension" \
3452 -s "server hello, secure renegotiation extension" \
3453 -c "found renegotiation extension" \
3454 -c "=> renegotiate" \
3455 -s "=> renegotiate" \
3456 -S "write hello request"
3457
Hanno Becker6a243642017-10-12 15:18:45 +01003458requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003459run_test "Renegotiation: nbio, server-initiated" \
Manuel Pégourié-Gonnardfa44f202015-03-27 17:52:25 +01003460 "$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 +02003461 "$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
Manuel Pégourié-Gonnardf07f4212014-08-15 19:04:47 +02003462 0 \
3463 -c "client hello, adding renegotiation extension" \
3464 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3465 -s "found renegotiation extension" \
3466 -s "server hello, secure renegotiation extension" \
3467 -c "found renegotiation extension" \
3468 -c "=> renegotiate" \
3469 -s "=> renegotiate" \
3470 -s "write hello request"
3471
Hanno Becker6a243642017-10-12 15:18:45 +01003472requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003473run_test "Renegotiation: openssl server, client-initiated" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02003474 "$O_SRV -www" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003475 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003476 0 \
3477 -c "client hello, adding renegotiation extension" \
3478 -c "found renegotiation extension" \
3479 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003480 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003481 -C "error" \
3482 -c "HTTP/1.0 200 [Oo][Kk]"
3483
Paul Bakker539d9722015-02-08 16:18:35 +01003484requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003485requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003486run_test "Renegotiation: gnutls server strict, client-initiated" \
3487 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003488 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003489 0 \
3490 -c "client hello, adding renegotiation extension" \
3491 -c "found renegotiation extension" \
3492 -c "=> renegotiate" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003493 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard51362962014-08-30 21:22:47 +02003494 -C "error" \
3495 -c "HTTP/1.0 200 [Oo][Kk]"
3496
Paul Bakker539d9722015-02-08 16:18:35 +01003497requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003498requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003499run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
3500 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3501 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
3502 1 \
3503 -c "client hello, adding renegotiation extension" \
3504 -C "found renegotiation extension" \
3505 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003506 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003507 -c "error" \
3508 -C "HTTP/1.0 200 [Oo][Kk]"
3509
Paul Bakker539d9722015-02-08 16:18:35 +01003510requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003511requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003512run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
3513 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3514 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3515 allow_legacy=0" \
3516 1 \
3517 -c "client hello, adding renegotiation extension" \
3518 -C "found renegotiation extension" \
3519 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003520 -c "mbedtls_ssl_handshake() returned" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003521 -c "error" \
3522 -C "HTTP/1.0 200 [Oo][Kk]"
3523
Paul Bakker539d9722015-02-08 16:18:35 +01003524requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003525requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003526run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
3527 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3528 "$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
3529 allow_legacy=1" \
3530 0 \
3531 -c "client hello, adding renegotiation extension" \
3532 -C "found renegotiation extension" \
3533 -c "=> renegotiate" \
3534 -C "ssl_hanshake() returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003535 -C "error" \
3536 -c "HTTP/1.0 200 [Oo][Kk]"
3537
Hanno Becker6a243642017-10-12 15:18:45 +01003538requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard30d16eb2014-08-19 17:43:50 +02003539run_test "Renegotiation: DTLS, client-initiated" \
3540 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
3541 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
3542 0 \
3543 -c "client hello, adding renegotiation extension" \
3544 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3545 -s "found renegotiation extension" \
3546 -s "server hello, secure renegotiation extension" \
3547 -c "found renegotiation extension" \
3548 -c "=> renegotiate" \
3549 -s "=> renegotiate" \
3550 -S "write hello request"
3551
Hanno Becker6a243642017-10-12 15:18:45 +01003552requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003553run_test "Renegotiation: DTLS, server-initiated" \
3554 "$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
Manuel Pégourié-Gonnarddf9a0a82014-10-02 14:17:18 +02003555 "$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
3556 read_timeout=1000 max_resend=2" \
Manuel Pégourié-Gonnardc392b242014-08-19 17:53:11 +02003557 0 \
3558 -c "client hello, adding renegotiation extension" \
3559 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3560 -s "found renegotiation extension" \
3561 -s "server hello, secure renegotiation extension" \
3562 -c "found renegotiation extension" \
3563 -c "=> renegotiate" \
3564 -s "=> renegotiate" \
3565 -s "write hello request"
3566
Hanno Becker6a243642017-10-12 15:18:45 +01003567requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Andres AG692ad842017-01-19 16:30:57 +00003568run_test "Renegotiation: DTLS, renego_period overflow" \
3569 "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
3570 "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
3571 0 \
3572 -c "client hello, adding renegotiation extension" \
3573 -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
3574 -s "found renegotiation extension" \
3575 -s "server hello, secure renegotiation extension" \
3576 -s "record counter limit reached: renegotiate" \
3577 -c "=> renegotiate" \
3578 -s "=> renegotiate" \
Hanno Becker6a243642017-10-12 15:18:45 +01003579 -s "write hello request"
Andres AG692ad842017-01-19 16:30:57 +00003580
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00003581requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01003582requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003583run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
3584 "$G_SRV -u --mtu 4096" \
3585 "$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
3586 0 \
3587 -c "client hello, adding renegotiation extension" \
3588 -c "found renegotiation extension" \
3589 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003590 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardf1499f62014-08-31 17:13:13 +02003591 -C "error" \
3592 -s "Extra-header:"
3593
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003594# Test for the "secure renegotation" extension only (no actual renegotiation)
3595
Paul Bakker539d9722015-02-08 16:18:35 +01003596requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003597run_test "Renego ext: gnutls server strict, client default" \
3598 "$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
3599 "$P_CLI debug_level=3" \
3600 0 \
3601 -c "found renegotiation extension" \
3602 -C "error" \
3603 -c "HTTP/1.0 200 [Oo][Kk]"
3604
Paul Bakker539d9722015-02-08 16:18:35 +01003605requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003606run_test "Renego ext: gnutls server unsafe, client default" \
3607 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3608 "$P_CLI debug_level=3" \
3609 0 \
3610 -C "found renegotiation extension" \
3611 -C "error" \
3612 -c "HTTP/1.0 200 [Oo][Kk]"
3613
Paul Bakker539d9722015-02-08 16:18:35 +01003614requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003615run_test "Renego ext: gnutls server unsafe, client break legacy" \
3616 "$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
3617 "$P_CLI debug_level=3 allow_legacy=-1" \
3618 1 \
3619 -C "found renegotiation extension" \
3620 -c "error" \
3621 -C "HTTP/1.0 200 [Oo][Kk]"
3622
Paul Bakker539d9722015-02-08 16:18:35 +01003623requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003624run_test "Renego ext: gnutls client strict, server default" \
3625 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003626 "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003627 0 \
3628 -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3629 -s "server hello, secure renegotiation extension"
3630
Paul Bakker539d9722015-02-08 16:18:35 +01003631requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003632run_test "Renego ext: gnutls client unsafe, server default" \
3633 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003634 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003635 0 \
3636 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3637 -S "server hello, secure renegotiation extension"
3638
Paul Bakker539d9722015-02-08 16:18:35 +01003639requires_gnutls
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003640run_test "Renego ext: gnutls client unsafe, server break legacy" \
3641 "$P_SRV debug_level=3 allow_legacy=-1" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003642 "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \
Manuel Pégourié-Gonnard85d915b2014-11-03 20:10:36 +01003643 1 \
3644 -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \
3645 -S "server hello, secure renegotiation extension"
3646
Janos Follath0b242342016-02-17 10:11:21 +00003647# Tests for silently dropping trailing extra bytes in .der certificates
3648
3649requires_gnutls
3650run_test "DER format: no trailing bytes" \
3651 "$P_SRV crt_file=data_files/server5-der0.crt \
3652 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003653 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003654 0 \
3655 -c "Handshake was completed" \
3656
3657requires_gnutls
3658run_test "DER format: with a trailing zero byte" \
3659 "$P_SRV crt_file=data_files/server5-der1a.crt \
3660 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003661 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003662 0 \
3663 -c "Handshake was completed" \
3664
3665requires_gnutls
3666run_test "DER format: with a trailing random byte" \
3667 "$P_SRV crt_file=data_files/server5-der1b.crt \
3668 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003669 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003670 0 \
3671 -c "Handshake was completed" \
3672
3673requires_gnutls
3674run_test "DER format: with 2 trailing random bytes" \
3675 "$P_SRV crt_file=data_files/server5-der2.crt \
3676 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003677 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003678 0 \
3679 -c "Handshake was completed" \
3680
3681requires_gnutls
3682run_test "DER format: with 4 trailing random bytes" \
3683 "$P_SRV crt_file=data_files/server5-der4.crt \
3684 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003685 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003686 0 \
3687 -c "Handshake was completed" \
3688
3689requires_gnutls
3690run_test "DER format: with 8 trailing random bytes" \
3691 "$P_SRV crt_file=data_files/server5-der8.crt \
3692 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003693 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003694 0 \
3695 -c "Handshake was completed" \
3696
3697requires_gnutls
3698run_test "DER format: with 9 trailing random bytes" \
3699 "$P_SRV crt_file=data_files/server5-der9.crt \
3700 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02003701 "$G_CLI localhost" \
Janos Follath0b242342016-02-17 10:11:21 +00003702 0 \
3703 -c "Handshake was completed" \
3704
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03003705# Tests for auth_mode, there are duplicated tests using ca callback for authentication
3706# When updating these tests, modify the matching authentication tests accordingly
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003707
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003708run_test "Authentication: server badcert, client required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003709 "$P_SRV crt_file=data_files/server5-badsign.crt \
3710 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003711 "$P_CLI debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003712 1 \
3713 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003714 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003715 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003716 -c "X509 - Certificate verification failed"
3717
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003718run_test "Authentication: server badcert, client optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003719 "$P_SRV crt_file=data_files/server5-badsign.crt \
3720 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003721 "$P_CLI debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003722 0 \
3723 -c "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003724 -c "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003725 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003726 -C "X509 - Certificate verification failed"
3727
Hanno Beckere6706e62017-05-15 16:05:15 +01003728run_test "Authentication: server goodcert, client optional, no trusted CA" \
3729 "$P_SRV" \
3730 "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
3731 0 \
3732 -c "x509_verify_cert() returned" \
3733 -c "! The certificate is not correctly signed by the trusted CA" \
3734 -c "! Certificate verification flags"\
3735 -C "! mbedtls_ssl_handshake returned" \
3736 -C "X509 - Certificate verification failed" \
3737 -C "SSL - No CA Chain is set, but required to operate"
3738
3739run_test "Authentication: server goodcert, client required, no trusted CA" \
3740 "$P_SRV" \
3741 "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
3742 1 \
3743 -c "x509_verify_cert() returned" \
3744 -c "! The certificate is not correctly signed by the trusted CA" \
3745 -c "! Certificate verification flags"\
3746 -c "! mbedtls_ssl_handshake returned" \
3747 -c "SSL - No CA Chain is set, but required to operate"
3748
3749# The purpose of the next two tests is to test the client's behaviour when receiving a server
3750# certificate with an unsupported elliptic curve. This should usually not happen because
3751# the client informs the server about the supported curves - it does, though, in the
3752# corner case of a static ECDH suite, because the server doesn't check the curve on that
3753# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
3754# different means to have the server ignoring the client's supported curve list.
3755
3756requires_config_enabled MBEDTLS_ECP_C
3757run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
3758 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3759 crt_file=data_files/server5.ku-ka.crt" \
3760 "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
3761 1 \
3762 -c "bad certificate (EC key curve)"\
3763 -c "! Certificate verification flags"\
3764 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
3765
3766requires_config_enabled MBEDTLS_ECP_C
3767run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
3768 "$P_SRV debug_level=1 key_file=data_files/server5.key \
3769 crt_file=data_files/server5.ku-ka.crt" \
3770 "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
3771 1 \
3772 -c "bad certificate (EC key curve)"\
3773 -c "! Certificate verification flags"\
3774 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
3775
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003776run_test "Authentication: server badcert, client none" \
Manuel Pégourié-Gonnardc1da6642014-02-25 14:18:30 +01003777 "$P_SRV crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003778 key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003779 "$P_CLI debug_level=1 auth_mode=none" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003780 0 \
3781 -C "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003782 -C "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003783 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003784 -C "X509 - Certificate verification failed"
3785
Simon Butcher99000142016-10-13 17:21:01 +01003786run_test "Authentication: client SHA256, server required" \
3787 "$P_SRV auth_mode=required" \
3788 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3789 key_file=data_files/server6.key \
3790 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
3791 0 \
3792 -c "Supported Signature Algorithm found: 4," \
3793 -c "Supported Signature Algorithm found: 5,"
3794
3795run_test "Authentication: client SHA384, server required" \
3796 "$P_SRV auth_mode=required" \
3797 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
3798 key_file=data_files/server6.key \
3799 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
3800 0 \
3801 -c "Supported Signature Algorithm found: 4," \
3802 -c "Supported Signature Algorithm found: 5,"
3803
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003804run_test "Authentication: client has no cert, server required (TLS)" \
3805 "$P_SRV debug_level=3 auth_mode=required" \
3806 "$P_CLI debug_level=3 crt_file=none \
3807 key_file=data_files/server5.key" \
3808 1 \
3809 -S "skip write certificate request" \
3810 -C "skip parse certificate request" \
3811 -c "got a certificate request" \
3812 -c "= write certificate$" \
3813 -C "skip write certificate$" \
3814 -S "x509_verify_cert() returned" \
3815 -s "client has no certificate" \
3816 -s "! mbedtls_ssl_handshake returned" \
3817 -c "! mbedtls_ssl_handshake returned" \
3818 -s "No client certification received from the client, but required by the authentication mode"
3819
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003820run_test "Authentication: client badcert, server required" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003821 "$P_SRV debug_level=3 auth_mode=required" \
3822 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003823 key_file=data_files/server5.key" \
3824 1 \
3825 -S "skip write certificate request" \
3826 -C "skip parse certificate request" \
3827 -c "got a certificate request" \
3828 -C "skip write certificate" \
3829 -C "skip write certificate verify" \
3830 -S "skip parse certificate verify" \
3831 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02003832 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003833 -s "! mbedtls_ssl_handshake returned" \
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003834 -s "send alert level=2 message=48" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003835 -c "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003836 -s "X509 - Certificate verification failed"
Gilles Peskine1cc8e342017-05-03 16:28:34 +02003837# We don't check that the client receives the alert because it might
3838# detect that its write end of the connection is closed and abort
3839# before reading the alert message.
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003840
Janos Follath89baba22017-04-10 14:34:35 +01003841run_test "Authentication: client cert not trusted, server required" \
3842 "$P_SRV debug_level=3 auth_mode=required" \
3843 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
3844 key_file=data_files/server5.key" \
3845 1 \
3846 -S "skip write certificate request" \
3847 -C "skip parse certificate request" \
3848 -c "got a certificate request" \
3849 -C "skip write certificate" \
3850 -C "skip write certificate verify" \
3851 -S "skip parse certificate verify" \
3852 -s "x509_verify_cert() returned" \
3853 -s "! The certificate is not correctly signed by the trusted CA" \
3854 -s "! mbedtls_ssl_handshake returned" \
3855 -c "! mbedtls_ssl_handshake returned" \
3856 -s "X509 - Certificate verification failed"
3857
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003858run_test "Authentication: client badcert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003859 "$P_SRV debug_level=3 auth_mode=optional" \
3860 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003861 key_file=data_files/server5.key" \
3862 0 \
3863 -S "skip write certificate request" \
3864 -C "skip parse certificate request" \
3865 -c "got a certificate request" \
3866 -C "skip write certificate" \
3867 -C "skip write certificate verify" \
3868 -S "skip parse certificate verify" \
3869 -s "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003870 -s "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003871 -S "! mbedtls_ssl_handshake returned" \
3872 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003873 -S "X509 - Certificate verification failed"
3874
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003875run_test "Authentication: client badcert, server none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003876 "$P_SRV debug_level=3 auth_mode=none" \
3877 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003878 key_file=data_files/server5.key" \
3879 0 \
3880 -s "skip write certificate request" \
3881 -C "skip parse certificate request" \
3882 -c "got no certificate request" \
3883 -c "skip write certificate" \
3884 -c "skip write certificate verify" \
3885 -s "skip parse certificate verify" \
3886 -S "x509_verify_cert() returned" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003887 -S "! The certificate is not correctly signed by the trusted CA" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003888 -S "! mbedtls_ssl_handshake returned" \
3889 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01003890 -S "X509 - Certificate verification failed"
3891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003892run_test "Authentication: client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003893 "$P_SRV debug_level=3 auth_mode=optional" \
3894 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003895 0 \
3896 -S "skip write certificate request" \
3897 -C "skip parse certificate request" \
3898 -c "got a certificate request" \
3899 -C "skip write certificate$" \
3900 -C "got no certificate to send" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003901 -c "skip write certificate verify" \
3902 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003903 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003904 -S "! mbedtls_ssl_handshake returned" \
3905 -C "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003906 -S "X509 - Certificate verification failed"
3907
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003908run_test "Authentication: openssl client no cert, server optional" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003909 "$P_SRV debug_level=3 auth_mode=optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003910 "$O_CLI" \
3911 0 \
3912 -S "skip write certificate request" \
3913 -s "skip parse certificate verify" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01003914 -s "! Certificate was missing" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003915 -S "! mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003916 -S "X509 - Certificate verification failed"
3917
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02003918run_test "Authentication: client no cert, openssl server optional" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003919 "$O_SRV -verify 10" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02003920 "$P_CLI debug_level=3 crt_file=none key_file=none" \
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003921 0 \
3922 -C "skip parse certificate request" \
3923 -c "got a certificate request" \
3924 -C "skip write certificate$" \
3925 -c "skip write certificate verify" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02003926 -C "! mbedtls_ssl_handshake returned"
Manuel Pégourié-Gonnardde515cc2014-02-27 14:58:26 +01003927
Gilles Peskinefd8332e2017-05-03 16:25:07 +02003928run_test "Authentication: client no cert, openssl server required" \
3929 "$O_SRV -Verify 10" \
3930 "$P_CLI debug_level=3 crt_file=none key_file=none" \
3931 1 \
3932 -C "skip parse certificate request" \
3933 -c "got a certificate request" \
3934 -C "skip write certificate$" \
3935 -c "skip write certificate verify" \
3936 -c "! mbedtls_ssl_handshake returned"
3937
Manuel Pégourié-Gonnard9107b5f2017-07-06 12:16:25 +02003938# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
3939# default value (8)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003940
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003941MAX_IM_CA='8'
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003942MAX_IM_CA_CONFIG=$( ../scripts/config.py get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003943
Simon Butcherbcfa6f42017-07-28 15:59:35 +01003944if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
Gilles Peskine231befa2020-08-26 20:05:11 +02003945 cat <<EOF
3946${CONFIG_H} contains a value for the configuration of
3947MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script's
3948test value of ${MAX_IM_CA}.
Simon Butcher06b78632017-07-28 01:00:17 +01003949
Gilles Peskine231befa2020-08-26 20:05:11 +02003950The tests assume this value and if it changes, the tests in this
3951script should also be adjusted.
3952EOF
Simon Butcher06b78632017-07-28 01:00:17 +01003953 exit 1
Hanno Beckera6bca9f2017-07-26 13:35:11 +01003954fi
3955
Angus Grattonc4dd0732018-04-11 16:28:39 +10003956requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003957run_test "Authentication: server max_int chain, client default" \
3958 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
3959 key_file=data_files/dir-maxpath/09.key" \
3960 "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
3961 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003962 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003963
Angus Grattonc4dd0732018-04-11 16:28:39 +10003964requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003965run_test "Authentication: server max_int+1 chain, client default" \
3966 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3967 key_file=data_files/dir-maxpath/10.key" \
3968 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
3969 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003970 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003971
Angus Grattonc4dd0732018-04-11 16:28:39 +10003972requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003973run_test "Authentication: server max_int+1 chain, client optional" \
3974 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3975 key_file=data_files/dir-maxpath/10.key" \
3976 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3977 auth_mode=optional" \
3978 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003979 -c "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003980
Angus Grattonc4dd0732018-04-11 16:28:39 +10003981requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003982run_test "Authentication: server max_int+1 chain, client none" \
3983 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
3984 key_file=data_files/dir-maxpath/10.key" \
3985 "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
3986 auth_mode=none" \
3987 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003988 -C "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003989
Angus Grattonc4dd0732018-04-11 16:28:39 +10003990requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003991run_test "Authentication: client max_int+1 chain, server default" \
3992 "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
3993 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
3994 key_file=data_files/dir-maxpath/10.key" \
3995 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01003996 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003997
Angus Grattonc4dd0732018-04-11 16:28:39 +10003998requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02003999run_test "Authentication: client max_int+1 chain, server optional" \
4000 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4001 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4002 key_file=data_files/dir-maxpath/10.key" \
4003 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004004 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004005
Angus Grattonc4dd0732018-04-11 16:28:39 +10004006requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004007run_test "Authentication: client max_int+1 chain, server required" \
4008 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4009 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4010 key_file=data_files/dir-maxpath/10.key" \
4011 1 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004012 -s "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004013
Angus Grattonc4dd0732018-04-11 16:28:39 +10004014requires_full_size_output_buffer
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004015run_test "Authentication: client max_int chain, server required" \
4016 "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4017 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4018 key_file=data_files/dir-maxpath/09.key" \
4019 0 \
Antonin Décimo36e89b52019-01-23 15:24:37 +01004020 -S "X509 - A fatal error occurred"
Manuel Pégourié-Gonnard81bb6b62017-06-26 10:45:33 +02004021
Janos Follath89baba22017-04-10 14:34:35 +01004022# Tests for CA list in CertificateRequest messages
4023
4024run_test "Authentication: send CA list in CertificateRequest (default)" \
4025 "$P_SRV debug_level=3 auth_mode=required" \
4026 "$P_CLI crt_file=data_files/server6.crt \
4027 key_file=data_files/server6.key" \
4028 0 \
4029 -s "requested DN"
4030
4031run_test "Authentication: do not send CA list in CertificateRequest" \
4032 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4033 "$P_CLI crt_file=data_files/server6.crt \
4034 key_file=data_files/server6.key" \
4035 0 \
4036 -S "requested DN"
4037
4038run_test "Authentication: send CA list in CertificateRequest, client self signed" \
4039 "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
4040 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4041 key_file=data_files/server5.key" \
4042 1 \
4043 -S "requested DN" \
4044 -s "x509_verify_cert() returned" \
4045 -s "! The certificate is not correctly signed by the trusted CA" \
4046 -s "! mbedtls_ssl_handshake returned" \
4047 -c "! mbedtls_ssl_handshake returned" \
4048 -s "X509 - Certificate verification failed"
4049
Jarno Lamsaf7a7f9e2019-04-01 15:11:54 +03004050# Tests for auth_mode, using CA callback, these are duplicated from the authentication tests
4051# When updating these tests, modify the matching authentication tests accordingly
Hanno Becker746aaf32019-03-28 15:25:23 +00004052
4053requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4054run_test "Authentication, CA callback: server badcert, client required" \
4055 "$P_SRV crt_file=data_files/server5-badsign.crt \
4056 key_file=data_files/server5.key" \
4057 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required" \
4058 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004059 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004060 -c "x509_verify_cert() returned" \
4061 -c "! The certificate is not correctly signed by the trusted CA" \
4062 -c "! mbedtls_ssl_handshake returned" \
4063 -c "X509 - Certificate verification failed"
4064
4065requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4066run_test "Authentication, CA callback: server badcert, client optional" \
4067 "$P_SRV crt_file=data_files/server5-badsign.crt \
4068 key_file=data_files/server5.key" \
4069 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional" \
4070 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004071 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004072 -c "x509_verify_cert() returned" \
4073 -c "! The certificate is not correctly signed by the trusted CA" \
4074 -C "! mbedtls_ssl_handshake returned" \
4075 -C "X509 - Certificate verification failed"
4076
4077# The purpose of the next two tests is to test the client's behaviour when receiving a server
4078# certificate with an unsupported elliptic curve. This should usually not happen because
4079# the client informs the server about the supported curves - it does, though, in the
4080# corner case of a static ECDH suite, because the server doesn't check the curve on that
4081# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
4082# different means to have the server ignoring the client's supported curve list.
4083
4084requires_config_enabled MBEDTLS_ECP_C
4085requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4086run_test "Authentication, CA callback: server ECDH p256v1, client required, p256v1 unsupported" \
4087 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4088 crt_file=data_files/server5.ku-ka.crt" \
4089 "$P_CLI ca_callback=1 debug_level=3 auth_mode=required curves=secp521r1" \
4090 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004091 -c "use CA callback for X.509 CRT verification" \
4092 -c "bad certificate (EC key curve)" \
4093 -c "! Certificate verification flags" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004094 -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
4095
4096requires_config_enabled MBEDTLS_ECP_C
4097requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4098run_test "Authentication, CA callback: server ECDH p256v1, client optional, p256v1 unsupported" \
4099 "$P_SRV debug_level=1 key_file=data_files/server5.key \
4100 crt_file=data_files/server5.ku-ka.crt" \
4101 "$P_CLI ca_callback=1 debug_level=3 auth_mode=optional curves=secp521r1" \
4102 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004103 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004104 -c "bad certificate (EC key curve)"\
4105 -c "! Certificate verification flags"\
4106 -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
4107
4108requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4109run_test "Authentication, CA callback: client SHA256, server required" \
4110 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4111 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4112 key_file=data_files/server6.key \
4113 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
4114 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004115 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004116 -c "Supported Signature Algorithm found: 4," \
4117 -c "Supported Signature Algorithm found: 5,"
4118
4119requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4120run_test "Authentication, CA callback: client SHA384, server required" \
4121 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4122 "$P_CLI debug_level=3 crt_file=data_files/server6.crt \
4123 key_file=data_files/server6.key \
4124 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256" \
4125 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004126 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004127 -c "Supported Signature Algorithm found: 4," \
4128 -c "Supported Signature Algorithm found: 5,"
4129
4130requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4131run_test "Authentication, CA callback: client badcert, server required" \
4132 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4133 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4134 key_file=data_files/server5.key" \
4135 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004136 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004137 -S "skip write certificate request" \
4138 -C "skip parse certificate request" \
4139 -c "got a certificate request" \
4140 -C "skip write certificate" \
4141 -C "skip write certificate verify" \
4142 -S "skip parse certificate verify" \
4143 -s "x509_verify_cert() returned" \
4144 -s "! The certificate is not correctly signed by the trusted CA" \
4145 -s "! mbedtls_ssl_handshake returned" \
4146 -s "send alert level=2 message=48" \
4147 -c "! mbedtls_ssl_handshake returned" \
4148 -s "X509 - Certificate verification failed"
4149# We don't check that the client receives the alert because it might
4150# detect that its write end of the connection is closed and abort
4151# before reading the alert message.
4152
4153requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4154run_test "Authentication, CA callback: client cert not trusted, server required" \
4155 "$P_SRV ca_callback=1 debug_level=3 auth_mode=required" \
4156 "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
4157 key_file=data_files/server5.key" \
4158 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004159 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004160 -S "skip write certificate request" \
4161 -C "skip parse certificate request" \
4162 -c "got a certificate request" \
4163 -C "skip write certificate" \
4164 -C "skip write certificate verify" \
4165 -S "skip parse certificate verify" \
4166 -s "x509_verify_cert() returned" \
4167 -s "! The certificate is not correctly signed by the trusted CA" \
4168 -s "! mbedtls_ssl_handshake returned" \
4169 -c "! mbedtls_ssl_handshake returned" \
4170 -s "X509 - Certificate verification failed"
4171
4172requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4173run_test "Authentication, CA callback: client badcert, server optional" \
4174 "$P_SRV ca_callback=1 debug_level=3 auth_mode=optional" \
4175 "$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
4176 key_file=data_files/server5.key" \
4177 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004178 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004179 -S "skip write certificate request" \
4180 -C "skip parse certificate request" \
4181 -c "got a certificate request" \
4182 -C "skip write certificate" \
4183 -C "skip write certificate verify" \
4184 -S "skip parse certificate verify" \
4185 -s "x509_verify_cert() returned" \
4186 -s "! The certificate is not correctly signed by the trusted CA" \
4187 -S "! mbedtls_ssl_handshake returned" \
4188 -C "! mbedtls_ssl_handshake returned" \
4189 -S "X509 - Certificate verification failed"
4190
4191requires_full_size_output_buffer
4192requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4193run_test "Authentication, CA callback: server max_int chain, client default" \
4194 "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
4195 key_file=data_files/dir-maxpath/09.key" \
4196 "$P_CLI ca_callback=1 debug_level=3 server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
4197 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004198 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004199 -C "X509 - A fatal error occurred"
4200
4201requires_full_size_output_buffer
4202requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4203run_test "Authentication, CA callback: server max_int+1 chain, client default" \
4204 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4205 key_file=data_files/dir-maxpath/10.key" \
4206 "$P_CLI debug_level=3 ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
4207 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004208 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004209 -c "X509 - A fatal error occurred"
4210
4211requires_full_size_output_buffer
4212requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4213run_test "Authentication, CA callback: server max_int+1 chain, client optional" \
4214 "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
4215 key_file=data_files/dir-maxpath/10.key" \
4216 "$P_CLI ca_callback=1 server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
4217 debug_level=3 auth_mode=optional" \
4218 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004219 -c "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004220 -c "X509 - A fatal error occurred"
4221
4222requires_full_size_output_buffer
4223requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4224run_test "Authentication, CA callback: client max_int+1 chain, server optional" \
4225 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
4226 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4227 key_file=data_files/dir-maxpath/10.key" \
4228 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004229 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004230 -s "X509 - A fatal error occurred"
4231
4232requires_full_size_output_buffer
4233requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4234run_test "Authentication, CA callback: client max_int+1 chain, server required" \
4235 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4236 "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
4237 key_file=data_files/dir-maxpath/10.key" \
4238 1 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004239 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004240 -s "X509 - A fatal error occurred"
4241
4242requires_full_size_output_buffer
4243requires_config_enabled MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
4244run_test "Authentication, CA callback: client max_int chain, server required" \
4245 "$P_SRV ca_callback=1 debug_level=3 ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
4246 "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
4247 key_file=data_files/dir-maxpath/09.key" \
4248 0 \
Janos Follathd7ecbd62019-04-05 14:52:17 +01004249 -s "use CA callback for X.509 CRT verification" \
Hanno Becker746aaf32019-03-28 15:25:23 +00004250 -S "X509 - A fatal error occurred"
4251
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004252# Tests for certificate selection based on SHA verson
4253
Hanno Beckerc5722d12020-10-09 11:10:42 +01004254requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnarddf331a52015-01-08 16:43:07 +01004255run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
4256 "$P_SRV crt_file=data_files/server5.crt \
4257 key_file=data_files/server5.key \
4258 crt_file2=data_files/server5-sha1.crt \
4259 key_file2=data_files/server5.key" \
4260 "$P_CLI force_version=tls1_2" \
4261 0 \
4262 -c "signed using.*ECDSA with SHA256" \
4263 -C "signed using.*ECDSA with SHA1"
4264
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004265# tests for SNI
4266
Hanno Beckerc5722d12020-10-09 11:10:42 +01004267requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004268run_test "SNI: no SNI callback" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004269 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004270 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004271 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004272 0 \
4273 -S "parse ServerName extension" \
4274 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4275 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004276
Hanno Beckerc5722d12020-10-09 11:10:42 +01004277requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004278run_test "SNI: matching cert 1" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004279 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004280 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004281 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 +02004282 "$P_CLI server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004283 0 \
4284 -s "parse ServerName extension" \
4285 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4286 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004287
Hanno Beckerc5722d12020-10-09 11:10:42 +01004288requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004289run_test "SNI: matching cert 2" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004290 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004291 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004292 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 +02004293 "$P_CLI server_name=polarssl.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004294 0 \
4295 -s "parse ServerName extension" \
4296 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4297 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004298
Hanno Beckerc5722d12020-10-09 11:10:42 +01004299requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004300run_test "SNI: no matching cert" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02004301 "$P_SRV debug_level=3 \
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004302 crt_file=data_files/server5.crt key_file=data_files/server5.key \
Manuel Pégourié-Gonnard4d6f1782015-06-19 14:40:39 +02004303 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 +02004304 "$P_CLI server_name=nonesuch.example" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004305 1 \
4306 -s "parse ServerName extension" \
4307 -s "ssl_sni_wrapper() returned" \
4308 -s "mbedtls_ssl_handshake returned" \
4309 -c "mbedtls_ssl_handshake returned" \
4310 -c "SSL - A fatal alert message was received from our peer"
Manuel Pégourié-Gonnard96ea2f22014-02-25 12:26:29 +01004311
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004312run_test "SNI: client auth no override: optional" \
4313 "$P_SRV debug_level=3 auth_mode=optional \
4314 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4315 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4316 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004317 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004318 -S "skip write certificate request" \
4319 -C "skip parse certificate request" \
4320 -c "got a certificate request" \
4321 -C "skip write certificate" \
4322 -C "skip write certificate verify" \
4323 -S "skip parse certificate verify"
4324
4325run_test "SNI: client auth override: none -> optional" \
4326 "$P_SRV debug_level=3 auth_mode=none \
4327 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4328 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4329 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004330 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004331 -S "skip write certificate request" \
4332 -C "skip parse certificate request" \
4333 -c "got a certificate request" \
4334 -C "skip write certificate" \
4335 -C "skip write certificate verify" \
4336 -S "skip parse certificate verify"
4337
4338run_test "SNI: client auth override: optional -> none" \
4339 "$P_SRV debug_level=3 auth_mode=optional \
4340 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4341 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4342 "$P_CLI debug_level=3 server_name=localhost" \
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004343 0 \
Manuel Pégourié-Gonnardc948a792015-06-22 16:04:20 +02004344 -s "skip write certificate request" \
4345 -C "skip parse certificate request" \
4346 -c "got no certificate request" \
4347 -c "skip write certificate" \
4348 -c "skip write certificate verify" \
4349 -s "skip parse certificate verify"
4350
Manuel Pégourié-Gonnard6ea831d2015-06-22 16:50:52 +02004351run_test "SNI: CA no override" \
4352 "$P_SRV debug_level=3 auth_mode=optional \
4353 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4354 ca_file=data_files/test-ca.crt \
4355 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4356 "$P_CLI debug_level=3 server_name=localhost \
4357 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4358 1 \
4359 -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 -s "x509_verify_cert() returned" \
4366 -s "! The certificate is not correctly signed by the trusted CA" \
4367 -S "The certificate has been revoked (is on a CRL)"
4368
4369run_test "SNI: CA override" \
4370 "$P_SRV debug_level=3 auth_mode=optional \
4371 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4372 ca_file=data_files/test-ca.crt \
4373 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4374 "$P_CLI debug_level=3 server_name=localhost \
4375 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4376 0 \
4377 -S "skip write certificate request" \
4378 -C "skip parse certificate request" \
4379 -c "got a certificate request" \
4380 -C "skip write certificate" \
4381 -C "skip write certificate verify" \
4382 -S "skip parse certificate verify" \
4383 -S "x509_verify_cert() returned" \
4384 -S "! The certificate is not correctly signed by the trusted CA" \
4385 -S "The certificate has been revoked (is on a CRL)"
4386
4387run_test "SNI: CA override with CRL" \
4388 "$P_SRV debug_level=3 auth_mode=optional \
4389 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4390 ca_file=data_files/test-ca.crt \
4391 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4392 "$P_CLI debug_level=3 server_name=localhost \
4393 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4394 1 \
4395 -S "skip write certificate request" \
4396 -C "skip parse certificate request" \
4397 -c "got a certificate request" \
4398 -C "skip write certificate" \
4399 -C "skip write certificate verify" \
4400 -S "skip parse certificate verify" \
4401 -s "x509_verify_cert() returned" \
4402 -S "! The certificate is not correctly signed by the trusted CA" \
4403 -s "The certificate has been revoked (is on a CRL)"
4404
Andres AG1a834452016-12-07 10:01:30 +00004405# Tests for SNI and DTLS
4406
Hanno Beckerc5722d12020-10-09 11:10:42 +01004407requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004408run_test "SNI: DTLS, no SNI callback" \
4409 "$P_SRV debug_level=3 dtls=1 \
4410 crt_file=data_files/server5.crt key_file=data_files/server5.key" \
4411 "$P_CLI server_name=localhost dtls=1" \
4412 0 \
4413 -S "parse ServerName extension" \
4414 -c "issuer name *: C=NL, O=PolarSSL, CN=Polarssl Test EC CA" \
4415 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4416
Hanno Beckerc5722d12020-10-09 11:10:42 +01004417requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004418run_test "SNI: DTLS, matching cert 1" \
Andres AG1a834452016-12-07 10:01:30 +00004419 "$P_SRV debug_level=3 dtls=1 \
4420 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4421 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4422 "$P_CLI server_name=localhost dtls=1" \
4423 0 \
4424 -s "parse ServerName extension" \
4425 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4426 -c "subject name *: C=NL, O=PolarSSL, CN=localhost"
4427
Hanno Beckerc5722d12020-10-09 11:10:42 +01004428requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Andres Amaya Garcia54306c12018-05-01 20:27:37 +01004429run_test "SNI: DTLS, matching cert 2" \
4430 "$P_SRV debug_level=3 dtls=1 \
4431 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4432 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4433 "$P_CLI server_name=polarssl.example dtls=1" \
4434 0 \
4435 -s "parse ServerName extension" \
4436 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
4437 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
4438
4439run_test "SNI: DTLS, no matching cert" \
4440 "$P_SRV debug_level=3 dtls=1 \
4441 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4442 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
4443 "$P_CLI server_name=nonesuch.example dtls=1" \
4444 1 \
4445 -s "parse ServerName extension" \
4446 -s "ssl_sni_wrapper() returned" \
4447 -s "mbedtls_ssl_handshake returned" \
4448 -c "mbedtls_ssl_handshake returned" \
4449 -c "SSL - A fatal alert message was received from our peer"
4450
4451run_test "SNI: DTLS, client auth no override: optional" \
4452 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4453 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4454 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-" \
4455 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4456 0 \
4457 -S "skip write certificate request" \
4458 -C "skip parse certificate request" \
4459 -c "got a certificate request" \
4460 -C "skip write certificate" \
4461 -C "skip write certificate verify" \
4462 -S "skip parse certificate verify"
4463
4464run_test "SNI: DTLS, client auth override: none -> optional" \
4465 "$P_SRV debug_level=3 auth_mode=none dtls=1 \
4466 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4467 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,optional" \
4468 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4469 0 \
4470 -S "skip write certificate request" \
4471 -C "skip parse certificate request" \
4472 -c "got a certificate request" \
4473 -C "skip write certificate" \
4474 -C "skip write certificate verify" \
4475 -S "skip parse certificate verify"
4476
4477run_test "SNI: DTLS, client auth override: optional -> none" \
4478 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4479 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4480 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,none" \
4481 "$P_CLI debug_level=3 server_name=localhost dtls=1" \
4482 0 \
4483 -s "skip write certificate request" \
4484 -C "skip parse certificate request" \
4485 -c "got no certificate request" \
4486 -c "skip write certificate" \
4487 -c "skip write certificate verify" \
4488 -s "skip parse certificate verify"
4489
4490run_test "SNI: DTLS, CA no override" \
4491 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4492 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4493 ca_file=data_files/test-ca.crt \
4494 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,required" \
4495 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4496 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4497 1 \
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 -s "x509_verify_cert() returned" \
4505 -s "! The certificate is not correctly signed by the trusted CA" \
4506 -S "The certificate has been revoked (is on a CRL)"
4507
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004508run_test "SNI: DTLS, CA override" \
Andres AG1a834452016-12-07 10:01:30 +00004509 "$P_SRV debug_level=3 auth_mode=optional dtls=1 \
4510 crt_file=data_files/server5.crt key_file=data_files/server5.key \
4511 ca_file=data_files/test-ca.crt \
4512 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,-,required" \
4513 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4514 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4515 0 \
4516 -S "skip write certificate request" \
4517 -C "skip parse certificate request" \
4518 -c "got a certificate request" \
4519 -C "skip write certificate" \
4520 -C "skip write certificate verify" \
4521 -S "skip parse certificate verify" \
4522 -S "x509_verify_cert() returned" \
4523 -S "! The certificate is not correctly signed by the trusted CA" \
4524 -S "The certificate has been revoked (is on a CRL)"
4525
Andres Amaya Garciaf77d3d32018-05-01 20:26:47 +01004526run_test "SNI: DTLS, CA override with CRL" \
Andres AG1a834452016-12-07 10:01:30 +00004527 "$P_SRV debug_level=3 auth_mode=optional \
4528 crt_file=data_files/server5.crt key_file=data_files/server5.key dtls=1 \
4529 ca_file=data_files/test-ca.crt \
4530 sni=localhost,data_files/server2.crt,data_files/server2.key,data_files/test-ca2.crt,data_files/crl-ec-sha256.pem,required" \
4531 "$P_CLI debug_level=3 server_name=localhost dtls=1 \
4532 crt_file=data_files/server6.crt key_file=data_files/server6.key" \
4533 1 \
4534 -S "skip write certificate request" \
4535 -C "skip parse certificate request" \
4536 -c "got a certificate request" \
4537 -C "skip write certificate" \
4538 -C "skip write certificate verify" \
4539 -S "skip parse certificate verify" \
4540 -s "x509_verify_cert() returned" \
4541 -S "! The certificate is not correctly signed by the trusted CA" \
4542 -s "The certificate has been revoked (is on a CRL)"
4543
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004544# Tests for non-blocking I/O: exercise a variety of handshake flows
4545
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004546run_test "Non-blocking I/O: basic handshake" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004547 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4548 "$P_CLI nbio=2 tickets=0" \
4549 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004550 -S "mbedtls_ssl_handshake returned" \
4551 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004552 -c "Read from server: .* bytes read"
4553
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004554run_test "Non-blocking I/O: client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004555 "$P_SRV nbio=2 tickets=0 auth_mode=required" \
4556 "$P_CLI nbio=2 tickets=0" \
4557 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004558 -S "mbedtls_ssl_handshake returned" \
4559 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004560 -c "Read from server: .* bytes read"
4561
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004562run_test "Non-blocking I/O: ticket" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004563 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4564 "$P_CLI nbio=2 tickets=1" \
4565 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004566 -S "mbedtls_ssl_handshake returned" \
4567 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004568 -c "Read from server: .* bytes read"
4569
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004570run_test "Non-blocking I/O: ticket + client auth" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004571 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4572 "$P_CLI nbio=2 tickets=1" \
4573 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004574 -S "mbedtls_ssl_handshake returned" \
4575 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004576 -c "Read from server: .* bytes read"
4577
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004578run_test "Non-blocking I/O: ticket + client auth + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004579 "$P_SRV nbio=2 tickets=1 auth_mode=required" \
4580 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4581 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004582 -S "mbedtls_ssl_handshake returned" \
4583 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004584 -c "Read from server: .* bytes read"
4585
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004586run_test "Non-blocking I/O: ticket + resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004587 "$P_SRV nbio=2 tickets=1 auth_mode=none" \
4588 "$P_CLI nbio=2 tickets=1 reconnect=1" \
4589 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004590 -S "mbedtls_ssl_handshake returned" \
4591 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004592 -c "Read from server: .* bytes read"
4593
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004594run_test "Non-blocking I/O: session-id resume" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004595 "$P_SRV nbio=2 tickets=0 auth_mode=none" \
4596 "$P_CLI nbio=2 tickets=0 reconnect=1" \
4597 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004598 -S "mbedtls_ssl_handshake returned" \
4599 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0b6609b2014-02-26 14:45:12 +01004600 -c "Read from server: .* bytes read"
4601
Hanno Becker00076712017-11-15 16:39:08 +00004602# Tests for event-driven I/O: exercise a variety of handshake flows
4603
4604run_test "Event-driven I/O: basic handshake" \
4605 "$P_SRV event=1 tickets=0 auth_mode=none" \
4606 "$P_CLI event=1 tickets=0" \
4607 0 \
4608 -S "mbedtls_ssl_handshake returned" \
4609 -C "mbedtls_ssl_handshake returned" \
4610 -c "Read from server: .* bytes read"
4611
4612run_test "Event-driven I/O: client auth" \
4613 "$P_SRV event=1 tickets=0 auth_mode=required" \
4614 "$P_CLI event=1 tickets=0" \
4615 0 \
4616 -S "mbedtls_ssl_handshake returned" \
4617 -C "mbedtls_ssl_handshake returned" \
4618 -c "Read from server: .* bytes read"
4619
4620run_test "Event-driven I/O: ticket" \
4621 "$P_SRV event=1 tickets=1 auth_mode=none" \
4622 "$P_CLI event=1 tickets=1" \
4623 0 \
4624 -S "mbedtls_ssl_handshake returned" \
4625 -C "mbedtls_ssl_handshake returned" \
4626 -c "Read from server: .* bytes read"
4627
4628run_test "Event-driven I/O: ticket + client auth" \
4629 "$P_SRV event=1 tickets=1 auth_mode=required" \
4630 "$P_CLI event=1 tickets=1" \
4631 0 \
4632 -S "mbedtls_ssl_handshake returned" \
4633 -C "mbedtls_ssl_handshake returned" \
4634 -c "Read from server: .* bytes read"
4635
4636run_test "Event-driven I/O: ticket + client auth + resume" \
4637 "$P_SRV event=1 tickets=1 auth_mode=required" \
4638 "$P_CLI event=1 tickets=1 reconnect=1" \
4639 0 \
4640 -S "mbedtls_ssl_handshake returned" \
4641 -C "mbedtls_ssl_handshake returned" \
4642 -c "Read from server: .* bytes read"
4643
4644run_test "Event-driven I/O: ticket + resume" \
4645 "$P_SRV event=1 tickets=1 auth_mode=none" \
4646 "$P_CLI event=1 tickets=1 reconnect=1" \
4647 0 \
4648 -S "mbedtls_ssl_handshake returned" \
4649 -C "mbedtls_ssl_handshake returned" \
4650 -c "Read from server: .* bytes read"
4651
4652run_test "Event-driven I/O: session-id resume" \
4653 "$P_SRV event=1 tickets=0 auth_mode=none" \
4654 "$P_CLI event=1 tickets=0 reconnect=1" \
4655 0 \
4656 -S "mbedtls_ssl_handshake returned" \
4657 -C "mbedtls_ssl_handshake returned" \
4658 -c "Read from server: .* bytes read"
4659
Hanno Becker6a33f592018-03-13 11:38:46 +00004660run_test "Event-driven I/O, DTLS: basic handshake" \
4661 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
4662 "$P_CLI dtls=1 event=1 tickets=0" \
4663 0 \
4664 -c "Read from server: .* bytes read"
4665
4666run_test "Event-driven I/O, DTLS: client auth" \
4667 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
4668 "$P_CLI dtls=1 event=1 tickets=0" \
4669 0 \
4670 -c "Read from server: .* bytes read"
4671
4672run_test "Event-driven I/O, DTLS: ticket" \
4673 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
4674 "$P_CLI dtls=1 event=1 tickets=1" \
4675 0 \
4676 -c "Read from server: .* bytes read"
4677
4678run_test "Event-driven I/O, DTLS: ticket + client auth" \
4679 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
4680 "$P_CLI dtls=1 event=1 tickets=1" \
4681 0 \
4682 -c "Read from server: .* bytes read"
4683
4684run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \
4685 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004686 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004687 0 \
4688 -c "Read from server: .* bytes read"
4689
4690run_test "Event-driven I/O, DTLS: ticket + resume" \
4691 "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004692 "$P_CLI dtls=1 event=1 tickets=1 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004693 0 \
4694 -c "Read from server: .* bytes read"
4695
4696run_test "Event-driven I/O, DTLS: session-id resume" \
4697 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004698 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Becker6a33f592018-03-13 11:38:46 +00004699 0 \
4700 -c "Read from server: .* bytes read"
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004701
4702# This test demonstrates the need for the mbedtls_ssl_check_pending function.
4703# During session resumption, the client will send its ApplicationData record
4704# within the same datagram as the Finished messages. In this situation, the
4705# server MUST NOT idle on the underlying transport after handshake completion,
4706# because the ApplicationData request has already been queued internally.
4707run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \
Hanno Becker8d832182018-03-15 10:14:19 +00004708 -p "$P_PXY pack=50" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004709 "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01004710 "$P_CLI dtls=1 event=1 tickets=0 reconnect=1 skip_close_notify=1" \
Hanno Beckerbc6c1102018-03-13 11:39:40 +00004711 0 \
4712 -c "Read from server: .* bytes read"
4713
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004714# Tests for version negotiation
4715
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004716run_test "Version check: all -> 1.2" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004717 "$P_SRV" \
4718 "$P_CLI" \
4719 0 \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02004720 -S "mbedtls_ssl_handshake returned" \
4721 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnarda3d808e2014-02-26 16:33:03 +01004722 -s "Protocol is TLSv1.2" \
4723 -c "Protocol is TLSv1.2"
4724
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004725# Tests for ALPN extension
4726
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004727run_test "ALPN: none" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004728 "$P_SRV debug_level=3" \
4729 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004730 0 \
4731 -C "client hello, adding alpn extension" \
4732 -S "found alpn extension" \
4733 -C "got an alert message, type: \\[2:120]" \
4734 -S "server hello, adding alpn extension" \
4735 -C "found alpn extension " \
4736 -C "Application Layer Protocol is" \
4737 -S "Application Layer Protocol is"
4738
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004739run_test "ALPN: client only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004740 "$P_SRV debug_level=3" \
4741 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004742 0 \
4743 -c "client hello, adding alpn extension" \
4744 -s "found alpn extension" \
4745 -C "got an alert message, type: \\[2:120]" \
4746 -S "server hello, adding alpn extension" \
4747 -C "found alpn extension " \
4748 -c "Application Layer Protocol is (none)" \
4749 -S "Application Layer Protocol is"
4750
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004751run_test "ALPN: server only" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004752 "$P_SRV debug_level=3 alpn=abc,1234" \
4753 "$P_CLI debug_level=3" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004754 0 \
4755 -C "client hello, adding alpn extension" \
4756 -S "found alpn extension" \
4757 -C "got an alert message, type: \\[2:120]" \
4758 -S "server hello, adding alpn extension" \
4759 -C "found alpn extension " \
4760 -C "Application Layer Protocol is" \
4761 -s "Application Layer Protocol is (none)"
4762
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004763run_test "ALPN: both, common cli1-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004764 "$P_SRV debug_level=3 alpn=abc,1234" \
4765 "$P_CLI debug_level=3 alpn=abc,1234" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004766 0 \
4767 -c "client hello, adding alpn extension" \
4768 -s "found alpn extension" \
4769 -C "got an alert message, type: \\[2:120]" \
4770 -s "server hello, adding alpn extension" \
4771 -c "found alpn extension" \
4772 -c "Application Layer Protocol is abc" \
4773 -s "Application Layer Protocol is abc"
4774
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004775run_test "ALPN: both, common cli2-srv1" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004776 "$P_SRV debug_level=3 alpn=abc,1234" \
4777 "$P_CLI debug_level=3 alpn=1234,abc" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004778 0 \
4779 -c "client hello, adding alpn extension" \
4780 -s "found alpn extension" \
4781 -C "got an alert message, type: \\[2:120]" \
4782 -s "server hello, adding alpn extension" \
4783 -c "found alpn extension" \
4784 -c "Application Layer Protocol is abc" \
4785 -s "Application Layer Protocol is abc"
4786
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004787run_test "ALPN: both, common cli1-srv2" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004788 "$P_SRV debug_level=3 alpn=abc,1234" \
4789 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004790 0 \
4791 -c "client hello, adding alpn extension" \
4792 -s "found alpn extension" \
4793 -C "got an alert message, type: \\[2:120]" \
4794 -s "server hello, adding alpn extension" \
4795 -c "found alpn extension" \
4796 -c "Application Layer Protocol is 1234" \
4797 -s "Application Layer Protocol is 1234"
4798
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004799run_test "ALPN: both, no common" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004800 "$P_SRV debug_level=3 alpn=abc,123" \
4801 "$P_CLI debug_level=3 alpn=1234,abcde" \
Manuel Pégourié-Gonnardf6521de2014-04-07 12:42:04 +02004802 1 \
4803 -c "client hello, adding alpn extension" \
4804 -s "found alpn extension" \
4805 -c "got an alert message, type: \\[2:120]" \
4806 -S "server hello, adding alpn extension" \
4807 -C "found alpn extension" \
4808 -C "Application Layer Protocol is 1234" \
4809 -S "Application Layer Protocol is 1234"
4810
Manuel Pégourié-Gonnard83d8c732014-04-07 13:24:21 +02004811
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004812# Tests for keyUsage in leaf certificates, part 1:
4813# server-side certificate/suite selection
4814
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004815run_test "keyUsage srv: RSA, digitalSignature -> (EC)DHE-RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004816 "$P_SRV key_file=data_files/server2.key \
4817 crt_file=data_files/server2.ku-ds.crt" \
4818 "$P_CLI" \
4819 0 \
Manuel Pégourié-Gonnard17cde5f2014-05-22 14:42:39 +02004820 -c "Ciphersuite is TLS-[EC]*DHE-RSA-WITH-"
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004821
4822
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004823run_test "keyUsage srv: RSA, keyEncipherment -> RSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004824 "$P_SRV key_file=data_files/server2.key \
4825 crt_file=data_files/server2.ku-ke.crt" \
4826 "$P_CLI" \
4827 0 \
4828 -c "Ciphersuite is TLS-RSA-WITH-"
4829
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004830run_test "keyUsage srv: RSA, keyAgreement -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004831 "$P_SRV key_file=data_files/server2.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004832 crt_file=data_files/server2.ku-ka.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004833 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004834 1 \
4835 -C "Ciphersuite is "
4836
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004837run_test "keyUsage srv: ECDSA, digitalSignature -> ECDHE-ECDSA" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004838 "$P_SRV key_file=data_files/server5.key \
4839 crt_file=data_files/server5.ku-ds.crt" \
4840 "$P_CLI" \
4841 0 \
4842 -c "Ciphersuite is TLS-ECDHE-ECDSA-WITH-"
4843
4844
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004845run_test "keyUsage srv: ECDSA, keyAgreement -> ECDH-" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004846 "$P_SRV key_file=data_files/server5.key \
4847 crt_file=data_files/server5.ku-ka.crt" \
4848 "$P_CLI" \
4849 0 \
4850 -c "Ciphersuite is TLS-ECDH-"
4851
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004852run_test "keyUsage srv: ECDSA, keyEncipherment -> fail" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004853 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004854 crt_file=data_files/server5.ku-ke.crt" \
Manuel Pégourié-Gonnardf2629b92014-08-30 14:20:14 +02004855 "$P_CLI" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004856 1 \
4857 -C "Ciphersuite is "
4858
4859# Tests for keyUsage in leaf certificates, part 2:
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004860# client-side checking of server cert
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004861
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004862run_test "keyUsage cli: DigitalSignature+KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004863 "$O_SRV -key data_files/server2.key \
4864 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004865 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004866 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4867 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004868 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004869 -C "Processing of the Certificate handshake message failed" \
4870 -c "Ciphersuite is TLS-"
4871
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004872run_test "keyUsage cli: DigitalSignature+KeyEncipherment, DHE-RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004873 "$O_SRV -key data_files/server2.key \
4874 -cert data_files/server2.ku-ds_ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004875 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004876 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4877 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004878 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004879 -C "Processing of the Certificate handshake message failed" \
4880 -c "Ciphersuite is TLS-"
4881
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004882run_test "keyUsage cli: KeyEncipherment, RSA: OK" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004883 "$O_SRV -key data_files/server2.key \
4884 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004885 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004886 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4887 0 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004888 -C "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004889 -C "Processing of the Certificate handshake message failed" \
4890 -c "Ciphersuite is TLS-"
4891
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004892run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004893 "$O_SRV -key data_files/server2.key \
4894 -cert data_files/server2.ku-ke.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004895 "$P_CLI debug_level=1 \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004896 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4897 1 \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004898 -c "bad certificate (usage extensions)" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004899 -c "Processing of the Certificate handshake message failed" \
4900 -C "Ciphersuite is TLS-"
4901
Manuel Pégourié-Gonnarde6efa6f2015-04-20 11:01:48 +01004902run_test "keyUsage cli: KeyEncipherment, DHE-RSA: fail, soft" \
4903 "$O_SRV -key data_files/server2.key \
4904 -cert data_files/server2.ku-ke.crt" \
4905 "$P_CLI debug_level=1 auth_mode=optional \
4906 force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA" \
4907 0 \
4908 -c "bad certificate (usage extensions)" \
4909 -C "Processing of the Certificate handshake message failed" \
4910 -c "Ciphersuite is TLS-" \
4911 -c "! Usage does not match the keyUsage extension"
4912
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004913run_test "keyUsage cli: DigitalSignature, 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.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: DigitalSignature, RSA: fail" \
Manuel Pégourié-Gonnard7f2a07d2014-04-09 09:50:57 +02004924 "$O_SRV -key data_files/server2.key \
4925 -cert data_files/server2.ku-ds.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 1 \
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é-Gonnarde6efa6f2015-04-20 11:01:48 +01004933run_test "keyUsage cli: DigitalSignature, RSA: fail, soft" \
4934 "$O_SRV -key data_files/server2.key \
4935 -cert data_files/server2.ku-ds.crt" \
4936 "$P_CLI debug_level=1 auth_mode=optional \
4937 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
4938 0 \
4939 -c "bad certificate (usage extensions)" \
4940 -C "Processing of the Certificate handshake message failed" \
4941 -c "Ciphersuite is TLS-" \
4942 -c "! Usage does not match the keyUsage extension"
4943
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004944# Tests for keyUsage in leaf certificates, part 3:
4945# server-side checking of client cert
4946
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004947run_test "keyUsage cli-auth: RSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004948 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004949 "$O_CLI -key data_files/server2.key \
4950 -cert data_files/server2.ku-ds.crt" \
4951 0 \
4952 -S "bad certificate (usage extensions)" \
4953 -S "Processing of the Certificate handshake message failed"
4954
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004955run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004956 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004957 "$O_CLI -key data_files/server2.key \
4958 -cert data_files/server2.ku-ke.crt" \
4959 0 \
4960 -s "bad certificate (usage extensions)" \
4961 -S "Processing of the Certificate handshake message failed"
4962
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004963run_test "keyUsage cli-auth: RSA, KeyEncipherment: fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004964 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004965 "$O_CLI -key data_files/server2.key \
4966 -cert data_files/server2.ku-ke.crt" \
4967 1 \
4968 -s "bad certificate (usage extensions)" \
4969 -s "Processing of the Certificate handshake message failed"
4970
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004971run_test "keyUsage cli-auth: ECDSA, DigitalSignature: OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004972 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004973 "$O_CLI -key data_files/server5.key \
4974 -cert data_files/server5.ku-ds.crt" \
4975 0 \
4976 -S "bad certificate (usage extensions)" \
4977 -S "Processing of the Certificate handshake message failed"
4978
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004979run_test "keyUsage cli-auth: ECDSA, KeyAgreement: fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02004980 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnarda9db85d2014-04-09 14:53:05 +02004981 "$O_CLI -key data_files/server5.key \
4982 -cert data_files/server5.ku-ka.crt" \
4983 0 \
4984 -s "bad certificate (usage extensions)" \
4985 -S "Processing of the Certificate handshake message failed"
4986
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004987# Tests for extendedKeyUsage, part 1: server-side certificate/suite selection
4988
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004989run_test "extKeyUsage srv: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004990 "$P_SRV key_file=data_files/server5.key \
4991 crt_file=data_files/server5.eku-srv.crt" \
4992 "$P_CLI" \
4993 0
4994
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02004995run_test "extKeyUsage srv: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02004996 "$P_SRV key_file=data_files/server5.key \
4997 crt_file=data_files/server5.eku-srv.crt" \
4998 "$P_CLI" \
4999 0
5000
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005001run_test "extKeyUsage srv: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005002 "$P_SRV key_file=data_files/server5.key \
5003 crt_file=data_files/server5.eku-cs_any.crt" \
5004 "$P_CLI" \
5005 0
5006
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005007run_test "extKeyUsage srv: codeSign -> fail" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005008 "$P_SRV key_file=data_files/server5.key \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005009 crt_file=data_files/server5.eku-cli.crt" \
Manuel Pégourié-Gonnard7eb58cb2015-07-07 11:54:14 +02005010 "$P_CLI" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005011 1
5012
5013# Tests for extendedKeyUsage, part 2: client-side checking of server cert
5014
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005015run_test "extKeyUsage cli: serverAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005016 "$O_SRV -key data_files/server5.key \
5017 -cert data_files/server5.eku-srv.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005018 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005019 0 \
5020 -C "bad certificate (usage extensions)" \
5021 -C "Processing of the Certificate handshake message failed" \
5022 -c "Ciphersuite is TLS-"
5023
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005024run_test "extKeyUsage cli: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005025 "$O_SRV -key data_files/server5.key \
5026 -cert data_files/server5.eku-srv_cli.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005027 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005028 0 \
5029 -C "bad certificate (usage extensions)" \
5030 -C "Processing of the Certificate handshake message failed" \
5031 -c "Ciphersuite is TLS-"
5032
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005033run_test "extKeyUsage cli: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005034 "$O_SRV -key data_files/server5.key \
5035 -cert data_files/server5.eku-cs_any.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005036 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005037 0 \
5038 -C "bad certificate (usage extensions)" \
5039 -C "Processing of the Certificate handshake message failed" \
5040 -c "Ciphersuite is TLS-"
5041
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005042run_test "extKeyUsage cli: codeSign -> fail" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005043 "$O_SRV -key data_files/server5.key \
5044 -cert data_files/server5.eku-cs.crt" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005045 "$P_CLI debug_level=1" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005046 1 \
5047 -c "bad certificate (usage extensions)" \
5048 -c "Processing of the Certificate handshake message failed" \
5049 -C "Ciphersuite is TLS-"
5050
5051# Tests for extendedKeyUsage, part 3: server-side checking of client cert
5052
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005053run_test "extKeyUsage cli-auth: clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005054 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005055 "$O_CLI -key data_files/server5.key \
5056 -cert data_files/server5.eku-cli.crt" \
5057 0 \
5058 -S "bad certificate (usage extensions)" \
5059 -S "Processing of the Certificate handshake message failed"
5060
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005061run_test "extKeyUsage cli-auth: serverAuth,clientAuth -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005062 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005063 "$O_CLI -key data_files/server5.key \
5064 -cert data_files/server5.eku-srv_cli.crt" \
5065 0 \
5066 -S "bad certificate (usage extensions)" \
5067 -S "Processing of the Certificate handshake message failed"
5068
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005069run_test "extKeyUsage cli-auth: codeSign,anyEKU -> OK" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005070 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005071 "$O_CLI -key data_files/server5.key \
5072 -cert data_files/server5.eku-cs_any.crt" \
5073 0 \
5074 -S "bad certificate (usage extensions)" \
5075 -S "Processing of the Certificate handshake message failed"
5076
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005077run_test "extKeyUsage cli-auth: codeSign -> fail (soft)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005078 "$P_SRV debug_level=1 auth_mode=optional" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005079 "$O_CLI -key data_files/server5.key \
5080 -cert data_files/server5.eku-cs.crt" \
5081 0 \
5082 -s "bad certificate (usage extensions)" \
5083 -S "Processing of the Certificate handshake message failed"
5084
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005085run_test "extKeyUsage cli-auth: codeSign -> fail (hard)" \
Manuel Pégourié-Gonnard644e8f32014-08-30 21:59:31 +02005086 "$P_SRV debug_level=1 auth_mode=required" \
Manuel Pégourié-Gonnard0408fd12014-04-11 11:06:22 +02005087 "$O_CLI -key data_files/server5.key \
5088 -cert data_files/server5.eku-cs.crt" \
5089 1 \
5090 -s "bad certificate (usage extensions)" \
5091 -s "Processing of the Certificate handshake message failed"
5092
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005093# Tests for DHM parameters loading
5094
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005095run_test "DHM parameters: reference" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005096 "$P_SRV" \
5097 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5098 debug_level=3" \
5099 0 \
5100 -c "value of 'DHM: P ' (2048 bits)" \
Hanno Becker13be9902017-09-27 17:17:30 +01005101 -c "value of 'DHM: G ' (2 bits)"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005102
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005103run_test "DHM parameters: other parameters" \
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005104 "$P_SRV dhm_file=data_files/dhparams.pem" \
5105 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5106 debug_level=3" \
5107 0 \
5108 -c "value of 'DHM: P ' (1024 bits)" \
5109 -c "value of 'DHM: G ' (2 bits)"
5110
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005111# Tests for DHM client-side size checking
5112
5113run_test "DHM size: server default, client default, OK" \
5114 "$P_SRV" \
5115 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5116 debug_level=1" \
5117 0 \
5118 -C "DHM prime too short:"
5119
5120run_test "DHM size: server default, client 2048, OK" \
5121 "$P_SRV" \
5122 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5123 debug_level=1 dhmlen=2048" \
5124 0 \
5125 -C "DHM prime too short:"
5126
5127run_test "DHM size: server 1024, client default, OK" \
5128 "$P_SRV dhm_file=data_files/dhparams.pem" \
5129 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5130 debug_level=1" \
5131 0 \
5132 -C "DHM prime too short:"
5133
Gilles Peskinec6b0d962020-12-08 22:31:52 +01005134run_test "DHM size: server 999, client 999, OK" \
5135 "$P_SRV dhm_file=data_files/dh.999.pem" \
5136 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5137 debug_level=1 dhmlen=999" \
5138 0 \
5139 -C "DHM prime too short:"
5140
5141run_test "DHM size: server 1000, client 1000, OK" \
5142 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5143 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5144 debug_level=1 dhmlen=1000" \
5145 0 \
5146 -C "DHM prime too short:"
5147
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005148run_test "DHM size: server 1000, client default, rejected" \
5149 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5150 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5151 debug_level=1" \
5152 1 \
5153 -c "DHM prime too short:"
5154
Gilles Peskinec6b0d962020-12-08 22:31:52 +01005155run_test "DHM size: server 1000, client 1001, rejected" \
5156 "$P_SRV dhm_file=data_files/dh.1000.pem" \
5157 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5158 debug_level=1 dhmlen=1001" \
5159 1 \
5160 -c "DHM prime too short:"
5161
5162run_test "DHM size: server 999, client 1000, rejected" \
5163 "$P_SRV dhm_file=data_files/dh.999.pem" \
5164 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5165 debug_level=1 dhmlen=1000" \
5166 1 \
5167 -c "DHM prime too short:"
5168
5169run_test "DHM size: server 998, client 999, rejected" \
5170 "$P_SRV dhm_file=data_files/dh.998.pem" \
5171 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5172 debug_level=1 dhmlen=999" \
5173 1 \
5174 -c "DHM prime too short:"
5175
Manuel Pégourié-Gonnard7a010aa2015-06-12 11:19:10 +02005176run_test "DHM size: server default, client 2049, rejected" \
5177 "$P_SRV" \
5178 "$P_CLI force_ciphersuite=TLS-DHE-RSA-WITH-AES-128-CBC-SHA \
5179 debug_level=1 dhmlen=2049" \
5180 1 \
5181 -c "DHM prime too short:"
5182
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005183# Tests for PSK callback
5184
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005185run_test "PSK callback: psk, no callback" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005186 "$P_SRV psk=abc123 psk_identity=foo" \
5187 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5188 psk_identity=foo psk=abc123" \
5189 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005190 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005191 -S "SSL - Unknown identity received" \
5192 -S "SSL - Verification of the message MAC failed"
5193
Hanno Beckerf7027512018-10-23 15:27:39 +01005194requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5195run_test "PSK callback: opaque psk on client, no callback" \
5196 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5197 "$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 +00005198 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005199 0 \
5200 -c "skip PMS generation for opaque PSK"\
5201 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005202 -C "session hash for extended master secret"\
5203 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005204 -S "SSL - None of the common ciphersuites is usable" \
5205 -S "SSL - Unknown identity received" \
5206 -S "SSL - Verification of the message MAC failed"
5207
5208requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5209run_test "PSK callback: opaque psk on client, no callback, SHA-384" \
5210 "$P_SRV extended_ms=0 debug_level=1 psk=abc123 psk_identity=foo" \
5211 "$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 +00005212 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005213 0 \
5214 -c "skip PMS generation for opaque PSK"\
5215 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005216 -C "session hash for extended master secret"\
5217 -S "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005218 -S "SSL - None of the common ciphersuites is usable" \
5219 -S "SSL - Unknown identity received" \
5220 -S "SSL - Verification of the message MAC failed"
5221
5222requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5223run_test "PSK callback: opaque psk on client, no callback, EMS" \
5224 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5225 "$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 +00005226 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005227 0 \
5228 -c "skip PMS generation for opaque PSK"\
5229 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005230 -c "session hash for extended master secret"\
5231 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005232 -S "SSL - None of the common ciphersuites is usable" \
5233 -S "SSL - Unknown identity received" \
5234 -S "SSL - Verification of the message MAC failed"
5235
5236requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5237run_test "PSK callback: opaque psk on client, no callback, SHA-384, EMS" \
5238 "$P_SRV extended_ms=1 debug_level=3 psk=abc123 psk_identity=foo" \
5239 "$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 +00005240 psk_identity=foo psk=abc123 psk_opaque=1" \
Hanno Beckerf7027512018-10-23 15:27:39 +01005241 0 \
5242 -c "skip PMS generation for opaque PSK"\
5243 -S "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005244 -c "session hash for extended master secret"\
5245 -s "session hash for extended master secret"\
Hanno Beckerf7027512018-10-23 15:27:39 +01005246 -S "SSL - None of the common ciphersuites is usable" \
5247 -S "SSL - Unknown identity received" \
5248 -S "SSL - Verification of the message MAC failed"
5249
Hanno Becker28c79dc2018-10-26 13:15:08 +01005250requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5251run_test "PSK callback: raw psk on client, static opaque on server, no callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005252 "$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 +01005253 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5254 psk_identity=foo psk=abc123" \
5255 0 \
5256 -C "skip PMS generation for opaque PSK"\
5257 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005258 -C "session hash for extended master secret"\
5259 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005260 -S "SSL - None of the common ciphersuites is usable" \
5261 -S "SSL - Unknown identity received" \
5262 -S "SSL - Verification of the message MAC failed"
5263
5264requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5265run_test "PSK callback: raw psk on client, static opaque on server, no callback, SHA-384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005266 "$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 +01005267 "$P_CLI extended_ms=0 debug_level=1 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5268 psk_identity=foo psk=abc123" \
5269 0 \
5270 -C "skip PMS generation for opaque PSK"\
5271 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005272 -C "session hash for extended master secret"\
5273 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005274 -S "SSL - None of the common ciphersuites is usable" \
5275 -S "SSL - Unknown identity received" \
5276 -S "SSL - Verification of the message MAC failed"
5277
5278requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5279run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005280 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005281 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5282 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5283 psk_identity=foo psk=abc123 extended_ms=1" \
5284 0 \
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 Becker28c79dc2018-10-26 13:15:08 +01005287 -C "skip PMS generation for opaque PSK"\
5288 -s "skip PMS generation for opaque PSK"\
5289 -S "SSL - None of the common ciphersuites is usable" \
5290 -S "SSL - Unknown identity received" \
5291 -S "SSL - Verification of the message MAC failed"
5292
5293requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5294run_test "PSK callback: raw psk on client, static opaque on server, no callback, EMS, SHA384" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005295 "$P_SRV debug_level=3 psk=abc123 psk_identity=foo psk_opaque=1 min_version=tls1_2 \
Hanno Becker28c79dc2018-10-26 13:15:08 +01005296 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5297 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5298 psk_identity=foo psk=abc123 extended_ms=1" \
5299 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005300 -c "session hash for extended master secret"\
5301 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005302 -C "skip PMS generation for opaque PSK"\
5303 -s "skip PMS generation for opaque PSK"\
5304 -S "SSL - None of the common ciphersuites is usable" \
5305 -S "SSL - Unknown identity received" \
5306 -S "SSL - Verification of the message MAC failed"
5307
5308requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5309run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005310 "$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 +01005311 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5312 psk_identity=def psk=beef" \
5313 0 \
5314 -C "skip PMS generation for opaque PSK"\
5315 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005316 -C "session hash for extended master secret"\
5317 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005318 -S "SSL - None of the common ciphersuites is usable" \
5319 -S "SSL - Unknown identity received" \
5320 -S "SSL - Verification of the message MAC failed"
5321
5322requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5323run_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 +00005324 "$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 +01005325 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5326 psk_identity=def psk=beef" \
5327 0 \
5328 -C "skip PMS generation for opaque PSK"\
5329 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005330 -C "session hash for extended master secret"\
5331 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005332 -S "SSL - None of the common ciphersuites is usable" \
5333 -S "SSL - Unknown identity received" \
5334 -S "SSL - Verification of the message MAC failed"
5335
5336requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5337run_test "PSK callback: raw psk on client, no static PSK on server, opaque PSK from callback, EMS" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005338 "$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 +01005339 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA extended_ms=1" \
5340 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5341 psk_identity=abc psk=dead extended_ms=1" \
5342 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005343 -c "session hash for extended master secret"\
5344 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005345 -C "skip PMS generation for opaque PSK"\
5346 -s "skip PMS generation for opaque PSK"\
5347 -S "SSL - None of the common ciphersuites is usable" \
5348 -S "SSL - Unknown identity received" \
5349 -S "SSL - Verification of the message MAC failed"
5350
5351requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5352run_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 +00005353 "$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 +01005354 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 extended_ms=1" \
5355 "$P_CLI debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-256-CBC-SHA384 \
5356 psk_identity=abc psk=dead extended_ms=1" \
5357 0 \
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005358 -c "session hash for extended master secret"\
5359 -s "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005360 -C "skip PMS generation for opaque PSK"\
5361 -s "skip PMS generation for opaque PSK"\
5362 -S "SSL - None of the common ciphersuites is usable" \
5363 -S "SSL - Unknown identity received" \
5364 -S "SSL - Verification of the message MAC failed"
5365
5366requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5367run_test "PSK callback: raw psk on client, mismatching static raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005368 "$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 +01005369 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5370 psk_identity=def psk=beef" \
5371 0 \
5372 -C "skip PMS generation for opaque PSK"\
5373 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005374 -C "session hash for extended master secret"\
5375 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005376 -S "SSL - None of the common ciphersuites is usable" \
5377 -S "SSL - Unknown identity received" \
5378 -S "SSL - Verification of the message MAC failed"
5379
5380requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5381run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005382 "$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 +01005383 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5384 psk_identity=def psk=beef" \
5385 0 \
5386 -C "skip PMS generation for opaque PSK"\
5387 -s "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005388 -C "session hash for extended master secret"\
5389 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005390 -S "SSL - None of the common ciphersuites is usable" \
5391 -S "SSL - Unknown identity received" \
5392 -S "SSL - Verification of the message MAC failed"
5393
5394requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5395run_test "PSK callback: raw psk on client, mismatching static opaque PSK on server, raw PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005396 "$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 +01005397 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5398 psk_identity=def psk=beef" \
5399 0 \
5400 -C "skip PMS generation for opaque PSK"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005401 -C "session hash for extended master secret"\
5402 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005403 -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, id-matching but wrong raw PSK on server, opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005409 "$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 +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"\
Manuel Pégourié-Gonnard8faa70e2019-05-20 12:09:50 +02005414 -C "session hash for extended master secret"\
5415 -S "session hash for extended master secret"\
Hanno Becker28c79dc2018-10-26 13:15:08 +01005416 -S "SSL - None of the common ciphersuites is usable" \
5417 -S "SSL - Unknown identity received" \
5418 -S "SSL - Verification of the message MAC failed"
5419
5420requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
5421run_test "PSK callback: raw psk on client, matching opaque PSK on server, wrong opaque PSK from callback" \
Hanno Becker1d911cd2018-11-15 13:06:09 +00005422 "$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 +01005423 "$P_CLI extended_ms=0 debug_level=3 min_version=tls1_2 force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5424 psk_identity=def psk=beef" \
5425 1 \
5426 -s "SSL - Verification of the message MAC failed"
5427
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005428run_test "PSK callback: no psk, no callback" \
Manuel Pégourié-Gonnard10c3c9f2014-06-10 15:28:52 +02005429 "$P_SRV" \
5430 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5431 psk_identity=foo psk=abc123" \
5432 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005433 -s "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005434 -S "SSL - Unknown identity received" \
5435 -S "SSL - Verification of the message MAC failed"
5436
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005437run_test "PSK callback: callback overrides other settings" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005438 "$P_SRV psk=abc123 psk_identity=foo psk_list=abc,dead,def,beef" \
5439 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5440 psk_identity=foo psk=abc123" \
5441 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005442 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005443 -s "SSL - Unknown identity received" \
5444 -S "SSL - Verification of the message MAC failed"
5445
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005446run_test "PSK callback: first id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005447 "$P_SRV psk_list=abc,dead,def,beef" \
5448 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5449 psk_identity=abc psk=dead" \
5450 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005451 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005452 -S "SSL - Unknown identity received" \
5453 -S "SSL - Verification of the message MAC failed"
5454
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005455run_test "PSK callback: second id matches" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005456 "$P_SRV psk_list=abc,dead,def,beef" \
5457 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5458 psk_identity=def psk=beef" \
5459 0 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005460 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005461 -S "SSL - Unknown identity received" \
5462 -S "SSL - Verification of the message MAC failed"
5463
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005464run_test "PSK callback: no match" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005465 "$P_SRV psk_list=abc,dead,def,beef" \
5466 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5467 psk_identity=ghi psk=beef" \
5468 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005469 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005470 -s "SSL - Unknown identity received" \
5471 -S "SSL - Verification of the message MAC failed"
5472
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005473run_test "PSK callback: wrong key" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005474 "$P_SRV psk_list=abc,dead,def,beef" \
5475 "$P_CLI force_ciphersuite=TLS-PSK-WITH-AES-128-CBC-SHA \
5476 psk_identity=abc psk=beef" \
5477 1 \
Manuel Pégourié-Gonnardf01768c2015-01-08 17:06:16 +01005478 -S "SSL - None of the common ciphersuites is usable" \
Manuel Pégourié-Gonnarda6781c92014-06-10 15:00:46 +02005479 -S "SSL - Unknown identity received" \
5480 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnard0cc7e312014-06-09 11:36:47 +02005481
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005482# Tests for EC J-PAKE
5483
Hanno Beckerfa452c42020-08-14 15:42:49 +01005484requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005485run_test "ECJPAKE: client not configured" \
5486 "$P_SRV debug_level=3" \
5487 "$P_CLI debug_level=3" \
5488 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005489 -C "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005490 -C "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005491 -S "found ecjpake kkpp extension" \
5492 -S "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005493 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005494 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005495 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005496 -S "None of the common ciphersuites is usable"
5497
Hanno Beckerfa452c42020-08-14 15:42:49 +01005498requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005499run_test "ECJPAKE: server not configured" \
5500 "$P_SRV debug_level=3" \
5501 "$P_CLI debug_level=3 ecjpake_pw=bla \
5502 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5503 1 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005504 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005505 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005506 -s "found ecjpake kkpp extension" \
5507 -s "skip ecjpake kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005508 -s "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005509 -S "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005510 -C "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnarde511b4e2015-09-16 14:11:09 +02005511 -s "None of the common ciphersuites is usable"
5512
Hanno Beckerfa452c42020-08-14 15:42:49 +01005513requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005514run_test "ECJPAKE: working, TLS" \
5515 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5516 "$P_CLI debug_level=3 ecjpake_pw=bla \
5517 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
Manuel Pégourié-Gonnard0f1660a2015-09-16 22:41:06 +02005518 0 \
Hanno Beckeree63af62020-08-14 15:41:23 +01005519 -c "add ciphersuite: 0xc0ff" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005520 -c "adding ecjpake_kkpp extension" \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005521 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005522 -s "found ecjpake kkpp extension" \
5523 -S "skip ecjpake kkpp extension" \
5524 -S "ciphersuite mismatch: ecjpake not configured" \
Manuel Pégourié-Gonnard55c7f992015-09-16 15:35:27 +02005525 -s "server hello, ecjpake kkpp extension" \
Manuel Pégourié-Gonnard0a1324a2015-09-16 16:01:00 +02005526 -c "found ecjpake_kkpp extension" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005527 -S "None of the common ciphersuites is usable" \
5528 -S "SSL - Verification of the message MAC failed"
5529
Janos Follath74537a62016-09-02 13:45:28 +01005530server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005531requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005532run_test "ECJPAKE: password mismatch, TLS" \
5533 "$P_SRV debug_level=3 ecjpake_pw=bla" \
5534 "$P_CLI debug_level=3 ecjpake_pw=bad \
5535 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5536 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005537 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005538 -s "SSL - Verification of the message MAC failed"
5539
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005540requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005541run_test "ECJPAKE: working, DTLS" \
5542 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5543 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5544 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5545 0 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005546 -c "re-using cached ecjpake parameters" \
5547 -S "SSL - Verification of the message MAC failed"
5548
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005549requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005550run_test "ECJPAKE: working, DTLS, no cookie" \
5551 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla cookies=0" \
5552 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bla \
5553 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5554 0 \
5555 -C "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005556 -S "SSL - Verification of the message MAC failed"
5557
Janos Follath74537a62016-09-02 13:45:28 +01005558server_needs_more_time 1
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005559requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005560run_test "ECJPAKE: password mismatch, DTLS" \
5561 "$P_SRV debug_level=3 dtls=1 ecjpake_pw=bla" \
5562 "$P_CLI debug_level=3 dtls=1 ecjpake_pw=bad \
5563 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5564 1 \
Manuel Pégourié-Gonnardd0d8cb32015-09-17 14:16:30 +02005565 -c "re-using cached ecjpake parameters" \
Manuel Pégourié-Gonnard921f2d02015-09-16 22:52:18 +02005566 -s "SSL - Verification of the message MAC failed"
Manuel Pégourié-Gonnardbf57be62015-09-16 15:04:01 +02005567
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005568# for tests with configs/config-thread.h
Manuel Pégourié-Gonnard12ca6f52015-10-20 15:24:51 +02005569requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE
Manuel Pégourié-Gonnardca700b22015-10-20 14:47:00 +02005570run_test "ECJPAKE: working, DTLS, nolog" \
5571 "$P_SRV dtls=1 ecjpake_pw=bla" \
5572 "$P_CLI dtls=1 ecjpake_pw=bla \
5573 force_ciphersuite=TLS-ECJPAKE-WITH-AES-128-CCM-8" \
5574 0
5575
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005576# Tests for ciphersuites per version
5577
Manuel Pégourié-Gonnardaa946b22019-03-01 10:14:58 +01005578requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
5579requires_config_enabled MBEDTLS_CAMELLIA_C
5580requires_config_enabled MBEDTLS_AES_C
Manuel Pégourié-Gonnard8e03c712014-08-30 21:42:40 +02005581run_test "Per-version suites: TLS 1.2" \
Mateusz Starzyk06b07fb2021-02-18 13:55:21 +01005582 "$P_SRV version_suites=TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005583 "$P_CLI force_version=tls1_2" \
5584 0 \
5585 -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"
5586
Manuel Pégourié-Gonnard4cc8c632015-07-23 12:24:03 +02005587# Test for ClientHello without extensions
5588
Manuel Pégourié-Gonnardd55bc202015-08-04 16:22:30 +02005589requires_gnutls
Manuel Pégourié-Gonnardbc4da292020-01-30 12:45:14 +01005590run_test "ClientHello without extensions" \
Manuel Pégourié-Gonnard77cbeff2020-01-30 10:58:57 +01005591 "$P_SRV debug_level=3" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02005592 "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \
Gilles Peskine5d2511c2017-05-12 13:16:40 +02005593 0 \
5594 -s "dumping 'client hello extensions' (0 bytes)"
5595
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005596# Tests for mbedtls_ssl_get_bytes_avail()
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005597
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005598run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005599 "$P_SRV" \
5600 "$P_CLI request_size=100" \
5601 0 \
5602 -s "Read from client: 100 bytes read$"
5603
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02005604run_test "mbedtls_ssl_get_bytes_avail: extra data" \
Manuel Pégourié-Gonnard95c0a632014-06-11 18:32:36 +02005605 "$P_SRV" \
5606 "$P_CLI request_size=500" \
5607 0 \
5608 -s "Read from client: 500 bytes read (.*+.*)"
Manuel Pégourié-Gonnard90805a82014-06-11 14:06:01 +02005609
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005610# Tests for small client packets
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005611
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005612run_test "Small client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005613 "$P_SRV" \
5614 "$P_CLI request_size=1 force_version=tls1_2 \
5615 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5616 0 \
5617 -s "Read from client: 1 bytes read"
5618
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005619run_test "Small client packet TLS 1.2 BlockCipher, without EtM" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005620 "$P_SRV" \
Hanno Becker8501f982017-11-10 08:59:04 +00005621 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005622 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
Manuel Pégourié-Gonnard169dd6a2014-11-04 16:15:39 +01005623 0 \
5624 -s "Read from client: 1 bytes read"
5625
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005626run_test "Small client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005627 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005628 "$P_CLI request_size=1 force_version=tls1_2 \
5629 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005630 0 \
5631 -s "Read from client: 1 bytes read"
5632
Hanno Becker32c55012017-11-10 08:42:54 +00005633requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005634run_test "Small client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005635 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005636 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005637 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005638 0 \
5639 -s "Read from client: 1 bytes read"
5640
Hanno Becker8501f982017-11-10 08:59:04 +00005641requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005642run_test "Small client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005643 "$P_SRV trunc_hmac=1" \
Hanno Becker8501f982017-11-10 08:59:04 +00005644 "$P_CLI request_size=1 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005645 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005646 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 AEAD" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005650 "$P_SRV" \
5651 "$P_CLI request_size=1 force_version=tls1_2 \
5652 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5653 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 AEAD shorter tag" \
Manuel Pégourié-Gonnardee415032014-06-18 15:08:56 +02005657 "$P_SRV" \
5658 "$P_CLI request_size=1 force_version=tls1_2 \
5659 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5660 0 \
5661 -s "Read from client: 1 bytes read"
5662
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005663# Tests for small client packets in DTLS
Hanno Beckere2148042017-11-10 08:59:18 +00005664
5665requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005666run_test "Small client packet DTLS 1.2" \
Hanno Beckere2148042017-11-10 08:59:18 +00005667 "$P_SRV dtls=1 force_version=dtls1_2" \
5668 "$P_CLI dtls=1 request_size=1 \
5669 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5670 0 \
5671 -s "Read from client: 1 bytes read"
5672
5673requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005674run_test "Small client packet DTLS 1.2, without EtM" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005675 "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005676 "$P_CLI dtls=1 request_size=1 \
5677 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5678 0 \
5679 -s "Read from client: 1 bytes read"
5680
5681requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5682requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005683run_test "Small client packet DTLS 1.2, truncated hmac" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005684 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005685 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005686 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Hanno Beckere2148042017-11-10 08:59:18 +00005687 0 \
5688 -s "Read from client: 1 bytes read"
5689
5690requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5691requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005692run_test "Small client packet DTLS 1.2, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005693 "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
Hanno Beckere2148042017-11-10 08:59:18 +00005694 "$P_CLI dtls=1 request_size=1 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005695 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
Hanno Beckere2148042017-11-10 08:59:18 +00005696 0 \
5697 -s "Read from client: 1 bytes read"
5698
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005699# Tests for small server packets
5700
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005701run_test "Small server packet TLS 1.2 BlockCipher" \
5702 "$P_SRV response_size=1" \
5703 "$P_CLI force_version=tls1_2 \
5704 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5705 0 \
5706 -c "Read from server: 1 bytes read"
5707
5708run_test "Small server packet TLS 1.2 BlockCipher, without EtM" \
5709 "$P_SRV response_size=1" \
5710 "$P_CLI force_version=tls1_2 \
5711 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
5712 0 \
5713 -c "Read from server: 1 bytes read"
5714
5715run_test "Small server packet TLS 1.2 BlockCipher larger MAC" \
5716 "$P_SRV response_size=1" \
5717 "$P_CLI force_version=tls1_2 \
5718 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5719 0 \
5720 -c "Read from server: 1 bytes read"
5721
5722requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5723run_test "Small server packet TLS 1.2 BlockCipher, truncated MAC" \
5724 "$P_SRV response_size=1 trunc_hmac=1" \
5725 "$P_CLI force_version=tls1_2 \
5726 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5727 0 \
5728 -c "Read from server: 1 bytes read"
5729
5730requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5731run_test "Small server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5732 "$P_SRV response_size=1 trunc_hmac=1" \
5733 "$P_CLI force_version=tls1_2 \
5734 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5735 0 \
5736 -c "Read from server: 1 bytes read"
5737
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005738run_test "Small server packet TLS 1.2 AEAD" \
5739 "$P_SRV response_size=1" \
5740 "$P_CLI force_version=tls1_2 \
5741 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5742 0 \
5743 -c "Read from server: 1 bytes read"
5744
5745run_test "Small server packet TLS 1.2 AEAD shorter tag" \
5746 "$P_SRV response_size=1" \
5747 "$P_CLI force_version=tls1_2 \
5748 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5749 0 \
5750 -c "Read from server: 1 bytes read"
5751
5752# Tests for small server packets in DTLS
5753
5754requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005755run_test "Small server packet DTLS 1.2" \
5756 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2" \
5757 "$P_CLI dtls=1 \
5758 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5759 0 \
5760 -c "Read from server: 1 bytes read"
5761
5762requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5763run_test "Small server packet DTLS 1.2, without EtM" \
5764 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 etm=0" \
5765 "$P_CLI dtls=1 \
5766 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5767 0 \
5768 -c "Read from server: 1 bytes read"
5769
5770requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5771requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5772run_test "Small server packet DTLS 1.2, truncated hmac" \
5773 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1" \
5774 "$P_CLI dtls=1 \
5775 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
5776 0 \
5777 -c "Read from server: 1 bytes read"
5778
5779requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
5780requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5781run_test "Small server packet DTLS 1.2, without EtM, truncated MAC" \
5782 "$P_SRV dtls=1 response_size=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
5783 "$P_CLI dtls=1 \
5784 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
5785 0 \
5786 -c "Read from server: 1 bytes read"
5787
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005788# Test for large client packets
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005789
Angus Grattonc4dd0732018-04-11 16:28:39 +10005790# How many fragments do we expect to write $1 bytes?
5791fragments_for_write() {
5792 echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))"
5793}
5794
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005795run_test "Large client packet TLS 1.2 BlockCipher" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005796 "$P_SRV" \
5797 "$P_CLI request_size=16384 force_version=tls1_2 \
5798 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5799 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005800 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5801 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005802
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005803run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005804 "$P_SRV" \
5805 "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
5806 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5807 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005808 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Hanno Becker278fc7a2017-11-10 09:16:28 +00005809
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005810run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005811 "$P_SRV" \
Manuel Pégourié-Gonnardc82ee352015-01-07 16:35:25 +01005812 "$P_CLI request_size=16384 force_version=tls1_2 \
5813 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005814 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005815 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5816 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005817
Hanno Becker32c55012017-11-10 08:42:54 +00005818requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005819run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005820 "$P_SRV trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005821 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005822 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005823 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005824 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005825
Hanno Becker278fc7a2017-11-10 09:16:28 +00005826requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005827run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
Hanno Becker909f9a32017-11-21 17:10:12 +00005828 "$P_SRV trunc_hmac=1" \
Hanno Becker278fc7a2017-11-10 09:16:28 +00005829 "$P_CLI request_size=16384 force_version=tls1_2 \
Hanno Becker909f9a32017-11-21 17:10:12 +00005830 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005831 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005832 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5833 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005834
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005835run_test "Large client packet TLS 1.2 AEAD" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005836 "$P_SRV" \
5837 "$P_CLI request_size=16384 force_version=tls1_2 \
5838 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5839 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005840 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5841 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005842
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005843run_test "Large client packet TLS 1.2 AEAD shorter tag" \
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005844 "$P_SRV" \
5845 "$P_CLI request_size=16384 force_version=tls1_2 \
5846 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5847 0 \
Angus Grattonc4dd0732018-04-11 16:28:39 +10005848 -c "16384 bytes written in $(fragments_for_write 16384) fragments" \
5849 -s "Read from client: $MAX_CONTENT_LEN bytes read"
Manuel Pégourié-Gonnard8920f692014-06-18 22:05:08 +02005850
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005851run_test "Large server packet TLS 1.2 BlockCipher" \
5852 "$P_SRV response_size=16384" \
5853 "$P_CLI force_version=tls1_2 \
5854 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5855 0 \
5856 -c "Read from server: 16384 bytes read"
5857
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005858run_test "Large server packet TLS 1.2 BlockCipher, without EtM" \
5859 "$P_SRV response_size=16384" \
5860 "$P_CLI force_version=tls1_2 etm=0 \
5861 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
5862 0 \
5863 -s "16384 bytes written in 1 fragments" \
5864 -c "Read from server: 16384 bytes read"
5865
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005866run_test "Large server packet TLS 1.2 BlockCipher larger MAC" \
5867 "$P_SRV response_size=16384" \
5868 "$P_CLI force_version=tls1_2 \
5869 force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
5870 0 \
5871 -c "Read from server: 16384 bytes read"
5872
5873requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
5874run_test "Large server packet TLS 1.2 BlockCipher truncated MAC" \
5875 "$P_SRV response_size=16384" \
5876 "$P_CLI force_version=tls1_2 \
5877 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
5878 trunc_hmac=1" \
5879 0 \
5880 -c "Read from server: 16384 bytes read"
5881
Andrzej Kurekc19fc552018-06-19 09:37:30 -04005882run_test "Large server packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
5883 "$P_SRV response_size=16384 trunc_hmac=1" \
5884 "$P_CLI force_version=tls1_2 \
5885 force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
5886 0 \
5887 -s "16384 bytes written in 1 fragments" \
5888 -c "Read from server: 16384 bytes read"
5889
Andrzej Kurek30e731d2017-10-12 13:50:29 +02005890run_test "Large server packet TLS 1.2 AEAD" \
5891 "$P_SRV response_size=16384" \
5892 "$P_CLI force_version=tls1_2 \
5893 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
5894 0 \
5895 -c "Read from server: 16384 bytes read"
5896
5897run_test "Large server packet TLS 1.2 AEAD shorter tag" \
5898 "$P_SRV response_size=16384" \
5899 "$P_CLI force_version=tls1_2 \
5900 force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
5901 0 \
5902 -c "Read from server: 16384 bytes read"
5903
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005904# Tests for restartable ECC
5905
5906requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5907run_test "EC restart: TLS, default" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005908 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005909 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005910 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005911 debug_level=1" \
5912 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005913 -C "x509_verify_cert.*4b00" \
5914 -C "mbedtls_pk_verify.*4b00" \
5915 -C "mbedtls_ecdh_make_public.*4b00" \
5916 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005917
5918requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5919run_test "EC restart: TLS, max_ops=0" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005920 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005921 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005922 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005923 debug_level=1 ec_max_ops=0" \
5924 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005925 -C "x509_verify_cert.*4b00" \
5926 -C "mbedtls_pk_verify.*4b00" \
5927 -C "mbedtls_ecdh_make_public.*4b00" \
5928 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005929
5930requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5931run_test "EC restart: TLS, max_ops=65535" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005932 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005933 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005934 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005935 debug_level=1 ec_max_ops=65535" \
5936 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005937 -C "x509_verify_cert.*4b00" \
5938 -C "mbedtls_pk_verify.*4b00" \
5939 -C "mbedtls_ecdh_make_public.*4b00" \
5940 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005941
5942requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5943run_test "EC restart: TLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005944 "$P_SRV auth_mode=required" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005945 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02005946 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005947 debug_level=1 ec_max_ops=1000" \
5948 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005949 -c "x509_verify_cert.*4b00" \
5950 -c "mbedtls_pk_verify.*4b00" \
5951 -c "mbedtls_ecdh_make_public.*4b00" \
5952 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02005953
5954requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005955run_test "EC restart: TLS, max_ops=1000, badsign" \
5956 "$P_SRV auth_mode=required \
5957 crt_file=data_files/server5-badsign.crt \
5958 key_file=data_files/server5.key" \
5959 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5960 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5961 debug_level=1 ec_max_ops=1000" \
5962 1 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005963 -c "x509_verify_cert.*4b00" \
5964 -C "mbedtls_pk_verify.*4b00" \
5965 -C "mbedtls_ecdh_make_public.*4b00" \
5966 -C "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005967 -c "! The certificate is not correctly signed by the trusted CA" \
5968 -c "! mbedtls_ssl_handshake returned" \
5969 -c "X509 - Certificate verification failed"
5970
5971requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5972run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \
5973 "$P_SRV auth_mode=required \
5974 crt_file=data_files/server5-badsign.crt \
5975 key_file=data_files/server5.key" \
5976 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5977 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5978 debug_level=1 ec_max_ops=1000 auth_mode=optional" \
5979 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005980 -c "x509_verify_cert.*4b00" \
5981 -c "mbedtls_pk_verify.*4b00" \
5982 -c "mbedtls_ecdh_make_public.*4b00" \
5983 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02005984 -c "! The certificate is not correctly signed by the trusted CA" \
5985 -C "! mbedtls_ssl_handshake returned" \
5986 -C "X509 - Certificate verification failed"
5987
5988requires_config_enabled MBEDTLS_ECP_RESTARTABLE
5989run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \
5990 "$P_SRV auth_mode=required \
5991 crt_file=data_files/server5-badsign.crt \
5992 key_file=data_files/server5.key" \
5993 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
5994 key_file=data_files/server5.key crt_file=data_files/server5.crt \
5995 debug_level=1 ec_max_ops=1000 auth_mode=none" \
5996 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02005997 -C "x509_verify_cert.*4b00" \
5998 -c "mbedtls_pk_verify.*4b00" \
5999 -c "mbedtls_ecdh_make_public.*4b00" \
6000 -c "mbedtls_pk_sign.*4b00" \
Manuel Pégourié-Gonnard3bf49c42017-08-15 13:47:06 +02006001 -C "! The certificate is not correctly signed by the trusted CA" \
6002 -C "! mbedtls_ssl_handshake returned" \
6003 -C "X509 - Certificate verification failed"
6004
6005requires_config_enabled MBEDTLS_ECP_RESTARTABLE
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006006run_test "EC restart: DTLS, max_ops=1000" \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006007 "$P_SRV auth_mode=required dtls=1" \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006008 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard862cde52017-05-17 11:56:15 +02006009 key_file=data_files/server5.key crt_file=data_files/server5.crt \
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006010 dtls=1 debug_level=1 ec_max_ops=1000" \
6011 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006012 -c "x509_verify_cert.*4b00" \
6013 -c "mbedtls_pk_verify.*4b00" \
6014 -c "mbedtls_ecdh_make_public.*4b00" \
6015 -c "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard2350b4e2017-05-16 09:26:48 +02006016
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006017requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6018run_test "EC restart: TLS, max_ops=1000 no client auth" \
6019 "$P_SRV" \
6020 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6021 debug_level=1 ec_max_ops=1000" \
6022 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006023 -c "x509_verify_cert.*4b00" \
6024 -c "mbedtls_pk_verify.*4b00" \
6025 -c "mbedtls_ecdh_make_public.*4b00" \
6026 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006027
6028requires_config_enabled MBEDTLS_ECP_RESTARTABLE
6029run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \
6030 "$P_SRV psk=abc123" \
6031 "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \
6032 psk=abc123 debug_level=1 ec_max_ops=1000" \
6033 0 \
Manuel Pégourié-Gonnardb5d668a2018-06-13 11:22:01 +02006034 -C "x509_verify_cert.*4b00" \
6035 -C "mbedtls_pk_verify.*4b00" \
6036 -C "mbedtls_ecdh_make_public.*4b00" \
6037 -C "mbedtls_pk_sign.*4b00"
Manuel Pégourié-Gonnard32033da2017-05-18 12:49:27 +02006038
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006039# Tests of asynchronous private key support in SSL
6040
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006041requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006042run_test "SSL async private: sign, delay=0" \
6043 "$P_SRV \
6044 async_operations=s async_private_delay1=0 async_private_delay2=0" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006045 "$P_CLI" \
6046 0 \
6047 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006048 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006049
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006050requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006051run_test "SSL async private: sign, delay=1" \
6052 "$P_SRV \
6053 async_operations=s async_private_delay1=1 async_private_delay2=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006054 "$P_CLI" \
6055 0 \
6056 -s "Async sign callback: using key slot " \
6057 -s "Async resume (slot [0-9]): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006058 -s "Async resume (slot [0-9]): sign done, status=0"
6059
Gilles Peskine12d0cc12018-04-26 15:06:56 +02006060requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6061run_test "SSL async private: sign, delay=2" \
6062 "$P_SRV \
6063 async_operations=s async_private_delay1=2 async_private_delay2=2" \
6064 "$P_CLI" \
6065 0 \
6066 -s "Async sign callback: using key slot " \
6067 -U "Async sign callback: using key slot " \
6068 -s "Async resume (slot [0-9]): call 1 more times." \
6069 -s "Async resume (slot [0-9]): call 0 more times." \
6070 -s "Async resume (slot [0-9]): sign done, status=0"
6071
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006072requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Hanno Beckerc5722d12020-10-09 11:10:42 +01006073requires_config_disabled MBEDTLS_X509_REMOVE_INFO
Gilles Peskine807d74a2018-04-30 10:30:49 +02006074run_test "SSL async private: sign, SNI" \
6075 "$P_SRV debug_level=3 \
6076 async_operations=s async_private_delay1=0 async_private_delay2=0 \
6077 crt_file=data_files/server5.crt key_file=data_files/server5.key \
6078 sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \
6079 "$P_CLI server_name=polarssl.example" \
6080 0 \
6081 -s "Async sign callback: using key slot " \
6082 -s "Async resume (slot [0-9]): sign done, status=0" \
6083 -s "parse ServerName extension" \
6084 -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \
6085 -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example"
6086
6087requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006088run_test "SSL async private: decrypt, delay=0" \
6089 "$P_SRV \
6090 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6091 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6092 0 \
6093 -s "Async decrypt callback: using key slot " \
6094 -s "Async resume (slot [0-9]): decrypt done, status=0"
6095
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006096requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006097run_test "SSL async private: decrypt, delay=1" \
6098 "$P_SRV \
6099 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6100 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6101 0 \
6102 -s "Async decrypt callback: using key slot " \
6103 -s "Async resume (slot [0-9]): call 0 more times." \
6104 -s "Async resume (slot [0-9]): decrypt done, status=0"
6105
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006106requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006107run_test "SSL async private: decrypt RSA-PSK, delay=0" \
6108 "$P_SRV psk=abc123 \
6109 async_operations=d async_private_delay1=0 async_private_delay2=0" \
6110 "$P_CLI psk=abc123 \
6111 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6112 0 \
6113 -s "Async decrypt callback: using key slot " \
6114 -s "Async resume (slot [0-9]): decrypt done, status=0"
6115
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006116requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006117run_test "SSL async private: decrypt RSA-PSK, delay=1" \
6118 "$P_SRV psk=abc123 \
6119 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6120 "$P_CLI psk=abc123 \
6121 force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \
6122 0 \
6123 -s "Async decrypt callback: using key slot " \
6124 -s "Async resume (slot [0-9]): call 0 more times." \
6125 -s "Async resume (slot [0-9]): decrypt done, status=0"
6126
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006127requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006128run_test "SSL async private: sign callback not present" \
6129 "$P_SRV \
6130 async_operations=d async_private_delay1=1 async_private_delay2=1" \
6131 "$P_CLI; [ \$? -eq 1 ] &&
6132 $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6133 0 \
6134 -S "Async sign callback" \
6135 -s "! mbedtls_ssl_handshake returned" \
6136 -s "The own private key or pre-shared key is not set, but needed" \
6137 -s "Async resume (slot [0-9]): decrypt done, status=0" \
6138 -s "Successful connection"
6139
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006140requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006141run_test "SSL async private: decrypt callback not present" \
6142 "$P_SRV debug_level=1 \
6143 async_operations=s async_private_delay1=1 async_private_delay2=1" \
6144 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA;
6145 [ \$? -eq 1 ] && $P_CLI" \
6146 0 \
6147 -S "Async decrypt callback" \
6148 -s "! mbedtls_ssl_handshake returned" \
6149 -s "got no RSA private key" \
6150 -s "Async resume (slot [0-9]): sign done, status=0" \
6151 -s "Successful connection"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006152
6153# key1: ECDSA, key2: RSA; use key1 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006154requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006155run_test "SSL async private: slot 0 used with key1" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006156 "$P_SRV \
6157 async_operations=s async_private_delay1=1 \
6158 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6159 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006160 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6161 0 \
6162 -s "Async sign callback: using key slot 0," \
6163 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006164 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006165
6166# key1: ECDSA, key2: RSA; use key2 from slot 0
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006167requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006168run_test "SSL async private: slot 0 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006169 "$P_SRV \
6170 async_operations=s async_private_delay2=1 \
6171 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6172 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006173 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6174 0 \
6175 -s "Async sign callback: using key slot 0," \
6176 -s "Async resume (slot 0): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006177 -s "Async resume (slot 0): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006178
6179# key1: ECDSA, key2: RSA; use key2 from slot 1
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006180requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinead28bf02018-04-26 00:19:16 +02006181run_test "SSL async private: slot 1 used with key2" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006182 "$P_SRV \
Gilles Peskine168dae82018-04-25 23:35:42 +02006183 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006184 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6185 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006186 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6187 0 \
6188 -s "Async sign callback: using key slot 1," \
6189 -s "Async resume (slot 1): call 0 more times." \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006190 -s "Async resume (slot 1): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006191
6192# key1: ECDSA, key2: RSA; use key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006193requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006194run_test "SSL async private: fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006195 "$P_SRV \
6196 async_operations=s async_private_delay1=1 \
6197 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6198 key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006199 "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6200 0 \
6201 -s "Async sign callback: no key matches this certificate."
6202
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006203requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006204run_test "SSL async private: sign, error in start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006205 "$P_SRV \
6206 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6207 async_private_error=1" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006208 "$P_CLI" \
6209 1 \
6210 -s "Async sign callback: injected error" \
6211 -S "Async resume" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006212 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006213 -s "! mbedtls_ssl_handshake returned"
6214
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006215requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006216run_test "SSL async private: sign, cancel after start" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006217 "$P_SRV \
6218 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6219 async_private_error=2" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006220 "$P_CLI" \
6221 1 \
6222 -s "Async sign callback: using key slot " \
6223 -S "Async resume" \
6224 -s "Async cancel"
6225
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006226requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006227run_test "SSL async private: sign, error in resume" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006228 "$P_SRV \
6229 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6230 async_private_error=3" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006231 "$P_CLI" \
6232 1 \
6233 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006234 -s "Async resume callback: sign done but injected error" \
Gilles Peskine37289cd2018-04-27 11:50:14 +02006235 -S "Async cancel" \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006236 -s "! mbedtls_ssl_handshake returned"
6237
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006238requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006239run_test "SSL async private: decrypt, error in start" \
6240 "$P_SRV \
6241 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6242 async_private_error=1" \
6243 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6244 1 \
6245 -s "Async decrypt callback: injected error" \
6246 -S "Async resume" \
6247 -S "Async cancel" \
6248 -s "! mbedtls_ssl_handshake returned"
6249
6250requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6251run_test "SSL async private: decrypt, cancel after start" \
6252 "$P_SRV \
6253 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6254 async_private_error=2" \
6255 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6256 1 \
6257 -s "Async decrypt callback: using key slot " \
6258 -S "Async resume" \
6259 -s "Async cancel"
6260
6261requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
6262run_test "SSL async private: decrypt, error in resume" \
6263 "$P_SRV \
6264 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6265 async_private_error=3" \
6266 "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6267 1 \
6268 -s "Async decrypt callback: using key slot " \
6269 -s "Async resume callback: decrypt done but injected error" \
6270 -S "Async cancel" \
6271 -s "! mbedtls_ssl_handshake returned"
6272
6273requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006274run_test "SSL async private: cancel after start then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006275 "$P_SRV \
6276 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6277 async_private_error=-2" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006278 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6279 0 \
6280 -s "Async cancel" \
6281 -s "! mbedtls_ssl_handshake returned" \
6282 -s "Async resume" \
6283 -s "Successful connection"
6284
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006285requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006286run_test "SSL async private: error in resume then operate correctly" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006287 "$P_SRV \
6288 async_operations=s async_private_delay1=1 async_private_delay2=1 \
6289 async_private_error=-3" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006290 "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \
6291 0 \
6292 -s "! mbedtls_ssl_handshake returned" \
6293 -s "Async resume" \
6294 -s "Successful connection"
6295
6296# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006297requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006298run_test "SSL async private: cancel after start then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006299 "$P_SRV \
6300 async_operations=s async_private_delay1=1 async_private_error=-2 \
6301 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6302 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006303 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6304 [ \$? -eq 1 ] &&
6305 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6306 0 \
Gilles Peskinededa75a2018-04-30 10:02:45 +02006307 -s "Async sign callback: using key slot 0" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006308 -S "Async resume" \
6309 -s "Async cancel" \
6310 -s "! mbedtls_ssl_handshake returned" \
6311 -s "Async sign callback: no key matches this certificate." \
6312 -s "Successful connection"
6313
6314# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006315requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine725f1cb2018-06-12 15:06:40 +02006316run_test "SSL async private: sign, error in resume then fall back to transparent key" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006317 "$P_SRV \
6318 async_operations=s async_private_delay1=1 async_private_error=-3 \
6319 key_file=data_files/server5.key crt_file=data_files/server5.crt \
6320 key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \
Gilles Peskine60ee4ca2018-01-08 11:28:05 +01006321 "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256;
6322 [ \$? -eq 1 ] &&
6323 $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \
6324 0 \
6325 -s "Async resume" \
6326 -s "! mbedtls_ssl_handshake returned" \
6327 -s "Async sign callback: no key matches this certificate." \
6328 -s "Successful connection"
6329
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006330requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006331requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006332run_test "SSL async private: renegotiation: client-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006333 "$P_SRV \
6334 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006335 exchanges=2 renegotiation=1" \
6336 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \
6337 0 \
6338 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006339 -s "Async resume (slot [0-9]): sign done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006340
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006341requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006342requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006343run_test "SSL async private: renegotiation: server-initiated, sign" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006344 "$P_SRV \
6345 async_operations=s async_private_delay1=1 async_private_delay2=1 \
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006346 exchanges=2 renegotiation=1 renegotiate=1" \
6347 "$P_CLI exchanges=2 renegotiation=1" \
6348 0 \
6349 -s "Async sign callback: using key slot " \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006350 -s "Async resume (slot [0-9]): sign done, status=0"
6351
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006352requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006353requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006354run_test "SSL async private: renegotiation: client-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006355 "$P_SRV \
6356 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6357 exchanges=2 renegotiation=1" \
6358 "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \
6359 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6360 0 \
6361 -s "Async decrypt callback: using key slot " \
6362 -s "Async resume (slot [0-9]): decrypt done, status=0"
6363
Gilles Peskineb74a1c72018-04-24 13:09:22 +02006364requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006365requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine654bab72019-09-16 15:19:20 +02006366run_test "SSL async private: renegotiation: server-initiated, decrypt" \
Gilles Peskinefcca9d82018-01-12 13:47:48 +01006367 "$P_SRV \
6368 async_operations=d async_private_delay1=1 async_private_delay2=1 \
6369 exchanges=2 renegotiation=1 renegotiate=1" \
6370 "$P_CLI exchanges=2 renegotiation=1 \
6371 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
6372 0 \
6373 -s "Async decrypt callback: using key slot " \
6374 -s "Async resume (slot [0-9]): decrypt done, status=0"
Gilles Peskine3665f1d2018-01-05 21:22:12 +01006375
Ron Eldor58093c82018-06-28 13:22:05 +03006376# Tests for ECC extensions (rfc 4492)
6377
Ron Eldor643df7c2018-06-28 16:17:00 +03006378requires_config_enabled MBEDTLS_AES_C
6379requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6380requires_config_enabled MBEDTLS_SHA256_C
6381requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006382run_test "Force a non ECC ciphersuite in the client side" \
6383 "$P_SRV debug_level=3" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006384 "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006385 0 \
6386 -C "client hello, adding supported_elliptic_curves extension" \
6387 -C "client hello, adding supported_point_formats extension" \
6388 -S "found supported elliptic curves extension" \
6389 -S "found supported point formats extension"
6390
Ron Eldor643df7c2018-06-28 16:17:00 +03006391requires_config_enabled MBEDTLS_AES_C
6392requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6393requires_config_enabled MBEDTLS_SHA256_C
6394requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006395run_test "Force a non ECC ciphersuite in the server side" \
Ron Eldor643df7c2018-06-28 16:17:00 +03006396 "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \
Ron Eldor58093c82018-06-28 13:22:05 +03006397 "$P_CLI debug_level=3" \
6398 0 \
6399 -C "found supported_point_formats extension" \
6400 -S "server hello, supported_point_formats extension"
6401
Ron Eldor643df7c2018-06-28 16:17:00 +03006402requires_config_enabled MBEDTLS_AES_C
6403requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6404requires_config_enabled MBEDTLS_SHA256_C
6405requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006406run_test "Force an ECC ciphersuite in the client side" \
6407 "$P_SRV debug_level=3" \
6408 "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6409 0 \
6410 -c "client hello, adding supported_elliptic_curves extension" \
6411 -c "client hello, adding supported_point_formats extension" \
6412 -s "found supported elliptic curves extension" \
6413 -s "found supported point formats extension"
6414
Ron Eldor643df7c2018-06-28 16:17:00 +03006415requires_config_enabled MBEDTLS_AES_C
6416requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
6417requires_config_enabled MBEDTLS_SHA256_C
6418requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
Ron Eldor58093c82018-06-28 13:22:05 +03006419run_test "Force an ECC ciphersuite in the server side" \
6420 "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \
6421 "$P_CLI debug_level=3" \
6422 0 \
6423 -c "found supported_point_formats extension" \
6424 -s "server hello, supported_point_formats extension"
6425
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006426# Tests for DTLS HelloVerifyRequest
6427
6428run_test "DTLS cookie: enabled" \
6429 "$P_SRV dtls=1 debug_level=2" \
6430 "$P_CLI dtls=1 debug_level=2" \
6431 0 \
6432 -s "cookie verification failed" \
6433 -s "cookie verification passed" \
6434 -S "cookie verification skipped" \
6435 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006436 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006437 -S "SSL - The requested feature is not available"
6438
6439run_test "DTLS cookie: disabled" \
6440 "$P_SRV dtls=1 debug_level=2 cookies=0" \
6441 "$P_CLI dtls=1 debug_level=2" \
6442 0 \
6443 -S "cookie verification failed" \
6444 -S "cookie verification passed" \
6445 -s "cookie verification skipped" \
6446 -C "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006447 -S "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006448 -S "SSL - The requested feature is not available"
6449
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006450run_test "DTLS cookie: default (failing)" \
6451 "$P_SRV dtls=1 debug_level=2 cookies=-1" \
6452 "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \
6453 1 \
6454 -s "cookie verification failed" \
6455 -S "cookie verification passed" \
6456 -S "cookie verification skipped" \
6457 -C "received hello verify request" \
6458 -S "hello verification requested" \
6459 -s "SSL - The requested feature is not available"
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006460
6461requires_ipv6
6462run_test "DTLS cookie: enabled, IPv6" \
6463 "$P_SRV dtls=1 debug_level=2 server_addr=::1" \
6464 "$P_CLI dtls=1 debug_level=2 server_addr=::1" \
6465 0 \
6466 -s "cookie verification failed" \
6467 -s "cookie verification passed" \
6468 -S "cookie verification skipped" \
6469 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006470 -s "hello verification requested" \
Manuel Pégourié-Gonnard0eb6cab2014-07-23 20:17:47 +02006471 -S "SSL - The requested feature is not available"
6472
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006473run_test "DTLS cookie: enabled, nbio" \
6474 "$P_SRV dtls=1 nbio=2 debug_level=2" \
6475 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6476 0 \
6477 -s "cookie verification failed" \
6478 -s "cookie verification passed" \
6479 -S "cookie verification skipped" \
6480 -c "received hello verify request" \
Manuel Pégourié-Gonnardcaecdae2014-10-13 19:04:37 +02006481 -s "hello verification requested" \
Manuel Pégourié-Gonnard579950c2014-09-29 17:47:33 +02006482 -S "SSL - The requested feature is not available"
6483
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006484# Tests for client reconnecting from the same port with DTLS
6485
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006486not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006487run_test "DTLS client reconnect from same port: reference" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02006488 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
6489 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006490 0 \
6491 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006492 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006493 -S "Client initiated reconnection from same port"
6494
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006495not_with_valgrind # spurious resend
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006496run_test "DTLS client reconnect from same port: reconnect" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02006497 "$P_SRV dtls=1 exchanges=2 read_timeout=20000 hs_timeout=10000-20000" \
6498 "$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 +02006499 0 \
6500 -C "resend" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006501 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006502 -s "Client initiated reconnection from same port"
6503
Paul Bakker362689d2016-05-13 10:33:25 +01006504not_with_valgrind # server/client too slow to respond in time (next test has higher timeouts)
6505run_test "DTLS client reconnect from same port: reconnect, nbio, no valgrind" \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006506 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 nbio=2" \
6507 "$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 +02006508 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006509 -S "The operation timed out" \
Manuel Pégourié-Gonnardd745a1a2015-09-08 12:40:43 +02006510 -s "Client initiated reconnection from same port"
6511
Paul Bakker362689d2016-05-13 10:33:25 +01006512only_with_valgrind # Only with valgrind, do previous test but with higher read_timeout and hs_timeout
6513run_test "DTLS client reconnect from same port: reconnect, nbio, valgrind" \
6514 "$P_SRV dtls=1 exchanges=2 read_timeout=2000 nbio=2 hs_timeout=1500-6000" \
6515 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=1500-3000 reconnect_hard=1" \
6516 0 \
6517 -S "The operation timed out" \
6518 -s "Client initiated reconnection from same port"
6519
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006520run_test "DTLS client reconnect from same port: no cookies" \
6521 "$P_SRV dtls=1 exchanges=2 read_timeout=1000 cookies=0" \
Manuel Pégourié-Gonnard6ad23b92015-09-15 12:57:46 +02006522 "$P_CLI dtls=1 exchanges=2 debug_level=2 hs_timeout=500-8000 reconnect_hard=1" \
6523 0 \
Manuel Pégourié-Gonnard259db912015-09-09 11:37:17 +02006524 -s "The operation timed out" \
6525 -S "Client initiated reconnection from same port"
6526
Manuel Pégourié-Gonnardbaad2de2020-03-13 11:11:02 +01006527run_test "DTLS client reconnect from same port: attacker-injected" \
6528 -p "$P_PXY inject_clihlo=1" \
6529 "$P_SRV dtls=1 exchanges=2 debug_level=1" \
6530 "$P_CLI dtls=1 exchanges=2" \
6531 0 \
6532 -s "possible client reconnect from the same port" \
6533 -S "Client initiated reconnection from same port"
6534
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006535# Tests for various cases of client authentication with DTLS
6536# (focused on handshake flows and message parsing)
6537
6538run_test "DTLS client auth: required" \
6539 "$P_SRV dtls=1 auth_mode=required" \
6540 "$P_CLI dtls=1" \
6541 0 \
6542 -s "Verifying peer X.509 certificate... ok"
6543
6544run_test "DTLS client auth: optional, client has no cert" \
6545 "$P_SRV dtls=1 auth_mode=optional" \
6546 "$P_CLI dtls=1 crt_file=none key_file=none" \
6547 0 \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006548 -s "! Certificate was missing"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006549
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006550run_test "DTLS client auth: none, client has no cert" \
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006551 "$P_SRV dtls=1 auth_mode=none" \
6552 "$P_CLI dtls=1 crt_file=none key_file=none debug_level=2" \
6553 0 \
6554 -c "skip write certificate$" \
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +01006555 -s "! Certificate verification was skipped"
Manuel Pégourié-Gonnard08a1d4b2014-09-26 10:35:50 +02006556
Manuel Pégourié-Gonnard0a885742015-08-04 12:08:35 +02006557run_test "DTLS wrong PSK: badmac alert" \
6558 "$P_SRV dtls=1 psk=abc123 force_ciphersuite=TLS-PSK-WITH-AES-128-GCM-SHA256" \
6559 "$P_CLI dtls=1 psk=abc124" \
6560 1 \
6561 -s "SSL - Verification of the message MAC failed" \
6562 -c "SSL - A fatal alert message was received from our peer"
6563
Manuel Pégourié-Gonnard502bf302014-08-20 13:12:58 +02006564# Tests for receiving fragmented handshake messages with DTLS
6565
6566requires_gnutls
6567run_test "DTLS reassembly: no fragmentation (gnutls server)" \
6568 "$G_SRV -u --mtu 2048 -a" \
6569 "$P_CLI dtls=1 debug_level=2" \
6570 0 \
6571 -C "found fragmented DTLS handshake message" \
6572 -C "error"
6573
6574requires_gnutls
6575run_test "DTLS reassembly: some fragmentation (gnutls server)" \
6576 "$G_SRV -u --mtu 512" \
6577 "$P_CLI dtls=1 debug_level=2" \
6578 0 \
6579 -c "found fragmented DTLS handshake message" \
6580 -C "error"
6581
6582requires_gnutls
6583run_test "DTLS reassembly: more fragmentation (gnutls server)" \
6584 "$G_SRV -u --mtu 128" \
6585 "$P_CLI dtls=1 debug_level=2" \
6586 0 \
6587 -c "found fragmented DTLS handshake message" \
6588 -C "error"
6589
6590requires_gnutls
6591run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
6592 "$G_SRV -u --mtu 128" \
6593 "$P_CLI dtls=1 nbio=2 debug_level=2" \
6594 0 \
6595 -c "found fragmented DTLS handshake message" \
6596 -C "error"
6597
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006598requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006599requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006600run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
6601 "$G_SRV -u --mtu 256" \
6602 "$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
6603 0 \
6604 -c "found fragmented DTLS handshake message" \
6605 -c "client hello, adding renegotiation extension" \
6606 -c "found renegotiation extension" \
6607 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006608 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006609 -C "error" \
6610 -s "Extra-header:"
6611
6612requires_gnutls
Hanno Becker6a243642017-10-12 15:18:45 +01006613requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006614run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
6615 "$G_SRV -u --mtu 256" \
6616 "$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
6617 0 \
6618 -c "found fragmented DTLS handshake message" \
6619 -c "client hello, adding renegotiation extension" \
6620 -c "found renegotiation extension" \
6621 -c "=> renegotiate" \
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +02006622 -C "mbedtls_ssl_handshake returned" \
Manuel Pégourié-Gonnard0c4cbc72014-09-02 14:47:31 +02006623 -C "error" \
6624 -s "Extra-header:"
6625
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006626# Tests for sending fragmented handshake messages with DTLS
6627#
6628# Use client auth when we need the client to send large messages,
6629# and use large cert chains on both sides too (the long chains we have all use
6630# both RSA and ECDSA, but ideally we should have long chains with either).
6631# Sizes reached (UDP payload):
6632# - 2037B for server certificate
6633# - 1542B for client certificate
6634# - 1013B for newsessionticket
6635# - all others below 512B
6636# All those tests assume MAX_CONTENT_LEN is at least 2048
6637
6638requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6639requires_config_enabled MBEDTLS_RSA_C
6640requires_config_enabled MBEDTLS_ECDSA_C
6641requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6642run_test "DTLS fragmenting: none (for reference)" \
6643 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6644 crt_file=data_files/server7_int-ca.crt \
6645 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006646 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006647 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006648 "$P_CLI dtls=1 debug_level=2 \
6649 crt_file=data_files/server8_int-ca2.crt \
6650 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006651 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006652 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006653 0 \
6654 -S "found fragmented DTLS handshake message" \
6655 -C "found fragmented DTLS handshake message" \
6656 -C "error"
6657
6658requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6659requires_config_enabled MBEDTLS_RSA_C
6660requires_config_enabled MBEDTLS_ECDSA_C
6661requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006662run_test "DTLS fragmenting: server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006663 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6664 crt_file=data_files/server7_int-ca.crt \
6665 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006666 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006667 max_frag_len=1024" \
6668 "$P_CLI dtls=1 debug_level=2 \
6669 crt_file=data_files/server8_int-ca2.crt \
6670 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006671 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006672 max_frag_len=2048" \
6673 0 \
6674 -S "found fragmented DTLS handshake message" \
6675 -c "found fragmented DTLS handshake message" \
6676 -C "error"
6677
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006678# With the MFL extension, the server has no way of forcing
6679# the client to not exceed a certain MTU; hence, the following
6680# test can't be replicated with an MTU proxy such as the one
6681# `client-initiated, server only (max_frag_len)` below.
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006682requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6683requires_config_enabled MBEDTLS_RSA_C
6684requires_config_enabled MBEDTLS_ECDSA_C
6685requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006686run_test "DTLS fragmenting: server only (more) (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006687 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6688 crt_file=data_files/server7_int-ca.crt \
6689 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006690 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006691 max_frag_len=512" \
6692 "$P_CLI dtls=1 debug_level=2 \
6693 crt_file=data_files/server8_int-ca2.crt \
6694 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006695 hs_timeout=2500-60000 \
Hanno Becker69ca0ad2018-08-24 12:11:35 +01006696 max_frag_len=4096" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006697 0 \
6698 -S "found fragmented DTLS handshake message" \
6699 -c "found fragmented DTLS handshake message" \
6700 -C "error"
6701
6702requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6703requires_config_enabled MBEDTLS_RSA_C
6704requires_config_enabled MBEDTLS_ECDSA_C
6705requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006706run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006707 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6708 crt_file=data_files/server7_int-ca.crt \
6709 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006710 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006711 max_frag_len=2048" \
6712 "$P_CLI dtls=1 debug_level=2 \
6713 crt_file=data_files/server8_int-ca2.crt \
6714 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006715 hs_timeout=2500-60000 \
6716 max_frag_len=1024" \
6717 0 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006718 -S "found fragmented DTLS handshake message" \
6719 -c "found fragmented DTLS handshake message" \
6720 -C "error"
6721
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006722# While not required by the standard defining the MFL extension
6723# (according to which it only applies to records, not to datagrams),
6724# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6725# as otherwise there wouldn't be any means to communicate MTU restrictions
6726# to the peer.
6727# The next test checks that no datagrams significantly larger than the
6728# negotiated MFL are sent.
6729requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6730requires_config_enabled MBEDTLS_RSA_C
6731requires_config_enabled MBEDTLS_ECDSA_C
6732requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6733run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006734 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006735 "$P_SRV dtls=1 debug_level=2 auth_mode=none \
6736 crt_file=data_files/server7_int-ca.crt \
6737 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006738 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006739 max_frag_len=2048" \
6740 "$P_CLI dtls=1 debug_level=2 \
6741 crt_file=data_files/server8_int-ca2.crt \
6742 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006743 hs_timeout=2500-60000 \
6744 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006745 0 \
6746 -S "found fragmented DTLS handshake message" \
6747 -c "found fragmented DTLS handshake message" \
6748 -C "error"
6749
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006750requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6751requires_config_enabled MBEDTLS_RSA_C
6752requires_config_enabled MBEDTLS_ECDSA_C
6753requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006754run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006755 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6756 crt_file=data_files/server7_int-ca.crt \
6757 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006758 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006759 max_frag_len=2048" \
6760 "$P_CLI dtls=1 debug_level=2 \
6761 crt_file=data_files/server8_int-ca2.crt \
6762 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006763 hs_timeout=2500-60000 \
6764 max_frag_len=1024" \
Manuel Pégourié-Gonnard2cb17e22017-09-19 13:00:47 +02006765 0 \
6766 -s "found fragmented DTLS handshake message" \
6767 -c "found fragmented DTLS handshake message" \
6768 -C "error"
6769
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006770# While not required by the standard defining the MFL extension
6771# (according to which it only applies to records, not to datagrams),
6772# Mbed TLS will never send datagrams larger than MFL + { Max record expansion },
6773# as otherwise there wouldn't be any means to communicate MTU restrictions
6774# to the peer.
6775# The next test checks that no datagrams significantly larger than the
6776# negotiated MFL are sent.
6777requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6778requires_config_enabled MBEDTLS_RSA_C
6779requires_config_enabled MBEDTLS_ECDSA_C
6780requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
6781run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \
Andrzej Kurek0fc9cf42018-10-09 03:09:41 -04006782 -p "$P_PXY mtu=1110" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006783 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6784 crt_file=data_files/server7_int-ca.crt \
6785 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006786 hs_timeout=2500-60000 \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006787 max_frag_len=2048" \
6788 "$P_CLI dtls=1 debug_level=2 \
6789 crt_file=data_files/server8_int-ca2.crt \
6790 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006791 hs_timeout=2500-60000 \
6792 max_frag_len=1024" \
Hanno Beckerc92b5c82018-08-24 11:48:01 +01006793 0 \
6794 -s "found fragmented DTLS handshake message" \
6795 -c "found fragmented DTLS handshake message" \
6796 -C "error"
6797
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006798requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6799requires_config_enabled MBEDTLS_RSA_C
6800requires_config_enabled MBEDTLS_ECDSA_C
6801run_test "DTLS fragmenting: none (for reference) (MTU)" \
6802 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6803 crt_file=data_files/server7_int-ca.crt \
6804 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006805 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006806 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006807 "$P_CLI dtls=1 debug_level=2 \
6808 crt_file=data_files/server8_int-ca2.crt \
6809 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006810 hs_timeout=2500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006811 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006812 0 \
6813 -S "found fragmented DTLS handshake message" \
6814 -C "found fragmented DTLS handshake message" \
6815 -C "error"
6816
6817requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6818requires_config_enabled MBEDTLS_RSA_C
6819requires_config_enabled MBEDTLS_ECDSA_C
6820run_test "DTLS fragmenting: client (MTU)" \
6821 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6822 crt_file=data_files/server7_int-ca.crt \
6823 key_file=data_files/server7.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006824 hs_timeout=3500-60000 \
Hanno Becker12405e72018-08-13 16:45:46 +01006825 mtu=4096" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006826 "$P_CLI dtls=1 debug_level=2 \
6827 crt_file=data_files/server8_int-ca2.crt \
6828 key_file=data_files/server8.key \
Andrzej Kurek948fe802018-10-05 15:42:44 -04006829 hs_timeout=3500-60000 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006830 mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006831 0 \
6832 -s "found fragmented DTLS handshake message" \
6833 -C "found fragmented DTLS handshake message" \
6834 -C "error"
6835
6836requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6837requires_config_enabled MBEDTLS_RSA_C
6838requires_config_enabled MBEDTLS_ECDSA_C
6839run_test "DTLS fragmenting: server (MTU)" \
6840 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6841 crt_file=data_files/server7_int-ca.crt \
6842 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006843 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006844 mtu=512" \
6845 "$P_CLI dtls=1 debug_level=2 \
6846 crt_file=data_files/server8_int-ca2.crt \
6847 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006848 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006849 mtu=2048" \
6850 0 \
6851 -S "found fragmented DTLS handshake message" \
6852 -c "found fragmented DTLS handshake message" \
6853 -C "error"
6854
6855requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6856requires_config_enabled MBEDTLS_RSA_C
6857requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006858run_test "DTLS fragmenting: both (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006859 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnardb747c6c2018-08-12 13:28:53 +02006860 "$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 \
Andrzej Kurek95805282018-10-11 08:55:37 -04006864 mtu=1024" \
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 \
6869 mtu=1024" \
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
Andrzej Kurek77826052018-10-11 07:34:08 -04006875# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006876requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6877requires_config_enabled MBEDTLS_RSA_C
6878requires_config_enabled MBEDTLS_ECDSA_C
6879requires_config_enabled MBEDTLS_SHA256_C
6880requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6881requires_config_enabled MBEDTLS_AES_C
6882requires_config_enabled MBEDTLS_GCM_C
6883run_test "DTLS fragmenting: both (MTU=512)" \
Hanno Becker8d832182018-03-15 10:14:19 +00006884 -p "$P_PXY mtu=512" \
Hanno Becker72a4f032017-11-15 16:39:20 +00006885 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6886 crt_file=data_files/server7_int-ca.crt \
6887 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006888 hs_timeout=2500-60000 \
Hanno Becker72a4f032017-11-15 16:39:20 +00006889 mtu=512" \
6890 "$P_CLI dtls=1 debug_level=2 \
6891 crt_file=data_files/server8_int-ca2.crt \
6892 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006893 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6894 hs_timeout=2500-60000 \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006895 mtu=512" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02006896 0 \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02006897 -s "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02006898 -c "found fragmented DTLS handshake message" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02006899 -C "error"
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02006900
Andrzej Kurek7311c782018-10-11 06:49:41 -04006901# Test for automatic MTU reduction on repeated resend.
Andrzej Kurek77826052018-10-11 07:34:08 -04006902# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006903# The ratio of max/min timeout should ideally equal 4 to accept two
6904# retransmissions, but in some cases (like both the server and client using
6905# fragmentation and auto-reduction) an extra retransmission might occur,
6906# hence the ratio of 8.
Hanno Becker37029eb2018-08-29 17:01:40 +01006907not_with_valgrind
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006908requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6909requires_config_enabled MBEDTLS_RSA_C
6910requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006911requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6912requires_config_enabled MBEDTLS_AES_C
6913requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02006914run_test "DTLS fragmenting: proxy MTU: auto-reduction (not valgrind)" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006915 -p "$P_PXY mtu=508" \
6916 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6917 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006918 key_file=data_files/server7.key \
6919 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006920 "$P_CLI dtls=1 debug_level=2 \
6921 crt_file=data_files/server8_int-ca2.crt \
6922 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006923 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
6924 hs_timeout=400-3200" \
Manuel Pégourié-Gonnardb8eec192018-08-20 09:34:02 +02006925 0 \
6926 -s "found fragmented DTLS handshake message" \
6927 -c "found fragmented DTLS handshake message" \
6928 -C "error"
6929
Andrzej Kurek77826052018-10-11 07:34:08 -04006930# Forcing ciphersuite for this test to fit the MTU of 508 with full config.
Hanno Becker108992e2018-08-29 17:04:18 +01006931only_with_valgrind
6932requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6933requires_config_enabled MBEDTLS_RSA_C
6934requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006935requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6936requires_config_enabled MBEDTLS_AES_C
6937requires_config_enabled MBEDTLS_GCM_C
Gilles Peskine0d8b86a2019-09-20 18:03:11 +02006938run_test "DTLS fragmenting: proxy MTU: auto-reduction (with valgrind)" \
Hanno Becker108992e2018-08-29 17:04:18 +01006939 -p "$P_PXY mtu=508" \
6940 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6941 crt_file=data_files/server7_int-ca.crt \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006942 key_file=data_files/server7.key \
Hanno Becker108992e2018-08-29 17:04:18 +01006943 hs_timeout=250-10000" \
6944 "$P_CLI dtls=1 debug_level=2 \
6945 crt_file=data_files/server8_int-ca2.crt \
6946 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006947 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Hanno Becker108992e2018-08-29 17:04:18 +01006948 hs_timeout=250-10000" \
6949 0 \
6950 -s "found fragmented DTLS handshake message" \
6951 -c "found fragmented DTLS handshake message" \
6952 -C "error"
6953
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006954# 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 +02006955# OTOH the client might resend if the server is to slow to reset after sending
6956# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006957not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006958requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6959requires_config_enabled MBEDTLS_RSA_C
6960requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006961run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006962 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006963 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6964 crt_file=data_files/server7_int-ca.crt \
6965 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006966 hs_timeout=10000-60000 \
6967 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006968 "$P_CLI dtls=1 debug_level=2 \
6969 crt_file=data_files/server8_int-ca2.crt \
6970 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04006971 hs_timeout=10000-60000 \
6972 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006973 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006974 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02006975 -s "found fragmented DTLS handshake message" \
6976 -c "found fragmented DTLS handshake message" \
6977 -C "error"
6978
Andrzej Kurek77826052018-10-11 07:34:08 -04006979# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04006980# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend
6981# OTOH the client might resend if the server is to slow to reset after sending
6982# a HelloVerifyRequest, so only check for no retransmission server-side
Andrzej Kurek35f2f302018-10-09 08:52:14 -04006983not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006984requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
6985requires_config_enabled MBEDTLS_RSA_C
6986requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04006987requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
6988requires_config_enabled MBEDTLS_AES_C
6989requires_config_enabled MBEDTLS_GCM_C
6990run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006991 -p "$P_PXY mtu=512" \
6992 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
6993 crt_file=data_files/server7_int-ca.crt \
6994 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04006995 hs_timeout=10000-60000 \
6996 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02006997 "$P_CLI dtls=1 debug_level=2 \
6998 crt_file=data_files/server8_int-ca2.crt \
6999 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007000 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7001 hs_timeout=10000-60000 \
7002 mtu=512" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007003 0 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007004 -S "autoreduction" \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007005 -s "found fragmented DTLS handshake message" \
7006 -c "found fragmented DTLS handshake message" \
7007 -C "error"
7008
Andrzej Kurek7311c782018-10-11 06:49:41 -04007009not_with_valgrind # spurious autoreduction due to timeout
7010requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7011requires_config_enabled MBEDTLS_RSA_C
7012requires_config_enabled MBEDTLS_ECDSA_C
7013run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007014 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007015 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7016 crt_file=data_files/server7_int-ca.crt \
7017 key_file=data_files/server7.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007018 hs_timeout=10000-60000 \
7019 mtu=1024 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007020 "$P_CLI dtls=1 debug_level=2 \
7021 crt_file=data_files/server8_int-ca2.crt \
7022 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007023 hs_timeout=10000-60000 \
7024 mtu=1024 nbio=2" \
7025 0 \
7026 -S "autoreduction" \
7027 -s "found fragmented DTLS handshake message" \
7028 -c "found fragmented DTLS handshake message" \
7029 -C "error"
7030
Andrzej Kurek77826052018-10-11 07:34:08 -04007031# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Andrzej Kurek7311c782018-10-11 06:49:41 -04007032not_with_valgrind # spurious autoreduction due to timeout
7033requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7034requires_config_enabled MBEDTLS_RSA_C
7035requires_config_enabled MBEDTLS_ECDSA_C
7036requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7037requires_config_enabled MBEDTLS_AES_C
7038requires_config_enabled MBEDTLS_GCM_C
7039run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \
7040 -p "$P_PXY mtu=512" \
7041 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7042 crt_file=data_files/server7_int-ca.crt \
7043 key_file=data_files/server7.key \
7044 hs_timeout=10000-60000 \
7045 mtu=512 nbio=2" \
7046 "$P_CLI dtls=1 debug_level=2 \
7047 crt_file=data_files/server8_int-ca2.crt \
7048 key_file=data_files/server8.key \
7049 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
7050 hs_timeout=10000-60000 \
7051 mtu=512 nbio=2" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007052 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007053 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007054 -s "found fragmented DTLS handshake message" \
7055 -c "found fragmented DTLS handshake message" \
7056 -C "error"
7057
Andrzej Kurek77826052018-10-11 07:34:08 -04007058# Forcing ciphersuite for this test to fit the MTU of 1450 with full config.
Hanno Beckerb841b4f2018-08-28 10:25:51 +01007059# This ensures things still work after session_reset().
7060# It also exercises the "resumed handshake" flow.
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007061# Since we don't support reading fragmented ClientHello yet,
7062# up the MTU to 1450 (larger than ClientHello with session ticket,
7063# but still smaller than client's Certificate to ensure fragmentation).
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007064# An autoreduction on the client-side might happen if the server is
7065# slow to reset, therefore omitting '-C "autoreduction"' below.
Manuel Pégourié-Gonnard2f2d9022018-08-21 12:17:54 +02007066# reco_delay avoids races where the client reconnects before the server has
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007067# resumed listening, which would result in a spurious autoreduction.
7068not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007069requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7070requires_config_enabled MBEDTLS_RSA_C
7071requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007072requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7073requires_config_enabled MBEDTLS_AES_C
7074requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007075run_test "DTLS fragmenting: proxy MTU, resumed handshake" \
7076 -p "$P_PXY mtu=1450" \
7077 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7078 crt_file=data_files/server7_int-ca.crt \
7079 key_file=data_files/server7.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007080 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007081 mtu=1450" \
7082 "$P_CLI dtls=1 debug_level=2 \
7083 crt_file=data_files/server8_int-ca2.crt \
7084 key_file=data_files/server8.key \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007085 hs_timeout=10000-60000 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007086 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01007087 mtu=1450 reconnect=1 skip_close_notify=1 reco_delay=1" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007088 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007089 -S "autoreduction" \
Manuel Pégourié-Gonnard19c62f92018-08-16 10:50:39 +02007090 -s "found fragmented DTLS handshake message" \
7091 -c "found fragmented DTLS handshake message" \
7092 -C "error"
7093
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007094# An autoreduction on the client-side might happen if the server is
7095# slow to reset, therefore omitting '-C "autoreduction"' below.
7096not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007097requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7098requires_config_enabled MBEDTLS_RSA_C
7099requires_config_enabled MBEDTLS_ECDSA_C
7100requires_config_enabled MBEDTLS_SHA256_C
7101requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7102requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7103requires_config_enabled MBEDTLS_CHACHAPOLY_C
7104run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \
7105 -p "$P_PXY mtu=512" \
7106 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7107 crt_file=data_files/server7_int-ca.crt \
7108 key_file=data_files/server7.key \
7109 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007110 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007111 mtu=512" \
7112 "$P_CLI dtls=1 debug_level=2 \
7113 crt_file=data_files/server8_int-ca2.crt \
7114 key_file=data_files/server8.key \
7115 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007116 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007117 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007118 mtu=512" \
7119 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007120 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007121 -s "found fragmented DTLS handshake message" \
7122 -c "found fragmented DTLS handshake message" \
7123 -C "error"
7124
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007125# An autoreduction on the client-side might happen if the server is
7126# slow to reset, therefore omitting '-C "autoreduction"' below.
7127not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007128requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7129requires_config_enabled MBEDTLS_RSA_C
7130requires_config_enabled MBEDTLS_ECDSA_C
7131requires_config_enabled MBEDTLS_SHA256_C
7132requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7133requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7134requires_config_enabled MBEDTLS_AES_C
7135requires_config_enabled MBEDTLS_GCM_C
7136run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \
7137 -p "$P_PXY mtu=512" \
7138 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7139 crt_file=data_files/server7_int-ca.crt \
7140 key_file=data_files/server7.key \
7141 exchanges=2 renegotiation=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007142 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007143 mtu=512" \
7144 "$P_CLI dtls=1 debug_level=2 \
7145 crt_file=data_files/server8_int-ca2.crt \
7146 key_file=data_files/server8.key \
7147 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007148 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007149 hs_timeout=10000-60000 \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007150 mtu=512" \
7151 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007152 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007153 -s "found fragmented DTLS handshake message" \
7154 -c "found fragmented DTLS handshake message" \
7155 -C "error"
7156
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007157# An autoreduction on the client-side might happen if the server is
7158# slow to reset, therefore omitting '-C "autoreduction"' below.
7159not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007160requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7161requires_config_enabled MBEDTLS_RSA_C
7162requires_config_enabled MBEDTLS_ECDSA_C
7163requires_config_enabled MBEDTLS_SHA256_C
7164requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7165requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7166requires_config_enabled MBEDTLS_AES_C
7167requires_config_enabled MBEDTLS_CCM_C
7168run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007169 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007170 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7171 crt_file=data_files/server7_int-ca.crt \
7172 key_file=data_files/server7.key \
7173 exchanges=2 renegotiation=1 \
7174 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007175 hs_timeout=10000-60000 \
7176 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007177 "$P_CLI dtls=1 debug_level=2 \
7178 crt_file=data_files/server8_int-ca2.crt \
7179 key_file=data_files/server8.key \
7180 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007181 hs_timeout=10000-60000 \
7182 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007183 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007184 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007185 -s "found fragmented DTLS handshake message" \
7186 -c "found fragmented DTLS handshake message" \
7187 -C "error"
7188
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007189# An autoreduction on the client-side might happen if the server is
7190# slow to reset, therefore omitting '-C "autoreduction"' below.
7191not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007192requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7193requires_config_enabled MBEDTLS_RSA_C
7194requires_config_enabled MBEDTLS_ECDSA_C
7195requires_config_enabled MBEDTLS_SHA256_C
7196requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7197requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7198requires_config_enabled MBEDTLS_AES_C
7199requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7200requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC
7201run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007202 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007203 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7204 crt_file=data_files/server7_int-ca.crt \
7205 key_file=data_files/server7.key \
7206 exchanges=2 renegotiation=1 \
7207 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007208 hs_timeout=10000-60000 \
7209 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007210 "$P_CLI dtls=1 debug_level=2 \
7211 crt_file=data_files/server8_int-ca2.crt \
7212 key_file=data_files/server8.key \
7213 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007214 hs_timeout=10000-60000 \
7215 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007216 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007217 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007218 -s "found fragmented DTLS handshake message" \
7219 -c "found fragmented DTLS handshake message" \
7220 -C "error"
7221
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007222# An autoreduction on the client-side might happen if the server is
7223# slow to reset, therefore omitting '-C "autoreduction"' below.
7224not_with_valgrind # spurious autoreduction due to timeout
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007225requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7226requires_config_enabled MBEDTLS_RSA_C
7227requires_config_enabled MBEDTLS_ECDSA_C
7228requires_config_enabled MBEDTLS_SHA256_C
7229requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7230requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
7231requires_config_enabled MBEDTLS_AES_C
7232requires_config_enabled MBEDTLS_CIPHER_MODE_CBC
7233run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007234 -p "$P_PXY mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007235 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7236 crt_file=data_files/server7_int-ca.crt \
7237 key_file=data_files/server7.key \
7238 exchanges=2 renegotiation=1 \
7239 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007240 hs_timeout=10000-60000 \
7241 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007242 "$P_CLI dtls=1 debug_level=2 \
7243 crt_file=data_files/server8_int-ca2.crt \
7244 key_file=data_files/server8.key \
7245 exchanges=2 renegotiation=1 renegotiate=1 \
Andrzej Kurek52f84912018-10-05 07:53:40 -04007246 hs_timeout=10000-60000 \
7247 mtu=1024" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007248 0 \
Andrzej Kurek35f2f302018-10-09 08:52:14 -04007249 -S "autoreduction" \
Manuel Pégourié-Gonnard72c27072018-08-13 12:37:51 +02007250 -s "found fragmented DTLS handshake message" \
7251 -c "found fragmented DTLS handshake message" \
7252 -C "error"
7253
Andrzej Kurek77826052018-10-11 07:34:08 -04007254# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007255requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7256requires_config_enabled MBEDTLS_RSA_C
7257requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007258requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7259requires_config_enabled MBEDTLS_AES_C
7260requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007261client_needs_more_time 2
7262run_test "DTLS fragmenting: proxy MTU + 3d" \
7263 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007264 "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007265 crt_file=data_files/server7_int-ca.crt \
7266 key_file=data_files/server7.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007267 hs_timeout=250-10000 mtu=512" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007268 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007269 crt_file=data_files/server8_int-ca2.crt \
7270 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007271 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007272 hs_timeout=250-10000 mtu=512" \
Manuel Pégourié-Gonnard2d56f0d2018-08-16 11:09:03 +02007273 0 \
7274 -s "found fragmented DTLS handshake message" \
7275 -c "found fragmented DTLS handshake message" \
7276 -C "error"
7277
Andrzej Kurek77826052018-10-11 07:34:08 -04007278# Forcing ciphersuite for this test to fit the MTU of 512 with full config.
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007279requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7280requires_config_enabled MBEDTLS_RSA_C
7281requires_config_enabled MBEDTLS_ECDSA_C
Andrzej Kurek7311c782018-10-11 06:49:41 -04007282requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA
7283requires_config_enabled MBEDTLS_AES_C
7284requires_config_enabled MBEDTLS_GCM_C
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007285client_needs_more_time 2
7286run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \
7287 -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \
7288 "$P_SRV dtls=1 debug_level=2 auth_mode=required \
7289 crt_file=data_files/server7_int-ca.crt \
7290 key_file=data_files/server7.key \
7291 hs_timeout=250-10000 mtu=512 nbio=2" \
7292 "$P_CLI dtls=1 debug_level=2 \
7293 crt_file=data_files/server8_int-ca2.crt \
7294 key_file=data_files/server8.key \
Andrzej Kurek7311c782018-10-11 06:49:41 -04007295 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \
Manuel Pégourié-Gonnardc1d54b72018-08-22 10:02:59 +02007296 hs_timeout=250-10000 mtu=512 nbio=2" \
7297 0 \
7298 -s "found fragmented DTLS handshake message" \
7299 -c "found fragmented DTLS handshake message" \
7300 -C "error"
7301
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007302# interop tests for DTLS fragmentating with reliable connection
7303#
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007304# here and below we just want to test that the we fragment in a way that
7305# pleases other implementations, so we don't need the peer to fragment
7306requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7307requires_config_enabled MBEDTLS_RSA_C
7308requires_config_enabled MBEDTLS_ECDSA_C
7309requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007310requires_gnutls
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007311run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \
7312 "$G_SRV -u" \
7313 "$P_CLI dtls=1 debug_level=2 \
7314 crt_file=data_files/server8_int-ca2.crt \
7315 key_file=data_files/server8.key \
7316 mtu=512 force_version=dtls1_2" \
7317 0 \
7318 -c "fragmenting handshake message" \
7319 -C "error"
7320
Hanno Beckerb9a00862018-08-28 10:20:22 +01007321# We use --insecure for the GnuTLS client because it expects
7322# the hostname / IP it connects to to be the name used in the
7323# certificate obtained from the server. Here, however, it
7324# connects to 127.0.0.1 while our test certificates use 'localhost'
7325# as the server name in the certificate. This will make the
7326# certifiate validation fail, but passing --insecure makes
7327# GnuTLS continue the connection nonetheless.
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007328requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7329requires_config_enabled MBEDTLS_RSA_C
7330requires_config_enabled MBEDTLS_ECDSA_C
7331requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard61512982018-08-21 09:40:07 +02007332requires_gnutls
Andrzej Kurekb4593462018-10-11 08:43:30 -04007333requires_not_i686
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007334run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007335 "$P_SRV dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007336 crt_file=data_files/server7_int-ca.crt \
7337 key_file=data_files/server7.key \
7338 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard34aa1872018-08-23 19:07:15 +02007339 "$G_CLI -u --insecure 127.0.0.1" \
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007340 0 \
7341 -s "fragmenting handshake message"
7342
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007343requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7344requires_config_enabled MBEDTLS_RSA_C
7345requires_config_enabled MBEDTLS_ECDSA_C
7346requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7347run_test "DTLS fragmenting: openssl server, DTLS 1.2" \
7348 "$O_SRV -dtls1_2 -verify 10" \
7349 "$P_CLI dtls=1 debug_level=2 \
7350 crt_file=data_files/server8_int-ca2.crt \
7351 key_file=data_files/server8.key \
7352 mtu=512 force_version=dtls1_2" \
7353 0 \
7354 -c "fragmenting handshake message" \
7355 -C "error"
7356
7357requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7358requires_config_enabled MBEDTLS_RSA_C
7359requires_config_enabled MBEDTLS_ECDSA_C
Manuel Pégourié-Gonnard1218bc02018-08-17 10:51:26 +02007360requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7361run_test "DTLS fragmenting: openssl client, DTLS 1.2" \
7362 "$P_SRV dtls=1 debug_level=2 \
7363 crt_file=data_files/server7_int-ca.crt \
7364 key_file=data_files/server7.key \
7365 mtu=512 force_version=dtls1_2" \
7366 "$O_CLI -dtls1_2" \
7367 0 \
7368 -s "fragmenting handshake message"
7369
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007370# interop tests for DTLS fragmentating with unreliable connection
7371#
7372# again we just want to test that the we fragment in a way that
7373# pleases other implementations, so we don't need the peer to fragment
7374requires_gnutls_next
7375requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7376requires_config_enabled MBEDTLS_RSA_C
7377requires_config_enabled MBEDTLS_ECDSA_C
7378requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007379client_needs_more_time 4
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007380run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \
7381 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7382 "$G_NEXT_SRV -u" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007383 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007384 crt_file=data_files/server8_int-ca2.crt \
7385 key_file=data_files/server8.key \
Manuel Pégourié-Gonnard02f3a8a2018-08-20 10:49:28 +02007386 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007387 0 \
7388 -c "fragmenting handshake message" \
7389 -C "error"
7390
7391requires_gnutls_next
7392requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7393requires_config_enabled MBEDTLS_RSA_C
7394requires_config_enabled MBEDTLS_ECDSA_C
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007395requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7396client_needs_more_time 4
7397run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \
7398 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7399 "$P_SRV dtls=1 debug_level=2 \
7400 crt_file=data_files/server7_int-ca.crt \
7401 key_file=data_files/server7.key \
7402 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
k-stachowiak17a38d32019-02-18 15:29:56 +01007403 "$G_NEXT_CLI -u --insecure 127.0.0.1" \
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007404 0 \
7405 -s "fragmenting handshake message"
7406
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007407## Interop test with OpenSSL might trigger a bug in recent versions (including
7408## all versions installed on the CI machines), reported here:
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007409## Bug report: https://github.com/openssl/openssl/issues/6902
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007410## They should be re-enabled once a fixed version of OpenSSL is available
7411## (this should happen in some 1.1.1_ release according to the ticket).
Hanno Becker3b8b40c2018-08-28 10:25:41 +01007412skip_next_test
7413requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7414requires_config_enabled MBEDTLS_RSA_C
7415requires_config_enabled MBEDTLS_ECDSA_C
7416requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7417client_needs_more_time 4
7418run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \
7419 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7420 "$O_SRV -dtls1_2 -verify 10" \
7421 "$P_CLI dtls=1 debug_level=2 \
7422 crt_file=data_files/server8_int-ca2.crt \
7423 key_file=data_files/server8.key \
7424 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7425 0 \
7426 -c "fragmenting handshake message" \
7427 -C "error"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007428
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007429skip_next_test
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007430requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
7431requires_config_enabled MBEDTLS_RSA_C
7432requires_config_enabled MBEDTLS_ECDSA_C
Manuel Pégourié-Gonnardc1eda672018-09-03 10:41:49 +02007433requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
7434client_needs_more_time 4
7435run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \
7436 -p "$P_PXY drop=8 delay=8 duplicate=8" \
7437 "$P_SRV dtls=1 debug_level=2 \
7438 crt_file=data_files/server7_int-ca.crt \
7439 key_file=data_files/server7.key \
7440 hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \
7441 "$O_CLI -dtls1_2" \
7442 0 \
7443 -s "fragmenting handshake message"
Manuel Pégourié-Gonnard38110df2018-08-17 12:44:54 +02007444
Ron Eldorb4655392018-07-05 18:25:39 +03007445# Tests for DTLS-SRTP (RFC 5764)
7446requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7447run_test "DTLS-SRTP all profiles supported" \
7448 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7449 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7450 0 \
7451 -s "found use_srtp extension" \
7452 -s "found srtp profile" \
7453 -s "selected srtp profile" \
7454 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007455 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007456 -c "client hello, adding use_srtp extension" \
7457 -c "found use_srtp extension" \
7458 -c "found srtp profile" \
7459 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007460 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007461 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007462 -C "error"
7463
Johan Pascal9bc50b02020-09-24 12:01:13 +02007464
Ron Eldorb4655392018-07-05 18:25:39 +03007465requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7466run_test "DTLS-SRTP server supports all profiles. Client supports one profile." \
7467 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
Johan Pascal43f94902020-09-22 12:25:52 +02007468 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=5 debug_level=3" \
Ron Eldorb4655392018-07-05 18:25:39 +03007469 0 \
7470 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007471 -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
7472 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
Ron Eldorb4655392018-07-05 18:25:39 +03007473 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007474 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007475 -c "client hello, adding use_srtp extension" \
7476 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007477 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
Ron Eldorb4655392018-07-05 18:25:39 +03007478 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007479 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007480 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007481 -C "error"
7482
7483requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007484run_test "DTLS-SRTP server supports one profile. Client supports all profiles." \
Johan Pascal43f94902020-09-22 12:25:52 +02007485 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldorb4655392018-07-05 18:25:39 +03007486 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7487 0 \
7488 -s "found use_srtp extension" \
7489 -s "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007490 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007491 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007492 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007493 -c "client hello, adding use_srtp extension" \
7494 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007495 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007496 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007497 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007498 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007499 -C "error"
7500
7501requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7502run_test "DTLS-SRTP server and Client support only one matching profile." \
7503 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7504 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7505 0 \
7506 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007507 -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
7508 -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007509 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007510 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007511 -c "client hello, adding use_srtp extension" \
7512 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007513 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007514 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007515 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007516 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007517 -C "error"
7518
7519requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7520run_test "DTLS-SRTP server and Client support only one different profile." \
7521 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
Johan Pascal43f94902020-09-22 12:25:52 +02007522 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldorb4655392018-07-05 18:25:39 +03007523 0 \
7524 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007525 -s "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldorb4655392018-07-05 18:25:39 +03007526 -S "selected srtp profile" \
7527 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007528 -S "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007529 -c "client hello, adding use_srtp extension" \
7530 -C "found use_srtp extension" \
7531 -C "found srtp profile" \
7532 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007533 -C "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007534 -C "error"
7535
7536requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7537run_test "DTLS-SRTP server doesn't support use_srtp extension." \
7538 "$P_SRV dtls=1 debug_level=3" \
7539 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7540 0 \
7541 -s "found use_srtp extension" \
7542 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007543 -S "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007544 -c "client hello, adding use_srtp extension" \
7545 -C "found use_srtp extension" \
7546 -C "found srtp profile" \
7547 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007548 -C "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007549 -C "error"
7550
7551requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7552run_test "DTLS-SRTP all profiles supported. mki used" \
7553 "$P_SRV dtls=1 use_srtp=1 support_mki=1 debug_level=3" \
7554 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
7555 0 \
7556 -s "found use_srtp extension" \
7557 -s "found srtp profile" \
7558 -s "selected srtp profile" \
7559 -s "server hello, adding use_srtp extension" \
7560 -s "dumping 'using mki' (8 bytes)" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007561 -s "DTLS-SRTP key material is"\
Ron Eldorb4655392018-07-05 18:25:39 +03007562 -c "client hello, adding use_srtp extension" \
7563 -c "found use_srtp extension" \
7564 -c "found srtp profile" \
7565 -c "selected srtp profile" \
7566 -c "dumping 'sending mki' (8 bytes)" \
7567 -c "dumping 'received mki' (8 bytes)" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007568 -c "DTLS-SRTP key material is"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007569 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Johan Pascal20c7db32020-10-26 22:45:58 +01007570 -g "find_in_both '^ *DTLS-SRTP mki value: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007571 -C "error"
7572
7573requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
7574run_test "DTLS-SRTP all profiles supported. server doesn't support mki." \
7575 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7576 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
7577 0 \
7578 -s "found use_srtp extension" \
7579 -s "found srtp profile" \
7580 -s "selected srtp profile" \
7581 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007582 -s "DTLS-SRTP key material is"\
Johan Pascal5ef72d22020-10-28 17:05:47 +01007583 -s "DTLS-SRTP no mki value negotiated"\
Ron Eldorb4655392018-07-05 18:25:39 +03007584 -S "dumping 'using mki' (8 bytes)" \
7585 -c "client hello, adding use_srtp extension" \
7586 -c "found use_srtp extension" \
7587 -c "found srtp profile" \
7588 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007589 -c "DTLS-SRTP key material is"\
Johan Pascal5ef72d22020-10-28 17:05:47 +01007590 -c "DTLS-SRTP no mki value negotiated"\
Johan Pascal9bc50b02020-09-24 12:01:13 +02007591 -g "find_in_both '^ *Keying material: [0-9A-F]*$'"\
Ron Eldorb4655392018-07-05 18:25:39 +03007592 -c "dumping 'sending mki' (8 bytes)" \
7593 -C "dumping 'received mki' (8 bytes)" \
7594 -C "error"
7595
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007596requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007597requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007598run_test "DTLS-SRTP all profiles supported. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007599 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7600 "$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 +03007601 0 \
7602 -s "found use_srtp extension" \
7603 -s "found srtp profile" \
7604 -s "selected srtp profile" \
7605 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007606 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007607 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_80"
7608
7609requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007610requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007611run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007612 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7613 "$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 +03007614 0 \
7615 -s "found use_srtp extension" \
7616 -s "found srtp profile" \
7617 -s "selected srtp profile" \
7618 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007619 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007620 -c "SRTP profile: SRTP_NULL_HMAC_SHA1_80"
7621
7622requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007623requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007624run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007625 "$P_SRV dtls=1 use_srtp=1 debug_level=3" \
7626 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007627 0 \
7628 -s "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007629 -s "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
7630 -s "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007631 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007632 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007633 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
7634
7635requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007636requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007637run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls client." \
Johan Pascal43f94902020-09-22 12:25:52 +02007638 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldor5d991c92019-01-15 18:54:03 +02007639 "$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 +03007640 0 \
7641 -s "found use_srtp extension" \
7642 -s "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007643 -s "selected srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007644 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007645 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007646 -c "SRTP profile: SRTP_NULL_SHA1_32"
7647
7648requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007649requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007650run_test "DTLS-SRTP server and Client support only one matching profile. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007651 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7652 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007653 0 \
7654 -s "found use_srtp extension" \
7655 -s "found srtp profile" \
7656 -s "selected srtp profile" \
7657 -s "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007658 -s "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007659 -c "SRTP profile: SRTP_AES128_CM_HMAC_SHA1_32"
7660
7661requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007662requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007663run_test "DTLS-SRTP server and Client support only one different profile. gnutls client." \
Ron Eldor5d991c92019-01-15 18:54:03 +02007664 "$P_SRV dtls=1 use_srtp=1 srtp_force_profile=1 debug_level=3" \
7665 "$G_CLI -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32 --insecure 127.0.0.1" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007666 0 \
7667 -s "found use_srtp extension" \
7668 -s "found srtp profile" \
7669 -S "selected srtp profile" \
7670 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007671 -S "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007672 -C "SRTP profile:"
7673
7674requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007675requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007676run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls client" \
Ron Eldor5d991c92019-01-15 18:54:03 +02007677 "$P_SRV dtls=1 debug_level=3" \
7678 "$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 +03007679 0 \
7680 -s "found use_srtp extension" \
7681 -S "server hello, adding use_srtp extension" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007682 -S "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007683 -C "SRTP profile:"
7684
7685requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007686requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007687run_test "DTLS-SRTP all profiles supported. gnutls server" \
7688 "$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" \
7689 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7690 0 \
7691 -c "client hello, adding use_srtp extension" \
7692 -c "found use_srtp extension" \
7693 -c "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007694 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007695 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007696 -C "error"
7697
7698requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007699requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007700run_test "DTLS-SRTP server supports all profiles. Client supports all profiles, in different order. gnutls server." \
7701 "$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" \
7702 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7703 0 \
7704 -c "client hello, adding use_srtp extension" \
7705 -c "found use_srtp extension" \
7706 -c "found srtp profile" \
Johan Pascal43f94902020-09-22 12:25:52 +02007707 -c "selected srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_80" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007708 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007709 -C "error"
7710
7711requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007712requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007713run_test "DTLS-SRTP server supports all profiles. Client supports one profile. gnutls server." \
7714 "$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" \
7715 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7716 0 \
7717 -c "client hello, adding use_srtp extension" \
7718 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007719 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007720 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007721 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007722 -C "error"
7723
7724requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007725requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007726run_test "DTLS-SRTP server supports one profile. Client supports all profiles. gnutls server." \
7727 "$G_SRV -u --srtp-profiles=SRTP_NULL_HMAC_SHA1_80" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007728 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007729 0 \
7730 -c "client hello, adding use_srtp extension" \
7731 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007732 -c "found srtp profile: MBEDTLS_TLS_SRTP_NULL_HMAC_SHA1_80" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007733 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007734 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007735 -C "error"
7736
7737requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007738requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007739run_test "DTLS-SRTP server and Client support only one matching profile. gnutls server." \
7740 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
7741 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=2 debug_level=3" \
7742 0 \
7743 -c "client hello, adding use_srtp extension" \
7744 -c "found use_srtp extension" \
Johan Pascal43f94902020-09-22 12:25:52 +02007745 -c "found srtp profile: MBEDTLS_TLS_SRTP_AES128_CM_HMAC_SHA1_32" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007746 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007747 -c "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007748 -C "error"
7749
7750requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007751requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007752run_test "DTLS-SRTP server and Client support only one different profile. gnutls server." \
7753 "$G_SRV -u --srtp-profiles=SRTP_AES128_CM_HMAC_SHA1_32" \
Johan Pascal43f94902020-09-22 12:25:52 +02007754 "$P_CLI dtls=1 use_srtp=1 srtp_force_profile=6 debug_level=3" \
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007755 0 \
7756 -c "client hello, adding use_srtp extension" \
7757 -C "found use_srtp extension" \
7758 -C "found srtp profile" \
7759 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007760 -C "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007761 -C "error"
7762
7763requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007764requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007765run_test "DTLS-SRTP server doesn't support use_srtp extension. gnutls server" \
7766 "$G_SRV -u" \
7767 "$P_CLI dtls=1 use_srtp=1 debug_level=3" \
7768 0 \
7769 -c "client hello, adding use_srtp extension" \
7770 -C "found use_srtp extension" \
7771 -C "found srtp profile" \
7772 -C "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007773 -C "DTLS-SRTP key material is"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007774 -C "error"
7775
7776requires_config_enabled MBEDTLS_SSL_DTLS_SRTP
Ron Eldor5d991c92019-01-15 18:54:03 +02007777requires_gnutls
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007778run_test "DTLS-SRTP all profiles supported. mki used. gnutls server." \
7779 "$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" \
7780 "$P_CLI dtls=1 use_srtp=1 mki=542310ab34290481 debug_level=3" \
7781 0 \
7782 -c "client hello, adding use_srtp extension" \
7783 -c "found use_srtp extension" \
7784 -c "found srtp profile" \
7785 -c "selected srtp profile" \
Johan Pascal9bc97ca2020-09-21 23:44:45 +02007786 -c "DTLS-SRTP key material is"\
Johan Pascal20c7db32020-10-26 22:45:58 +01007787 -c "DTLS-SRTP mki value:"\
Ron Eldor3c6a44b2018-07-10 10:32:10 +03007788 -c "dumping 'sending mki' (8 bytes)" \
7789 -c "dumping 'received mki' (8 bytes)" \
7790 -C "error"
7791
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007792# Tests for specific things with "unreliable" UDP connection
7793
7794not_with_valgrind # spurious resend due to timeout
7795run_test "DTLS proxy: reference" \
7796 -p "$P_PXY" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007797 "$P_SRV dtls=1 debug_level=2 hs_timeout=10000-20000" \
7798 "$P_CLI dtls=1 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard64dffc52014-09-02 13:39:16 +02007799 0 \
7800 -C "replayed record" \
7801 -S "replayed record" \
Hanno Beckerb2a86c32019-07-19 15:43:09 +01007802 -C "Buffer record from epoch" \
7803 -S "Buffer record from epoch" \
7804 -C "ssl_buffer_message" \
7805 -S "ssl_buffer_message" \
Manuel Pégourié-Gonnarda7756172014-08-31 18:37:01 +02007806 -C "discarding invalid record" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007807 -S "discarding invalid record" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007808 -S "resend" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007809 -s "Extra-header:" \
Manuel Pégourié-Gonnardbe9eb872014-09-05 17:45:19 +02007810 -c "HTTP/1.0 200 OK"
7811
7812not_with_valgrind # spurious resend due to timeout
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007813run_test "DTLS proxy: duplicate every packet" \
7814 -p "$P_PXY duplicate=1" \
Manuel Pégourié-Gonnardb6929892019-09-09 11:14:37 +02007815 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
7816 "$P_CLI dtls=1 dgram_packing=0 debug_level=2 hs_timeout=10000-20000" \
Manuel Pégourié-Gonnard990f9e42014-09-06 12:27:02 +02007817 0 \
7818 -c "replayed record" \
7819 -s "replayed record" \
7820 -c "record from another epoch" \
7821 -s "record from another epoch" \
7822 -S "resend" \
7823 -s "Extra-header:" \
7824 -c "HTTP/1.0 200 OK"
7825
7826run_test "DTLS proxy: duplicate every packet, server anti-replay off" \
7827 -p "$P_PXY duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007828 "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \
7829 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007830 0 \
7831 -c "replayed record" \
7832 -S "replayed record" \
7833 -c "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007834 -s "record from another epoch" \
7835 -c "resend" \
7836 -s "resend" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007837 -s "Extra-header:" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007838 -c "HTTP/1.0 200 OK"
7839
7840run_test "DTLS proxy: multiple records in same datagram" \
7841 -p "$P_PXY pack=50" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007842 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7843 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007844 0 \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007845 -c "next record in same datagram" \
7846 -s "next record in same datagram"
7847
7848run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \
7849 -p "$P_PXY pack=50 duplicate=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007850 "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \
7851 "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007852 0 \
7853 -c "next record in same datagram" \
7854 -s "next record in same datagram"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007855
Manuel Pégourié-Gonnard246c13a2014-09-24 13:56:09 +02007856run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \
7857 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007858 "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \
7859 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnard63eca932014-09-08 16:39:08 +02007860 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007861 -c "discarding invalid record (mac)" \
7862 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007863 -s "Extra-header:" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007864 -c "HTTP/1.0 200 OK" \
7865 -S "too many records with bad MAC" \
7866 -S "Verification of the message MAC failed"
7867
7868run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \
7869 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007870 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \
7871 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007872 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007873 -C "discarding invalid record (mac)" \
7874 -S "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007875 -S "Extra-header:" \
7876 -C "HTTP/1.0 200 OK" \
7877 -s "too many records with bad MAC" \
7878 -s "Verification of the message MAC failed"
7879
7880run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \
7881 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007882 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \
7883 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007884 0 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007885 -c "discarding invalid record (mac)" \
7886 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007887 -s "Extra-header:" \
7888 -c "HTTP/1.0 200 OK" \
7889 -S "too many records with bad MAC" \
7890 -S "Verification of the message MAC failed"
7891
7892run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\
7893 -p "$P_PXY bad_ad=1" \
Hanno Becker1c9a24c2018-08-14 13:46:33 +01007894 "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \
7895 "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007896 1 \
Manuel Pégourié-Gonnard74a13782014-10-14 22:34:08 +02007897 -c "discarding invalid record (mac)" \
7898 -s "discarding invalid record (mac)" \
Manuel Pégourié-Gonnarde698f592014-10-14 19:36:36 +02007899 -s "Extra-header:" \
7900 -c "HTTP/1.0 200 OK" \
7901 -s "too many records with bad MAC" \
7902 -s "Verification of the message MAC failed"
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007903
7904run_test "DTLS proxy: delay ChangeCipherSpec" \
7905 -p "$P_PXY delay_ccs=1" \
Hanno Beckerc4305232018-08-14 13:41:21 +01007906 "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \
7907 "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007908 0 \
7909 -c "record from another epoch" \
7910 -s "record from another epoch" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02007911 -s "Extra-header:" \
7912 -c "HTTP/1.0 200 OK"
7913
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007914# Tests for reordering support with DTLS
7915
Hanno Becker56cdfd12018-08-17 13:42:15 +01007916run_test "DTLS reordering: Buffer out-of-order handshake message on client" \
7917 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007918 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7919 hs_timeout=2500-60000" \
7920 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7921 hs_timeout=2500-60000" \
Hanno Beckere3842212018-08-16 15:28:59 +01007922 0 \
7923 -c "Buffering HS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007924 -c "Next handshake message has been buffered - load"\
7925 -S "Buffering HS message" \
7926 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007927 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007928 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007929 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01007930 -S "Remember CCS message"
Hanno Beckere3842212018-08-16 15:28:59 +01007931
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007932run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \
7933 -p "$P_PXY delay_srv=ServerHello" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007934 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7935 hs_timeout=2500-60000" \
7936 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7937 hs_timeout=2500-60000" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007938 0 \
7939 -c "Buffering HS message" \
7940 -c "found fragmented DTLS handshake message"\
7941 -c "Next handshake message 1 not or only partially bufffered" \
7942 -c "Next handshake message has been buffered - load"\
7943 -S "Buffering HS message" \
7944 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007945 -C "Injecting buffered CCS message" \
Hanno Beckerdc1e9502018-08-28 16:02:33 +01007946 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007947 -S "Injecting buffered CCS message" \
Hanno Beckeraa5d0c42018-08-16 13:15:19 +01007948 -S "Remember CCS message"
7949
Hanno Beckera1adcca2018-08-24 14:41:07 +01007950# The client buffers the ServerKeyExchange before receiving the fragmented
7951# Certificate message; at the time of writing, together these are aroudn 1200b
7952# in size, so that the bound below ensures that the certificate can be reassembled
7953# while keeping the ServerKeyExchange.
7954requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300
7955run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \
Hanno Beckere3567052018-08-21 16:50:43 +01007956 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007957 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7958 hs_timeout=2500-60000" \
7959 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7960 hs_timeout=2500-60000" \
Hanno Beckere3567052018-08-21 16:50:43 +01007961 0 \
7962 -c "Buffering HS message" \
7963 -c "Next handshake message has been buffered - load"\
Hanno Beckera1adcca2018-08-24 14:41:07 +01007964 -C "attempt to make space by freeing buffered messages" \
7965 -S "Buffering HS message" \
7966 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007967 -C "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007968 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007969 -S "Injecting buffered CCS message" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007970 -S "Remember CCS message"
7971
7972# The size constraints ensure that the delayed certificate message can't
7973# be reassembled while keeping the ServerKeyExchange message, but it can
7974# when dropping it first.
7975requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900
7976requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299
7977run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \
7978 -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007979 "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
7980 hs_timeout=2500-60000" \
7981 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7982 hs_timeout=2500-60000" \
Hanno Beckera1adcca2018-08-24 14:41:07 +01007983 0 \
7984 -c "Buffering HS message" \
7985 -c "attempt to make space by freeing buffered future messages" \
7986 -c "Enough space available after freeing buffered HS messages" \
Hanno Beckere3567052018-08-21 16:50:43 +01007987 -S "Buffering HS message" \
7988 -S "Next handshake message has been buffered - load"\
Hanno Becker39b8bc92018-08-28 17:17:13 +01007989 -C "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007990 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01007991 -S "Injecting buffered CCS message" \
Hanno Beckere3567052018-08-21 16:50:43 +01007992 -S "Remember CCS message"
7993
Hanno Becker56cdfd12018-08-17 13:42:15 +01007994run_test "DTLS reordering: Buffer out-of-order handshake message on server" \
7995 -p "$P_PXY delay_cli=Certificate" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04007996 "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \
7997 hs_timeout=2500-60000" \
7998 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
7999 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008000 0 \
8001 -C "Buffering HS message" \
8002 -C "Next handshake message has been buffered - load"\
8003 -s "Buffering HS message" \
8004 -s "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008005 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008006 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008007 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008008 -S "Remember CCS message"
8009
8010run_test "DTLS reordering: Buffer out-of-order CCS message on client"\
8011 -p "$P_PXY delay_srv=NewSessionTicket" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008012 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8013 hs_timeout=2500-60000" \
8014 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8015 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008016 0 \
8017 -C "Buffering HS message" \
8018 -C "Next handshake message has been buffered - load"\
8019 -S "Buffering HS message" \
8020 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008021 -c "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008022 -c "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008023 -S "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008024 -S "Remember CCS message"
8025
8026run_test "DTLS reordering: Buffer out-of-order CCS message on server"\
8027 -p "$P_PXY delay_cli=ClientKeyExchange" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008028 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8029 hs_timeout=2500-60000" \
8030 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8031 hs_timeout=2500-60000" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008032 0 \
8033 -C "Buffering HS message" \
8034 -C "Next handshake message has been buffered - load"\
8035 -S "Buffering HS message" \
8036 -S "Next handshake message has been buffered - load" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008037 -C "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008038 -C "Remember CCS message" \
Hanno Becker39b8bc92018-08-28 17:17:13 +01008039 -s "Injecting buffered CCS message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008040 -s "Remember CCS message"
8041
Hanno Beckera1adcca2018-08-24 14:41:07 +01008042run_test "DTLS reordering: Buffer encrypted Finished message" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008043 -p "$P_PXY delay_ccs=1" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008044 "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \
8045 hs_timeout=2500-60000" \
8046 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \
8047 hs_timeout=2500-60000" \
Hanno Beckerb34149c2018-08-16 15:29:06 +01008048 0 \
8049 -s "Buffer record from epoch 1" \
Hanno Becker56cdfd12018-08-17 13:42:15 +01008050 -s "Found buffered record from current epoch - load" \
8051 -c "Buffer record from epoch 1" \
8052 -c "Found buffered record from current epoch - load"
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008053
Hanno Beckera1adcca2018-08-24 14:41:07 +01008054# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec
8055# from the server are delayed, so that the encrypted Finished message
8056# is received and buffered. When the fragmented NewSessionTicket comes
8057# in afterwards, the encrypted Finished message must be freed in order
8058# to make space for the NewSessionTicket to be reassembled.
8059# This works only in very particular circumstances:
8060# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering
8061# of the NewSessionTicket, but small enough to also allow buffering of
8062# the encrypted Finished message.
8063# - The MTU setting on the server must be so small that the NewSessionTicket
8064# needs to be fragmented.
8065# - All messages sent by the server must be small enough to be either sent
8066# without fragmentation or be reassembled within the bounds of
8067# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based
8068# handshake, omitting CRTs.
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008069requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 190
8070requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 230
Hanno Beckera1adcca2018-08-24 14:41:07 +01008071run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \
8072 -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \
Manuel Pégourié-Gonnardeef4c752019-05-28 10:21:30 +02008073 "$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 +01008074 "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \
8075 0 \
8076 -s "Buffer record from epoch 1" \
8077 -s "Found buffered record from current epoch - load" \
8078 -c "Buffer record from epoch 1" \
8079 -C "Found buffered record from current epoch - load" \
8080 -c "Enough space available after freeing future epoch record"
8081
Manuel Pégourié-Gonnarda0719722014-09-20 12:46:27 +02008082# Tests for "randomly unreliable connection": try a variety of flows and peers
8083
8084client_needs_more_time 2
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008085run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \
8086 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008087 "$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 +02008088 psk=abc123" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008089 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008090 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8091 0 \
8092 -s "Extra-header:" \
8093 -c "HTTP/1.0 200 OK"
8094
Janos Follath74537a62016-09-02 13:45:28 +01008095client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008096run_test "DTLS proxy: 3d, \"short\" RSA handshake" \
8097 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008098 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8099 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008100 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
8101 0 \
8102 -s "Extra-header:" \
8103 -c "HTTP/1.0 200 OK"
8104
Janos Follath74537a62016-09-02 13:45:28 +01008105client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008106run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \
8107 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008108 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \
8109 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008110 0 \
8111 -s "Extra-header:" \
8112 -c "HTTP/1.0 200 OK"
8113
Janos Follath74537a62016-09-02 13:45:28 +01008114client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008115run_test "DTLS proxy: 3d, FS, client auth" \
8116 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008117 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \
8118 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008119 0 \
8120 -s "Extra-header:" \
8121 -c "HTTP/1.0 200 OK"
8122
Janos Follath74537a62016-09-02 13:45:28 +01008123client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008124run_test "DTLS proxy: 3d, FS, ticket" \
8125 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008126 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \
8127 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008128 0 \
8129 -s "Extra-header:" \
8130 -c "HTTP/1.0 200 OK"
8131
Janos Follath74537a62016-09-02 13:45:28 +01008132client_needs_more_time 2
Manuel Pégourié-Gonnard18e519a2014-09-24 19:09:17 +02008133run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \
8134 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008135 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \
8136 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \
Manuel Pégourié-Gonnard825a49e2014-09-23 11:00:37 +02008137 0 \
8138 -s "Extra-header:" \
8139 -c "HTTP/1.0 200 OK"
8140
Janos Follath74537a62016-09-02 13:45:28 +01008141client_needs_more_time 2
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008142run_test "DTLS proxy: 3d, max handshake, nbio" \
8143 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008144 "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008145 auth_mode=required" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008146 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008147 0 \
8148 -s "Extra-header:" \
8149 -c "HTTP/1.0 200 OK"
8150
Janos Follath74537a62016-09-02 13:45:28 +01008151client_needs_more_time 4
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008152run_test "DTLS proxy: 3d, min handshake, resumption" \
8153 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008154 "$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 +02008155 psk=abc123 debug_level=3" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008156 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008157 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard7a26d732014-10-02 14:50:46 +02008158 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8159 0 \
8160 -s "a session has been resumed" \
8161 -c "a session has been resumed" \
8162 -s "Extra-header:" \
8163 -c "HTTP/1.0 200 OK"
8164
Janos Follath74537a62016-09-02 13:45:28 +01008165client_needs_more_time 4
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008166run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \
8167 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008168 "$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 +02008169 psk=abc123 debug_level=3 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008170 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard56941fe2020-02-17 11:04:33 +01008171 debug_level=3 reconnect=1 skip_close_notify=1 read_timeout=1000 max_resend=10 \
Manuel Pégourié-Gonnard85beb302014-10-02 17:59:19 +02008172 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \
8173 0 \
8174 -s "a session has been resumed" \
8175 -c "a session has been resumed" \
8176 -s "Extra-header:" \
8177 -c "HTTP/1.0 200 OK"
8178
Janos Follath74537a62016-09-02 13:45:28 +01008179client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008180requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008181run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008182 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008183 "$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 +02008184 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008185 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008186 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard1b753f12014-09-25 16:09:36 +02008187 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8188 0 \
8189 -c "=> renegotiate" \
8190 -s "=> renegotiate" \
8191 -s "Extra-header:" \
8192 -c "HTTP/1.0 200 OK"
8193
Janos Follath74537a62016-09-02 13:45:28 +01008194client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008195requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008196run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
8197 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008198 "$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 +02008199 psk=abc123 renegotiation=1 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008200 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnard37a4de22014-10-01 16:38:03 +02008201 renegotiate=1 debug_level=2 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008202 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8203 0 \
8204 -c "=> renegotiate" \
8205 -s "=> renegotiate" \
8206 -s "Extra-header:" \
8207 -c "HTTP/1.0 200 OK"
8208
Janos Follath74537a62016-09-02 13:45:28 +01008209client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008210requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008211run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008212 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008213 "$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 +02008214 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008215 debug_level=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008216 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008217 renegotiation=1 exchanges=4 debug_level=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008218 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8219 0 \
8220 -c "=> renegotiate" \
8221 -s "=> renegotiate" \
8222 -s "Extra-header:" \
8223 -c "HTTP/1.0 200 OK"
8224
Janos Follath74537a62016-09-02 13:45:28 +01008225client_needs_more_time 4
Hanno Becker6a243642017-10-12 15:18:45 +01008226requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008227run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008228 -p "$P_PXY drop=5 delay=5 duplicate=5" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008229 "$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 +02008230 psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008231 debug_level=2 nbio=2" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008232 "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \
Manuel Pégourié-Gonnarda6ace042014-10-15 12:44:41 +02008233 renegotiation=1 exchanges=4 debug_level=2 nbio=2 \
Manuel Pégourié-Gonnardba958b82014-10-09 16:13:44 +02008234 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \
8235 0 \
8236 -c "=> renegotiate" \
8237 -s "=> renegotiate" \
8238 -s "Extra-header:" \
8239 -c "HTTP/1.0 200 OK"
8240
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008241## Interop tests with OpenSSL might trigger a bug in recent versions (including
8242## all versions installed on the CI machines), reported here:
8243## Bug report: https://github.com/openssl/openssl/issues/6902
8244## They should be re-enabled once a fixed version of OpenSSL is available
8245## (this should happen in some 1.1.1_ release according to the ticket).
8246skip_next_test
Janos Follath74537a62016-09-02 13:45:28 +01008247client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008248not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008249run_test "DTLS proxy: 3d, openssl server" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008250 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8251 "$O_SRV -dtls1 -mtu 2048" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008252 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008253 0 \
Manuel Pégourié-Gonnardd0fd1da2014-09-25 17:00:27 +02008254 -c "HTTP/1.0 200 OK"
8255
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008256skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008257client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008258not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008259run_test "DTLS proxy: 3d, openssl server, fragmentation" \
8260 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8261 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008262 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008263 0 \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008264 -c "HTTP/1.0 200 OK"
8265
Manuel Pégourié-Gonnard82986c12018-09-03 10:50:21 +02008266skip_next_test # see above
Janos Follath74537a62016-09-02 13:45:28 +01008267client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008268not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008269run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \
8270 -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \
8271 "$O_SRV -dtls1 -mtu 768" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008272 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008273 0 \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008274 -c "HTTP/1.0 200 OK"
8275
Manuel Pégourié-Gonnard96999962015-02-17 16:02:37 +00008276requires_gnutls
Janos Follath74537a62016-09-02 13:45:28 +01008277client_needs_more_time 6
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008278not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008279run_test "DTLS proxy: 3d, gnutls server" \
8280 -p "$P_PXY drop=5 delay=5 duplicate=5" \
8281 "$G_SRV -u --mtu 2048 -a" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008282 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008283 0 \
8284 -s "Extra-header:" \
8285 -c "Extra-header:"
8286
k-stachowiak17a38d32019-02-18 15:29:56 +01008287requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008288client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008289not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008290run_test "DTLS proxy: 3d, gnutls server, fragmentation" \
8291 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008292 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008293 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \
Manuel Pégourié-Gonnard9590e0a2014-09-26 16:27:59 +02008294 0 \
8295 -s "Extra-header:" \
8296 -c "Extra-header:"
8297
k-stachowiak17a38d32019-02-18 15:29:56 +01008298requires_gnutls_next
Janos Follath74537a62016-09-02 13:45:28 +01008299client_needs_more_time 8
Manuel Pégourié-Gonnardd68434e2015-08-31 12:48:22 +02008300not_with_valgrind # risk of non-mbedtls peer timing out
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008301run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \
8302 -p "$P_PXY drop=5 delay=5 duplicate=5" \
k-stachowiak17a38d32019-02-18 15:29:56 +01008303 "$G_NEXT_SRV -u --mtu 512" \
Andrzej Kurek948fe802018-10-05 15:42:44 -04008304 "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \
Manuel Pégourié-Gonnard6093d812014-09-29 17:52:57 +02008305 0 \
8306 -s "Extra-header:" \
8307 -c "Extra-header:"
8308
Ron Eldorf75e2522019-05-14 20:38:49 +03008309requires_config_enabled MBEDTLS_SSL_EXPORT_KEYS
8310run_test "export keys functionality" \
8311 "$P_SRV eap_tls=1 debug_level=3" \
8312 "$P_CLI eap_tls=1 debug_level=3" \
8313 0 \
8314 -s "exported maclen is " \
8315 -s "exported keylen is " \
8316 -s "exported ivlen is " \
8317 -c "exported maclen is " \
8318 -c "exported keylen is " \
Ron Eldor65d8c262019-06-04 13:05:36 +03008319 -c "exported ivlen is " \
8320 -c "EAP-TLS key material is:"\
8321 -s "EAP-TLS key material is:"\
8322 -c "EAP-TLS IV is:" \
8323 -s "EAP-TLS IV is:"
Ron Eldorf75e2522019-05-14 20:38:49 +03008324
Piotr Nowicki0937ed22019-11-26 16:32:40 +01008325# Test heap memory usage after handshake
8326requires_config_enabled MBEDTLS_MEMORY_DEBUG
8327requires_config_enabled MBEDTLS_MEMORY_BUFFER_ALLOC_C
8328requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
8329run_tests_memory_after_hanshake
8330
Manuel Pégourié-Gonnard8520dac2014-02-21 12:12:23 +01008331# Final report
8332
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008333echo "------------------------------------------------------------------------"
8334
8335if [ $FAILS = 0 ]; then
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008336 printf "PASSED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008337else
Manuel Pégourié-Gonnardf46f1282014-12-11 11:51:28 +01008338 printf "FAILED"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008339fi
Manuel Pégourié-Gonnard72e51ee2014-08-31 10:22:11 +02008340PASSES=$(( $TESTS - $FAILS ))
Manuel Pégourié-Gonnard6f4fbbb2014-08-14 14:31:29 +02008341echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
Manuel Pégourié-Gonnard33a752e2014-02-21 09:47:37 +01008342
8343exit $FAILS